1 /*
2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #ifndef LOG_TAG
16 #define LOG_TAG "bt_ipc_avrcp_ct_observer_stub"
17 #endif
18
19 #include "bluetooth_avrcp_ct_observer_stub.h"
20 #include "bluetooth_log.h"
21 #include "ipc_types.h"
22 #include "string_ex.h"
23 #include "bluetooth_errorcode.h"
24
25 namespace OHOS {
26 namespace Bluetooth {
27 using namespace OHOS::bluetooth;
28
29 const uint32_t AVRCP_COMPANY_ID_COUNT_MAX = 0xFF;
30 const uint32_t AVRCP_CAPABILITY_COUNT_MAX = 0xFF;
31 const uint32_t AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX = 0xFF;
32 const uint32_t AVRCP_PLAYER_APP_SETTING_VALUE_NUM_MAX = 0xFF;
33 const uint32_t AVRCP_ELEMENT_ATTRIBUTE_NUM_MAX = 0xFF;
34 const uint32_t AVRCP_FOLDER_DEPTH_MAX = 0xFF;
35 const uint32_t AVRCP_MEDIA_PLAYER_NUM_MAX = 0xFF;
36 const uint32_t AVRCP_FOLDER_ITEMS_NUM_MAX = 0xFFFF;
37
BluetoothAvrcpCtObserverStub()38 BluetoothAvrcpCtObserverStub::BluetoothAvrcpCtObserverStub()
39 {
40 HILOGD("start.");
41 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_CONNECTION_STATE_CHANGED)] =
42 BluetoothAvrcpCtObserverStub::OnConnectionStateChangedInner;
43 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_PRESS_BUTTON)] =
44 BluetoothAvrcpCtObserverStub::OnPressButtonInner;
45 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_RELEASE_BUTTON)] =
46 BluetoothAvrcpCtObserverStub::OnReleaseButtonInner;
47 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_SET_BROWSED_PLAYER)] =
48 BluetoothAvrcpCtObserverStub::OnSetBrowsedPlayerInner;
49 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_CAPABILITIES)] =
50 BluetoothAvrcpCtObserverStub::OnGetCapabilitiesInner;
51 memberFuncMap_[static_cast<uint32_t>(
52 BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_PLAYER_APP_SETTING_ATTRIBUTES)] =
53 BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingAttributesInner;
54 memberFuncMap_[static_cast<uint32_t>(
55 BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_PLAYER_APP_SETTING_VALUES)] =
56 BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingValuesInner;
57 memberFuncMap_[static_cast<uint32_t>(
58 BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_PLAYER_APP_SETTING_CURRENT_VALUE)] =
59 BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingCurrentValueInner;
60 memberFuncMap_[static_cast<uint32_t>(
61 BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_SET_PLAYER_APP_SETTING_CURRENT_VALUE)] =
62 BluetoothAvrcpCtObserverStub::OnSetPlayerAppSettingCurrentValueInner;
63 memberFuncMap_[static_cast<uint32_t>(
64 BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_PLAYER_APP_SETTING_ATTRIBUTE_TEXT)] =
65 BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingAttributeTextInner;
66 memberFuncMap_[static_cast<uint32_t>(
67 BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_PLAYER_APP_SETTING_VALUE_TEXT)] =
68 BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingValueTextInner;
69 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_ELEMENT_ATTRIBUTRES)] =
70 BluetoothAvrcpCtObserverStub::OnGetElementAttributesInner;
71 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_PLAY_STATUS)] =
72 BluetoothAvrcpCtObserverStub::OnGetPlayStatusInner;
73 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_PLAY_ITEM)] =
74 BluetoothAvrcpCtObserverStub::OnPlayItemInner;
75 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_TOTAL_NUMBER_OF_ITEMS)] =
76 BluetoothAvrcpCtObserverStub::OnGetTotalNumberOfItemsInner;
77 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_ITEM_ATTRIBUTES)] =
78 BluetoothAvrcpCtObserverStub::OnGetItemAttributesInner;
79 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_SET_ABSOLUTE_VOLUME)] =
80 BluetoothAvrcpCtObserverStub::OnSetAbsoluteVolumeInner;
81 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_PLAYBACK_STATUS_CHANGED)] =
82 BluetoothAvrcpCtObserverStub::OnPlaybackStatusChangedInner;
83 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_TRACK_CHANGED)] =
84 BluetoothAvrcpCtObserverStub::OnTrackChangedInner;
85 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_TRACK_REACHED_END)] =
86 BluetoothAvrcpCtObserverStub::OnTrackReachedEndInner;
87 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_TRACK_REACHED_START)] =
88 BluetoothAvrcpCtObserverStub::OnTrackReachedStartInner;
89 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_PLAYBACK_POS_CHANGED)] =
90 BluetoothAvrcpCtObserverStub::OnPlaybackPosChangedInner;
91 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_PLAY_APP_SETTING_CHANGED)] =
92 BluetoothAvrcpCtObserverStub::OnPlayerAppSettingChangedInner;
93 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_NOW_PLAYING_CONTENT_CHANGED)] =
94 BluetoothAvrcpCtObserverStub::OnNowPlayingContentChangedInner;
95 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_AVAILABLE_PLAYER_CHANGED)] =
96 BluetoothAvrcpCtObserverStub::OnAvailablePlayersChangedInner;
97 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_ADDRESSED_PLAYER_CHANGED)] =
98 BluetoothAvrcpCtObserverStub::OnAddressedPlayerChangedInner;
99 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_UID_CHANGED)] =
100 BluetoothAvrcpCtObserverStub::OnUidChangedInner;
101 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_VOLUME_CHANGED)] =
102 BluetoothAvrcpCtObserverStub::OnVolumeChangedInner;
103 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_MEDIA_PLAYERS)] =
104 BluetoothAvrcpCtObserverStub::OnGetMediaPlayersInner;
105 memberFuncMap_[static_cast<uint32_t>(BluetoothAvrcpCtObserverInterfaceCode::AVRCP_CT_GET_FOLDER_ITEMS)] =
106 BluetoothAvrcpCtObserverStub::OnGetFolderItemsInner;
107 }
108
~BluetoothAvrcpCtObserverStub()109 BluetoothAvrcpCtObserverStub::~BluetoothAvrcpCtObserverStub()
110 {
111 HILOGD("start.");
112 memberFuncMap_.clear();
113 }
114
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)115 int BluetoothAvrcpCtObserverStub::OnRemoteRequest(
116 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
117 {
118 HILOGD("BluetoothAvrcpCtObserverStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d",
119 code, option.GetFlags());
120 if (BluetoothAvrcpCtObserverStub::GetDescriptor() != data.ReadInterfaceToken()) {
121 HILOGI("local descriptor is not equal to remote");
122 return ERR_INVALID_STATE;
123 }
124
125 auto itFunc = memberFuncMap_.find(code);
126 if (itFunc != memberFuncMap_.end()) {
127 auto memberFunc = itFunc->second;
128 if (memberFunc != nullptr) {
129 return memberFunc(this, data, reply);
130 }
131 }
132
133 HILOGW("BluetoothAvrcpCtObserverStub::OnRemoteRequest, default case, need check.");
134 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
135 }
136
OnConnectionStateChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)137 ErrCode BluetoothAvrcpCtObserverStub::OnConnectionStateChangedInner(
138 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
139 {
140 std::string addr = data.ReadString();
141 int state = data.ReadInt32();
142 int cause = data.ReadInt32();
143
144 stub->OnConnectionStateChanged(RawAddress(addr), state, cause);
145 return NO_ERROR;
146 }
147
OnPressButtonInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)148 ErrCode BluetoothAvrcpCtObserverStub::OnPressButtonInner(
149 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
150 {
151 std::string addr = data.ReadString();
152 int button = data.ReadInt32();
153 int result = data.ReadInt32();
154
155 stub->OnPressButton(RawAddress(addr), button, result);
156 return NO_ERROR;
157 }
158
OnReleaseButtonInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)159 ErrCode BluetoothAvrcpCtObserverStub::OnReleaseButtonInner(
160 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
161 {
162 std::string addr = data.ReadString();
163 int button = data.ReadInt32();
164 int result = data.ReadInt32();
165
166 stub->OnReleaseButton(RawAddress(addr), button, result);
167 return NO_ERROR;
168 }
169
OnSetBrowsedPlayerInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)170 ErrCode BluetoothAvrcpCtObserverStub::OnSetBrowsedPlayerInner(
171 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
172 {
173 std::string addr = data.ReadString();
174 int uidCounter = data.ReadInt32();
175 uint32_t numberOfItems = data.ReadUint32();
176 std::vector<std::string> folderNames {};
177 int32_t namesSize = data.ReadInt32();
178 if (static_cast<uint32_t>(namesSize) > AVRCP_FOLDER_DEPTH_MAX) {
179 return BT_ERR_INVALID_PARAM;
180 }
181 for (int i = 0; i < namesSize; i++) {
182 std::string name = data.ReadString();
183 folderNames.push_back(name);
184 }
185 int result = data.ReadInt32();
186 int detail = data.ReadInt32();
187
188 stub->OnSetBrowsedPlayer(RawAddress(addr), uidCounter, numberOfItems, folderNames, result, detail);
189 return NO_ERROR;
190 }
191
OnGetCapabilitiesInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)192 ErrCode BluetoothAvrcpCtObserverStub::OnGetCapabilitiesInner(
193 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
194 {
195 std::string addr = data.ReadString();
196 std::vector<uint32_t> companies {};
197 int32_t companiesSize = data.ReadInt32();
198 if (static_cast<uint32_t>(companiesSize) > AVRCP_COMPANY_ID_COUNT_MAX) {
199 return BT_ERR_INVALID_PARAM;
200 }
201 for (int i = 0; i < companiesSize; i++) {
202 uint32_t company = data.ReadUint32();
203 companies.push_back(company);
204 }
205
206 std::vector<uint8_t> events {};
207 int32_t eventsSize = data.ReadInt32();
208 if (static_cast<uint32_t>(eventsSize) > AVRCP_CAPABILITY_COUNT_MAX) {
209 return BT_ERR_INVALID_PARAM;
210 }
211 for (int i = 0; i < eventsSize; i++) {
212 uint8_t event = static_cast<uint8_t>(data.ReadInt32());
213 events.push_back(event);
214 }
215
216 int result = data.ReadInt32();
217
218 stub->OnGetCapabilities(RawAddress(addr), companies, events, result);
219 return NO_ERROR;
220 }
221
OnGetPlayerAppSettingAttributesInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)222 ErrCode BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingAttributesInner(
223 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
224 {
225 std::string addr = data.ReadString();
226
227 std::vector<uint8_t> attributes {};
228 int32_t attributesSize = data.ReadInt32();
229 if (static_cast<uint32_t>(attributesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
230 return BT_ERR_INVALID_PARAM;
231 }
232 for (int i = 0; i < attributesSize; i++) {
233 uint8_t attrbute = static_cast<uint8_t>(data.ReadInt32());
234 attributes.push_back(attrbute);
235 }
236
237 int result = data.ReadInt32();
238
239 stub->OnGetPlayerAppSettingAttributes(RawAddress(addr), attributes, result);
240 return NO_ERROR;
241 }
242
OnGetPlayerAppSettingValuesInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)243 ErrCode BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingValuesInner(
244 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
245 {
246 std::string addr = data.ReadString();
247 int attrbute = data.ReadInt32();
248
249 std::vector<uint8_t> values {};
250 int32_t valuesSize = data.ReadInt32();
251 if (static_cast<uint32_t>(valuesSize) > AVRCP_PLAYER_APP_SETTING_VALUE_NUM_MAX) {
252 return BT_ERR_INVALID_PARAM;
253 }
254 for (int i = 0; i < valuesSize; i++) {
255 uint8_t value = static_cast<uint8_t>(data.ReadInt32());
256 values.push_back(value);
257 }
258 int result = data.ReadInt32();
259
260 stub->OnGetPlayerAppSettingValues(RawAddress(addr), attrbute, values, result);
261 return NO_ERROR;
262 }
263
OnGetPlayerAppSettingCurrentValueInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)264 ErrCode BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingCurrentValueInner(
265 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
266 {
267 std::string addr = data.ReadString();
268 std::vector<uint8_t> attrbutes {};
269 int32_t attrbutesSize = data.ReadInt32();
270 if (static_cast<uint32_t>(attrbutesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
271 return BT_ERR_INVALID_PARAM;
272 }
273 for (int i = 0; i < attrbutesSize; i++) {
274 uint8_t attrbute = static_cast<uint8_t>(data.ReadInt32());
275 attrbutes.push_back(attrbute);
276 }
277
278 std::vector<uint8_t> values {};
279 int32_t valuesSize = data.ReadInt32();
280 if (static_cast<uint32_t>(valuesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
281 return BT_ERR_INVALID_PARAM;
282 }
283 for (int i = 0; i < valuesSize; i++) {
284 uint8_t value = static_cast<uint8_t>(data.ReadInt32());
285 values.push_back(value);
286 }
287 int result = data.ReadInt32();
288
289 stub->OnGetPlayerAppSettingCurrentValue(RawAddress(addr), attrbutes, values, result);
290 return NO_ERROR;
291 }
292
OnSetPlayerAppSettingCurrentValueInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)293 ErrCode BluetoothAvrcpCtObserverStub::OnSetPlayerAppSettingCurrentValueInner(
294 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
295 {
296 std::string addr = data.ReadString();
297 int result = data.ReadInt32();
298
299 stub->OnSetPlayerAppSettingCurrentValue(RawAddress(addr), result);
300 return NO_ERROR;
301 }
302
OnGetPlayerAppSettingAttributeTextInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)303 ErrCode BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingAttributeTextInner(
304 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
305 {
306 std::string addr = data.ReadString();
307 std::vector<uint8_t> attrbutes {};
308 int32_t attrbutesSize = data.ReadInt32();
309 if (static_cast<uint32_t>(attrbutesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
310 return BT_ERR_INVALID_PARAM;
311 }
312 for (int i = 0; i < attrbutesSize; i++) {
313 uint8_t attrbute = static_cast<uint8_t>(data.ReadInt32());
314 attrbutes.push_back(attrbute);
315 }
316
317 std::vector<std::string> attributeNames {};
318 int32_t valuesSize = data.ReadInt32();
319 if (static_cast<uint32_t>(valuesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
320 return BT_ERR_INVALID_PARAM;
321 }
322 for (int i = 0; i < valuesSize; i++) {
323 std::string value = data.ReadString();
324 attributeNames.push_back(value);
325 }
326
327 int result = data.ReadInt32();
328
329 stub->OnGetPlayerAppSettingAttributeText(RawAddress(addr), attrbutes, attributeNames, result);
330 return NO_ERROR;
331 }
332
OnGetPlayerAppSettingValueTextInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)333 ErrCode BluetoothAvrcpCtObserverStub::OnGetPlayerAppSettingValueTextInner(
334 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
335 {
336 std::string addr = data.ReadString();
337 std::vector<uint8_t> values {};
338 int32_t valuesSize = data.ReadInt32();
339 if (static_cast<uint32_t>(valuesSize) > AVRCP_PLAYER_APP_SETTING_VALUE_NUM_MAX) {
340 return BT_ERR_INVALID_PARAM;
341 }
342 for (int i = 0; i < valuesSize; i++) {
343 uint8_t attrbute = static_cast<uint8_t>(data.ReadInt32());
344 values.push_back(attrbute);
345 }
346
347 std::vector<std::string> valueNames {};
348 int32_t valueNamesSize = data.ReadInt32();
349 if (static_cast<uint32_t>(valueNamesSize) > AVRCP_PLAYER_APP_SETTING_VALUE_NUM_MAX) {
350 return BT_ERR_INVALID_PARAM;
351 }
352 for (int i = 0; i < valueNamesSize; i++) {
353 std::string value = data.ReadString();
354 valueNames.push_back(value);
355 }
356
357 int result = data.ReadInt32();
358
359 stub->OnGetPlayerAppSettingValueText(RawAddress(addr), values, valueNames, result);
360 return NO_ERROR;
361 }
362
OnGetElementAttributesInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)363 ErrCode BluetoothAvrcpCtObserverStub::OnGetElementAttributesInner(
364 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
365 {
366 std::string addr = data.ReadString();
367 std::vector<uint32_t> attribtues {};
368 int32_t valuesSize = data.ReadInt32();
369 if (static_cast<uint32_t>(valuesSize) > AVRCP_ELEMENT_ATTRIBUTE_NUM_MAX) {
370 return BT_ERR_INVALID_PARAM;
371 }
372 for (int i = 0; i < valuesSize; i++) {
373 uint32_t attrbute = data.ReadUint32();
374 attribtues.push_back(attrbute);
375 }
376
377 std::vector<std::string> valueNames {};
378 int32_t valueNamesSize = data.ReadInt32();
379 if (static_cast<uint32_t>(valueNamesSize) > AVRCP_ELEMENT_ATTRIBUTE_NUM_MAX) {
380 return BT_ERR_INVALID_PARAM;
381 }
382 for (int i = 0; i < valueNamesSize; i++) {
383 std::string value = data.ReadString();
384 valueNames.push_back(value);
385 }
386
387 int result = data.ReadInt32();
388
389 stub->OnGetElementAttributes(RawAddress(addr), attribtues, valueNames, result);
390 return NO_ERROR;
391 }
392
OnGetPlayStatusInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)393 ErrCode BluetoothAvrcpCtObserverStub::OnGetPlayStatusInner(
394 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
395 {
396 std::string addr = data.ReadString();
397 uint32_t songLength = data.ReadUint32();
398 uint32_t songPosition = data.ReadUint32();
399 uint8_t playStatus = static_cast<uint8_t>(data.ReadInt32());
400
401 int result = data.ReadInt32();
402
403 stub->OnGetPlayStatus(RawAddress(addr), songLength, songPosition, playStatus, result);
404 return NO_ERROR;
405 }
406
OnPlayItemInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)407 ErrCode BluetoothAvrcpCtObserverStub::OnPlayItemInner(
408 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
409 {
410 std::string addr = data.ReadString();
411 int status = data.ReadInt32();
412 int result = data.ReadInt32();
413
414 stub->OnPlayItem(RawAddress(addr), status, result);
415 return NO_ERROR;
416 }
417
OnGetTotalNumberOfItemsInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)418 ErrCode BluetoothAvrcpCtObserverStub::OnGetTotalNumberOfItemsInner(
419 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
420 {
421 std::string addr = data.ReadString();
422 uint16_t uidCounter = static_cast<uint16_t>(data.ReadInt32());
423 uint32_t numOfItems = data.ReadUint32();
424 int result = data.ReadInt32();
425 int detail = data.ReadInt32();
426
427 stub->OnGetTotalNumberOfItems(RawAddress(addr), uidCounter, numOfItems, result, detail);
428 return NO_ERROR;
429 }
430
OnGetItemAttributesInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)431 ErrCode BluetoothAvrcpCtObserverStub::OnGetItemAttributesInner(
432 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
433 {
434 std::string addr = data.ReadString();
435 std::vector<uint32_t> attribtues {};
436 int32_t attribtuesSize = data.ReadInt32();
437 if (static_cast<uint32_t>(attribtuesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
438 return BT_ERR_INVALID_PARAM;
439 }
440 for (int i = 0; i < attribtuesSize; i++) {
441 uint32_t attrbute = data.ReadUint32();
442 attribtues.push_back(attrbute);
443 }
444
445 std::vector<std::string> valueNames {};
446 int32_t valuesSize = data.ReadInt32();
447 if (static_cast<uint32_t>(valuesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
448 return BT_ERR_INVALID_PARAM;
449 }
450 for (int i = 0; i < valuesSize; i++) {
451 std::string value = data.ReadString();
452 valueNames.push_back(value);
453 }
454
455 int result = data.ReadInt32();
456 int detail = data.ReadInt32();
457
458 stub->OnGetItemAttributes(RawAddress(addr), attribtues, valueNames, result, detail);
459 return NO_ERROR;
460 }
461
OnSetAbsoluteVolumeInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)462 ErrCode BluetoothAvrcpCtObserverStub::OnSetAbsoluteVolumeInner(
463 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
464 {
465 std::string addr = data.ReadString();
466 uint8_t volume = static_cast<uint8_t>(data.ReadInt32());
467 int result = data.ReadInt32();
468
469 stub->OnSetAbsoluteVolume(RawAddress(addr), volume, result);
470 return NO_ERROR;
471 }
472
OnPlaybackStatusChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)473 ErrCode BluetoothAvrcpCtObserverStub::OnPlaybackStatusChangedInner(
474 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
475 {
476 std::string addr = data.ReadString();
477 uint8_t playStatus = static_cast<uint8_t>(data.ReadInt32());
478 int result = data.ReadInt32();
479
480 stub->OnPlaybackStatusChanged(RawAddress(addr), playStatus, result);
481 return NO_ERROR;
482 }
483
OnTrackChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)484 ErrCode BluetoothAvrcpCtObserverStub::OnTrackChangedInner(
485 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
486 {
487 std::string addr = data.ReadString();
488 uint64_t uid = data.ReadUint64();
489 int result = data.ReadInt32();
490
491 stub->OnTrackChanged(RawAddress(addr), uid, result);
492 return NO_ERROR;
493 }
494
OnTrackReachedEndInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)495 ErrCode BluetoothAvrcpCtObserverStub::OnTrackReachedEndInner(
496 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
497 {
498 std::string addr = data.ReadString();
499 int result = data.ReadInt32();
500
501 stub->OnTrackReachedEnd(RawAddress(addr), result);
502 return NO_ERROR;
503 }
504
OnTrackReachedStartInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)505 ErrCode BluetoothAvrcpCtObserverStub::OnTrackReachedStartInner(
506 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
507 {
508 std::string addr = data.ReadString();
509 int result = data.ReadInt32();
510
511 stub->OnTrackReachedStart(RawAddress(addr), result);
512 return NO_ERROR;
513 }
514
OnPlaybackPosChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)515 ErrCode BluetoothAvrcpCtObserverStub::OnPlaybackPosChangedInner(
516 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
517 {
518 std::string addr = data.ReadString();
519 uint32_t playbackPos = data.ReadUint32();
520 int result = data.ReadInt32();
521
522 stub->OnPlaybackPosChanged(RawAddress(addr), playbackPos, result);
523 return NO_ERROR;
524 }
525
OnPlayerAppSettingChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)526 ErrCode BluetoothAvrcpCtObserverStub::OnPlayerAppSettingChangedInner(
527 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
528 {
529 std::string addr = data.ReadString();
530 std::vector<uint8_t> attribtues {};
531 int32_t attribtuesSize = data.ReadInt32();
532 if (static_cast<uint32_t>(attribtuesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
533 return BT_ERR_INVALID_PARAM;
534 }
535 for (int i = 0; i < attribtuesSize; i++) {
536 int32_t attrbute = data.ReadInt32();
537 attribtues.push_back(attrbute);
538 }
539
540 std::vector<uint8_t> values {};
541 int32_t valuesSize = data.ReadInt32();
542 if (static_cast<uint32_t>(valuesSize) > AVRCP_PLAYER_APP_SETTING_ATTRIBUTES_NUM_MAX) {
543 return BT_ERR_INVALID_PARAM;
544 }
545 for (int i = 0; i < valuesSize; i++) {
546 int32_t attrbute = data.ReadInt32();
547 values.push_back(attrbute);
548 }
549
550 int result = data.ReadInt32();
551
552 stub->OnPlayerAppSettingChanged(RawAddress(addr), attribtues, values, result);
553 return NO_ERROR;
554 }
555
OnNowPlayingContentChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)556 ErrCode BluetoothAvrcpCtObserverStub::OnNowPlayingContentChangedInner(
557 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
558 {
559 std::string addr = data.ReadString();
560 int result = data.ReadInt32();
561
562 stub->OnNowPlayingContentChanged(RawAddress(addr), result);
563 return NO_ERROR;
564 }
565
OnAvailablePlayersChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)566 ErrCode BluetoothAvrcpCtObserverStub::OnAvailablePlayersChangedInner(
567 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
568 {
569 std::string addr = data.ReadString();
570 int result = data.ReadInt32();
571
572 stub->OnAvailablePlayersChanged(RawAddress(addr), result);
573 return NO_ERROR;
574 }
575
OnAddressedPlayerChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)576 ErrCode BluetoothAvrcpCtObserverStub::OnAddressedPlayerChangedInner(
577 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
578 {
579 std::string addr = data.ReadString();
580 uint16_t playerId = static_cast<uint16_t>(data.ReadInt32());
581 uint16_t uidCounter = static_cast<uint16_t>(data.ReadInt32());
582 int result = data.ReadInt32();
583 stub->OnAddressedPlayerChanged(RawAddress(addr), playerId, uidCounter, result);
584 return NO_ERROR;
585 }
586
OnUidChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)587 ErrCode BluetoothAvrcpCtObserverStub::OnUidChangedInner(
588 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
589 {
590 std::string addr = data.ReadString();
591 uint16_t uidCounter = static_cast<uint16_t>(data.ReadInt32());
592 int result = data.ReadInt32();
593 stub->OnUidChanged(RawAddress(addr), uidCounter, result);
594 return NO_ERROR;
595 }
596
OnVolumeChangedInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)597 ErrCode BluetoothAvrcpCtObserverStub::OnVolumeChangedInner(
598 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
599 {
600 std::string addr = data.ReadString();
601 uint8_t volume = static_cast<uint8_t>(data.ReadInt32());
602 int result = data.ReadInt32();
603 stub->OnVolumeChanged(RawAddress(addr), volume, result);
604 return NO_ERROR;
605 }
606
OnGetMediaPlayersInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)607 ErrCode BluetoothAvrcpCtObserverStub::OnGetMediaPlayersInner(
608 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
609 {
610 std::string addr = data.ReadString();
611 uint16_t uidCounter = static_cast<uint16_t>(data.ReadInt32());
612
613 std::vector<BluetoothAvrcpMpItem> items {};
614 int32_t itemsSize = data.ReadInt32();
615 if (static_cast<uint32_t>(itemsSize) > AVRCP_MEDIA_PLAYER_NUM_MAX) {
616 return BT_ERR_INVALID_PARAM;
617 }
618 for (int i = 0; i < itemsSize; i++) {
619 std::shared_ptr<BluetoothAvrcpMpItem> item(data.ReadParcelable<BluetoothAvrcpMpItem>());
620 if (!item) {
621 return TRANSACTION_ERR;
622 }
623 items.push_back(*item);
624 }
625 int result = data.ReadInt32();
626 int detail = data.ReadInt32();
627 stub->OnGetMediaPlayers(RawAddress(addr), uidCounter, items, result, detail);
628 return NO_ERROR;
629 }
630
OnGetFolderItemsInner(BluetoothAvrcpCtObserverStub * stub,MessageParcel & data,MessageParcel & reply)631 ErrCode BluetoothAvrcpCtObserverStub::OnGetFolderItemsInner(
632 BluetoothAvrcpCtObserverStub *stub, MessageParcel &data, MessageParcel &reply)
633 {
634 std::string addr = data.ReadString();
635 uint8_t uidCounter = static_cast<uint8_t>(data.ReadInt32());
636
637 std::vector<BluetoothAvrcpMeItem> items {};
638 int32_t itemsSize = data.ReadInt32();
639 if (static_cast<uint32_t>(itemsSize) > AVRCP_FOLDER_ITEMS_NUM_MAX) {
640 return BT_ERR_INVALID_PARAM;
641 }
642 for (int i = 0; i < itemsSize; i++) {
643 std::shared_ptr<BluetoothAvrcpMeItem> item(data.ReadParcelable<BluetoothAvrcpMeItem>());
644 if (!item) {
645 return TRANSACTION_ERR;
646 }
647 items.push_back(*item);
648 }
649 int result = data.ReadInt32();
650 int detail = data.ReadInt32();
651 stub->OnGetFolderItems(RawAddress(addr), uidCounter, items, result, detail);
652 return NO_ERROR;
653 }
654 } // namespace Bluetooth
655 } // namespace OHOS
656