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::BT_UPDATE_REFUSE_POLICY,
265 std::bind(&BluetoothHostStub::UpdateRefusePolicyInner,
266 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
267 {BluetoothHostInterfaceCode::PROCESS_RANDOM_DEVICE_ID_COMMAND,
268 std::bind(&BluetoothHostStub::ProcessRandomDeviceIdCommandInner,
269 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
270 };
271
BluetoothHostStub()272 BluetoothHostStub::BluetoothHostStub(){};
~BluetoothHostStub()273 BluetoothHostStub::~BluetoothHostStub()
274 {}
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)275 int32_t BluetoothHostStub::OnRemoteRequest(
276 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
277 {
278 HILOGI("BluetoothHostStub::OnRemoteRequest, cmd = %{public}u, flags= %{public}d", code, option.GetFlags());
279 if (BluetoothHostStub::GetDescriptor() != data.ReadInterfaceToken()) {
280 HILOGE("BluetoothHostStub::OnRemoteRequest, local descriptor is not equal to remote");
281 return ERR_INVALID_STATE;
282 }
283 auto itFunc = memberFuncMap_.find(code);
284 if (itFunc != memberFuncMap_.end()) {
285 auto memberFunc = itFunc->second;
286 if (memberFunc != nullptr) {
287 return memberFunc(this, data, reply);
288 }
289 }
290 HILOGW("BluetoothHostStub::OnRemoteRequest, default case, need check.");
291 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
292 }
293
RegisterObserverInner(MessageParcel & data,MessageParcel & reply)294 ErrCode BluetoothHostStub::RegisterObserverInner(MessageParcel &data, MessageParcel &reply)
295 {
296 HILOGI("BluetoothHostStub::RegisterObserverInner starts");
297 sptr<IRemoteObject> remote = data.ReadRemoteObject();
298 const sptr<IBluetoothHostObserver> observer = OHOS::iface_cast<IBluetoothHostObserver>(remote);
299 RegisterObserver(observer);
300 return NO_ERROR;
301 }
302
DeregisterObserverInner(MessageParcel & data,MessageParcel & reply)303 ErrCode BluetoothHostStub::DeregisterObserverInner(MessageParcel &data, MessageParcel &reply)
304 {
305 HILOGI("BluetoothHostStub::DeregisterObserverInner starts");
306 sptr<IRemoteObject> remote = data.ReadRemoteObject();
307 const sptr<IBluetoothHostObserver> observer = OHOS::iface_cast<IBluetoothHostObserver>(remote);
308 DeregisterObserver(observer);
309 return NO_ERROR;
310 }
311
EnableBtInner(MessageParcel & data,MessageParcel & reply)312 int32_t BluetoothHostStub::EnableBtInner(MessageParcel &data, MessageParcel &reply)
313 {
314 int32_t result = EnableBt();
315 bool ret = reply.WriteInt32(result);
316 if (!ret) {
317 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
318 return ERR_INVALID_VALUE;
319 }
320 return NO_ERROR;
321 }
322
DisableBtInner(MessageParcel & data,MessageParcel & reply)323 int32_t BluetoothHostStub::DisableBtInner(MessageParcel &data, MessageParcel &reply)
324 {
325 int32_t result = DisableBt();
326 bool ret = reply.WriteInt32(result);
327 if (!ret) {
328 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
329 return BT_ERR_IPC_TRANS_FAILED;
330 }
331 return NO_ERROR;
332 }
333
GetProfileInner(MessageParcel & data,MessageParcel & reply)334 ErrCode BluetoothHostStub::GetProfileInner(MessageParcel &data, MessageParcel &reply)
335 {
336 HILOGI("BluetoothHostStub::GetProfileInner starts");
337 std::string name = data.ReadString();
338 sptr<IRemoteObject> result = GetProfile(name);
339 bool ret = reply.WriteRemoteObject(result);
340 if (!ret) {
341 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
342 return TRANSACTION_ERR;
343 }
344 return NO_ERROR;
345 }
346
GetBleRemoteInner(MessageParcel & data,MessageParcel & reply)347 ErrCode BluetoothHostStub::GetBleRemoteInner(MessageParcel &data, MessageParcel &reply)
348 {
349 HILOGI("BluetoothHostStub::GetBleRemoteInner starts");
350 std::string name = data.ReadString();
351 sptr<IRemoteObject> result = GetBleRemote(name);
352 bool ret = reply.WriteRemoteObject(result);
353 if (!ret) {
354 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
355 return TRANSACTION_ERR;
356 }
357 return NO_ERROR;
358 }
359
BluetoothFactoryResetInner(MessageParcel & data,MessageParcel & reply)360 int32_t BluetoothHostStub::BluetoothFactoryResetInner(MessageParcel &data, MessageParcel &reply)
361 {
362 int32_t result = BluetoothFactoryReset();
363 bool ret = reply.WriteInt32(result);
364 if (!ret) {
365 HILOGE("WriteInt32 failed");
366 return ERR_INVALID_VALUE;
367 }
368 return NO_ERROR;
369 }
370
GetBtStateInner(MessageParcel & data,MessageParcel & reply)371 ErrCode BluetoothHostStub::GetBtStateInner(MessageParcel &data, MessageParcel &reply)
372 {
373 HILOGI("BluetoothHostStub::GetBtStateInner starts");
374 int32_t state = 0;
375 int32_t result = GetBtState(state);
376 (void)reply.WriteInt32(result);
377 (void)reply.WriteInt32(state);
378 return NO_ERROR;
379 }
380
GetLocalAddressInner(MessageParcel & data,MessageParcel & reply)381 int32_t BluetoothHostStub::GetLocalAddressInner(MessageParcel &data, MessageParcel &reply)
382 {
383 std::string addr = "00:00:00:00:00:00";
384 int32_t result = GetLocalAddress(addr);
385
386 CHECK_AND_RETURN_LOG_RET(reply.WriteInt32(result), BT_ERR_IPC_TRANS_FAILED, "writing res failed");
387 CHECK_AND_RETURN_LOG_RET((result == BT_NO_ERROR), NO_ERROR, "get local addr failed");
388 CHECK_AND_RETURN_LOG_RET(reply.WriteString(addr), BT_ERR_IPC_TRANS_FAILED, "writing addr failed");
389 return NO_ERROR;
390 }
391
DisableBleInner(MessageParcel & data,MessageParcel & reply)392 int32_t BluetoothHostStub::DisableBleInner(MessageParcel &data, MessageParcel &reply)
393 {
394 int32_t result = DisableBle();
395 bool ret = reply.WriteInt32(result);
396 if (!ret) {
397 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
398 return BT_ERR_IPC_TRANS_FAILED;
399 }
400 return NO_ERROR;
401 }
402
EnableBleInner(MessageParcel & data,MessageParcel & reply)403 int32_t BluetoothHostStub::EnableBleInner(MessageParcel &data, MessageParcel &reply)
404 {
405 int32_t result = EnableBle();
406 bool ret = reply.WriteInt32(result);
407 if (!ret) {
408 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
409 return BT_ERR_IPC_TRANS_FAILED;
410 }
411 return NO_ERROR;
412 }
413
GetProfileListInner(MessageParcel & data,MessageParcel & reply)414 ErrCode BluetoothHostStub::GetProfileListInner(MessageParcel &data, MessageParcel &reply)
415 {
416 std::vector<uint32_t> result = GetProfileList();
417 bool ret = reply.WriteUInt32Vector(result);
418 if (!ret) {
419 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
420 return TRANSACTION_ERR;
421 }
422 return NO_ERROR;
423 }
424
GetMaxNumConnectedAudioDevicesInner(MessageParcel & data,MessageParcel & reply)425 ErrCode BluetoothHostStub::GetMaxNumConnectedAudioDevicesInner(MessageParcel &data, MessageParcel &reply)
426 {
427 int32_t result = GetMaxNumConnectedAudioDevices();
428 bool ret = reply.WriteInt32(result);
429 if (!ret) {
430 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
431 return TRANSACTION_ERR;
432 }
433 return NO_ERROR;
434 }
435
GetBtConnectionStateInner(MessageParcel & data,MessageParcel & reply)436 int32_t BluetoothHostStub::GetBtConnectionStateInner(MessageParcel &data, MessageParcel &reply)
437 {
438 HILOGI("BluetoothHostStub::GetBtConnectionStateInner starts");
439 int32_t state = 0;
440 int32_t result = GetBtConnectionState(state);
441 bool ret = reply.WriteInt32(result);
442 if (!ret) {
443 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
444 return BT_ERR_IPC_TRANS_FAILED;
445 }
446 ret = reply.WriteInt32(state);
447 if (!ret) {
448 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
449 return BT_ERR_IPC_TRANS_FAILED;
450 }
451 return NO_ERROR;
452 }
453
GetBtProfileConnStateInner(MessageParcel & data,MessageParcel & reply)454 int32_t BluetoothHostStub::GetBtProfileConnStateInner(MessageParcel &data, MessageParcel &reply)
455 {
456 uint32_t profileId;
457 data.ReadUint32(profileId);
458 int32_t state = 0;
459 int32_t result = GetBtProfileConnState(profileId, state);
460 bool ret = reply.WriteInt32(result);
461 if (!ret) {
462 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
463 return BT_ERR_IPC_TRANS_FAILED;
464 }
465 ret = reply.WriteInt32(state);
466 if (!ret) {
467 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
468 return BT_ERR_IPC_TRANS_FAILED;
469 }
470 return NO_ERROR;
471 }
472
GetLocalDeviceClassInner(MessageParcel & data,MessageParcel & reply)473 ErrCode BluetoothHostStub::GetLocalDeviceClassInner(MessageParcel &data, MessageParcel &reply)
474 {
475 int32_t result = GetLocalDeviceClass();
476 bool ret = reply.WriteInt32(result);
477 if (!ret) {
478 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
479 return TRANSACTION_ERR;
480 }
481 return NO_ERROR;
482 }
483
SetLocalDeviceClassInner(MessageParcel & data,MessageParcel & reply)484 ErrCode BluetoothHostStub::SetLocalDeviceClassInner(MessageParcel &data, MessageParcel &reply)
485 {
486 int32_t deviceClass;
487 data.ReadInt32(deviceClass);
488 bool result = SetLocalDeviceClass(deviceClass);
489 bool ret = reply.WriteInt32(result);
490 if (!ret) {
491 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
492 return TRANSACTION_ERR;
493 }
494 return NO_ERROR;
495 }
496
GetLocalNameInner(MessageParcel & data,MessageParcel & reply)497 int32_t BluetoothHostStub::GetLocalNameInner(MessageParcel &data, MessageParcel &reply)
498 {
499 std::string name = "";
500 int32_t result = GetLocalName(name);
501 bool ret = reply.WriteInt32(result);
502 if (!ret) {
503 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
504 return BT_ERR_IPC_TRANS_FAILED;
505 }
506 ret = reply.WriteString(name);
507 if (!ret) {
508 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
509 return BT_ERR_IPC_TRANS_FAILED;
510 }
511 return NO_ERROR;
512 }
513
SetLocalNameInner(MessageParcel & data,MessageParcel & reply)514 int32_t BluetoothHostStub::SetLocalNameInner(MessageParcel &data, MessageParcel &reply)
515 {
516 std::string name;
517 data.ReadString(name);
518 int32_t result = SetLocalName(name);
519 bool ret = reply.WriteInt32(result);
520 if (!ret) {
521 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
522 return BT_ERR_IPC_TRANS_FAILED;
523 }
524
525 return NO_ERROR;
526 }
527
GetDeviceTypeInner(MessageParcel & data,MessageParcel & reply)528 ErrCode BluetoothHostStub::GetDeviceTypeInner(MessageParcel &data, MessageParcel &reply)
529 {
530 int32_t transport;
531 if (!data.ReadInt32(transport)) {
532 HILOGE("BluetoothHostStub::GetDeviceType transport failed");
533 return TRANSACTION_ERR;
534 }
535 std::string address;
536 if (!data.ReadString(address)) {
537 HILOGE("BluetoothHostStub::GetDeviceType address failed");
538 return TRANSACTION_ERR;
539 }
540 int result = GetDeviceType(transport, address);
541 bool ret = reply.WriteInt32(result);
542 if (!ret) {
543 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
544 return ERR_INVALID_VALUE;
545 }
546 return NO_ERROR;
547 }
548
GetBtScanModeInner(MessageParcel & data,MessageParcel & reply)549 int32_t BluetoothHostStub::GetBtScanModeInner(MessageParcel &data, MessageParcel &reply)
550 {
551 int32_t scanMode = 0;
552 int32_t result = GetBtScanMode(scanMode);
553 bool ret = reply.WriteInt32(result);
554 if (!ret) {
555 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
556 return BT_ERR_IPC_TRANS_FAILED;
557 }
558 ret = reply.WriteInt32(scanMode);
559 if (!ret) {
560 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
561 return BT_ERR_IPC_TRANS_FAILED;
562 }
563 return NO_ERROR;
564 }
565
GetPhonebookPermissionInner(MessageParcel & data,MessageParcel & reply)566 ErrCode BluetoothHostStub::GetPhonebookPermissionInner(MessageParcel &data, MessageParcel &reply)
567 {
568 std::string address;
569 if (!data.ReadString(address)) {
570 HILOGE("BluetoothHostStub::GetPhonebookPermission address failed");
571 return TRANSACTION_ERR;
572 }
573 int result = GetPhonebookPermission(address);
574 bool ret = reply.WriteInt32(result);
575 if (!ret) {
576 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
577 return TRANSACTION_ERR;
578 }
579 return NO_ERROR;
580 }
581
SetBtScanModeInner(MessageParcel & data,MessageParcel & reply)582 int32_t BluetoothHostStub::SetBtScanModeInner(MessageParcel &data, MessageParcel &reply)
583 {
584 int32_t mode;
585 data.ReadInt32(mode);
586 int32_t duration;
587 data.ReadInt32(duration);
588 int32_t result = SetBtScanMode(mode, duration);
589 bool ret = reply.WriteInt32(result);
590 if (!ret) {
591 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
592 return BT_ERR_IPC_TRANS_FAILED;
593 }
594 return NO_ERROR;
595 }
596
SetPhonebookPermissionInner(MessageParcel & data,MessageParcel & reply)597 ErrCode BluetoothHostStub::SetPhonebookPermissionInner(MessageParcel &data, MessageParcel &reply)
598 {
599 std::string address;
600 if (!data.ReadString(address)) {
601 HILOGE("BluetoothHostStub::SetPhonebookPermission address failed");
602 return TRANSACTION_ERR;
603 }
604 int32_t permission;
605 if (!data.ReadInt32(permission)) {
606 HILOGE("BluetoothHostStub::SetPhonebookPermission permission failed");
607 return TRANSACTION_ERR;
608 }
609 bool result = SetPhonebookPermission(address, permission);
610 bool ret = reply.WriteBool(result);
611 if (!ret) {
612 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
613 return ERR_INVALID_VALUE;
614 }
615 return NO_ERROR;
616 }
617
GetBondableModeInner(MessageParcel & data,MessageParcel & reply)618 ErrCode BluetoothHostStub::GetBondableModeInner(MessageParcel &data, MessageParcel &reply)
619 {
620 int32_t transport;
621 data.ReadInt32(transport);
622 int32_t result = GetBondableMode(transport);
623 bool ret = reply.WriteInt32(result);
624 if (!ret) {
625 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
626 return TRANSACTION_ERR;
627 }
628 return NO_ERROR;
629 }
GetMessagePermissionInner(MessageParcel & data,MessageParcel & reply)630 ErrCode BluetoothHostStub::GetMessagePermissionInner(MessageParcel &data, MessageParcel &reply)
631 {
632 std::string address;
633 if (!data.ReadString(address)) {
634 HILOGE("BluetoothHostStub::GetMessagePermission address failed");
635 return TRANSACTION_ERR;
636 }
637 int result = GetMessagePermission(address);
638 bool ret = reply.WriteInt32(result);
639 if (!ret) {
640 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
641 return TRANSACTION_ERR;
642 }
643 return NO_ERROR;
644 }
645
SetBondableModeInner(MessageParcel & data,MessageParcel & reply)646 ErrCode BluetoothHostStub::SetBondableModeInner(MessageParcel &data, MessageParcel &reply)
647 {
648 int32_t transport;
649 data.ReadInt32(transport);
650 int32_t mode;
651 data.ReadInt32(mode);
652
653 bool result = SetBondableMode(transport, mode);
654 bool ret = reply.WriteInt32(result);
655 if (!ret) {
656 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
657 return ERR_INVALID_VALUE;
658 }
659 return NO_ERROR;
660 }
661
SetMessagePermissionInner(MessageParcel & data,MessageParcel & reply)662 ErrCode BluetoothHostStub::SetMessagePermissionInner(MessageParcel &data, MessageParcel &reply)
663 {
664 std::string address;
665 if (!data.ReadString(address)) {
666 HILOGE("BluetoothHostStub::SetMessagePermission address failed");
667 return TRANSACTION_ERR;
668 }
669 int32_t permission;
670 if (!data.ReadInt32(permission)) {
671 HILOGE("BluetoothHostStub::SetMessagePermission permission failed");
672 return TRANSACTION_ERR;
673 }
674 bool result = SetMessagePermission(address, permission);
675 bool ret = reply.WriteBool(result);
676 if (!ret) {
677 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
678 return TRANSACTION_ERR;
679 }
680 return NO_ERROR;
681 }
682
GetPowerModeInner(MessageParcel & data,MessageParcel & reply)683 ErrCode BluetoothHostStub::GetPowerModeInner(MessageParcel &data, MessageParcel &reply)
684 {
685 std::string address;
686 if (!data.ReadString(address)) {
687 HILOGE("BluetoothHostStub::GetPowerMode address failed");
688 return TRANSACTION_ERR;
689 }
690 int result = GetPowerMode(address);
691 bool ret = reply.WriteInt32(result);
692 if (!ret) {
693 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
694 return TRANSACTION_ERR;
695 }
696 return NO_ERROR;
697 }
698
StartBtDiscoveryInner(MessageParcel & data,MessageParcel & reply)699 int32_t BluetoothHostStub::StartBtDiscoveryInner(MessageParcel &data, MessageParcel &reply)
700 {
701 int32_t result = StartBtDiscovery();
702 bool ret = reply.WriteInt32(result);
703 if (!ret) {
704 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
705 return BT_ERR_IPC_TRANS_FAILED;
706 }
707 return NO_ERROR;
708 }
709
CancelBtDiscoveryInner(MessageParcel & data,MessageParcel & reply)710 int32_t BluetoothHostStub::CancelBtDiscoveryInner(MessageParcel &data, MessageParcel &reply)
711 {
712 int32_t result = CancelBtDiscovery();
713 bool ret = reply.WriteInt32(result);
714 if (!ret) {
715 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
716 return BT_ERR_IPC_TRANS_FAILED;
717 }
718 return NO_ERROR;
719 }
720
GetDeviceNameInner(MessageParcel & data,MessageParcel & reply)721 int32_t BluetoothHostStub::GetDeviceNameInner(MessageParcel &data, MessageParcel &reply)
722 {
723 int32_t transport;
724 if (!data.ReadInt32(transport)) {
725 HILOGE("BluetoothHostStub::GetDeviceName transport failed");
726 return BT_ERR_IPC_TRANS_FAILED;
727 }
728 std::string address;
729 if (!data.ReadString(address)) {
730 HILOGE("BluetoothHostStub::GetDeviceName address failed");
731 return BT_ERR_IPC_TRANS_FAILED;
732 }
733 bool alias = true;
734 if (!data.ReadBool(alias)) {
735 HILOGE("BluetoothHostStub::GetDeviceName alias failed");
736 return BT_ERR_IPC_TRANS_FAILED;
737 }
738 std::string name = "";
739 int32_t result = GetDeviceName(transport, address, name, alias);
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 ret = reply.WriteString(name);
746 if (!ret) {
747 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
748 return BT_ERR_IPC_TRANS_FAILED;
749 }
750 return NO_ERROR;
751 }
752
GetDeviceAliasInner(MessageParcel & data,MessageParcel & reply)753 ErrCode BluetoothHostStub::GetDeviceAliasInner(MessageParcel &data, MessageParcel &reply)
754 {
755 std::string address;
756 if (!data.ReadString(address)) {
757 HILOGE("BluetoothHostStub::GetDeviceAlias address failed");
758 return TRANSACTION_ERR;
759 }
760 std::string result = GetDeviceAlias(address);
761 bool ret = reply.WriteString(result);
762 if (!ret) {
763 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
764 return TRANSACTION_ERR;
765 }
766 return NO_ERROR;
767 }
768
IsBtDiscoveringInner(MessageParcel & data,MessageParcel & reply)769 ErrCode BluetoothHostStub::IsBtDiscoveringInner(MessageParcel &data, MessageParcel &reply)
770 {
771 bool isDiscovering = false;
772 int32_t transport;
773 data.ReadInt32(transport);
774 int32_t result = IsBtDiscovering(isDiscovering, transport);
775 bool ret = reply.WriteInt32(result);
776 if (!ret) {
777 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
778 return BT_ERR_IPC_TRANS_FAILED;
779 }
780 ret = reply.WriteBool(isDiscovering);
781 if (!ret) {
782 HILOGE("BluetoothHostStub: reply isDiscovering writing failed in: %{public}s.", __func__);
783 return BT_ERR_IPC_TRANS_FAILED;
784 }
785 return BT_NO_ERROR;
786 }
787
SetDeviceAliasInner(MessageParcel & data,MessageParcel & reply)788 ErrCode BluetoothHostStub::SetDeviceAliasInner(MessageParcel &data, MessageParcel &reply)
789 {
790 std::string address;
791 if (!data.ReadString(address)) {
792 HILOGE("BluetoothHostStub::SetDeviceAlias address failed");
793 return TRANSACTION_ERR;
794 }
795 std::string aliasName;
796 if (!data.ReadString(aliasName)) {
797 HILOGE("BluetoothHostStub::SetDeviceAlias aliasName failed");
798 return TRANSACTION_ERR;
799 }
800 int32_t res = SetDeviceAlias(address, aliasName);
801 bool ret = reply.WriteInt32(res);
802 if (!ret) {
803 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
804 return TRANSACTION_ERR;
805 }
806 return NO_ERROR;
807 }
808
GetRemoteDeviceBatteryInfoInner(MessageParcel & data,MessageParcel & reply)809 int32_t BluetoothHostStub::GetRemoteDeviceBatteryInfoInner(MessageParcel &data, MessageParcel &reply)
810 {
811 std::string address;
812 if (!data.ReadString(address)) {
813 HILOGE("BluetoothHostStub::GetRemoteDeviceBattery address failed");
814 return TRANSACTION_ERR;
815 }
816 BluetoothBatteryInfo info;
817 int ret = GetRemoteDeviceBatteryInfo(address, info);
818 CHECK_AND_RETURN_LOG_RET(reply.WriteInt32(ret), BT_ERR_INTERNAL_ERROR, "write ret failed");
819 CHECK_AND_RETURN_LOG_RET(reply.WriteParcelable(&info), BT_ERR_INTERNAL_ERROR,
820 "write battery failed");
821 return BT_NO_ERROR;
822 }
823
GetBtDiscoveryEndMillisInner(MessageParcel & data,MessageParcel & reply)824 ErrCode BluetoothHostStub::GetBtDiscoveryEndMillisInner(MessageParcel &data, MessageParcel &reply)
825 {
826 int64_t result = GetBtDiscoveryEndMillis();
827 bool ret = reply.WriteInt64(result);
828 if (!ret) {
829 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
830 return TRANSACTION_ERR;
831 }
832 return NO_ERROR;
833 }
834
GetPairStateInner(MessageParcel & data,MessageParcel & reply)835 ErrCode BluetoothHostStub::GetPairStateInner(MessageParcel &data, MessageParcel &reply)
836 {
837 int32_t transport;
838 if (!data.ReadInt32(transport)) {
839 HILOGE("BluetoothHostStub::GetPairState transport failed");
840 return TRANSACTION_ERR;
841 }
842 std::string address;
843 if (!data.ReadString(address)) {
844 HILOGE("BluetoothHostStub::GetPairState address failed");
845 return TRANSACTION_ERR;
846 }
847 int32_t pairState;
848 int result = GetPairState(transport, address, pairState);
849 bool ret = reply.WriteInt32(result);
850 if (!ret) {
851 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
852 return BT_ERR_IPC_TRANS_FAILED;
853 }
854 ret = reply.WriteInt32(pairState);
855 if (!ret) {
856 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
857 return BT_ERR_IPC_TRANS_FAILED;
858 }
859 return BT_NO_ERROR;
860 }
861
GetPairedDevicesInner(MessageParcel & data,MessageParcel & reply)862 int32_t BluetoothHostStub::GetPairedDevicesInner(MessageParcel &data, MessageParcel &reply)
863 {
864 std::vector<BluetoothRawAddress> pairDevice;
865 int32_t result = GetPairedDevices(pairDevice);
866 bool ret = true;
867 if (!reply.WriteInt32(pairDevice.size())) {
868 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
869 return BT_ERR_IPC_TRANS_FAILED;
870 } else {
871 for (auto device : pairDevice) {
872 reply.WriteParcelable(&device);
873 }
874 }
875 ret = reply.WriteInt32(result);
876 if (!ret) {
877 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
878 return BT_ERR_IPC_TRANS_FAILED;
879 }
880 return NO_ERROR;
881 }
882
StartPairInner(MessageParcel & data,MessageParcel & reply)883 int32_t BluetoothHostStub::StartPairInner(MessageParcel &data, MessageParcel &reply)
884 {
885 int32_t transport;
886 if (!data.ReadInt32(transport)) {
887 HILOGE("BluetoothHostStub::StartPair transport failed");
888 return BT_ERR_IPC_TRANS_FAILED;
889 }
890 std::string address;
891 if (!data.ReadString(address)) {
892 HILOGE("BluetoothHostStub::StartPair address failed");
893 return BT_ERR_IPC_TRANS_FAILED;
894 }
895 int32_t result = StartPair(transport, address);
896 bool ret = reply.WriteInt32(result);
897 if (!ret) {
898 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
899 return BT_ERR_IPC_TRANS_FAILED;
900 }
901 return NO_ERROR;
902 }
903
RemovePairInner(MessageParcel & data,MessageParcel & reply)904 int32_t BluetoothHostStub::RemovePairInner(MessageParcel &data, MessageParcel &reply)
905 {
906 int32_t transport = data.ReadInt32();
907 sptr<BluetoothRawAddress> device = data.ReadStrongParcelable<BluetoothRawAddress>();
908 int32_t result = RemovePair(transport, device);
909 bool ret = reply.WriteInt32(result);
910 if (!ret) {
911 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
912 return TRANSACTION_ERR;
913 }
914 return NO_ERROR;
915 }
916
CancelPairingInner(MessageParcel & data,MessageParcel & reply)917 ErrCode BluetoothHostStub::CancelPairingInner(MessageParcel &data, MessageParcel &reply)
918 {
919 int32_t transport;
920 if (!data.ReadInt32(transport)) {
921 HILOGE("BluetoothHostStub::CancelPairing transport failed");
922 return TRANSACTION_ERR;
923 }
924 std::string address;
925 if (!data.ReadString(address)) {
926 HILOGE("BluetoothHostStub::CancelPairing address failed");
927 return TRANSACTION_ERR;
928 }
929 bool result = CancelPairing(transport, address);
930 bool ret = reply.WriteBool(result);
931 if (!ret) {
932 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
933 return TRANSACTION_ERR;
934 }
935 return NO_ERROR;
936 }
937
RemoveAllPairsInner(MessageParcel & data,MessageParcel & reply)938 ErrCode BluetoothHostStub::RemoveAllPairsInner(MessageParcel &data, MessageParcel &reply)
939 {
940 bool result = RemoveAllPairs();
941 bool ret = reply.WriteBool(result);
942 if (!ret) {
943 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
944 return TRANSACTION_ERR;
945 }
946
947 return NO_ERROR;
948 }
949
IsBondedFromLocalInner(MessageParcel & data,MessageParcel & reply)950 ErrCode BluetoothHostStub::IsBondedFromLocalInner(MessageParcel &data, MessageParcel &reply)
951 {
952 int32_t transport;
953 if (!data.ReadInt32(transport)) {
954 HILOGE("BluetoothHostStub::IsBondedFromLocal transport failed");
955 return TRANSACTION_ERR;
956 }
957 std::string address;
958 if (!data.ReadString(address)) {
959 HILOGE("BluetoothHostStub::IsBondedFromLocal address failed");
960 return TRANSACTION_ERR;
961 }
962 bool result = IsBondedFromLocal(transport, address);
963 bool ret = reply.WriteBool(result);
964 if (!ret) {
965 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
966 return TRANSACTION_ERR;
967 }
968 return NO_ERROR;
969 }
970
SetDevicePinInner(MessageParcel & data,MessageParcel & reply)971 int32_t BluetoothHostStub::SetDevicePinInner(MessageParcel &data, MessageParcel &reply)
972 {
973 std::string address;
974 if (!data.ReadString(address)) {
975 HILOGE("BluetoothHostStub::SetDevicePin address failed");
976 return BT_ERR_IPC_TRANS_FAILED;
977 }
978 std::string pin;
979 if (!data.ReadString(pin)) {
980 HILOGE("BluetoothHostStub::SetDevicePin pin failed");
981 return BT_ERR_IPC_TRANS_FAILED;
982 }
983 int32_t result = SetDevicePin(address, pin);
984 bool ret = reply.WriteInt32(result);
985 if (!ret) {
986 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
987 return BT_ERR_IPC_TRANS_FAILED;
988 }
989 return NO_ERROR;
990 }
991
IsAclConnectedInner(MessageParcel & data,MessageParcel & reply)992 ErrCode BluetoothHostStub::IsAclConnectedInner(MessageParcel &data, MessageParcel &reply)
993 {
994 int32_t transport;
995 if (!data.ReadInt32(transport)) {
996 HILOGE("BluetoothHostStub::IsAclConnected transport failed");
997 return TRANSACTION_ERR;
998 }
999 std::string address;
1000 if (!data.ReadString(address)) {
1001 HILOGE("BluetoothHostStub::IsAclConnected address failed");
1002 return TRANSACTION_ERR;
1003 }
1004 bool result = IsAclConnected(transport, address);
1005 bool ret = reply.WriteBool(result);
1006 if (!ret) {
1007 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1008 return TRANSACTION_ERR;
1009 }
1010 if (!ret) {
1011 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1012 return TRANSACTION_ERR;
1013 }
1014 return NO_ERROR;
1015 }
1016
RegisterRemoteDeviceObserverInner(MessageParcel & data,MessageParcel & reply)1017 ErrCode BluetoothHostStub::RegisterRemoteDeviceObserverInner(MessageParcel &data, MessageParcel &reply)
1018 {
1019 auto tempObject = data.ReadRemoteObject();
1020 sptr<IBluetoothRemoteDeviceObserver> observer;
1021 observer = iface_cast<IBluetoothRemoteDeviceObserver>(tempObject);
1022 RegisterRemoteDeviceObserver(observer);
1023 return NO_ERROR;
1024 }
1025
DeregisterRemoteDeviceObserverInner(MessageParcel & data,MessageParcel & reply)1026 ErrCode BluetoothHostStub::DeregisterRemoteDeviceObserverInner(MessageParcel &data, MessageParcel &reply)
1027 {
1028 auto tempObject = data.ReadRemoteObject();
1029 sptr<IBluetoothRemoteDeviceObserver> observer;
1030 observer = iface_cast<IBluetoothRemoteDeviceObserver>(tempObject);
1031 DeregisterRemoteDeviceObserver(observer);
1032 return NO_ERROR;
1033 }
1034
GetBleMaxAdvertisingDataLengthInner(MessageParcel & data,MessageParcel & reply)1035 ErrCode BluetoothHostStub::GetBleMaxAdvertisingDataLengthInner(MessageParcel &data, MessageParcel &reply)
1036 {
1037 int32_t result = GetBleMaxAdvertisingDataLength();
1038 bool ret = reply.WriteInt32(result);
1039 if (!ret) {
1040 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1041 return TRANSACTION_ERR;
1042 }
1043 return NO_ERROR;
1044 }
1045
IsAclEncryptedInner(MessageParcel & data,MessageParcel & reply)1046 ErrCode BluetoothHostStub::IsAclEncryptedInner(MessageParcel &data, MessageParcel &reply)
1047 {
1048 int32_t transport;
1049 if (!data.ReadInt32(transport)) {
1050 HILOGE("BluetoothHostStub::IsAclEncrypted transport failed");
1051 return TRANSACTION_ERR;
1052 }
1053 std::string address;
1054 if (!data.ReadString(address)) {
1055 HILOGE("BluetoothHostStub::IsAclEncrypted address failed");
1056 return TRANSACTION_ERR;
1057 }
1058 bool result = IsAclEncrypted(transport, address);
1059 bool ret = reply.WriteBool(result);
1060 if (!ret) {
1061 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1062 return TRANSACTION_ERR;
1063 }
1064 return NO_ERROR;
1065 }
1066
GetDeviceClassInner(MessageParcel & data,MessageParcel & reply)1067 int32_t BluetoothHostStub::GetDeviceClassInner(MessageParcel &data, MessageParcel &reply)
1068 {
1069 std::string address;
1070 if (!data.ReadString(address)) {
1071 HILOGE("BluetoothHostStub::GetDeviceClass address failed");
1072 return BT_ERR_IPC_TRANS_FAILED;
1073 }
1074 int32_t cod = 0;
1075 int result = GetDeviceClass(address, cod);
1076 bool ret = reply.WriteInt32(result);
1077 if (!ret) {
1078 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1079 return BT_ERR_IPC_TRANS_FAILED;
1080 }
1081 ret = reply.WriteInt32(cod);
1082 if (!ret) {
1083 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1084 return BT_ERR_IPC_TRANS_FAILED;
1085 }
1086 return NO_ERROR;
1087 }
1088
SetDevicePairingConfirmationInner(MessageParcel & data,MessageParcel & reply)1089 int32_t BluetoothHostStub::SetDevicePairingConfirmationInner(MessageParcel &data, MessageParcel &reply)
1090 {
1091 int32_t transport;
1092 if (!data.ReadInt32(transport)) {
1093 HILOGE("BluetoothHostStub::SetDevicePairingConfirmation transport failed");
1094 return BT_ERR_IPC_TRANS_FAILED;
1095 }
1096 std::string address;
1097 if (!data.ReadString(address)) {
1098 HILOGE("BluetoothHostStub::SetDevicePairingConfirmation address failed");
1099 return BT_ERR_IPC_TRANS_FAILED;
1100 }
1101 bool accept = false;
1102 if (!data.ReadBool(accept)) {
1103 HILOGE("BluetoothHostStub::SetDevicePairingConfirmation accept failed");
1104 return BT_ERR_IPC_TRANS_FAILED;
1105 }
1106 int32_t result = SetDevicePairingConfirmation(transport, address, accept);
1107 bool ret = reply.WriteInt32(result);
1108 if (!ret) {
1109 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1110 return BT_ERR_IPC_TRANS_FAILED;
1111 }
1112 return NO_ERROR;
1113 }
1114
SetDevicePasskeyInner(MessageParcel & data,MessageParcel & reply)1115 ErrCode BluetoothHostStub::SetDevicePasskeyInner(MessageParcel &data, MessageParcel &reply)
1116 {
1117 int32_t transport;
1118 if (!data.ReadInt32(transport)) {
1119 HILOGE("BluetoothHostStub::SetDevicePasskey transport failed");
1120 return TRANSACTION_ERR;
1121 }
1122 std::string address;
1123 if (!data.ReadString(address)) {
1124 HILOGE("BluetoothHostStub::SetDevicePasskey address failed");
1125 return TRANSACTION_ERR;
1126 }
1127 int32_t passkey;
1128 if (!data.ReadInt32(passkey)) {
1129 HILOGE("BluetoothHostStub::SetDevicePasskey passkey failed");
1130 return TRANSACTION_ERR;
1131 }
1132 bool accept = false;
1133 if (!data.ReadBool(accept)) {
1134 HILOGE("BluetoothHostStub::SetDevicePasskey accept failed");
1135 return TRANSACTION_ERR;
1136 }
1137 bool result = SetDevicePasskey(transport, address, passkey, accept);
1138 bool ret = reply.WriteBool(result);
1139 if (!ret) {
1140 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1141 return TRANSACTION_ERR;
1142 }
1143 return NO_ERROR;
1144 }
1145
PairRequestReplyInner(MessageParcel & data,MessageParcel & reply)1146 ErrCode BluetoothHostStub::PairRequestReplyInner(MessageParcel &data, MessageParcel &reply)
1147 {
1148 int32_t transport;
1149 if (!data.ReadInt32(transport)) {
1150 HILOGE("BluetoothHostStub::PairRequestReply transport failed");
1151 return TRANSACTION_ERR;
1152 }
1153 std::string address;
1154 if (!data.ReadString(address)) {
1155 HILOGE("BluetoothHostStub::PairRequestReply address failed");
1156 return TRANSACTION_ERR;
1157 }
1158 bool accept = false;
1159 if (!data.ReadBool(accept)) {
1160 HILOGE("BluetoothHostStub::PairRequestReply accept failed");
1161 return TRANSACTION_ERR;
1162 }
1163 bool result = PairRequestReply(transport, address, accept);
1164 bool ret = reply.WriteBool(result);
1165 if (!ret) {
1166 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1167 return TRANSACTION_ERR;
1168 }
1169 return NO_ERROR;
1170 }
1171
ReadRemoteRssiValueInner(MessageParcel & data,MessageParcel & reply)1172 ErrCode BluetoothHostStub::ReadRemoteRssiValueInner(MessageParcel &data, MessageParcel &reply)
1173 {
1174 std::string address;
1175 if (!data.ReadString(address)) {
1176 HILOGE("BluetoothHostStub::ReadRemoteRssiValue address failed");
1177 return TRANSACTION_ERR;
1178 }
1179 bool result = ReadRemoteRssiValue(address);
1180 bool ret = reply.WriteBool(result);
1181 if (!ret) {
1182 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1183 return TRANSACTION_ERR;
1184 }
1185 return NO_ERROR;
1186 }
1187
GetLocalSupportedUuidsInner(MessageParcel & data,MessageParcel & reply)1188 ErrCode BluetoothHostStub::GetLocalSupportedUuidsInner(MessageParcel &data, MessageParcel &reply)
1189 {
1190 std::vector<std::string> uuids;
1191 GetLocalSupportedUuids(uuids);
1192 int32_t size = uuids.size();
1193 bool ret = reply.WriteInt32(size);
1194 if (!ret) {
1195 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1196 return TRANSACTION_ERR;
1197 }
1198 for (auto uuid : uuids) {
1199 if (!reply.WriteString(uuid)) {
1200 HILOGE("BluetoothHostStub: GetLocalSupportedUuidsInner write uuid error");
1201 return TRANSACTION_ERR;
1202 }
1203 }
1204 return NO_ERROR;
1205 }
1206
GetDeviceUuidsInner(MessageParcel & data,MessageParcel & reply)1207 ErrCode BluetoothHostStub::GetDeviceUuidsInner(MessageParcel &data, MessageParcel &reply)
1208 {
1209 std::string address;
1210 std::vector<std::string> uuids;
1211 if (!data.ReadString(address)) {
1212 HILOGE("BluetoothHostProxy::GetDeviceUuids Read address error");
1213 return TRANSACTION_ERR;
1214 }
1215 int res = GetDeviceUuids(address, uuids);
1216 int32_t size = uuids.size();
1217 bool ret = reply.WriteInt32(size);
1218 if (!ret) {
1219 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1220 return TRANSACTION_ERR;
1221 }
1222 for (auto uuid : uuids) {
1223 if (!reply.WriteString(uuid)) {
1224 HILOGE("BluetoothHostStub: GetDeviceUuidsInner write uuid error");
1225 return TRANSACTION_ERR;
1226 }
1227 }
1228 if (!reply.WriteInt32(res)) {
1229 HILOGE("BluetoothHostStub: GetDeviceUuidsInner write result error");
1230 return TRANSACTION_ERR;
1231 }
1232 return NO_ERROR;
1233 }
1234
GetLocalProfileUuidsInner(MessageParcel & data,MessageParcel & reply)1235 ErrCode BluetoothHostStub::GetLocalProfileUuidsInner(MessageParcel &data, MessageParcel &reply)
1236 {
1237 return NO_ERROR;
1238 }
1239
RegisterBleAdapterObserverInner(MessageParcel & data,MessageParcel & reply)1240 ErrCode BluetoothHostStub::RegisterBleAdapterObserverInner(MessageParcel &data, MessageParcel &reply)
1241 {
1242 auto tempObject = data.ReadRemoteObject();
1243 sptr<IBluetoothHostObserver> observer;
1244 observer = iface_cast<IBluetoothHostObserver>(tempObject);
1245 RegisterBleAdapterObserver(observer);
1246 return NO_ERROR;
1247 }
1248
DeregisterBleAdapterObserverInner(MessageParcel & data,MessageParcel & reply)1249 ErrCode BluetoothHostStub::DeregisterBleAdapterObserverInner(MessageParcel &data, MessageParcel &reply)
1250 {
1251 auto tempObject = data.ReadRemoteObject();
1252 sptr<IBluetoothHostObserver> observer;
1253 observer = iface_cast<IBluetoothHostObserver>(tempObject);
1254 DeregisterBleAdapterObserver(observer);
1255 return NO_ERROR;
1256 }
1257
RegisterBlePeripheralCallbackInner(MessageParcel & data,MessageParcel & reply)1258 ErrCode BluetoothHostStub::RegisterBlePeripheralCallbackInner(MessageParcel &data, MessageParcel &reply)
1259 {
1260 auto tempObject = data.ReadRemoteObject();
1261 sptr<IBluetoothBlePeripheralObserver> observer;
1262 observer = iface_cast<IBluetoothBlePeripheralObserver>(tempObject);
1263 RegisterBlePeripheralCallback(observer);
1264 return NO_ERROR;
1265 }
1266
DeregisterBlePeripheralCallbackInner(MessageParcel & data,MessageParcel & reply)1267 ErrCode BluetoothHostStub::DeregisterBlePeripheralCallbackInner(MessageParcel &data, MessageParcel &reply)
1268 {
1269 auto tempObject = data.ReadRemoteObject();
1270 sptr<IBluetoothBlePeripheralObserver> observer;
1271 observer = iface_cast<IBluetoothBlePeripheralObserver>(tempObject);
1272 DeregisterBlePeripheralCallback(observer);
1273 return NO_ERROR;
1274 }
1275
SetFastScanInner(MessageParcel & data,MessageParcel & reply)1276 int32_t BluetoothHostStub::SetFastScanInner(MessageParcel &data, MessageParcel &reply)
1277 {
1278 return NO_ERROR;
1279 }
1280
GetRandomAddressInner(MessageParcel & data,MessageParcel & reply)1281 ErrCode BluetoothHostStub::GetRandomAddressInner(MessageParcel &data, MessageParcel &reply)
1282 {
1283 std::string realAddress = data.ReadString();
1284 std::string randomAddress;
1285 int result = GetRandomAddress(realAddress, randomAddress);
1286 bool ret = reply.WriteInt32(result);
1287 if (!ret) {
1288 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1289 return TRANSACTION_ERR;
1290 }
1291 if (result == NO_ERROR) {
1292 if (!reply.WriteString(randomAddress)) {
1293 HILOGE("BluetoothHostStub:GetRandomAddressInner write randomAddress error");
1294 return TRANSACTION_ERR;
1295 }
1296 }
1297 return NO_ERROR;
1298 }
1299
SyncRandomAddressInner(MessageParcel & data,MessageParcel & reply)1300 ErrCode BluetoothHostStub::SyncRandomAddressInner(MessageParcel &data, MessageParcel &reply)
1301 {
1302 return NO_ERROR;
1303 }
1304
StartCrediblePairInner(MessageParcel & data,MessageParcel & reply)1305 ErrCode BluetoothHostStub::StartCrediblePairInner(MessageParcel &data, MessageParcel &reply)
1306 {
1307 std::string address = data.ReadString();
1308 int32_t transport = data.ReadInt32();
1309 int result = StartCrediblePair(transport, address);
1310 bool ret = reply.WriteInt32(result);
1311 if (!ret) {
1312 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1313 }
1314 return NO_ERROR;
1315 }
1316
SatelliteControlInner(MessageParcel & data,MessageParcel & reply)1317 ErrCode BluetoothHostStub::SatelliteControlInner(MessageParcel &data, MessageParcel &reply)
1318 {
1319 return NO_ERROR;
1320 }
1321
ConnectAllowedProfilesInner(MessageParcel & data,MessageParcel & reply)1322 int32_t BluetoothHostStub::ConnectAllowedProfilesInner(MessageParcel &data, MessageParcel &reply)
1323 {
1324 reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1325 return NO_ERROR;
1326 }
1327
DisconnectAllowedProfilesInner(MessageParcel & data,MessageParcel & reply)1328 int32_t BluetoothHostStub::DisconnectAllowedProfilesInner(MessageParcel &data, MessageParcel &reply)
1329 {
1330 reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1331 return NO_ERROR;
1332 }
1333
SetDeviceCustomTypeInner(MessageParcel & data,MessageParcel & reply)1334 int32_t BluetoothHostStub::SetDeviceCustomTypeInner(MessageParcel &data, MessageParcel &reply)
1335 {
1336 std::string address;
1337 if (!data.ReadString(address)) {
1338 HILOGE("BluetoothHostStub::SetDeviceCustomType address failed");
1339 return TRANSACTION_ERR;
1340 }
1341 int32_t customType;
1342 if (!data.ReadInt32(customType)) {
1343 HILOGE("BluetoothHostStub::SetDeviceCustomType customType failed");
1344 return TRANSACTION_ERR;
1345 }
1346 bool ret = reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1347 if (!ret) {
1348 HILOGE("BluetoothHostStub: reply writing failed in: %{public}s.", __func__);
1349 return TRANSACTION_ERR;
1350 }
1351 return BT_ERR_API_NOT_SUPPORT;
1352 }
1353
RegisterBtResourceManagerObserverInner(MessageParcel & data,MessageParcel & reply)1354 int32_t BluetoothHostStub::RegisterBtResourceManagerObserverInner(MessageParcel &data, MessageParcel &reply)
1355 {
1356 auto tempObject = data.ReadRemoteObject();
1357 sptr<IBluetoothResourceManagerObserver> observer;
1358 observer = iface_cast<IBluetoothResourceManagerObserver>(tempObject);
1359 CHECK_AND_RETURN_LOG_RET(observer != nullptr, ERR_INVALID_VALUE, "observer is nullptr");
1360 RegisterBtResourceManagerObserver(observer);
1361 return NO_ERROR;
1362 }
1363
DeregisterBtResourceManagerObserverInner(MessageParcel & data,MessageParcel & reply)1364 int32_t BluetoothHostStub::DeregisterBtResourceManagerObserverInner(MessageParcel &data, MessageParcel &reply)
1365 {
1366 auto tempObject = data.ReadRemoteObject();
1367 sptr<IBluetoothResourceManagerObserver> observer;
1368 observer = iface_cast<IBluetoothResourceManagerObserver>(tempObject);
1369 CHECK_AND_RETURN_LOG_RET(observer != nullptr, ERR_INVALID_VALUE, "observer is nullptr");
1370 DeregisterBtResourceManagerObserver(observer);
1371 return NO_ERROR;
1372 }
1373
UpdateVirtualDeviceInner(MessageParcel & data,MessageParcel & reply)1374 int32_t BluetoothHostStub::UpdateVirtualDeviceInner(MessageParcel &data, MessageParcel &reply)
1375 {
1376 return BT_ERR_API_NOT_SUPPORT;
1377 }
1378
IsSupportVirtualAutoConnectInner(MessageParcel & data,MessageParcel & reply)1379 int32_t BluetoothHostStub::IsSupportVirtualAutoConnectInner(MessageParcel &data, MessageParcel &reply)
1380 {
1381 return BT_ERR_API_NOT_SUPPORT;
1382 }
1383
SetVirtualAutoConnectTypeInner(MessageParcel & data,MessageParcel & reply)1384 int32_t BluetoothHostStub::SetVirtualAutoConnectTypeInner(MessageParcel &data, MessageParcel &reply)
1385 {
1386 return BT_ERR_API_NOT_SUPPORT;
1387 }
1388
SetFastScanLevelInner(MessageParcel & data,MessageParcel & reply)1389 int32_t BluetoothHostStub::SetFastScanLevelInner(MessageParcel &data, MessageParcel &reply)
1390 {
1391 return BT_ERR_API_NOT_SUPPORT;
1392 }
1393
EnableBluetoothToRestrictModeInner(MessageParcel & data,MessageParcel & reply)1394 int32_t BluetoothHostStub::EnableBluetoothToRestrictModeInner(MessageParcel &data, MessageParcel &reply)
1395 {
1396 return BT_ERR_API_NOT_SUPPORT;
1397 }
1398
ControlDeviceActionInner(MessageParcel & data,MessageParcel & reply)1399 int32_t BluetoothHostStub::ControlDeviceActionInner(MessageParcel &data, MessageParcel &reply)
1400 {
1401 return BT_ERR_API_NOT_SUPPORT;
1402 }
1403
GetLastConnectionTimeInner(MessageParcel & data,MessageParcel & reply)1404 int32_t BluetoothHostStub::GetLastConnectionTimeInner(MessageParcel &data, MessageParcel &reply)
1405 {
1406 return NO_ERROR;
1407 }
1408
UpdateCloudBluetoothDevInner(MessageParcel & data,MessageParcel & reply)1409 int32_t BluetoothHostStub::UpdateCloudBluetoothDevInner(MessageParcel &data, MessageParcel &reply)
1410 {
1411 return NO_ERROR;
1412 }
1413
GetCloudBondStateInner(MessageParcel & data,MessageParcel & reply)1414 int32_t BluetoothHostStub::GetCloudBondStateInner(MessageParcel &data, MessageParcel &reply)
1415 {
1416 return NO_ERROR;
1417 }
1418
UpdateRefusePolicyInner(MessageParcel & data,MessageParcel & reply)1419 int32_t BluetoothHostStub::UpdateRefusePolicyInner(MessageParcel &data, MessageParcel &reply)
1420 {
1421 return BT_ERR_API_NOT_SUPPORT;
1422 }
1423
ProcessRandomDeviceIdCommandInner(MessageParcel & data,MessageParcel & reply)1424 int32_t BluetoothHostStub::ProcessRandomDeviceIdCommandInner(MessageParcel &data, MessageParcel &reply)
1425 {
1426 reply.WriteInt32(BT_ERR_API_NOT_SUPPORT);
1427 return NO_ERROR;
1428 }
1429 } // namespace Bluetooth
1430 } // namespace OHOS
1431