• 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(IBluetoothAvrcpTg::Code::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(IBluetoothAvrcpTg::Code::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         IBluetoothAvrcpTg::Code::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(IBluetoothAvrcpTg::Code::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(IBluetoothAvrcpTg::Code::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<sptr<BluetoothRawAddress>> BluetoothAvrcpTgProxy::GetConnectedDevices()
137 {
138     std::vector<sptr<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(IBluetoothAvrcpTg::Code::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         sptr<BluetoothRawAddress> rawAddress = reply.ReadStrongParcelable<BluetoothRawAddress>();
155         vec.push_back(rawAddress);
156     }
157     return vec;
158 }
159 
GetDevicesByStates(const std::vector<int32_t> & states)160 std::vector<sptr<BluetoothRawAddress>> BluetoothAvrcpTgProxy::GetDevicesByStates(const std::vector<int32_t> &states)
161 {
162     std::vector<sptr<BluetoothRawAddress>> vec;
163     MessageParcel data;
164     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
165         HILOGE("BluetoothAvrcpTgProxy::GetConnectedDevices WriteInterfaceToken error");
166         return vec;
167     }
168     int num = states.size();
169     if (!data.WriteInt32(num)) {
170         HILOGE("BluetoothAvrcpTgProxy::GetDevicesByStates num error");
171         return vec;
172     }
173     for (int i = 0; i < num; i++) {
174         if (!data.WriteInt32(states[i])) {
175             HILOGE("BluetoothAvrcpTgProxy::GetDevicesByStates states error");
176             return vec;
177         }
178     }
179 
180     MessageParcel reply;
181     MessageOption option = {MessageOption::TF_SYNC};
182     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_GET_DEVICES_BY_STATES, option, data, reply);
183     if (error != NO_ERROR) {
184         HILOGE("BluetoothAvrcpTgProxy::GetConnectedDevices done fail, error: %{public}d", error);
185         return vec;
186     }
187     int32_t size = reply.ReadInt32();
188     for (int32_t i = 0; i < size; i++) {
189         sptr<BluetoothRawAddress> rawAddress = reply.ReadStrongParcelable<BluetoothRawAddress>();
190         vec.push_back(rawAddress);
191     }
192     return vec;
193 }
194 
GetDeviceState(const BluetoothRawAddress & addr)195 int32_t BluetoothAvrcpTgProxy::GetDeviceState(const BluetoothRawAddress &addr)
196 {
197     HILOGI("BluetoothAvrcpTgProxy::GetDeviceState start");
198     MessageParcel data;
199     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
200         HILOGE("BluetoothAvrcpTgProxy::GetDeviceState WriteInterfaceToken error");
201         return -1;
202     }
203     if (!data.WriteParcelable(&addr)) {
204         HILOGE("BluetoothAvrcpTgProxy::GetDeviceState transport error");
205         return -1;
206     }
207 
208     MessageParcel reply;
209     MessageOption option = { MessageOption::TF_SYNC };
210     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_GET_DEVICE_STATE, option, data, reply);
211     if (error != NO_ERROR) {
212         HILOGE("BluetoothAvrcpTgProxy::GetDeviceState done fail, error: %{public}d", error);
213         return -1;
214     }
215     return reply.ReadInt32();
216 }
217 
NotifyPlaybackStatusChanged(int32_t playStatus,int32_t playbackPos)218 void BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged(int32_t playStatus, int32_t playbackPos)
219 {
220     HILOGI("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged start");
221     MessageParcel data;
222     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
223         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged WriteInterfaceToken error");
224         return;
225     }
226     if (!data.WriteInt32(playStatus)) {
227         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged playStatus error");
228         return;
229     }
230     if (!data.WriteInt32(playbackPos)) {
231         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged playbackPos error");
232         return;
233     }
234 
235     MessageParcel reply;
236     MessageOption option = { MessageOption::TF_ASYNC };
237     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_PLAYBACK_STATUS_CHANGED,
238                               option, data, reply);
239     if (error != NO_ERROR) {
240         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged done fail, error: %{public}d", error);
241         return;
242     }
243     return;
244 }
245 
NotifyTrackChanged(int64_t uid,int32_t playbackPos)246 void BluetoothAvrcpTgProxy::NotifyTrackChanged(int64_t uid, int32_t playbackPos)
247 {
248     HILOGI("BluetoothAvrcpTgProxy::NotifyTrackChanged start");
249     MessageParcel data;
250     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
251         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackChanged WriteInterfaceToken error");
252         return;
253     }
254     if (!data.WriteInt64(uid)) {
255         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackChanged uid error");
256         return;
257     }
258     if (!data.WriteInt32(playbackPos)) {
259         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackChanged playbackPos error");
260         return;
261     }
262 
263     MessageParcel reply;
264     MessageOption option = { MessageOption::TF_ASYNC };
265     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_TRACK_CHANGED, option, data, reply);
266     if (error != NO_ERROR) {
267         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackStatusChanged done fail, error: %{public}d", error);
268         return;
269     }
270     return;
271 }
272 
NotifyTrackReachedEnd(int32_t playbackPos)273 void BluetoothAvrcpTgProxy::NotifyTrackReachedEnd(int32_t playbackPos)
274 {
275     HILOGI("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd start");
276     MessageParcel data;
277     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
278         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd WriteInterfaceToken error");
279         return;
280     }
281     if (!data.WriteInt32(playbackPos)) {
282         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd playbackPos error");
283         return;
284     }
285 
286     MessageParcel reply;
287     MessageOption option = { MessageOption::TF_ASYNC };
288     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_TRACK_REACHED_END,
289                               option, data, reply);
290     if (error != NO_ERROR) {
291         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedEnd done fail, error: %{public}d", error);
292         return;
293     }
294     return;
295 }
296 
NotifyTrackReachedStart(int32_t playbackPos)297 void BluetoothAvrcpTgProxy::NotifyTrackReachedStart(int32_t playbackPos)
298 {
299     HILOGI("BluetoothAvrcpTgProxy::NotifyTrackReachedStart start");
300     MessageParcel data;
301     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
302         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedStart WriteInterfaceToken error");
303         return;
304     }
305     if (!data.WriteInt32(playbackPos)) {
306         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedStart playbackPos error");
307         return;
308     }
309 
310     MessageParcel reply;
311     MessageOption option = { MessageOption::TF_ASYNC };
312     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_TRACK_REACHED_START,
313                               option, data, reply);
314     if (error != NO_ERROR) {
315         HILOGE("BluetoothAvrcpTgProxy::NotifyTrackReachedStart done fail, error: %{public}d", error);
316         return;
317     }
318     return;
319 }
320 
NotifyPlaybackPosChanged(int32_t playbackPos)321 void BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged(int32_t playbackPos)
322 {
323     HILOGI("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged start");
324     MessageParcel data;
325     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
326         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged WriteInterfaceToken error");
327         return;
328     }
329     if (!data.WriteInt32(playbackPos)) {
330         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged playbackPos error");
331         return;
332     }
333 
334     MessageParcel reply;
335     MessageOption option = { MessageOption::TF_ASYNC };
336     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_PLAYBACK_POS_CHANGED,
337                               option, data, reply);
338     if (error != NO_ERROR) {
339         HILOGE("BluetoothAvrcpTgProxy::NotifyPlaybackPosChanged done fail, error: %{public}d", error);
340         return;
341     }
342     return;
343 }
344 
NotifyPlayerAppSettingChanged(const std::vector<int32_t> & attributes,const std::vector<int32_t> & values)345 void BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged(const std::vector<int32_t> &attributes,
346     const std::vector<int32_t> &values)
347 {
348     MessageParcel data;
349     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
350         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged WriteInterfaceToken error");
351         return;
352     }
353     int attributesNum = attributes.size();
354     if (!data.WriteInt32(attributesNum)) {
355         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged attributesNum error");
356         return;
357     }
358     for (int i = 0; i < attributesNum; i++) {
359         if (!data.WriteInt32(attributes[i])) {
360             HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged attributes error");
361             return;
362         }
363     }
364 
365     int valuesNum = values.size();
366     if (!data.WriteInt32(valuesNum)) {
367         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged valuesNum error");
368         return;
369     }
370     for (int i = 0; i < valuesNum; i++) {
371         if (!data.WriteInt32(values[i])) {
372             HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged values error");
373             return;
374         }
375     }
376 
377     MessageParcel reply;
378     MessageOption option = { MessageOption::TF_ASYNC };
379     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_PLAYER_APP_SETTING_CHANGED,
380                               option, data, reply);
381     if (error != NO_ERROR) {
382         HILOGE("BluetoothAvrcpTgProxy::NotifyPlayerAppSettingChanged done fail, error: %{public}d", error);
383         return;
384     }
385     return;
386 }
387 
NotifyNowPlayingContentChanged()388 void BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged()
389 {
390     HILOGI("BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged start");
391     MessageParcel data;
392     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
393         HILOGE("BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged WriteInterfaceToken error");
394         return;
395     }
396 
397     MessageParcel reply;
398     MessageOption option = { MessageOption::TF_ASYNC };
399     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_NOWPLAYING_CONTENT_CHANGED,
400                               option, data, reply);
401     if (error != NO_ERROR) {
402         HILOGE("BluetoothAvrcpTgProxy::NotifyNowPlayingContentChanged done fail, error: %{public}d", error);
403         return;
404     }
405     return;
406 }
407 
NotifyAvailablePlayersChanged()408 void BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged()
409 {
410     HILOGI("BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged start");
411     MessageParcel data;
412     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
413         HILOGE("BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged WriteInterfaceToken error");
414         return;
415     }
416 
417     MessageParcel reply;
418     MessageOption option = { MessageOption::TF_ASYNC };
419 
420     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_AVAILABLE_PLAYERS_CHANGED,
421                               option, data, reply);
422     if (error != NO_ERROR) {
423         HILOGE("BluetoothAvrcpTgProxy::NotifyAvailablePlayersChanged done fail, error: %{public}d", error);
424         return;
425     }
426     return;
427 }
428 
NotifyAddressedPlayerChanged(int32_t playerId,int32_t uidCounter)429 void BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged(int32_t playerId, int32_t uidCounter)
430 {
431     HILOGI("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged start");
432     MessageParcel data;
433     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
434         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged WriteInterfaceToken error");
435         return;
436     }
437     if (!data.WriteInt32(playerId)) {
438         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged playStatus error");
439         return;
440     }
441     if (!data.WriteInt32(uidCounter)) {
442         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged playbackPos error");
443         return;
444     }
445 
446     MessageParcel reply;
447     MessageOption option = { MessageOption::TF_ASYNC };
448     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_ADDRESSED_PLAYER_CHANGED,
449                               option, data, reply);
450     if (error != NO_ERROR) {
451         HILOGE("BluetoothAvrcpTgProxy::NotifyAddressedPlayerChanged done fail, error: %{public}d", error);
452         return;
453     }
454     return;
455 }
456 
NotifyUidChanged(int32_t uidCounter)457 void BluetoothAvrcpTgProxy::NotifyUidChanged(int32_t uidCounter)
458 {
459     HILOGI("BluetoothAvrcpTgProxy::NotifyUidChanged start");
460     MessageParcel data;
461     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
462         HILOGE("BluetoothAvrcpTgProxy::NotifyUidChanged WriteInterfaceToken error");
463         return;
464     }
465     if (!data.WriteInt32(uidCounter)) {
466         HILOGE("BluetoothAvrcpTgProxy::NotifyUidChanged playStatus error");
467         return;
468     }
469 
470     MessageParcel reply;
471     MessageOption option = { MessageOption::TF_ASYNC };
472     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_UID_CHANGED, option, data, reply);
473     if (error != NO_ERROR) {
474         HILOGE("BluetoothAvrcpTgProxy::NotifyUidChanged done fail, error: %{public}d", error);
475         return;
476     }
477     return;
478 }
479 
NotifyVolumeChanged(int32_t volume)480 void BluetoothAvrcpTgProxy::NotifyVolumeChanged(int32_t volume)
481 {
482     HILOGI("BluetoothAvrcpTgProxy::NotifyVolumeChanged start");
483     MessageParcel data;
484     if (!data.WriteInterfaceToken(BluetoothAvrcpTgProxy::GetDescriptor())) {
485         HILOGE("BluetoothAvrcpTgProxy::NotifyVolumeChanged WriteInterfaceToken error");
486         return;
487     }
488     if (!data.WriteInt32(volume)) {
489         HILOGE("BluetoothAvrcpTgProxy::NotifyVolumeChanged playStatus error");
490         return;
491     }
492 
493     MessageParcel reply;
494     MessageOption option = { MessageOption::TF_ASYNC };
495     int error = InnerTransact(IBluetoothAvrcpTg::Code::BT_AVRCP_TG_NOTIFY_VOLUME_CHANGED, option, data, reply);
496     if (error != NO_ERROR) {
497         HILOGE("BluetoothAvrcpTgProxy::NotifyVolumeChanged done fail, error: %{public}d", error);
498         return;
499     }
500     return;
501 }
502 
InnerTransact(uint32_t code,MessageOption & flags,MessageParcel & data,MessageParcel & reply)503 ErrCode BluetoothAvrcpTgProxy::InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply)
504 {
505     auto remote = Remote();
506     if (remote == nullptr) {
507         HILOGW("[InnerTransact] fail: get Remote fail code %{public}d", code);
508         return OBJECT_NULL;
509     }
510     int err = remote->SendRequest(code, data, reply, flags);
511     switch (err) {
512         case NO_ERROR: {
513             return NO_ERROR;
514         }
515         case DEAD_OBJECT: {
516             HILOGW("[InnerTransact] fail: ipcErr=%{public}d code %{public}d", err, code);
517             return DEAD_OBJECT;
518         }
519         default: {
520             HILOGW("[InnerTransact] fail: ipcErr=%{public}d code %{public}d", err, code);
521             return TRANSACTION_ERR;
522         }
523     }
524 }
525 }  // namespace Bluetooth
526 }  // namespace OHOS