• 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_observer_proxy.h"
17 #include "bluetooth_log.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
OnConnectionStateChanged(const BluetoothRawAddress & device,int32_t state)21 void BluetoothAvrcpTgObserverProxy::OnConnectionStateChanged(const BluetoothRawAddress &device, int32_t state)
22 {
23     HILOGI("BluetoothAvrcpTgObserverProxy::OnConnectionStateChanged Triggered!");
24     MessageParcel data;
25     if (!data.WriteInterfaceToken(BluetoothAvrcpTgObserverProxy::GetDescriptor())) {
26         HILOGE("BluetoothAvrcpTgObserverProxy::OnConnectionStateChanged WriteInterfaceToken error");
27         return;
28     }
29     if (!data.WriteParcelable(&device)) {
30         HILOGE("BluetoothAvrcpTgObserverProxy::OnConnectionStateChanged device error");
31         return;
32     }
33     if (!data.WriteInt32(state)) {
34         HILOGE("BluetoothAvrcpTgObserverProxy::OnConnectionStateChanged transport error");
35         return;
36     }
37 
38     MessageParcel reply;
39     MessageOption option = { MessageOption::TF_ASYNC };
40     int error = Remote()->SendRequest(
41         BluetoothAvrcpTgObserverInterfaceCode::BT_AVRCP_TG_OBSERVER_CONNECTION_STATE_CHANGED, data, reply, option);
42     if (error != NO_ERROR) {
43         HILOGE("BluetoothAvrcpTgObserverProxy::OnConnectionStateChanged done fail, error: %{public}d", error);
44         return;
45     }
46 }
47 }  // namespace Bluetooth
48 }  // namespace OHOS