• 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_map_mse_observer_proxy.h"
17 #include "bluetooth_log.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
OnConnectionStateChanged(const BluetoothRawAddress & device,int status)21 void BluetoothMapMseObserverProxy::OnConnectionStateChanged(
22     const BluetoothRawAddress &device, int status)
23 {
24     HILOGI("BluetoothMapMseObserverProxy::OnConnectionStateChanged Triggered!");
25     MessageParcel data;
26     if (!data.WriteInterfaceToken(BluetoothMapMseObserverProxy::GetDescriptor())) {
27         HILOGE("BluetoothMapMseObserverProxy::OnConnectionStateChanged WriteInterfaceToken error");
28         return;
29     }
30     if (!data.WriteParcelable(&device)) {
31         HILOGE("BluetoothMapMseObserverProxy::OnConnectionStateChanged error");
32         return;
33     }
34     if (!data.WriteInt32(status)) {
35         HILOGE("BluetoothMapMseObserverProxy::OnConnectionStateChanged transport error");
36         return;
37     }
38     MessageParcel reply;
39     MessageOption option {
40         MessageOption::TF_ASYNC
41     };
42     int error = Remote()->SendRequest(
43         BluetoothMapMseObserverInterfaceCode::MSE_ON_CONNECTION_STATE_CHANGED, data, reply, option);
44     if (error != NO_ERROR) {
45         HILOGE("BluetoothMapMseObserverProxy::OnConnectionStateChanged done fail, error: %{public}d", error);
46         return;
47     }
48 }
49 
OnPermission(const BluetoothRawAddress & device)50 void BluetoothMapMseObserverProxy::OnPermission(
51     const BluetoothRawAddress &device)
52 {
53     HILOGI("BluetoothMapMseObserverProxy::OnMapEventReported Triggered!");
54     MessageParcel data;
55     if (!data.WriteInterfaceToken(BluetoothMapMseObserverProxy::GetDescriptor())) {
56         HILOGE("BluetoothMapMseObserverProxy::OnMapEventReported WriteInterfaceToken error");
57         return;
58     }
59     if (!data.WriteParcelable(&device)) {
60         HILOGE("BluetoothMapMseObserverProxy::OnMapActionCompleted error");
61         return;
62     }
63     MessageParcel reply;
64     MessageOption option {
65         MessageOption::TF_ASYNC
66     };
67     int error = Remote()->SendRequest(
68         BluetoothMapMseObserverInterfaceCode::MSE_ON_PERMISSION, data, reply, option);
69     if (error != NO_ERROR) {
70         HILOGE("BluetoothMapMseObserverProxy::OnMapEventReported done fail, error: %{public}d", error);
71         return;
72     }
73 }
74 }  // namespace Bluetooth
75 }  // namespace OHOS
76