1 /*
2 * Copyright (C) 2021-2022 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_host_stub.h"
17 #include "bluetooth_log.h"
18 #include "bluetooth_errorcode.h"
19 #include "ipc_types.h"
20 #include "raw_address.h"
21 #include "string_ex.h"
22 #include "permission_utils.h"
23
24 namespace OHOS {
25 namespace Bluetooth {
26 const std::map<uint32_t, std::function<ErrCode(BluetoothHostStub *, MessageParcel &, MessageParcel &)>>
27 BluetoothHostStub::memberFuncMap_ = {
28 {BluetoothHostInterfaceCode::BT_REGISTER_OBSERVER,
29 std::bind(&BluetoothHostStub::RegisterObserverInner, std::placeholders::_1, std::placeholders::_2,
30 std::placeholders::_3)},
31 {BluetoothHostInterfaceCode::BT_DEREGISTER_OBSERVER,
32 std::bind(&BluetoothHostStub::DeregisterObserverInner, std::placeholders::_1, std::placeholders::_2,
33 std::placeholders::_3)},
34 {BluetoothHostInterfaceCode::BT_ENABLE,
35 std::bind(&BluetoothHostStub::EnableBtInner, std::placeholders::_1, std::placeholders::_2,
36 std::placeholders::_3)},
37 {BluetoothHostInterfaceCode::BT_DISABLE,
38 std::bind(&BluetoothHostStub::DisableBtInner, std::placeholders::_1, std::placeholders::_2,
39 std::placeholders::_3)},
40 {BluetoothHostInterfaceCode::BT_GETPROFILE,
41 std::bind(&BluetoothHostStub::GetProfileInner, std::placeholders::_1, std::placeholders::_2,
42 std::placeholders::_3)},
43 {BluetoothHostInterfaceCode::BT_GET_BLE,
44 std::bind(&BluetoothHostStub::GetBleRemoteInner, std::placeholders::_1, std::placeholders::_2,
45 std::placeholders::_3)},
46 {BluetoothHostInterfaceCode::BT_FACTORY_RESET,
47 std::bind(&BluetoothHostStub::BluetoothFactoryResetInner, std::placeholders::_1, std::placeholders::_2,
48 std::placeholders::_3)},
49 {BluetoothHostInterfaceCode::BT_GETSTATE,
50 std::bind(&BluetoothHostStub::GetBtStateInner, std::placeholders::_1, std::placeholders::_2,
51 std::placeholders::_3)},
52 {BluetoothHostInterfaceCode::BT_GET_LOCAL_ADDRESS,
53 std::bind(&BluetoothHostStub::GetLocalAddressInner, std::placeholders::_1, std::placeholders::_2,
54 std::placeholders::_3)},
55 {BluetoothHostInterfaceCode::BT_DISABLE_BLE,
56 std::bind(&BluetoothHostStub::DisableBleInner, std::placeholders::_1, std::placeholders::_2,
57 std::placeholders::_3)},
58 {BluetoothHostInterfaceCode::BT_ENABLE_BLE,
59 std::bind(&BluetoothHostStub::EnableBleInner, std::placeholders::_1, std::placeholders::_2,
60 std::placeholders::_3)},
61 {BluetoothHostInterfaceCode::BT_GET_PROFILE_LIST,
62 std::bind(&BluetoothHostStub::GetProfileListInner, std::placeholders::_1, std::placeholders::_2,
63 std::placeholders::_3)},
64 {BluetoothHostInterfaceCode::BT_GET_MAXNUM_CONNECTED_AUDIODEVICES,
65 std::bind(&BluetoothHostStub::GetMaxNumConnectedAudioDevicesInner, std::placeholders::_1,
66 std::placeholders::_2, std::placeholders::_3)},
67 {BluetoothHostInterfaceCode::BT_GET_BT_STATE,
68 std::bind(&BluetoothHostStub::GetBtConnectionStateInner, std::placeholders::_1, std::placeholders::_2,
69 std::placeholders::_3)},
70 {BluetoothHostInterfaceCode::BT_GET_BT_PROFILE_CONNSTATE,
71 std::bind(&BluetoothHostStub::GetBtProfileConnStateInner, std::placeholders::_1, std::placeholders::_2,
72 std::placeholders::_3)},
73 {BluetoothHostInterfaceCode::BT_GET_LOCAL_DEVICE_CLASS,
74 std::bind(&BluetoothHostStub::GetLocalDeviceClassInner, std::placeholders::_1, std::placeholders::_2,
75 std::placeholders::_3)},
76 {BluetoothHostInterfaceCode::BT_SET_LOCAL_DEVICE_CLASS,
77 std::bind(&BluetoothHostStub::SetLocalDeviceClassInner, std::placeholders::_1, std::placeholders::_2,
78 std::placeholders::_3)},
79 {BluetoothHostInterfaceCode::BT_GET_LOCAL_NAME,
80 std::bind(&BluetoothHostStub::GetLocalNameInner, std::placeholders::_1, std::placeholders::_2,
81 std::placeholders::_3)},
82 {BluetoothHostInterfaceCode::BT_SET_LOCAL_NAME,
83 std::bind(&BluetoothHostStub::SetLocalNameInner, std::placeholders::_1, std::placeholders::_2,
84 std::placeholders::_3)},
85 {BluetoothHostInterfaceCode::BT_GET_BT_SCAN_MODE,
86 std::bind(&BluetoothHostStub::GetBtScanModeInner, std::placeholders::_1, std::placeholders::_2,
87 std::placeholders::_3)},
88 {BluetoothHostInterfaceCode::BT_SET_BT_SCAN_MODE,
89 std::bind(&BluetoothHostStub::SetBtScanModeInner, std::placeholders::_1, std::placeholders::_2,
90 std::placeholders::_3)},
91 {BluetoothHostInterfaceCode::BT_GET_BONDABLE_MODE,
92 std::bind(&BluetoothHostStub::GetBondableModeInner, std::placeholders::_1, std::placeholders::_2,
93 std::placeholders::_3)},
94 {BluetoothHostInterfaceCode::BT_SET_BONDABLE_MODE,
95 std::bind(&BluetoothHostStub::SetBondableModeInner, std::placeholders::_1, std::placeholders::_2,
96 std::placeholders::_3)},
97 {BluetoothHostInterfaceCode::BT_START_BT_DISCOVERY,
98 std::bind(&BluetoothHostStub::StartBtDiscoveryInner, std::placeholders::_1, std::placeholders::_2,
99 std::placeholders::_3)},
100 {BluetoothHostInterfaceCode::BT_CANCEL_BT_DISCOVERY,
101 std::bind(&BluetoothHostStub::CancelBtDiscoveryInner, std::placeholders::_1, std::placeholders::_2,
102 std::placeholders::_3)},
103 {BluetoothHostInterfaceCode::BT_IS_BT_DISCOVERING,
104 std::bind(&BluetoothHostStub::IsBtDiscoveringInner, std::placeholders::_1, std::placeholders::_2,
105 std::placeholders::_3)},
106 {BluetoothHostInterfaceCode::BT_GET_BT_DISCOVERY_END_MILLIS,
107 std::bind(&BluetoothHostStub::GetBtDiscoveryEndMillisInner, std::placeholders::_1, std::placeholders::_2,
108 std::placeholders::_3)},
109 {BluetoothHostInterfaceCode::BT_GET_PAIRED_DEVICES,
110 std::bind(&BluetoothHostStub::GetPairedDevicesInner, std::placeholders::_1, std::placeholders::_2,
111 std::placeholders::_3)},
112 {BluetoothHostInterfaceCode::BT_REMOVE_PAIR,
113 std::bind(&BluetoothHostStub::RemovePairInner, std::placeholders::_1, std::placeholders::_2,
114 std::placeholders::_3)},
115 {BluetoothHostInterfaceCode::BT_REMOVE_ALL_PAIRS,
116 std::bind(&BluetoothHostStub::RemoveAllPairsInner, std::placeholders::_1, std::placeholders::_2,
117 std::placeholders::_3)},
118 {BluetoothHostInterfaceCode::BT_REGISTER_REMOTE_DEVICE_OBSERVER,
119 std::bind(&BluetoothHostStub::RegisterRemoteDeviceObserverInner, std::placeholders::_1,
120 std::placeholders::_2, std::placeholders::_3)},
121 {BluetoothHostInterfaceCode::BT_DEREGISTER_REMOTE_DEVICE_OBSERVER,
122 std::bind(&BluetoothHostStub::DeregisterRemoteDeviceObserverInner, std::placeholders::_1,
123 std::placeholders::_2, std::placeholders::_3)},
124 {BluetoothHostInterfaceCode::BT_GET_BLE_MAX_ADVERTISING_DATALENGTH,
125 std::bind(&BluetoothHostStub::GetBleMaxAdvertisingDataLengthInner, std::placeholders::_1,
126 std::placeholders::_2, std::placeholders::_3)},
127 {BluetoothHostInterfaceCode::GET_DEVICE_TYPE,
128 std::bind(&BluetoothHostStub::GetDeviceTypeInner, std::placeholders::_1, std::placeholders::_2,
129 std::placeholders::_3)},
130 {BluetoothHostInterfaceCode::GET_PHONEBOOK_PERMISSION,
131 std::bind(&BluetoothHostStub::GetPhonebookPermissionInner, std::placeholders::_1, std::placeholders::_2,
132 std::placeholders::_3)},
133 {BluetoothHostInterfaceCode::SET_PHONEBOOK_PERMISSION,
134 nullptr},
135 {BluetoothHostInterfaceCode::GET_MESSAGE_PERMISSION,
136 std::bind(&BluetoothHostStub::GetMessagePermissionInner, std::placeholders::_1, std::placeholders::_2,
137 std::placeholders::_3)},
138 {BluetoothHostInterfaceCode::SET_MESSAGE_PERMISSION,
139 nullptr},
140 {BluetoothHostInterfaceCode::GET_POWER_MODE,
141 std::bind(&BluetoothHostStub::GetPowerModeInner, std::placeholders::_1, std::placeholders::_2,
142 std::placeholders::_3)},
143 {BluetoothHostInterfaceCode::GET_DEVICE_NAME,
144 std::bind(&BluetoothHostStub::GetDeviceNameInner, std::placeholders::_1, std::placeholders::_2,
145 std::placeholders::_3)},
146 {BluetoothHostInterfaceCode::GET_DEVICE_ALIAS,
147 std::bind(&BluetoothHostStub::GetDeviceAliasInner, std::placeholders::_1, std::placeholders::_2,
148 std::placeholders::_3)},
149 {BluetoothHostInterfaceCode::SET_DEVICE_ALIAS,
150 std::bind(&BluetoothHostStub::SetDeviceAliasInner, std::placeholders::_1, std::placeholders::_2,
151 std::placeholders::_3)},
152 {BluetoothHostInterfaceCode::GET_DEVICE_BATTERY_INFO,
153 std::bind(&BluetoothHostStub::GetRemoteDeviceBatteryInfoInner, std::placeholders::_1, std::placeholders::_2,
154 std::placeholders::_3)},
155 {BluetoothHostInterfaceCode::GET_PAIR_STATE,
156 std::bind(&BluetoothHostStub::GetPairStateInner, std::placeholders::_1, std::placeholders::_2,
157 std::placeholders::_3)},
158 {BluetoothHostInterfaceCode::START_PAIR,
159 std::bind(&BluetoothHostStub::StartPairInner, std::placeholders::_1, std::placeholders::_2,
160 std::placeholders::_3)},
161 {BluetoothHostInterfaceCode::CANCEL_PAIRING,
162 std::bind(&BluetoothHostStub::CancelPairingInner, std::placeholders::_1, std::placeholders::_2,
163 std::placeholders::_3)},
164 {BluetoothHostInterfaceCode::IS_BONDED_FROM_LOCAL,
165 std::bind(&BluetoothHostStub::IsBondedFromLocalInner, std::placeholders::_1, std::placeholders::_2,
166 std::placeholders::_3)},
167 {BluetoothHostInterfaceCode::IS_ACL_CONNECTED,
168 std::bind(&BluetoothHostStub::IsAclConnectedInner, std::placeholders::_1, std::placeholders::_2,
169 std::placeholders::_3)},
170 {BluetoothHostInterfaceCode::IS_ACL_ENCRYPTED,
171 std::bind(&BluetoothHostStub::IsAclEncryptedInner, std::placeholders::_1, std::placeholders::_2,
172 std::placeholders::_3)},
173 {BluetoothHostInterfaceCode::GET_DEVICE_CLASS,
174 std::bind(&BluetoothHostStub::GetDeviceClassInner, std::placeholders::_1, std::placeholders::_2,
175 std::placeholders::_3)},
176 {BluetoothHostInterfaceCode::SET_DEVICE_PIN,
177 std::bind(&BluetoothHostStub::SetDevicePinInner, std::placeholders::_1, std::placeholders::_2,
178 std::placeholders::_3)},
179 {BluetoothHostInterfaceCode::SET_DEVICE_PAIRING_CONFIRMATION,
180 std::bind(&BluetoothHostStub::SetDevicePairingConfirmationInner, std::placeholders::_1,
181 std::placeholders::_2, std::placeholders::_3)},
182 {BluetoothHostInterfaceCode::SET_DEVICE_PASSKEY,
183 std::bind(&BluetoothHostStub::SetDevicePasskeyInner, std::placeholders::_1, std::placeholders::_2,
184 std::placeholders::_3)},
185 {BluetoothHostInterfaceCode::PAIR_REQUEST_PEPLY,
186 std::bind(&BluetoothHostStub::PairRequestReplyInner, std::placeholders::_1, std::placeholders::_2,
187 std::placeholders::_3)},
188 {BluetoothHostInterfaceCode::READ_REMOTE_RSSI_VALUE,
189 std::bind(&BluetoothHostStub::ReadRemoteRssiValueInner, std::placeholders::_1, std::placeholders::_2,
190 std::placeholders::_3)},
191 {BluetoothHostInterfaceCode::GET_LOCAL_SUPPORTED_UUIDS,
192 std::bind(&BluetoothHostStub::GetLocalSupportedUuidsInner, std::placeholders::_1, std::placeholders::_2,
193 std::placeholders::_3)},
194 {BluetoothHostInterfaceCode::GET_DEVICE_UUIDS,
195 std::bind(&BluetoothHostStub::GetDeviceUuidsInner, std::placeholders::_1, std::placeholders::_2,
196 std::placeholders::_3)},
197 {BluetoothHostInterfaceCode::GET_LOCAL_PROFILE_UUIDS,
198 std::bind(&BluetoothHostStub::GetLocalProfileUuidsInner, std::placeholders::_1, std::placeholders::_2,
199 std::placeholders::_3)},
200 {BluetoothHostInterfaceCode::BT_REGISTER_BLE_ADAPTER_OBSERVER,
201 std::bind(&BluetoothHostStub::RegisterBleAdapterObserverInner, std::placeholders::_1, std::placeholders::_2,
202 std::placeholders::_3)},
203 {BluetoothHostInterfaceCode::BT_DEREGISTER_BLE_ADAPTER_OBSERVER,
204 std::bind(&BluetoothHostStub::DeregisterBleAdapterObserverInner, std::placeholders::_1,
205 std::placeholders::_2, std::placeholders::_3)},
206 {BluetoothHostInterfaceCode::BT_REGISTER_BLE_PERIPHERAL_OBSERVER,
207 std::bind(&BluetoothHostStub::RegisterBlePeripheralCallbackInner, std::placeholders::_1,
208 std::placeholders::_2, std::placeholders::_3)},
209 {BluetoothHostInterfaceCode::BT_DEREGISTER_BLE_PERIPHERAL_OBSERVER,
210 std::bind(&BluetoothHostStub::DeregisterBlePeripheralCallbackInner, std::placeholders::_1,
211 std::placeholders::_2, std::placeholders::_3)},
212 {BluetoothHostInterfaceCode::BT_SET_FAST_SCAN,
213 std::bind(&BluetoothHostStub::SetFastScanInner, std::placeholders::_1,
214 std::placeholders::_2, std::placeholders::_3)},
215 {BluetoothHostInterfaceCode::GET_RANDOM_ADDRESS, std::bind(&BluetoothHostStub::GetRandomAddressInner,
216 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
217 {BluetoothHostInterfaceCode::SYNC_RANDOM_ADDRESS, std::bind(&BluetoothHostStub::SyncRandomAddressInner,
218 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
219 {BluetoothHostInterfaceCode::START_CREDIBLE_PAIR,
220 std::bind(&BluetoothHostStub::StartCrediblePairInner, std::placeholders::_1, std::placeholders::_2,
221 std::placeholders::_3)},
222 {BluetoothHostInterfaceCode::CONNECT_ALLOWED_PROFILES,
223 std::bind(&BluetoothHostStub::ConnectAllowedProfilesInner, std::placeholders::_1, std::placeholders::_2,
224 std::placeholders::_3)},
225 {BluetoothHostInterfaceCode::DISCONNECT_ALLOWED_PROFILES,
226 std::bind(&BluetoothHostStub::DisconnectAllowedProfilesInner, std::placeholders::_1, std::placeholders::_2,
227 std::placeholders::_3)},
228 {BluetoothHostInterfaceCode::SET_CUSTOM_TYPE,
229 std::bind(&BluetoothHostStub::SetDeviceCustomTypeInner, std::placeholders::_1, std::placeholders::_2,
230 std::placeholders::_3)},
231 {BluetoothHostInterfaceCode::SATELLITE_CONTROL,
232 std::bind(&BluetoothHostStub::SatelliteControlInner, std::placeholders::_1, std::placeholders::_2,
233 std::placeholders::_3)},
234 {BluetoothHostInterfaceCode::BT_REGISTER_RESOURCE_MANAGER_OBSERVER,
235 std::bind(&BluetoothHostStub::RegisterBtResourceManagerObserverInner,
236 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
237 {BluetoothHostInterfaceCode::BT_DEREGISTER_RESOURCE_MANAGER_OBSERVER,
238 std::bind(&BluetoothHostStub::DeregisterBtResourceManagerObserverInner,
239 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
240 {BluetoothHostInterfaceCode::UPDATE_VIRTUAL_DEVICE,
241 std::bind(&BluetoothHostStub::UpdateVirtualDeviceInner,
242 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
243 {BluetoothHostInterfaceCode::GET_VIRTUAL_AUTO_CONN_SWITCH,
244 std::bind(&BluetoothHostStub::IsSupportVirtualAutoConnectInner,
245 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
246 {BluetoothHostInterfaceCode::SET_VIRTUAL_AUTO_CONN_TYPE,
247 std::bind(&BluetoothHostStub::SetVirtualAutoConnectTypeInner,
248 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
249 {BluetoothHostInterfaceCode::SET_FAST_SCAN_LEVEL,
250 std::bind(&BluetoothHostStub::SetFastScanLevelInner,
251 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
252 {BluetoothHostInterfaceCode::CTRL_DEVICE_ACTION,
253 std::bind(&BluetoothHostStub::ControlDeviceActionInner,
254 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
255 {BluetoothHostInterfaceCode::GET_CONNECTION_TIME,
256 std::bind(&BluetoothHostStub::GetLastConnectionTimeInner,
257 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
258 {BluetoothHostInterfaceCode::BT_UPDATE_CLOUD_DEVICE,
259 std::bind(&BluetoothHostStub::UpdateCloudBluetoothDevInner,
260 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
261 {BluetoothHostInterfaceCode::GET_CLOUD_BOND_STATE,
262 std::bind(&BluetoothHostStub::GetCloudBondStateInner,
263 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
264 {BluetoothHostInterfaceCode::GET_DEVICE_TRANSPORT,
265 std::bind(&BluetoothHostStub::GetDeviceTransportInner,
266 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
267 {BluetoothHostInterfaceCode::BT_UPDATE_REFUSE_POLICY,
268 std::bind(&BluetoothHostStub::UpdateRefusePolicyInner,
269 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
270 {BluetoothHostInterfaceCode::PROCESS_RANDOM_DEVICE_ID_COMMAND,
271 std::bind(&BluetoothHostStub::ProcessRandomDeviceIdCommandInner,
272 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
273 {BluetoothHostInterfaceCode::BT_GET_CAR_KEY_DFX_DATA,
274 std::bind(&BluetoothHostStub::GetCarKeyDfxDataInner,
275 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
276 {BluetoothHostInterfaceCode::BT_SET_CAR_KEY_CARD_DATA,
277 std::bind(&BluetoothHostStub::SetCarKeyCardDataInner,
278 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
279 {BluetoothHostInterfaceCode::BT_NOTIFY_DIALOG_RESULT,
280 std::bind(&BluetoothHostStub::NotifyDialogResultInner,
281 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
282 };
283
BluetoothHostStub()284 BluetoothHostStub::BluetoothHostStub(){};
~BluetoothHostStub()285 BluetoothHostStub::~BluetoothHostStub()
286 {}
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)287 int32_t BluetoothHostStub::OnRemoteRequest(
288 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
289 {
290 HILOGI("BluetoothHostStub::OnRemoteRequest, cmd = %{public}u, flags= %{public}d", code, option.GetFlags());
291 if (BluetoothHostStub::GetDescriptor() != data.ReadInterfaceToken()) {
292 HILOGE("BluetoothHostStub::OnRemoteRequest, local descriptor is not equal to remote");
293 return ERR_INVALID_STATE;
294 }
295 auto itFunc = memberFuncMap_.find(code);
296 if (itFunc != memberFuncMap_.end()) {
297 auto memberFunc = itFunc->second;
298 if (memberFunc != nullptr) {
299 return memberFunc(this, data, reply);
300 }
301 }
302 HILOGW("BluetoothHostStub::OnRemoteRequest, default case, need check.");
303 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
304 }
305
RegisterObserverInner(MessageParcel & data,MessageParcel & reply)306 ErrCode BluetoothHostStub::RegisterObserverInner(MessageParcel &data, MessageParcel &reply)
307 {
308 HILOGI("BluetoothHostStub::RegisterObserverInner starts");
309 sptr<IRemoteObject> remote = data.ReadRemoteObject();
310 const sptr<IBluetoothHostObserver> observer = OHOS::iface_cast<IBluetoothHostObserver>(remote);
311 RegisterObserver(observer);
312 return NO_ERROR;
313 }
314
DeregisterObserverInner(MessageParcel & data,MessageParcel & reply)315 ErrCode BluetoothHostStub::DeregisterObserverInner(MessageParcel &data, MessageParcel &reply)
316 {
317 HILOGI("BluetoothHostStub::DeregisterObserverInner starts");
318 sptr<IRemoteObject> remote = data.ReadRemoteObject();
319 const sptr<IBluetoothHostObserver> observer = OHOS::iface_cast<IBluetoothHostObserver>(remote);
320 DeregisterObserver(observer);
321 return NO_ERROR;
322 }
323
EnableBtInner(MessageParcel & data,MessageParcel & reply)324 int32_t BluetoothHostStub::EnableBtInner(MessageParcel &data, MessageParcel &reply)
325 {
326 int32_t result = EnableBt();
327 bool ret = reply.WriteInt32(result);
328 if (!ret) {
329 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
330 return ERR_INVALID_VALUE;
331 }
332 return NO_ERROR;
333 }
334
DisableBtInner(MessageParcel & data,MessageParcel & reply)335 int32_t BluetoothHostStub::DisableBtInner(MessageParcel &data, MessageParcel &reply)
336 {
337 bool isAsync = false;
338 if (!data.ReadBool(isAsync)) {
339 HILOGE("BluetoothHostStub::DisableBt isAsync failed");
340 return BT_ERR_IPC_TRANS_FAILED;
341 }
342 int32_t result = DisableBt(isAsync);
343 bool ret = reply.WriteInt32(result);
344 if (!ret) {
345 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
346 return BT_ERR_IPC_TRANS_FAILED;
347 }
348 return NO_ERROR;
349 }
350
GetProfileInner(MessageParcel & data,MessageParcel & reply)351 ErrCode BluetoothHostStub::GetProfileInner(MessageParcel &data, MessageParcel &reply)
352 {
353 HILOGI("BluetoothHostStub::GetProfileInner starts");
354 std::string name = data.ReadString();
355 sptr<IRemoteObject> result = GetProfile(name);
356 bool ret = reply.WriteRemoteObject(result);
357 if (!ret) {
358 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
359 return TRANSACTION_ERR;
360 }
361 return NO_ERROR;
362 }
363
GetBleRemoteInner(MessageParcel & data,MessageParcel & reply)364 ErrCode BluetoothHostStub::GetBleRemoteInner(MessageParcel &data, MessageParcel &reply)
365 {
366 HILOGI("BluetoothHostStub::GetBleRemoteInner starts");
367 std::string name = data.ReadString();
368 sptr<IRemoteObject> result = GetBleRemote(name);
369 bool ret = reply.WriteRemoteObject(result);
370 if (!ret) {
371 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
372 return TRANSACTION_ERR;
373 }
374 return NO_ERROR;
375 }
376
BluetoothFactoryResetInner(MessageParcel & data,MessageParcel & reply)377 int32_t BluetoothHostStub::BluetoothFactoryResetInner(MessageParcel &data, MessageParcel &reply)
378 {
379 int32_t result = BluetoothFactoryReset();
380 bool ret = reply.WriteInt32(result);
381 if (!ret) {
382 HILOGE("WriteInt32 failed");
383 return ERR_INVALID_VALUE;
384 }
385 return NO_ERROR;
386 }
387
GetBtStateInner(MessageParcel & data,MessageParcel & reply)388 ErrCode BluetoothHostStub::GetBtStateInner(MessageParcel &data, MessageParcel &reply)
389 {
390 HILOGI("BluetoothHostStub::GetBtStateInner starts");
391 int32_t state = 0;
392 int32_t result = GetBtState(state);
393 (void)reply.WriteInt32(result);
394 (void)reply.WriteInt32(state);
395 return NO_ERROR;
396 }
397
GetLocalAddressInner(MessageParcel & data,MessageParcel & reply)398 int32_t BluetoothHostStub::GetLocalAddressInner(MessageParcel &data, MessageParcel &reply)
399 {
400 std::string addr = "00:00:00:00:00:00";
401 int32_t result = GetLocalAddress(addr);
402
403 CHECK_AND_RETURN_LOG_RET(reply.WriteInt32(result), BT_ERR_IPC_TRANS_FAILED, "writing res failed");
404 CHECK_AND_RETURN_LOG_RET((result == BT_NO_ERROR), NO_ERROR, "get local addr failed");
405 CHECK_AND_RETURN_LOG_RET(reply.WriteString(addr), BT_ERR_IPC_TRANS_FAILED, "writing addr failed");
406 return NO_ERROR;
407 }
408
DisableBleInner(MessageParcel & data,MessageParcel & reply)409 int32_t BluetoothHostStub::DisableBleInner(MessageParcel &data, MessageParcel &reply)
410 {
411 int32_t result = DisableBle();
412 bool ret = reply.WriteInt32(result);
413 if (!ret) {
414 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
415 return BT_ERR_IPC_TRANS_FAILED;
416 }
417 return NO_ERROR;
418 }
419
EnableBleInner(MessageParcel & data,MessageParcel & reply)420 int32_t BluetoothHostStub::EnableBleInner(MessageParcel &data, MessageParcel &reply)
421 {
422 bool noAutoConnect = false;
423 if (!data.ReadBool(noAutoConnect)) {
424 HILOGE("BluetoothHostStub::EnableBle noAutoConnect failed");
425 return BT_ERR_IPC_TRANS_FAILED;
426 }
427 bool isAsync = false;
428 if (!data.ReadBool(isAsync)) {
429 HILOGE("BluetoothHostStub::EnableBle isAsync failed");
430 return BT_ERR_IPC_TRANS_FAILED;
431 }
432 int32_t result = EnableBle(noAutoConnect, isAsync);
433 bool ret = reply.WriteInt32(result);
434 if (!ret) {
435 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
436 return BT_ERR_IPC_TRANS_FAILED;
437 }
438 return NO_ERROR;
439 }
440
GetProfileListInner(MessageParcel & data,MessageParcel & reply)441 ErrCode BluetoothHostStub::GetProfileListInner(MessageParcel &data, MessageParcel &reply)
442 {
443 std::vector<uint32_t> result = GetProfileList();
444 bool ret = reply.WriteUInt32Vector(result);
445 if (!ret) {
446 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
447 return TRANSACTION_ERR;
448 }
449 return NO_ERROR;
450 }
451
GetMaxNumConnectedAudioDevicesInner(MessageParcel & data,MessageParcel & reply)452 ErrCode BluetoothHostStub::GetMaxNumConnectedAudioDevicesInner(MessageParcel &data, MessageParcel &reply)
453 {
454 int32_t result = GetMaxNumConnectedAudioDevices();
455 bool ret = reply.WriteInt32(result);
456 if (!ret) {
457 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
458 return TRANSACTION_ERR;
459 }
460 return NO_ERROR;
461 }
462
GetBtConnectionStateInner(MessageParcel & data,MessageParcel & reply)463 int32_t BluetoothHostStub::GetBtConnectionStateInner(MessageParcel &data, MessageParcel &reply)
464 {
465 HILOGI("BluetoothHostStub::GetBtConnectionStateInner starts");
466 int32_t state = 0;
467 int32_t result = GetBtConnectionState(state);
468 bool ret = reply.WriteInt32(result);
469 if (!ret) {
470 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
471 return BT_ERR_IPC_TRANS_FAILED;
472 }
473 ret = reply.WriteInt32(state);
474 if (!ret) {
475 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
476 return BT_ERR_IPC_TRANS_FAILED;
477 }
478 return NO_ERROR;
479 }
480
GetBtProfileConnStateInner(MessageParcel & data,MessageParcel & reply)481 int32_t BluetoothHostStub::GetBtProfileConnStateInner(MessageParcel &data, MessageParcel &reply)
482 {
483 uint32_t profileId;
484 data.ReadUint32(profileId);
485 int32_t state = 0;
486 int32_t result = GetBtProfileConnState(profileId, state);
487 bool ret = reply.WriteInt32(result);
488 if (!ret) {
489 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
490 return BT_ERR_IPC_TRANS_FAILED;
491 }
492 ret = reply.WriteInt32(state);
493 if (!ret) {
494 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
495 return BT_ERR_IPC_TRANS_FAILED;
496 }
497 return NO_ERROR;
498 }
499
GetLocalDeviceClassInner(MessageParcel & data,MessageParcel & reply)500 ErrCode BluetoothHostStub::GetLocalDeviceClassInner(MessageParcel &data, MessageParcel &reply)
501 {
502 int32_t result = GetLocalDeviceClass();
503 bool ret = reply.WriteInt32(result);
504 if (!ret) {
505 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
506 return TRANSACTION_ERR;
507 }
508 return NO_ERROR;
509 }
510
SetLocalDeviceClassInner(MessageParcel & data,MessageParcel & reply)511 ErrCode BluetoothHostStub::SetLocalDeviceClassInner(MessageParcel &data, MessageParcel &reply)
512 {
513 int32_t deviceClass;
514 data.ReadInt32(deviceClass);
515 bool result = SetLocalDeviceClass(deviceClass);
516 bool ret = reply.WriteInt32(result);
517 if (!ret) {
518 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
519 return TRANSACTION_ERR;
520 }
521 return NO_ERROR;
522 }
523
GetLocalNameInner(MessageParcel & data,MessageParcel & reply)524 int32_t BluetoothHostStub::GetLocalNameInner(MessageParcel &data, MessageParcel &reply)
525 {
526 std::string name = "";
527 int32_t result = GetLocalName(name);
528 bool ret = reply.WriteInt32(result);
529 if (!ret) {
530 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
531 return BT_ERR_IPC_TRANS_FAILED;
532 }
533 ret = reply.WriteString(name);
534 if (!ret) {
535 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
536 return BT_ERR_IPC_TRANS_FAILED;
537 }
538 return NO_ERROR;
539 }
540
SetLocalNameInner(MessageParcel & data,MessageParcel & reply)541 int32_t BluetoothHostStub::SetLocalNameInner(MessageParcel &data, MessageParcel &reply)
542 {
543 std::string name;
544 data.ReadString(name);
545 int32_t result = SetLocalName(name);
546 bool ret = reply.WriteInt32(result);
547 if (!ret) {
548 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
549 return BT_ERR_IPC_TRANS_FAILED;
550 }
551
552 return NO_ERROR;
553 }
554
GetDeviceTypeInner(MessageParcel & data,MessageParcel & reply)555 ErrCode BluetoothHostStub::GetDeviceTypeInner(MessageParcel &data, MessageParcel &reply)
556 {
557 int32_t transport;
558 if (!data.ReadInt32(transport)) {
559 HILOGE("BluetoothHostStub::GetDeviceType transport failed");
560 return TRANSACTION_ERR;
561 }
562 std::string address;
563 if (!data.ReadString(address)) {
564 HILOGE("BluetoothHostStub::GetDeviceType address failed");
565 return TRANSACTION_ERR;
566 }
567 int result = GetDeviceType(transport, address);
568 bool ret = reply.WriteInt32(result);
569 if (!ret) {
570 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
571 return ERR_INVALID_VALUE;
572 }
573 return NO_ERROR;
574 }
575
GetBtScanModeInner(MessageParcel & data,MessageParcel & reply)576 int32_t BluetoothHostStub::GetBtScanModeInner(MessageParcel &data, MessageParcel &reply)
577 {
578 int32_t scanMode = 0;
579 int32_t result = GetBtScanMode(scanMode);
580 bool ret = reply.WriteInt32(result);
581 if (!ret) {
582 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
583 return BT_ERR_IPC_TRANS_FAILED;
584 }
585 ret = reply.WriteInt32(scanMode);
586 if (!ret) {
587 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
588 return BT_ERR_IPC_TRANS_FAILED;
589 }
590 return NO_ERROR;
591 }
592
GetPhonebookPermissionInner(MessageParcel & data,MessageParcel & reply)593 ErrCode BluetoothHostStub::GetPhonebookPermissionInner(MessageParcel &data, MessageParcel &reply)
594 {
595 std::string address;
596 if (!data.ReadString(address)) {
597 HILOGE("BluetoothHostStub::GetPhonebookPermission address failed");
598 return TRANSACTION_ERR;
599 }
600 int result = GetPhonebookPermission(address);
601 bool ret = reply.WriteInt32(result);
602 if (!ret) {
603 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
604 return TRANSACTION_ERR;
605 }
606 return NO_ERROR;
607 }
608
SetBtScanModeInner(MessageParcel & data,MessageParcel & reply)609 int32_t BluetoothHostStub::SetBtScanModeInner(MessageParcel &data, MessageParcel &reply)
610 {
611 int32_t mode;
612 data.ReadInt32(mode);
613 int32_t duration;
614 data.ReadInt32(duration);
615 int32_t result = SetBtScanMode(mode, duration);
616 bool ret = reply.WriteInt32(result);
617 if (!ret) {
618 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
619 return BT_ERR_IPC_TRANS_FAILED;
620 }
621 return NO_ERROR;
622 }
623
SetPhonebookPermissionInner(MessageParcel & data,MessageParcel & reply)624 ErrCode BluetoothHostStub::SetPhonebookPermissionInner(MessageParcel &data, MessageParcel &reply)
625 {
626 std::string address;
627 if (!data.ReadString(address)) {
628 HILOGE("BluetoothHostStub::SetPhonebookPermission address failed");
629 return TRANSACTION_ERR;
630 }
631 int32_t permission;
632 if (!data.ReadInt32(permission)) {
633 HILOGE("BluetoothHostStub::SetPhonebookPermission permission failed");
634 return TRANSACTION_ERR;
635 }
636 bool result = SetPhonebookPermission(address, permission);
637 bool ret = reply.WriteBool(result);
638 if (!ret) {
639 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
640 return ERR_INVALID_VALUE;
641 }
642 return NO_ERROR;
643 }
644
GetBondableModeInner(MessageParcel & data,MessageParcel & reply)645 ErrCode BluetoothHostStub::GetBondableModeInner(MessageParcel &data, MessageParcel &reply)
646 {
647 int32_t transport;
648 data.ReadInt32(transport);
649 int32_t result = GetBondableMode(transport);
650 bool ret = reply.WriteInt32(result);
651 if (!ret) {
652 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
653 return TRANSACTION_ERR;
654 }
655 return NO_ERROR;
656 }
GetMessagePermissionInner(MessageParcel & data,MessageParcel & reply)657 ErrCode BluetoothHostStub::GetMessagePermissionInner(MessageParcel &data, MessageParcel &reply)
658 {
659 std::string address;
660 if (!data.ReadString(address)) {
661 HILOGE("BluetoothHostStub::GetMessagePermission address failed");
662 return TRANSACTION_ERR;
663 }
664 int result = GetMessagePermission(address);
665 bool ret = reply.WriteInt32(result);
666 if (!ret) {
667 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
668 return TRANSACTION_ERR;
669 }
670 return NO_ERROR;
671 }
672
SetBondableModeInner(MessageParcel & data,MessageParcel & reply)673 ErrCode BluetoothHostStub::SetBondableModeInner(MessageParcel &data, MessageParcel &reply)
674 {
675 int32_t transport;
676 data.ReadInt32(transport);
677 int32_t mode;
678 data.ReadInt32(mode);
679
680 bool result = SetBondableMode(transport, mode);
681 bool ret = reply.WriteInt32(result);
682 if (!ret) {
683 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
684 return ERR_INVALID_VALUE;
685 }
686 return NO_ERROR;
687 }
688
SetMessagePermissionInner(MessageParcel & data,MessageParcel & reply)689 ErrCode BluetoothHostStub::SetMessagePermissionInner(MessageParcel &data, MessageParcel &reply)
690 {
691 std::string address;
692 if (!data.ReadString(address)) {
693 HILOGE("BluetoothHostStub::SetMessagePermission address failed");
694 return TRANSACTION_ERR;
695 }
696 int32_t permission;
697 if (!data.ReadInt32(permission)) {
698 HILOGE("BluetoothHostStub::SetMessagePermission permission failed");
699 return TRANSACTION_ERR;
700 }
701 bool result = SetMessagePermission(address, permission);
702 bool ret = reply.WriteBool(result);
703 if (!ret) {
704 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
705 return TRANSACTION_ERR;
706 }
707 return NO_ERROR;
708 }
709
GetPowerModeInner(MessageParcel & data,MessageParcel & reply)710 ErrCode BluetoothHostStub::GetPowerModeInner(MessageParcel &data, MessageParcel &reply)
711 {
712 std::string address;
713 if (!data.ReadString(address)) {
714 HILOGE("BluetoothHostStub::GetPowerMode address failed");
715 return TRANSACTION_ERR;
716 }
717 int result = GetPowerMode(address);
718 bool ret = reply.WriteInt32(result);
719 if (!ret) {
720 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
721 return TRANSACTION_ERR;
722 }
723 return NO_ERROR;
724 }
725
StartBtDiscoveryInner(MessageParcel & data,MessageParcel & reply)726 int32_t BluetoothHostStub::StartBtDiscoveryInner(MessageParcel &data, MessageParcel &reply)
727 {
728 int32_t result = StartBtDiscovery();
729 bool ret = reply.WriteInt32(result);
730 if (!ret) {
731 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
732 return BT_ERR_IPC_TRANS_FAILED;
733 }
734 return NO_ERROR;
735 }
736
CancelBtDiscoveryInner(MessageParcel & data,MessageParcel & reply)737 int32_t BluetoothHostStub::CancelBtDiscoveryInner(MessageParcel &data, MessageParcel &reply)
738 {
739 int32_t result = CancelBtDiscovery();
740 bool ret = reply.WriteInt32(result);
741 if (!ret) {
742 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
743 return BT_ERR_IPC_TRANS_FAILED;
744 }
745 return NO_ERROR;
746 }
747
GetDeviceNameInner(MessageParcel & data,MessageParcel & reply)748 int32_t BluetoothHostStub::GetDeviceNameInner(MessageParcel &data, MessageParcel &reply)
749 {
750 int32_t transport;
751 if (!data.ReadInt32(transport)) {
752 HILOGE("BluetoothHostStub::GetDeviceName transport failed");
753 return BT_ERR_IPC_TRANS_FAILED;
754 }
755 std::string address;
756 if (!data.ReadString(address)) {
757 HILOGE("BluetoothHostStub::GetDeviceName address failed");
758 return BT_ERR_IPC_TRANS_FAILED;
759 }
760 bool alias = true;
761 if (!data.ReadBool(alias)) {
762 HILOGE("BluetoothHostStub::GetDeviceName alias failed");
763 return BT_ERR_IPC_TRANS_FAILED;
764 }
765 std::string name = "";
766 int32_t result = GetDeviceName(transport, address, name, alias);
767 bool ret = reply.WriteInt32(result);
768 if (!ret) {
769 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
770 return BT_ERR_IPC_TRANS_FAILED;
771 }
772 ret = reply.WriteString(name);
773 if (!ret) {
774 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
775 return BT_ERR_IPC_TRANS_FAILED;
776 }
777 return NO_ERROR;
778 }
779
GetDeviceAliasInner(MessageParcel & data,MessageParcel & reply)780 ErrCode BluetoothHostStub::GetDeviceAliasInner(MessageParcel &data, MessageParcel &reply)
781 {
782 std::string address;
783 if (!data.ReadString(address)) {
784 HILOGE("BluetoothHostStub::GetDeviceAlias address failed");
785 return TRANSACTION_ERR;
786 }
787 std::string result = GetDeviceAlias(address);
788 bool ret = reply.WriteString(result);
789 if (!ret) {
790 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
791 return TRANSACTION_ERR;
792 }
793 return NO_ERROR;
794 }
795
IsBtDiscoveringInner(MessageParcel & data,MessageParcel & reply)796 ErrCode BluetoothHostStub::IsBtDiscoveringInner(MessageParcel &data, MessageParcel &reply)
797 {
798 bool isDiscovering = false;
799 int32_t transport;
800 data.ReadInt32(transport);
801 int32_t result = IsBtDiscovering(isDiscovering, transport);
802 bool ret = reply.WriteInt32(result);
803 if (!ret) {
804 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
805 return BT_ERR_IPC_TRANS_FAILED;
806 }
807 ret = reply.WriteBool(isDiscovering);
808 if (!ret) {
809 HILOGE("BluetoothHostStub: reply isDiscovering writing failed in: %{public}s.", __func__);
810 return BT_ERR_IPC_TRANS_FAILED;
811 }
812 return BT_NO_ERROR;
813 }
814
SetDeviceAliasInner(MessageParcel & data,MessageParcel & reply)815 ErrCode BluetoothHostStub::SetDeviceAliasInner(MessageParcel &data, MessageParcel &reply)
816 {
817 std::string address;
818 if (!data.ReadString(address)) {
819 HILOGE("BluetoothHostStub::SetDeviceAlias address failed");
820 return TRANSACTION_ERR;
821 }
822 std::string aliasName;
823 if (!data.ReadString(aliasName)) {
824 HILOGE("BluetoothHostStub::SetDeviceAlias aliasName failed");
825 return TRANSACTION_ERR;
826 }
827 int32_t res = SetDeviceAlias(address, aliasName);
828 bool ret = reply.WriteInt32(res);
829 if (!ret) {
830 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
831 return TRANSACTION_ERR;
832 }
833 return NO_ERROR;
834 }
835
GetRemoteDeviceBatteryInfoInner(MessageParcel & data,MessageParcel & reply)836 int32_t BluetoothHostStub::GetRemoteDeviceBatteryInfoInner(MessageParcel &data, MessageParcel &reply)
837 {
838 std::string address;
839 if (!data.ReadString(address)) {
840 HILOGE("BluetoothHostStub::GetRemoteDeviceBattery address failed");
841 return TRANSACTION_ERR;
842 }
843 BluetoothBatteryInfo info;
844 int ret = GetRemoteDeviceBatteryInfo(address, info);
845 CHECK_AND_RETURN_LOG_RET(reply.WriteInt32(ret), BT_ERR_INTERNAL_ERROR, "write ret failed");
846 CHECK_AND_RETURN_LOG_RET(reply.WriteParcelable(&info), BT_ERR_INTERNAL_ERROR,
847 "write battery failed");
848 return BT_NO_ERROR;
849 }
850
GetBtDiscoveryEndMillisInner(MessageParcel & data,MessageParcel & reply)851 ErrCode BluetoothHostStub::GetBtDiscoveryEndMillisInner(MessageParcel &data, MessageParcel &reply)
852 {
853 int64_t result = GetBtDiscoveryEndMillis();
854 bool ret = reply.WriteInt64(result);
855 if (!ret) {
856 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
857 return TRANSACTION_ERR;
858 }
859 return NO_ERROR;
860 }
861
GetPairStateInner(MessageParcel & data,MessageParcel & reply)862 ErrCode BluetoothHostStub::GetPairStateInner(MessageParcel &data, MessageParcel &reply)
863 {
864 int32_t transport;
865 if (!data.ReadInt32(transport)) {
866 HILOGE("BluetoothHostStub::GetPairState transport failed");
867 return TRANSACTION_ERR;
868 }
869 std::string address;
870 if (!data.ReadString(address)) {
871 HILOGE("BluetoothHostStub::GetPairState address failed");
872 return TRANSACTION_ERR;
873 }
874 int32_t pairState;
875 int result = GetPairState(transport, address, pairState);
876 bool ret = reply.WriteInt32(result);
877 if (!ret) {
878 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
879 return BT_ERR_IPC_TRANS_FAILED;
880 }
881 ret = reply.WriteInt32(pairState);
882 if (!ret) {
883 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
884 return BT_ERR_IPC_TRANS_FAILED;
885 }
886 return BT_NO_ERROR;
887 }
888
GetPairedDevicesInner(MessageParcel & data,MessageParcel & reply)889 int32_t BluetoothHostStub::GetPairedDevicesInner(MessageParcel &data, MessageParcel &reply)
890 {
891 std::vector<BluetoothRawAddress> pairDevice;
892 int32_t result = GetPairedDevices(pairDevice);
893 bool ret = true;
894 if (!reply.WriteInt32(pairDevice.size())) {
895 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
896 return BT_ERR_IPC_TRANS_FAILED;
897 } else {
898 for (auto device : pairDevice) {
899 reply.WriteParcelable(&device);
900 }
901 }
902 ret = reply.WriteInt32(result);
903 if (!ret) {
904 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
905 return BT_ERR_IPC_TRANS_FAILED;
906 }
907 return NO_ERROR;
908 }
909
StartPairInner(MessageParcel & data,MessageParcel & reply)910 int32_t BluetoothHostStub::StartPairInner(MessageParcel &data, MessageParcel &reply)
911 {
912 int32_t transport;
913 if (!data.ReadInt32(transport)) {
914 HILOGE("BluetoothHostStub::StartPair transport failed");
915 return BT_ERR_IPC_TRANS_FAILED;
916 }
917 std::string address;
918 if (!data.ReadString(address)) {
919 HILOGE("BluetoothHostStub::StartPair address failed");
920 return BT_ERR_IPC_TRANS_FAILED;
921 }
922 int32_t result = StartPair(transport, address);
923 bool ret = reply.WriteInt32(result);
924 if (!ret) {
925 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
926 return BT_ERR_IPC_TRANS_FAILED;
927 }
928 return NO_ERROR;
929 }
930
RemovePairInner(MessageParcel & data,MessageParcel & reply)931 int32_t BluetoothHostStub::RemovePairInner(MessageParcel &data, MessageParcel &reply)
932 {
933 int32_t transport = data.ReadInt32();
934 sptr<BluetoothRawAddress> device = data.ReadStrongParcelable<BluetoothRawAddress>();
935 int32_t result = RemovePair(transport, device);
936 bool ret = reply.WriteInt32(result);
937 if (!ret) {
938 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
939 return TRANSACTION_ERR;
940 }
941 return NO_ERROR;
942 }
943
CancelPairingInner(MessageParcel & data,MessageParcel & reply)944 ErrCode BluetoothHostStub::CancelPairingInner(MessageParcel &data, MessageParcel &reply)
945 {
946 int32_t transport;
947 if (!data.ReadInt32(transport)) {
948 HILOGE("BluetoothHostStub::CancelPairing transport failed");
949 return TRANSACTION_ERR;
950 }
951 std::string address;
952 if (!data.ReadString(address)) {
953 HILOGE("BluetoothHostStub::CancelPairing address failed");
954 return TRANSACTION_ERR;
955 }
956 bool result = CancelPairing(transport, address);
957 bool ret = reply.WriteBool(result);
958 if (!ret) {
959 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
960 return TRANSACTION_ERR;
961 }
962 return NO_ERROR;
963 }
964
RemoveAllPairsInner(MessageParcel & data,MessageParcel & reply)965 ErrCode BluetoothHostStub::RemoveAllPairsInner(MessageParcel &data, MessageParcel &reply)
966 {
967 bool result = RemoveAllPairs();
968 bool ret = reply.WriteBool(result);
969 if (!ret) {
970 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
971 return TRANSACTION_ERR;
972 }
973
974 return NO_ERROR;
975 }
976
IsBondedFromLocalInner(MessageParcel & data,MessageParcel & reply)977 ErrCode BluetoothHostStub::IsBondedFromLocalInner(MessageParcel &data, MessageParcel &reply)
978 {
979 int32_t transport;
980 if (!data.ReadInt32(transport)) {
981 HILOGE("BluetoothHostStub::IsBondedFromLocal transport failed");
982 return TRANSACTION_ERR;
983 }
984 std::string address;
985 if (!data.ReadString(address)) {
986 HILOGE("BluetoothHostStub::IsBondedFromLocal address failed");
987 return TRANSACTION_ERR;
988 }
989 bool result = IsBondedFromLocal(transport, address);
990 bool ret = reply.WriteBool(result);
991 if (!ret) {
992 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
993 return TRANSACTION_ERR;
994 }
995 return NO_ERROR;
996 }
997
SetDevicePinInner(MessageParcel & data,MessageParcel & reply)998 int32_t BluetoothHostStub::SetDevicePinInner(MessageParcel &data, MessageParcel &reply)
999 {
1000 std::string address;
1001 if (!data.ReadString(address)) {
1002 HILOGE("BluetoothHostStub::SetDevicePin address failed");
1003 return BT_ERR_IPC_TRANS_FAILED;
1004 }
1005 std::string pin;
1006 if (!data.ReadString(pin)) {
1007 HILOGE("BluetoothHostStub::SetDevicePin pin failed");
1008 return BT_ERR_IPC_TRANS_FAILED;
1009 }
1010 int32_t result = SetDevicePin(address, pin);
1011 bool ret = reply.WriteInt32(result);
1012 if (!ret) {
1013 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1014 return BT_ERR_IPC_TRANS_FAILED;
1015 }
1016 return NO_ERROR;
1017 }
1018
IsAclConnectedInner(MessageParcel & data,MessageParcel & reply)1019 ErrCode BluetoothHostStub::IsAclConnectedInner(MessageParcel &data, MessageParcel &reply)
1020 {
1021 int32_t transport;
1022 if (!data.ReadInt32(transport)) {
1023 HILOGE("BluetoothHostStub::IsAclConnected transport failed");
1024 return TRANSACTION_ERR;
1025 }
1026 std::string address;
1027 if (!data.ReadString(address)) {
1028 HILOGE("BluetoothHostStub::IsAclConnected address failed");
1029 return TRANSACTION_ERR;
1030 }
1031 bool result = IsAclConnected(transport, address);
1032 bool ret = reply.WriteBool(result);
1033 if (!ret) {
1034 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1035 return TRANSACTION_ERR;
1036 }
1037 if (!ret) {
1038 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1039 return TRANSACTION_ERR;
1040 }
1041 return NO_ERROR;
1042 }
1043
RegisterRemoteDeviceObserverInner(MessageParcel & data,MessageParcel & reply)1044 ErrCode BluetoothHostStub::RegisterRemoteDeviceObserverInner(MessageParcel &data, MessageParcel &reply)
1045 {
1046 auto tempObject = data.ReadRemoteObject();
1047 sptr<IBluetoothRemoteDeviceObserver> observer;
1048 observer = iface_cast<IBluetoothRemoteDeviceObserver>(tempObject);
1049 RegisterRemoteDeviceObserver(observer);
1050 return NO_ERROR;
1051 }
1052
DeregisterRemoteDeviceObserverInner(MessageParcel & data,MessageParcel & reply)1053 ErrCode BluetoothHostStub::DeregisterRemoteDeviceObserverInner(MessageParcel &data, MessageParcel &reply)
1054 {
1055 auto tempObject = data.ReadRemoteObject();
1056 sptr<IBluetoothRemoteDeviceObserver> observer;
1057 observer = iface_cast<IBluetoothRemoteDeviceObserver>(tempObject);
1058 DeregisterRemoteDeviceObserver(observer);
1059 return NO_ERROR;
1060 }
1061
GetBleMaxAdvertisingDataLengthInner(MessageParcel & data,MessageParcel & reply)1062 ErrCode BluetoothHostStub::GetBleMaxAdvertisingDataLengthInner(MessageParcel &data, MessageParcel &reply)
1063 {
1064 int32_t result = GetBleMaxAdvertisingDataLength();
1065 bool ret = reply.WriteInt32(result);
1066 if (!ret) {
1067 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1068 return TRANSACTION_ERR;
1069 }
1070 return NO_ERROR;
1071 }
1072
IsAclEncryptedInner(MessageParcel & data,MessageParcel & reply)1073 ErrCode BluetoothHostStub::IsAclEncryptedInner(MessageParcel &data, MessageParcel &reply)
1074 {
1075 int32_t transport;
1076 if (!data.ReadInt32(transport)) {
1077 HILOGE("BluetoothHostStub::IsAclEncrypted transport failed");
1078 return TRANSACTION_ERR;
1079 }
1080 std::string address;
1081 if (!data.ReadString(address)) {
1082 HILOGE("BluetoothHostStub::IsAclEncrypted address failed");
1083 return TRANSACTION_ERR;
1084 }
1085 bool result = IsAclEncrypted(transport, address);
1086 bool ret = reply.WriteBool(result);
1087 if (!ret) {
1088 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1089 return TRANSACTION_ERR;
1090 }
1091 return NO_ERROR;
1092 }
1093
GetDeviceClassInner(MessageParcel & data,MessageParcel & reply)1094 int32_t BluetoothHostStub::GetDeviceClassInner(MessageParcel &data, MessageParcel &reply)
1095 {
1096 std::string address;
1097 if (!data.ReadString(address)) {
1098 HILOGE("BluetoothHostStub::GetDeviceClass address failed");
1099 return BT_ERR_IPC_TRANS_FAILED;
1100 }
1101 int32_t cod = 0;
1102 int result = GetDeviceClass(address, cod);
1103 bool ret = reply.WriteInt32(result);
1104 if (!ret) {
1105 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1106 return BT_ERR_IPC_TRANS_FAILED;
1107 }
1108 ret = reply.WriteInt32(cod);
1109 if (!ret) {
1110 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1111 return BT_ERR_IPC_TRANS_FAILED;
1112 }
1113 return NO_ERROR;
1114 }
1115
SetDevicePairingConfirmationInner(MessageParcel & data,MessageParcel & reply)1116 int32_t BluetoothHostStub::SetDevicePairingConfirmationInner(MessageParcel &data, MessageParcel &reply)
1117 {
1118 int32_t transport;
1119 if (!data.ReadInt32(transport)) {
1120 HILOGE("BluetoothHostStub::SetDevicePairingConfirmation transport failed");
1121 return BT_ERR_IPC_TRANS_FAILED;
1122 }
1123 std::string address;
1124 if (!data.ReadString(address)) {
1125 HILOGE("BluetoothHostStub::SetDevicePairingConfirmation address failed");
1126 return BT_ERR_IPC_TRANS_FAILED;
1127 }
1128 bool accept = false;
1129 if (!data.ReadBool(accept)) {
1130 HILOGE("BluetoothHostStub::SetDevicePairingConfirmation accept failed");
1131 return BT_ERR_IPC_TRANS_FAILED;
1132 }
1133 int32_t result = SetDevicePairingConfirmation(transport, address, accept);
1134 bool ret = reply.WriteInt32(result);
1135 if (!ret) {
1136 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1137 return BT_ERR_IPC_TRANS_FAILED;
1138 }
1139 return NO_ERROR;
1140 }
1141
SetDevicePasskeyInner(MessageParcel & data,MessageParcel & reply)1142 ErrCode BluetoothHostStub::SetDevicePasskeyInner(MessageParcel &data, MessageParcel &reply)
1143 {
1144 int32_t transport;
1145 if (!data.ReadInt32(transport)) {
1146 HILOGE("BluetoothHostStub::SetDevicePasskey transport failed");
1147 return TRANSACTION_ERR;
1148 }
1149 std::string address;
1150 if (!data.ReadString(address)) {
1151 HILOGE("BluetoothHostStub::SetDevicePasskey address failed");
1152 return TRANSACTION_ERR;
1153 }
1154 int32_t passkey;
1155 if (!data.ReadInt32(passkey)) {
1156 HILOGE("BluetoothHostStub::SetDevicePasskey passkey failed");
1157 return TRANSACTION_ERR;
1158 }
1159 bool accept = false;
1160 if (!data.ReadBool(accept)) {
1161 HILOGE("BluetoothHostStub::SetDevicePasskey accept failed");
1162 return TRANSACTION_ERR;
1163 }
1164 bool result = SetDevicePasskey(transport, address, passkey, accept);
1165 bool ret = reply.WriteBool(result);
1166 if (!ret) {
1167 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1168 return TRANSACTION_ERR;
1169 }
1170 return NO_ERROR;
1171 }
1172
PairRequestReplyInner(MessageParcel & data,MessageParcel & reply)1173 ErrCode BluetoothHostStub::PairRequestReplyInner(MessageParcel &data, MessageParcel &reply)
1174 {
1175 int32_t transport;
1176 if (!data.ReadInt32(transport)) {
1177 HILOGE("BluetoothHostStub::PairRequestReply transport failed");
1178 return TRANSACTION_ERR;
1179 }
1180 std::string address;
1181 if (!data.ReadString(address)) {
1182 HILOGE("BluetoothHostStub::PairRequestReply address failed");
1183 return TRANSACTION_ERR;
1184 }
1185 bool accept = false;
1186 if (!data.ReadBool(accept)) {
1187 HILOGE("BluetoothHostStub::PairRequestReply accept failed");
1188 return TRANSACTION_ERR;
1189 }
1190 bool result = PairRequestReply(transport, address, accept);
1191 bool ret = reply.WriteBool(result);
1192 if (!ret) {
1193 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1194 return TRANSACTION_ERR;
1195 }
1196 return NO_ERROR;
1197 }
1198
ReadRemoteRssiValueInner(MessageParcel & data,MessageParcel & reply)1199 ErrCode BluetoothHostStub::ReadRemoteRssiValueInner(MessageParcel &data, MessageParcel &reply)
1200 {
1201 std::string address;
1202 if (!data.ReadString(address)) {
1203 HILOGE("BluetoothHostStub::ReadRemoteRssiValue address failed");
1204 return TRANSACTION_ERR;
1205 }
1206 bool result = ReadRemoteRssiValue(address);
1207 bool ret = reply.WriteBool(result);
1208 if (!ret) {
1209 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1210 return TRANSACTION_ERR;
1211 }
1212 return NO_ERROR;
1213 }
1214
GetLocalSupportedUuidsInner(MessageParcel & data,MessageParcel & reply)1215 ErrCode BluetoothHostStub::GetLocalSupportedUuidsInner(MessageParcel &data, MessageParcel &reply)
1216 {
1217 std::vector<std::string> uuids;
1218 GetLocalSupportedUuids(uuids);
1219 int32_t size = uuids.size();
1220 bool ret = reply.WriteInt32(size);
1221 if (!ret) {
1222 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1223 return TRANSACTION_ERR;
1224 }
1225 for (auto uuid : uuids) {
1226 if (!reply.WriteString(uuid)) {
1227 HILOGE("BluetoothHostStub: GetLocalSupportedUuidsInner write uuid error");
1228 return TRANSACTION_ERR;
1229 }
1230 }
1231 return NO_ERROR;
1232 }
1233
GetDeviceUuidsInner(MessageParcel & data,MessageParcel & reply)1234 ErrCode BluetoothHostStub::GetDeviceUuidsInner(MessageParcel &data, MessageParcel &reply)
1235 {
1236 std::string address;
1237 std::vector<std::string> uuids;
1238 if (!data.ReadString(address)) {
1239 HILOGE("BluetoothHostProxy::GetDeviceUuids Read address error");
1240 return TRANSACTION_ERR;
1241 }
1242 int res = GetDeviceUuids(address, uuids);
1243 int32_t size = uuids.size();
1244 bool ret = reply.WriteInt32(size);
1245 if (!ret) {
1246 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1247 return TRANSACTION_ERR;
1248 }
1249 for (auto uuid : uuids) {
1250 if (!reply.WriteString(uuid)) {
1251 HILOGE("BluetoothHostStub: GetDeviceUuidsInner write uuid error");
1252 return TRANSACTION_ERR;
1253 }
1254 }
1255 if (!reply.WriteInt32(res)) {
1256 HILOGE("BluetoothHostStub: GetDeviceUuidsInner write result error");
1257 return TRANSACTION_ERR;
1258 }
1259 return NO_ERROR;
1260 }
1261
GetLocalProfileUuidsInner(MessageParcel & data,MessageParcel & reply)1262 ErrCode BluetoothHostStub::GetLocalProfileUuidsInner(MessageParcel &data, MessageParcel &reply)
1263 {
1264 return NO_ERROR;
1265 }
1266
RegisterBleAdapterObserverInner(MessageParcel & data,MessageParcel & reply)1267 ErrCode BluetoothHostStub::RegisterBleAdapterObserverInner(MessageParcel &data, MessageParcel &reply)
1268 {
1269 auto tempObject = data.ReadRemoteObject();
1270 sptr<IBluetoothHostObserver> observer;
1271 observer = iface_cast<IBluetoothHostObserver>(tempObject);
1272 RegisterBleAdapterObserver(observer);
1273 return NO_ERROR;
1274 }
1275
DeregisterBleAdapterObserverInner(MessageParcel & data,MessageParcel & reply)1276 ErrCode BluetoothHostStub::DeregisterBleAdapterObserverInner(MessageParcel &data, MessageParcel &reply)
1277 {
1278 auto tempObject = data.ReadRemoteObject();
1279 sptr<IBluetoothHostObserver> observer;
1280 observer = iface_cast<IBluetoothHostObserver>(tempObject);
1281 DeregisterBleAdapterObserver(observer);
1282 return NO_ERROR;
1283 }
1284
RegisterBlePeripheralCallbackInner(MessageParcel & data,MessageParcel & reply)1285 ErrCode BluetoothHostStub::RegisterBlePeripheralCallbackInner(MessageParcel &data, MessageParcel &reply)
1286 {
1287 auto tempObject = data.ReadRemoteObject();
1288 sptr<IBluetoothBlePeripheralObserver> observer;
1289 observer = iface_cast<IBluetoothBlePeripheralObserver>(tempObject);
1290 RegisterBlePeripheralCallback(observer);
1291 return NO_ERROR;
1292 }
1293
DeregisterBlePeripheralCallbackInner(MessageParcel & data,MessageParcel & reply)1294 ErrCode BluetoothHostStub::DeregisterBlePeripheralCallbackInner(MessageParcel &data, MessageParcel &reply)
1295 {
1296 auto tempObject = data.ReadRemoteObject();
1297 sptr<IBluetoothBlePeripheralObserver> observer;
1298 observer = iface_cast<IBluetoothBlePeripheralObserver>(tempObject);
1299 DeregisterBlePeripheralCallback(observer);
1300 return NO_ERROR;
1301 }
1302
SetFastScanInner(MessageParcel & data,MessageParcel & reply)1303 int32_t BluetoothHostStub::SetFastScanInner(MessageParcel &data, MessageParcel &reply)
1304 {
1305 return NO_ERROR;
1306 }
1307
GetRandomAddressInner(MessageParcel & data,MessageParcel & reply)1308 ErrCode BluetoothHostStub::GetRandomAddressInner(MessageParcel &data, MessageParcel &reply)
1309 {
1310 std::string realAddress = data.ReadString();
1311 std::string randomAddress;
1312 int result = GetRandomAddress(realAddress, randomAddress);
1313 bool ret = reply.WriteInt32(result);
1314 if (!ret) {
1315 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1316 return TRANSACTION_ERR;
1317 }
1318 if (result != NO_ERROR) {
1319 if (!reply.WriteString(randomAddress)) {
1320 HILOGE("BluetoothHostStub:GetRandomAddressInner write randomAddress error");
1321 return TRANSACTION_ERR;
1322 }
1323 }
1324 return NO_ERROR;
1325 }
1326
SyncRandomAddressInner(MessageParcel & data,MessageParcel & reply)1327 ErrCode BluetoothHostStub::SyncRandomAddressInner(MessageParcel &data, MessageParcel &reply)
1328 {
1329 return NO_ERROR;
1330 }
1331
StartCrediblePairInner(MessageParcel & data,MessageParcel & reply)1332 ErrCode BluetoothHostStub::StartCrediblePairInner(MessageParcel &data, MessageParcel &reply)
1333 {
1334 std::string address = data.ReadString();
1335 int32_t transport = data.ReadInt32();
1336 int result = StartCrediblePair(transport, address);
1337 bool ret = reply.WriteInt32(result);
1338 if (!ret) {
1339 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1340 }
1341 return NO_ERROR;
1342 }
1343
SatelliteControlInner(MessageParcel & data,MessageParcel & reply)1344 ErrCode BluetoothHostStub::SatelliteControlInner(MessageParcel &data, MessageParcel &reply)
1345 {
1346 return NO_ERROR;
1347 }
1348
ConnectAllowedProfilesInner(MessageParcel & data,MessageParcel & reply)1349 int32_t BluetoothHostStub::ConnectAllowedProfilesInner(MessageParcel &data, MessageParcel &reply)
1350 {
1351 reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1352 return NO_ERROR;
1353 }
1354
DisconnectAllowedProfilesInner(MessageParcel & data,MessageParcel & reply)1355 int32_t BluetoothHostStub::DisconnectAllowedProfilesInner(MessageParcel &data, MessageParcel &reply)
1356 {
1357 reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1358 return NO_ERROR;
1359 }
1360
SetDeviceCustomTypeInner(MessageParcel & data,MessageParcel & reply)1361 int32_t BluetoothHostStub::SetDeviceCustomTypeInner(MessageParcel &data, MessageParcel &reply)
1362 {
1363 std::string address;
1364 if (!data.ReadString(address)) {
1365 HILOGE("BluetoothHostStub::SetDeviceCustomType address failed");
1366 return TRANSACTION_ERR;
1367 }
1368 int32_t customType;
1369 if (!data.ReadInt32(customType)) {
1370 HILOGE("BluetoothHostStub::SetDeviceCustomType customType failed");
1371 return TRANSACTION_ERR;
1372 }
1373 bool ret = reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1374 if (!ret) {
1375 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1376 return TRANSACTION_ERR;
1377 }
1378 return BT_ERR_API_NOT_SUPPORT;
1379 }
1380
RegisterBtResourceManagerObserverInner(MessageParcel & data,MessageParcel & reply)1381 int32_t BluetoothHostStub::RegisterBtResourceManagerObserverInner(MessageParcel &data, MessageParcel &reply)
1382 {
1383 auto tempObject = data.ReadRemoteObject();
1384 sptr<IBluetoothResourceManagerObserver> observer;
1385 observer = iface_cast<IBluetoothResourceManagerObserver>(tempObject);
1386 CHECK_AND_RETURN_LOG_RET(observer != nullptr, ERR_INVALID_VALUE, "observer is nullptr");
1387 RegisterBtResourceManagerObserver(observer);
1388 return NO_ERROR;
1389 }
1390
DeregisterBtResourceManagerObserverInner(MessageParcel & data,MessageParcel & reply)1391 int32_t BluetoothHostStub::DeregisterBtResourceManagerObserverInner(MessageParcel &data, MessageParcel &reply)
1392 {
1393 auto tempObject = data.ReadRemoteObject();
1394 sptr<IBluetoothResourceManagerObserver> observer;
1395 observer = iface_cast<IBluetoothResourceManagerObserver>(tempObject);
1396 CHECK_AND_RETURN_LOG_RET(observer != nullptr, ERR_INVALID_VALUE, "observer is nullptr");
1397 DeregisterBtResourceManagerObserver(observer);
1398 return NO_ERROR;
1399 }
1400
UpdateVirtualDeviceInner(MessageParcel & data,MessageParcel & reply)1401 int32_t BluetoothHostStub::UpdateVirtualDeviceInner(MessageParcel &data, MessageParcel &reply)
1402 {
1403 return BT_ERR_API_NOT_SUPPORT;
1404 }
1405
IsSupportVirtualAutoConnectInner(MessageParcel & data,MessageParcel & reply)1406 int32_t BluetoothHostStub::IsSupportVirtualAutoConnectInner(MessageParcel &data, MessageParcel &reply)
1407 {
1408 return BT_ERR_API_NOT_SUPPORT;
1409 }
1410
SetVirtualAutoConnectTypeInner(MessageParcel & data,MessageParcel & reply)1411 int32_t BluetoothHostStub::SetVirtualAutoConnectTypeInner(MessageParcel &data, MessageParcel &reply)
1412 {
1413 return BT_ERR_API_NOT_SUPPORT;
1414 }
1415
SetFastScanLevelInner(MessageParcel & data,MessageParcel & reply)1416 int32_t BluetoothHostStub::SetFastScanLevelInner(MessageParcel &data, MessageParcel &reply)
1417 {
1418 return BT_ERR_API_NOT_SUPPORT;
1419 }
1420
EnableBluetoothToRestrictModeInner(MessageParcel & data,MessageParcel & reply)1421 int32_t BluetoothHostStub::EnableBluetoothToRestrictModeInner(MessageParcel &data, MessageParcel &reply)
1422 {
1423 return BT_ERR_API_NOT_SUPPORT;
1424 }
1425
ControlDeviceActionInner(MessageParcel & data,MessageParcel & reply)1426 int32_t BluetoothHostStub::ControlDeviceActionInner(MessageParcel &data, MessageParcel &reply)
1427 {
1428 return BT_ERR_API_NOT_SUPPORT;
1429 }
1430
GetLastConnectionTimeInner(MessageParcel & data,MessageParcel & reply)1431 int32_t BluetoothHostStub::GetLastConnectionTimeInner(MessageParcel &data, MessageParcel &reply)
1432 {
1433 return NO_ERROR;
1434 }
1435
UpdateCloudBluetoothDevInner(MessageParcel & data,MessageParcel & reply)1436 int32_t BluetoothHostStub::UpdateCloudBluetoothDevInner(MessageParcel &data, MessageParcel &reply)
1437 {
1438 return NO_ERROR;
1439 }
1440
GetCloudBondStateInner(MessageParcel & data,MessageParcel & reply)1441 int32_t BluetoothHostStub::GetCloudBondStateInner(MessageParcel &data, MessageParcel &reply)
1442 {
1443 return NO_ERROR;
1444 }
1445
GetDeviceTransportInner(MessageParcel & data,MessageParcel & reply)1446 int32_t BluetoothHostStub::GetDeviceTransportInner(MessageParcel &data, MessageParcel &reply)
1447 {
1448 std::string address;
1449 if (!data.ReadString(address)) {
1450 HILOGE("BluetoothHostStub::GetDeviceTransport address failed");
1451 return BT_ERR_IPC_TRANS_FAILED;
1452 }
1453 int32_t transport = bluetooth::TRANSPORT_UNKNOWN;
1454 int32_t result = GetDeviceTransport(address, transport);
1455 bool ret = reply.WriteInt32(result);
1456 if (!ret) {
1457 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1458 return BT_ERR_IPC_TRANS_FAILED;
1459 }
1460 return NO_ERROR;
1461 }
1462
UpdateRefusePolicyInner(MessageParcel & data,MessageParcel & reply)1463 int32_t BluetoothHostStub::UpdateRefusePolicyInner(MessageParcel &data, MessageParcel &reply)
1464 {
1465 return BT_ERR_API_NOT_SUPPORT;
1466 }
1467
ProcessRandomDeviceIdCommandInner(MessageParcel & data,MessageParcel & reply)1468 int32_t BluetoothHostStub::ProcessRandomDeviceIdCommandInner(MessageParcel &data, MessageParcel &reply)
1469 {
1470 reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1471 return NO_ERROR;
1472 }
1473
GetCarKeyDfxDataInner(MessageParcel & data,MessageParcel & reply)1474 int32_t BluetoothHostStub::GetCarKeyDfxDataInner(MessageParcel &data, MessageParcel &reply)
1475 {
1476 return BT_ERR_API_NOT_SUPPORT;
1477 }
1478
SetCarKeyCardDataInner(MessageParcel & data,MessageParcel & reply)1479 int32_t BluetoothHostStub::SetCarKeyCardDataInner(MessageParcel &data, MessageParcel &reply)
1480 {
1481 return BT_ERR_API_NOT_SUPPORT;
1482 }
1483
NotifyDialogResultInner(MessageParcel & data,MessageParcel & reply)1484 int32_t BluetoothHostStub::NotifyDialogResultInner(MessageParcel &data, MessageParcel &reply)
1485 {
1486 return BT_ERR_API_NOT_SUPPORT;
1487 }
1488 } // namespace Bluetooth
1489 } // namespace OHOS
1490