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_mce_observer_proxy.h"
17 #include "bluetooth_log.h"
18
19 namespace OHOS {
20 namespace Bluetooth {
OnMapActionCompleted(const BluetoothRawAddress & device,const BluetoothIProfileMapAction & action,const int status)21 void BluetoothMapMceObserverProxy::OnMapActionCompleted(
22 const BluetoothRawAddress &device, const BluetoothIProfileMapAction &action, const int status)
23 {
24 HILOGI("BluetoothMapMceObserverProxy::OnMapActionCompleted Triggered!");
25 MessageParcel data;
26 if (!data.WriteInterfaceToken(BluetoothMapMceObserverProxy::GetDescriptor())) {
27 HILOGE("BluetoothMapMceObserverProxy::OnConnectionStateChanged WriteInterfaceToken error");
28 return;
29 }
30 if (!data.WriteParcelable(&device)) {
31 HILOGE("BluetoothMapMceObserverProxy::OnMapActionCompleted error");
32 return;
33 }
34 if (!data.WriteParcelable(&action)) {
35 HILOGE("BluetoothMapMceObserverProxy::OnMapActionCompleted error");
36 return;
37 }
38 if (!data.WriteInt32(status)) {
39 HILOGE("BluetoothMapMceObserverProxy::OnMapActionCompleted transport error");
40 return;
41 }
42 MessageParcel reply;
43 MessageOption option {
44 MessageOption::TF_ASYNC
45 };
46 int error = Remote()->SendRequest(
47 BluetoothMapMceObserverInterfaceCode::MCE_ON_ACTION_COMPLETED, data, reply, option);
48 if (error != NO_ERROR) {
49 HILOGE("BluetoothMapMceObserverProxy::OnMapActionCompleted done fail, error: %{public}d", error);
50 return;
51 }
52 }
53
OnConnectionStateChanged(const BluetoothRawAddress & device,int status)54 void BluetoothMapMceObserverProxy::OnConnectionStateChanged(
55 const BluetoothRawAddress &device, int status)
56 {
57 HILOGI("BluetoothMapMceObserverProxy::OnConnectionStateChanged Triggered!");
58 MessageParcel data;
59 if (!data.WriteInterfaceToken(BluetoothMapMceObserverProxy::GetDescriptor())) {
60 HILOGE("BluetoothMapMceObserverProxy::OnConnectionStateChanged WriteInterfaceToken error");
61 return;
62 }
63 if (!data.WriteParcelable(&device)) {
64 HILOGE("BluetoothMapMceObserverProxy::OnConnectionStateChanged error");
65 return;
66 }
67 if (!data.WriteInt32(status)) {
68 HILOGE("BluetoothMapMceObserverProxy::OnConnectionStateChanged transport error");
69 return;
70 }
71 MessageParcel reply;
72 MessageOption option {
73 MessageOption::TF_ASYNC
74 };
75 int error = Remote()->SendRequest(
76 BluetoothMapMceObserverInterfaceCode::MCE_ON_CONNECTION_STATE_CHANGED, data, reply, option);
77 if (error != NO_ERROR) {
78 HILOGE("BluetoothMapMceObserverProxy::OnConnectionStateChanged done fail, error: %{public}d", error);
79 return;
80 }
81 }
82
OnMapEventReported(const BluetoothRawAddress & device,const BluetoothIProfileMapEventReport & report)83 void BluetoothMapMceObserverProxy::OnMapEventReported(
84 const BluetoothRawAddress &device, const BluetoothIProfileMapEventReport &report)
85 {
86 HILOGI("BluetoothMapMceObserverProxy::OnMapEventReported Triggered!");
87 MessageParcel data;
88 if (!data.WriteInterfaceToken(BluetoothMapMceObserverProxy::GetDescriptor())) {
89 HILOGE("BluetoothMapMceObserverProxy::OnMapEventReported WriteInterfaceToken error");
90 return;
91 }
92 if (!data.WriteParcelable(&device)) {
93 HILOGE("BluetoothMapMceObserverProxy::OnMapActionCompleted error");
94 return;
95 }
96 if (!data.WriteParcelable(&report)) {
97 HILOGE("BluetoothMapMceObserverProxy::OnMapActionCompleted error");
98 return;
99 }
100 MessageParcel reply;
101 MessageOption option {
102 MessageOption::TF_ASYNC
103 };
104 int error = Remote()->SendRequest(
105 BluetoothMapMceObserverInterfaceCode::MCE_ON_EVENT_REPORTED, data, reply, option);
106 if (error != NO_ERROR) {
107 HILOGE("BluetoothMapMceObserverProxy::OnMapEventReported done fail, error: %{public}d", error);
108 return;
109 }
110 }
111
OnBmessageCompleted(const BluetoothRawAddress & device,const BluetoothIProfileBMessage & bmsg,const int status)112 void BluetoothMapMceObserverProxy::OnBmessageCompleted(
113 const BluetoothRawAddress &device, const BluetoothIProfileBMessage &bmsg, const int status)
114 {
115 HILOGI("BluetoothMapMceObserverProxy::OnBmessageCompleted Triggered!");
116 MessageParcel data;
117 if (!data.WriteInterfaceToken(BluetoothMapMceObserverProxy::GetDescriptor())) {
118 HILOGE("BluetoothMapMceObserverProxy::OnBmessageCompleted WriteInterfaceToken error");
119 return;
120 }
121 if (!data.WriteParcelable(&device)) {
122 HILOGE("BluetoothMapMceObserverProxy::OnBmessageCompleted error");
123 return;
124 }
125 if (!data.WriteParcelable(&bmsg)) {
126 HILOGE("BluetoothMapMceObserverProxy::OnBmessageCompleted error");
127 return;
128 }
129 if (!data.WriteInt32(status)) {
130 HILOGE("BluetoothMapMceObserverProxy::OnBmessageCompleted transport error");
131 return;
132 }
133 MessageParcel reply;
134 MessageOption option {
135 MessageOption::TF_ASYNC
136 };
137 int error = Remote()->SendRequest(
138 BluetoothMapMceObserverInterfaceCode::MCE_ON_BMESSAGE_COMPLETED, data, reply, option);
139 if (error != NO_ERROR) {
140 HILOGE("BluetoothMapMceObserverProxy::OnBmessageCompleted done fail, error: %{public}d", error);
141 return;
142 }
143 }
144
OnMessagesListingCompleted(const BluetoothRawAddress & device,const BluetoothIProfileMessagesListing & listing,const int status)145 void BluetoothMapMceObserverProxy::OnMessagesListingCompleted(
146 const BluetoothRawAddress &device, const BluetoothIProfileMessagesListing &listing, const int status)
147 {
148 HILOGI("BluetoothMapMceObserverProxy::OnMessagesListingCompleted Triggered!");
149 MessageParcel data;
150 if (!data.WriteInterfaceToken(BluetoothMapMceObserverProxy::GetDescriptor())) {
151 HILOGE("BluetoothMapMceObserverProxy::OnMessagesListingCompleted WriteInterfaceToken error");
152 return;
153 }
154 if (!data.WriteParcelable(&device)) {
155 HILOGE("BluetoothMapMceObserverProxy::OnMessagesListingCompleted error");
156 return;
157 }
158 if (!data.WriteParcelable(&listing)) {
159 HILOGE("BluetoothMapMceObserverProxy::OnMessagesListingCompleted error");
160 return;
161 }
162 if (!data.WriteInt32(status)) {
163 HILOGE("BluetoothMapMceObserverProxy::OnMessagesListingCompleted transport error");
164 return;
165 }
166 MessageParcel reply;
167 MessageOption option {
168 MessageOption::TF_ASYNC
169 };
170 int error = Remote()->SendRequest(
171 BluetoothMapMceObserverInterfaceCode::MCE_ON_MESSAGE_LIST_COMPLETED, data, reply, option);
172 if (error != NO_ERROR) {
173 HILOGE("BluetoothMapMceObserverProxy::OnMessagesListingCompleted done fail, error: %{public}d", error);
174 return;
175 }
176 }
177
OnConversationListingCompleted(const BluetoothRawAddress & device,const BluetoothIProfileConversationListing & listing,const int status)178 void BluetoothMapMceObserverProxy::OnConversationListingCompleted(
179 const BluetoothRawAddress &device, const BluetoothIProfileConversationListing &listing, const int status)
180 {
181 HILOGI("BluetoothMapMceObserverProxy::OnConversationListingCompleted Triggered!");
182 MessageParcel data;
183 if (!data.WriteInterfaceToken(BluetoothMapMceObserverProxy::GetDescriptor())) {
184 HILOGE("BluetoothMapMceObserverProxy::OnConversationListingCompleted WriteInterfaceToken error");
185 return;
186 }
187 if (!data.WriteParcelable(&device)) {
188 HILOGE("BluetoothMapMceObserverProxy::OnConversationListingCompleted error");
189 return;
190 }
191 if (!data.WriteParcelable(&listing)) {
192 HILOGE("BluetoothMapMceObserverProxy::OnConversationListingCompleted error");
193 return;
194 }
195 if (!data.WriteInt32(status)) {
196 HILOGE("BluetoothMapMceObserverProxy::OnConversationListingCompleted transport error");
197 return;
198 }
199 MessageParcel reply;
200 MessageOption option {
201 MessageOption::TF_ASYNC
202 };
203 int error = Remote()->SendRequest(
204 BluetoothMapMceObserverInterfaceCode::MCE_ON_CONVERSATION_LIST_COMPLETED, data, reply, option);
205 if (error != NO_ERROR) {
206 HILOGE("BluetoothMapMceObserverProxy::OnConversationListingCompleted done fail, error: %{public}d", error);
207 return;
208 }
209 }
210 } // namespace Bluetooth
211 } // namespace OHOS
212