• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 
16 #include "bluetooth_avrcp_tg_proxy.h"
17 #include "bluetooth_log.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
RegisterObserver(const sptr<IBluetoothAvrcpTgObserver> & observer)21 void BluetoothAvrcpTgProxy::RegisterObserver(const sptr<IBluetoothAvrcpTgObserver> &observer)
22 {
23     HILOGI("BluetoothAvrcpTgProxy::RegisterObserver start");
24     MessageParcel data;
25     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
26         HILOGE("BluetoothAvrcpTgProxy::RegisterObserver WriteInterfaceToken error");
27         return;
28     }
29     if (!data.WriteRemoteObject(observer->AsObject())) {
30         HILOGE("BluetoothAvrcpTgProxy::RegisterObserver observer error");
31         return;
32     }
33 
34     MessageParcel reply;
35     MessageOption option = { MessageOption::TF_ASYNC };
36     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_REGISTER_OBSERVER, option, data, reply);
37     if (error != NO_ERROR) {
38         HILOGE("BluetoothAvrcpTgProxy::RegisterObserver done fail, error: %{public}d", error);
39         return;
40     }
41     return;
42 }
43 
UnregisterObserver(const sptr<IBluetoothAvrcpTgObserver> & observer)44 void BluetoothAvrcpTgProxy::UnregisterObserver(const sptr<IBluetoothAvrcpTgObserver> &observer)
45 {
46     HILOGI("BluetoothAvrcpTgProxy::UnregisterObserver start");
47     MessageParcel data;
48     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
49         HILOGE("BluetoothAvrcpTgProxy::UnregisterObserver WriteInterfaceToken error");
50         return;
51     }
52     if (!data.WriteRemoteObject(observer->AsObject())) {
53         HILOGE("BluetoothAvrcpTgProxy::UnregisterObserver observer error");
54         return;
55     }
56 
57     MessageParcel reply;
58     MessageOption option = { MessageOption::TF_ASYNC };
59     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_UNREGISTER_OBSERVER, option, data, reply);
60     if (error != NO_ERROR) {
61         HILOGE("BluetoothAvrcpTgProxy::RegisterObserver done fail, error: %{public}d", error);
62         return;
63     }
64     return;
65 }
66 
SetActiveDevice(const BluetoothRawAddress & addr)67 void BluetoothAvrcpTgProxy::SetActiveDevice(const BluetoothRawAddress &addr)
68 {
69     MessageParcel data;
70     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
71         HILOGE("[SetActiveDevice] fail: write interface token failed.");
72         return;
73     }
74 
75     if (!data.WriteParcelable(&addr)) {
76         HILOGE("[SetActiveDevice] fail: write result failed");
77         return;
78     }
79 
80     MessageParcel reply;
81     MessageOption option = {MessageOption::TF_SYNC};
82     int error = InnerTransact(
83         BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_SET_ACTIVE_DEVICE, option, data, reply);
84     if (error != NO_ERROR) {
85         HILOGE("BluetoothAvrcpCtProxy::SetActiveDevice done fail, error: %{public}d", error);
86         return;
87     }
88 }
89 
Connect(const BluetoothRawAddress & addr)90 int32_t BluetoothAvrcpTgProxy::Connect(const BluetoothRawAddress &addr)
91 {
92     HILOGI("BluetoothAvrcpTgProxy::Connect start");
93     MessageParcel data;
94     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
95         HILOGE("BluetoothAvrcpTgProxy::Connect WriteInterfaceToken error");
96         return -1;
97     }
98     if (!data.WriteParcelable(&addr)) {
99         HILOGE("BluetoothAvrcpTgProxy::Connect transport error");
100         return -1;
101     }
102 
103     MessageParcel reply;
104     MessageOption option = { MessageOption::TF_SYNC };
105     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_CONNECT, option, data, reply);
106     if (error != NO_ERROR) {
107         HILOGE("BluetoothAvrcpTgProxy::Connect done fail, error: %{public}d", error);
108         return -1;
109     }
110     return reply.ReadInt32();
111 }
112 
Disconnect(const BluetoothRawAddress & addr)113 int32_t BluetoothAvrcpTgProxy::Disconnect(const BluetoothRawAddress &addr)
114 {
115     HILOGI("BluetoothAvrcpTgProxy::Disconnect start");
116     MessageParcel data;
117     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
118         HILOGE("BluetoothAvrcpTgProxy::Disconnect WriteInterfaceToken error");
119         return -1;
120     }
121     if (!data.WriteParcelable(&addr)) {
122         HILOGE("BluetoothAvrcpTgProxy::Disconnect transport error");
123         return -1;
124     }
125 
126     MessageParcel reply;
127     MessageOption option = { MessageOption::TF_SYNC };
128     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_DISCONNECT, option, data, reply);
129     if (error != NO_ERROR) {
130         HILOGE("BluetoothAvrcpTgProxy::Disconnect done fail, error: %{public}d", error);
131         return -1;
132     }
133     return reply.ReadInt32();
134 }
135 
GetConnectedDevices()136 std::vector<BluetoothRawAddress> BluetoothAvrcpTgProxy::GetConnectedDevices()
137 {
138     std::vector<BluetoothRawAddress> vec;
139     MessageParcel data;
140     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
141         HILOGE("BluetoothAvrcpTgProxy::GetConnectedDevices WriteInterfaceToken error");
142         return vec;
143     }
144 
145     MessageParcel reply;
146     MessageOption option = {MessageOption::TF_SYNC};
147     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_GET_CONNECTED_DEVICES, option, data, reply);
148     if (error != NO_ERROR) {
149         HILOGE("BluetoothAvrcpTgProxy::GetConnectedDevices done fail, error: %{public}d", error);
150         return vec;
151     }
152     int32_t size = reply.ReadInt32();
153     for (int32_t i = 0; i < size; i++) {
154         std::shared_ptr<BluetoothRawAddress> rawAddress(reply.ReadParcelable<BluetoothRawAddress>());
155         if (!rawAddress) {
156             return vec;
157         }
158         vec.push_back(*rawAddress);
159     }
160     return vec;
161 }
162 
GetDevicesByStates(const std::vector<int32_t> & states)163 std::vector<BluetoothRawAddress> BluetoothAvrcpTgProxy::GetDevicesByStates(const std::vector<int32_t> &states)
164 {
165     std::vector<BluetoothRawAddress> vec;
166     MessageParcel data;
167     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
168         HILOGE("BluetoothAvrcpTgProxy::GetConnectedDevices WriteInterfaceToken error");
169         return vec;
170     }
171     int num = states.size();
172     if (!data.WriteInt32(num)) {
173         HILOGE("BluetoothAvrcpTgProxy::GetDevicesByStates num error");
174         return vec;
175     }
176     for (int i = 0; i < num; i++) {
177         if (!data.WriteInt32(states[i])) {
178             HILOGE("BluetoothAvrcpTgProxy::GetDevicesByStates states error");
179             return vec;
180         }
181     }
182 
183     MessageParcel reply;
184     MessageOption option = {MessageOption::TF_SYNC};
185     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_GET_DEVICES_BY_STATES, option, data, reply);
186     if (error != NO_ERROR) {
187         HILOGE("BluetoothAvrcpTgProxy::GetConnectedDevices done fail, error: %{public}d", error);
188         return vec;
189     }
190     int32_t size = reply.ReadInt32();
191     for (int32_t i = 0; i < size; i++) {
192         std::shared_ptr<BluetoothRawAddress> rawAddress(reply.ReadParcelable<BluetoothRawAddress>());
193         vec.push_back(*rawAddress);
194     }
195     return vec;
196 }
197 
GetDeviceState(const BluetoothRawAddress & addr)198 int32_t BluetoothAvrcpTgProxy::GetDeviceState(const BluetoothRawAddress &addr)
199 {
200     HILOGI("BluetoothAvrcpTgProxy::GetDeviceState start");
201     MessageParcel data;
202     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
203         HILOGE("BluetoothAvrcpTgProxy::GetDeviceState WriteInterfaceToken error");
204         return -1;
205     }
206     if (!data.WriteParcelable(&addr)) {
207         HILOGE("BluetoothAvrcpTgProxy::GetDeviceState transport error");
208         return -1;
209     }
210 
211     MessageParcel reply;
212     MessageOption option = { MessageOption::TF_SYNC };
213     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_GET_DEVICE_STATE, option, data, reply);
214     if (error != NO_ERROR) {
215         HILOGE("BluetoothAvrcpTgProxy::GetDeviceState done fail, error: %{public}d", error);
216         return -1;
217     }
218     return reply.ReadInt32();
219 }
220 
NotifyPlaybackStatusChanged(int32_t playStatus,int32_t playbackPos)221 void BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged(int32_t playStatus, int32_t playbackPos)
222 {
223     HILOGI("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged start");
224     MessageParcel data;
225     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
226         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged WriteInterfaceToken error");
227         return;
228     }
229     if (!data.WriteInt32(playStatus)) {
230         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged playStatus error");
231         return;
232     }
233     if (!data.WriteInt32(playbackPos)) {
234         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged playbackPos error");
235         return;
236     }
237 
238     MessageParcel reply;
239     MessageOption option = { MessageOption::TF_ASYNC };
240     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_PLAYBACK_STATUS_CHANGED,
241                               option, data, reply);
242     if (error != NO_ERROR) {
243         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged done fail, error: %{public}d", error);
244         return;
245     }
246     return;
247 }
248 
NotifyTrackChanged(int64_t uid,int32_t playbackPos)249 void BluetoothAvrcpTgProxy::NotifyTrackChanged(int64_t uid, int32_t playbackPos)
250 {
251     HILOGI("BluetoothAvrcpTgProxy::NotifyTrackChanged start");
252     MessageParcel data;
253     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
254         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackChanged WriteInterfaceToken error");
255         return;
256     }
257     if (!data.WriteInt64(uid)) {
258         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackChanged uid error");
259         return;
260     }
261     if (!data.WriteInt32(playbackPos)) {
262         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackChanged playbackPos error");
263         return;
264     }
265 
266     MessageParcel reply;
267     MessageOption option = { MessageOption::TF_ASYNC };
268     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_TRACK_CHANGED, option, data, reply);
269     if (error != NO_ERROR) {
270         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged done fail, error: %{public}d", error);
271         return;
272     }
273     return;
274 }
275 
NotifyTrackReachedEnd(int32_t playbackPos)276 void BluetoothAvrcpTgProxy::NotifyTrackReachedEnd(int32_t playbackPos)
277 {
278     HILOGI("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd start");
279     MessageParcel data;
280     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
281         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd WriteInterfaceToken error");
282         return;
283     }
284     if (!data.WriteInt32(playbackPos)) {
285         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd playbackPos error");
286         return;
287     }
288 
289     MessageParcel reply;
290     MessageOption option = { MessageOption::TF_ASYNC };
291     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_TRACK_REACHED_END,
292                               option, data, reply);
293     if (error != NO_ERROR) {
294         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd done fail, error: %{public}d", error);
295         return;
296     }
297     return;
298 }
299 
NotifyTrackReachedStart(int32_t playbackPos)300 void BluetoothAvrcpTgProxy::NotifyTrackReachedStart(int32_t playbackPos)
301 {
302     HILOGI("BluetoothAvrcpTgProxy::NotifyTrackReachedStart start");
303     MessageParcel data;
304     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
305         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedStart WriteInterfaceToken error");
306         return;
307     }
308     if (!data.WriteInt32(playbackPos)) {
309         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedStart playbackPos error");
310         return;
311     }
312 
313     MessageParcel reply;
314     MessageOption option = { MessageOption::TF_ASYNC };
315     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_TRACK_REACHED_START,
316                               option, data, reply);
317     if (error != NO_ERROR) {
318         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedStart done fail, error: %{public}d", error);
319         return;
320     }
321     return;
322 }
323 
NotifyPlaybackPosChanged(int32_t playbackPos)324 void BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged(int32_t playbackPos)
325 {
326     HILOGI("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged start");
327     MessageParcel data;
328     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
329         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged WriteInterfaceToken error");
330         return;
331     }
332     if (!data.WriteInt32(playbackPos)) {
333         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged playbackPos error");
334         return;
335     }
336 
337     MessageParcel reply;
338     MessageOption option = { MessageOption::TF_ASYNC };
339     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_PLAYBACK_POS_CHANGED,
340                               option, data, reply);
341     if (error != NO_ERROR) {
342         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged done fail, error: %{public}d", error);
343         return;
344     }
345     return;
346 }
347 
NotifyPlayerAppSettingChanged(const std::vector<int32_t> & attributes,const std::vector<int32_t> & values)348 void BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged(const std::vector<int32_t> &attributes,
349     const std::vector<int32_t> &values)
350 {
351     MessageParcel data;
352     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
353         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged WriteInterfaceToken error");
354         return;
355     }
356     int attributesNum = attributes.size();
357     if (!data.WriteInt32(attributesNum)) {
358         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged attributesNum error");
359         return;
360     }
361     for (int i = 0; i < attributesNum; i++) {
362         if (!data.WriteInt32(attributes[i])) {
363             HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged attributes error");
364             return;
365         }
366     }
367 
368     int valuesNum = values.size();
369     if (!data.WriteInt32(valuesNum)) {
370         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged valuesNum error");
371         return;
372     }
373     for (int i = 0; i < valuesNum; i++) {
374         if (!data.WriteInt32(values[i])) {
375             HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged values error");
376             return;
377         }
378     }
379 
380     MessageParcel reply;
381     MessageOption option = { MessageOption::TF_ASYNC };
382     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_PLAYER_APP_SETTING_CHANGED,
383                               option, data, reply);
384     if (error != NO_ERROR) {
385         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged done fail, error: %{public}d", error);
386         return;
387     }
388     return;
389 }
390 
NotifyNowPlayingContentChanged()391 void BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged()
392 {
393     HILOGI("BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged start");
394     MessageParcel data;
395     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
396         HILOGE("BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged WriteInterfaceToken error");
397         return;
398     }
399 
400     MessageParcel reply;
401     MessageOption option = { MessageOption::TF_ASYNC };
402     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_NOWPLAYING_CONTENT_CHANGED,
403                               option, data, reply);
404     if (error != NO_ERROR) {
405         HILOGE("BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged done fail, error: %{public}d", error);
406         return;
407     }
408     return;
409 }
410 
NotifyAvailablePlayersChanged()411 void BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged()
412 {
413     HILOGI("BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged start");
414     MessageParcel data;
415     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
416         HILOGE("BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged WriteInterfaceToken error");
417         return;
418     }
419 
420     MessageParcel reply;
421     MessageOption option = { MessageOption::TF_ASYNC };
422 
423     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_AVAILABLE_PLAYERS_CHANGED,
424                               option, data, reply);
425     if (error != NO_ERROR) {
426         HILOGE("BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged done fail, error: %{public}d", error);
427         return;
428     }
429     return;
430 }
431 
NotifyAddressedPlayerChanged(int32_t playerId,int32_t uidCounter)432 void BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged(int32_t playerId, int32_t uidCounter)
433 {
434     HILOGI("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged start");
435     MessageParcel data;
436     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
437         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged WriteInterfaceToken error");
438         return;
439     }
440     if (!data.WriteInt32(playerId)) {
441         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged playStatus error");
442         return;
443     }
444     if (!data.WriteInt32(uidCounter)) {
445         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged playbackPos error");
446         return;
447     }
448 
449     MessageParcel reply;
450     MessageOption option = { MessageOption::TF_ASYNC };
451     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_ADDRESSED_PLAYER_CHANGED,
452                               option, data, reply);
453     if (error != NO_ERROR) {
454         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged done fail, error: %{public}d", error);
455         return;
456     }
457     return;
458 }
459 
NotifyUidChanged(int32_t uidCounter)460 void BluetoothAvrcpTgProxy::NotifyUidChanged(int32_t uidCounter)
461 {
462     HILOGI("BluetoothAvrcpTgProxy::NotifyUidChanged start");
463     MessageParcel data;
464     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
465         HILOGE("BluetoothAvrcpTgProxy::NotifyUidChanged WriteInterfaceToken error");
466         return;
467     }
468     if (!data.WriteInt32(uidCounter)) {
469         HILOGE("BluetoothAvrcpTgProxy::NotifyUidChanged playStatus error");
470         return;
471     }
472 
473     MessageParcel reply;
474     MessageOption option = { MessageOption::TF_ASYNC };
475     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_UID_CHANGED, option, data, reply);
476     if (error != NO_ERROR) {
477         HILOGE("BluetoothAvrcpTgProxy::NotifyUidChanged done fail, error: %{public}d", error);
478         return;
479     }
480     return;
481 }
482 
NotifyVolumeChanged(int32_t volume)483 void BluetoothAvrcpTgProxy::NotifyVolumeChanged(int32_t volume)
484 {
485     HILOGI("BluetoothAvrcpTgProxy::NotifyVolumeChanged start");
486     MessageParcel data;
487     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
488         HILOGE("BluetoothAvrcpTgProxy::NotifyVolumeChanged WriteInterfaceToken error");
489         return;
490     }
491     if (!data.WriteInt32(volume)) {
492         HILOGE("BluetoothAvrcpTgProxy::NotifyVolumeChanged playStatus error");
493         return;
494     }
495 
496     MessageParcel reply;
497     MessageOption option = { MessageOption::TF_ASYNC };
498     int error = InnerTransact(BluetoothAvrcpTgInterfaceCode::BT_AVRCP_TG_NOTIFY_VOLUME_CHANGED, option, data, reply);
499     if (error != NO_ERROR) {
500         HILOGE("BluetoothAvrcpTgProxy::NotifyVolumeChanged done fail, error: %{public}d", error);
501         return;
502     }
503     return;
504 }
505 
InnerTransact(uint32_t code,MessageOption & flags,MessageParcel & data,MessageParcel & reply)506 ErrCode BluetoothAvrcpTgProxy::InnerTransact(
507     uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply)
508 {
509     auto remote = Remote();
510     if (remote == nullptr) {
511         HILOGW("[InnerTransact] fail: get Remote fail code %{public}d", code);
512         return OBJECT_NULL;
513     }
514     int err = remote->SendRequest(code, data, reply, flags);
515     switch (err) {
516         case NO_ERROR: {
517             return NO_ERROR;
518         }
519         case DEAD_OBJECT: {
520             HILOGW("[InnerTransact] fail: ipcErr=%{public}d code %{public}d", err, code);
521             return DEAD_OBJECT;
522         }
523         default: {
524             HILOGW("[InnerTransact] fail: ipcErr=%{public}d code %{public}d", err, code);
525             return TRANSACTION_ERR;
526         }
527     }
528 }
529 }  // namespace Bluetooth
530 }  // namespace OHOS