• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup Bluetooth
18  * @{
19  *
20  * @brief Defines bluetooth host, including observer and common functions.
21  *
22  * @since 6
23  */
24 
25 /**
26  * @file bluetooth_host.h
27  *
28  * @brief Framework bluetooth host interface.
29  *
30  * @since 6
31  */
32 
33 #ifndef BLUETOOTH_HOST_H
34 #define BLUETOOTH_HOST_H
35 
36 #include <string>
37 
38 #include "bluetooth_battery_info.h"
39 #include "bluetooth_def.h"
40 #include "bluetooth_types.h"
41 #include "bluetooth_remote_device.h"
42 #include "bluetooth_device_class.h"
43 #include "refbase.h"
44 #include "bluetooth_no_destructor.h"
45 
46 namespace OHOS { class IRemoteObject; }
47 namespace OHOS {
48 namespace Bluetooth {
49 /**
50  * @brief Represents framework host device basic observer.
51  *
52  * @since 6
53  */
54 class BluetoothHostObserver {
55 public:
56     /**
57      * @brief A destructor used to delete the <b>BluetoothHostObserver</b> instance.
58      *
59      * @since 6
60      */
61     virtual ~BluetoothHostObserver() = default;
62 
63     // common
64     /**
65      * @brief Adapter state change function.
66      *
67      * @param transport Transport type when state change.
68      *        BTTransport::ADAPTER_BREDR : classic;
69      *        BTTransport::ADAPTER_BLE : ble.
70      * @param state Change to the new state.
71      *        BTStateID::STATE_TURNING_ON;
72      *        BTStateID::STATE_TURN_ON;
73      *        BTStateID::STATE_TURNING_OFF;
74      *        BTStateID::STATE_TURN_OFF.
75      * @since 6
76      */
77     virtual void OnStateChanged(const int transport, const int status) = 0;
78 
79     // gap
80     /**
81      * @brief Discovery state changed observer.
82      *
83      * @param status Device discovery status.
84      * @since 6
85      */
86     virtual void OnDiscoveryStateChanged(int status) = 0;
87 
88     /**
89      * @brief Discovery result observer.
90      *
91      * @param device Remote device.
92      * @param rssi Rssi of device.
93      * @param deviceName Name of device.
94      * @param deviceClass Class of device.
95      * @since 6
96      */
97     virtual void OnDiscoveryResult(
98         const BluetoothRemoteDevice &device, int rssi, const std::string deviceName, int deviceClass) = 0;
99 
100     /**
101      * @brief Pair request observer.
102      *
103      * @param device Remote device.
104      * @since 6
105      */
106     virtual void OnPairRequested(const BluetoothRemoteDevice &device) = 0;
107 
108     /**
109      * @brief Pair confirmed observer.
110      *
111      * @param device Remote device.
112      * @param reqType Pair type.
113      * @param number Paired passkey.
114      * @since 6
115      */
116     virtual void OnPairConfirmed(const BluetoothRemoteDevice &device, int reqType, int number) = 0;
117 
118     /**
119      * @brief Scan mode changed observer.
120      *
121      * @param mode Device scan mode.
122      * @since 6
123      */
124     virtual void OnScanModeChanged(int mode) = 0;
125 
126     /**
127      * @brief Device name changed observer.
128      *
129      * @param deviceName Device name.
130      * @since 6
131      */
132     virtual void OnDeviceNameChanged(const std::string &deviceName) = 0;
133 
134     /**
135      * @brief Device address changed observer.
136      *
137      * @param address Device address.
138      * @since 6
139      */
140     virtual void OnDeviceAddrChanged(const std::string &address) = 0;
141 };
142 
143 /**
144  * @brief Represents remote device observer.
145  *
146  * @since 6
147  */
148 class BluetoothRemoteDeviceObserver {
149 public:
150     /**
151      * @brief A destructor used to delete the <b>BluetoothRemoteDeviceObserver</b> instance.
152      *
153      * @since 6
154      */
155     virtual ~BluetoothRemoteDeviceObserver() = default;
156 
157     /**
158      * @brief Acl state changed observer.
159      *
160      * @param device Remote device.
161      * @param state Remote device acl state.
162      * @param reason Remote device reason.
163      * @since 6
164      */
165     virtual void OnAclStateChanged(const BluetoothRemoteDevice &device, int state, unsigned int reason) = 0;
166 
167     /**
168      * @brief Pair status changed observer.
169      *
170      * @param device Remote device.
171      * @param status Remote device pair status.
172      * @param cause Pair fail cause.
173      * @since 12
174      */
175     virtual void OnPairStatusChanged(const BluetoothRemoteDevice &device, int status, int cause) = 0;
176 
177     /**
178      * @brief Remote uuid changed observer.
179      *
180      * @param device Remote device.
181      * @param uuids Remote device uuids.
182      * @since 6
183      */
184     virtual void OnRemoteUuidChanged(const BluetoothRemoteDevice &device, const std::vector<ParcelUuid> &uuids) = 0;
185 
186     /**
187      * @brief Remote name changed observer.
188      *
189      * @param device Remote device.
190      * @param deviceName Remote device name.
191      * @since 6
192      */
193     virtual void OnRemoteNameChanged(const BluetoothRemoteDevice &device, const std::string &deviceName) = 0;
194 
195     /**
196      * @brief Remote alias changed observer.
197      *
198      * @param device Remote device.
199      * @param alias Remote device alias.
200      * @since 6
201      */
202     virtual void OnRemoteAliasChanged(const BluetoothRemoteDevice &device, const std::string &alias) = 0;
203 
204     /**
205      * @brief Remote cod changed observer.
206      *
207      * @param device Remote device.
208      * @param cod Remote device cod.
209      * @since 6
210      */
211     virtual void OnRemoteCodChanged(const BluetoothRemoteDevice &device, const BluetoothDeviceClass &cod) = 0;
212 
213     /**
214      * @brief Remote battery level changed observer.
215      *
216      * @param device Remote device.
217      * @param cod Remote device battery Level.
218      * @since 6
219      */
220     virtual void OnRemoteBatteryLevelChanged(const BluetoothRemoteDevice &device, int batteryLevel) = 0;
221 
222     /**
223      * @brief Remote rssi event observer.
224      *
225      * @param device Remote device.
226      * @param rssi Remote device rssi.
227      * @param status Read status.
228      * @since 6
229      */
230     virtual void OnReadRemoteRssiEvent(const BluetoothRemoteDevice &device, int rssi, int status) = 0;
231 
232     /**
233      * @brief Remote device battery info observer.
234      *
235      * @param device Remote device.
236      * @param batteryInfo Remote device batteryInfo
237      * @since 12
238      */
OnRemoteBatteryChanged(const BluetoothRemoteDevice & device,const DeviceBatteryInfo & batteryInfo)239     virtual void OnRemoteBatteryChanged(const BluetoothRemoteDevice &device, const DeviceBatteryInfo &batteryInfo)
240     {};
241 
242     /**
243      * @brief Remote device common value observer.
244      *
245      * @param device Remote device.
246      * @param value Remote device report info
247      * @since 12
248      */
OnRemoteDeviceCommonInfoReport(const BluetoothRemoteDevice & device,const std::vector<uint8_t> & value)249     virtual void OnRemoteDeviceCommonInfoReport(const BluetoothRemoteDevice &device, const std::vector<uint8_t> &value)
250     {};
251 };
252 
253 /**
254  * @brief Represents bluetooth resource manager observer.
255  *
256  * @since 12
257  */
258 class BluetoothResourceManagerObserver {
259 public:
260     /**
261      * @brief A destructor used to delete the <b>BluetoothResourceManagerObserver</b> instance.
262      *
263      * @since 12
264      */
265     virtual ~BluetoothResourceManagerObserver() = default;
266 
267     /**
268      * @brief sensing state changed observer.
269      *
270      * @param eventId bluetooth resource manager event id.
271      * @param info bluetooth sensing information.
272      * @since 12
273      */
OnSensingStateChanged(uint8_t eventId,const SensingInfo & info)274     virtual void OnSensingStateChanged(uint8_t eventId, const SensingInfo &info)
275     {};
276 
277     /**
278      * @brief bluetooth resource decision observer.
279      *
280      * @param eventId bluetooth resource manager event id.
281      * @param info bluetooth sensing information.
282      * @param result bluetooth resource decision result.
283      * @since 12
284      */
OnBluetoothResourceDecision(uint8_t eventId,const SensingInfo & info,uint32_t & result)285     virtual void OnBluetoothResourceDecision(uint8_t eventId, const SensingInfo &info, uint32_t &result)
286     {};
287 };
288 
289 /**
290  * @brief Represents framework host device.
291  *
292  * @since 6
293  */
294 class BLUETOOTH_API BluetoothHost {
295 public:
296     // common
297     /**
298      * @brief Get default host device.
299      *
300      * @return Returns the singleton instance.
301      * @since 6
302      */
303     static BluetoothHost &GetDefaultHost();
304 
305     /**
306      * @brief Get remote device instance.
307      *
308      * @param addr Remote device address.
309      * @param transport Adapter transport.
310      * @return Returns remote device instance.
311      * @since 6
312      */
313     BluetoothRemoteDevice GetRemoteDevice(const std::string &addr, int transport) const;
314 
315     /**
316      * @brief Register observer.
317      *
318      * @param observer Class BluetoothHostObserver pointer to register observer.
319      * @since 6
320      */
321     void RegisterObserver(std::shared_ptr<BluetoothHostObserver> observer);
322 
323     /**
324      * @brief Deregister observer.
325      *
326      * @param observer Class BluetoothHostObserver pointer to deregister observer.
327      * @since 6
328      */
329     void DeregisterObserver(std::shared_ptr<BluetoothHostObserver> observer);
330 
331     /**
332      * @brief Enable classic.
333      *
334      * @return Returns <b>true</b> if the operation is accepted;
335      *         returns <b>false</b> if the operation is rejected.
336      * @since 6
337      * @deprecated since 20
338      */
339     int EnableBt();
340 
341     /**
342      * @brief Disable classic.
343      *
344      * @param isAsync Indicate Async function flag.
345      * @return Returns <b>true</b> if the operation is accepted;
346      *         returns <b>false</b> if the operation is rejected.
347      * @since 6
348      */
349     int DisableBt(bool isAsync = false);
350 
351     /**
352      * @brief Get classic enable/disable state.
353      *
354      * @return Returns classic enable/disable state.
355      *         BTStateID::STATE_TURNING_ON;
356      *         BTStateID::STATE_TURN_ON;
357      *         BTStateID::STATE_TURNING_OFF;
358      *         BTStateID::STATE_TURN_OFF.
359      * @since 6
360      * @deprecated since 14
361      * @useinstead BluetoothHost#GetBluetoothState
362      */
363     int GetBtState() const;
364 
365     /**
366      * @brief Get classic enable/disable state.
367      *
368      * @param Returns classic enable/disable state.
369      *         BTStateID::STATE_TURNING_ON;
370      *         BTStateID::STATE_TURN_ON;
371      *         BTStateID::STATE_TURNING_OFF;
372      *         BTStateID::STATE_TURN_OFF.
373      * @since 6
374      * @deprecated since 14
375      * @useinstead BluetoothHost#GetBluetoothState
376      */
377     int GetBtState(int &state) const;
378 
379     /**
380      * @brief Get the current state of the local Bluetooth adapter.
381      *
382      * @return current state of Bluetooth adapter.
383      *         BluetoothState::STATE_TURN_OFF.
384      *         BluetoothState::STATE_TURNING_ON;
385      *         BluetoothState::STATE_TURN_ON;
386      *         BluetoothState::STATE_TURNING_OFF;
387      *         BluetoothState::STATE_BLE_TURNING_ON;
388      *         BluetoothState::STATE_BLE_ON;
389      *         BluetoothState::STATE_BLE_TURNING_OFF;
390      * @since 14
391      */
392     BluetoothState GetBluetoothState(void) const;
393 
394     /**
395      * @brief Disable ble.
396      *
397      * @return Returns <b>true</b> if the operation is accepted;
398      *         returns <b>false</b> if the operation is rejected.
399      * @since 6
400      * @deprecated since 20
401      */
402     int DisableBle();
403 
404     /**
405      * @brief Enable ble.
406      *
407      * @param isAsync Indicate Async function flag.
408      * @return Returns <b>true</b> if the operation is accepted;
409      *         returns <b>false</b> if the operation is rejected.
410      * @since 6
411      */
412     int EnableBle(bool isAsync = false);
413 
414     /**
415      * @brief Enable bluetooth without AutoConnect.
416      *
417      * @return Returns <b>true</b> if the operation is accepted;
418      *         returns <b>false</b> if the operation is rejected.
419      * @since 16
420      */
421     int EnableBluetoothNoAutoConnect();
422 
423     /**
424      * @brief Enable bluetooth to restrict mode.
425      *
426      * @return Returns BT_NO_ERROR if the operation is accepted;
427      *         returns others if the operation is rejected.
428      * @since 12
429      */
430     int EnableBluetoothToRestrictMode(void);
431 
432     /**
433      * @brief Get br/edr enable/disable state.
434      *
435      * @return Returns <b>true</b> if br is enabled;
436      *         returns <b>false</b> if br is not enabled.
437      * @since 6
438      */
439     bool IsBrEnabled() const;
440 
441     /**
442      * @brief Get ble enable/disable state.
443      *
444      * @return Returns <b>true</b> if ble is enabled;
445      *         returns <b>false</b> if ble is not enabled.
446      * @since 6
447      */
448     bool IsBleEnabled() const;
449 
450     /**
451      * @brief Factory reset bluetooth service.
452      *
453      * @return Returns <b>true</b> if the operation is successful;
454      *         returns <b>false</b> if the operation fails.
455      * @since 6
456      */
457     int BluetoothFactoryReset();
458 
459     /**
460      * @brief Get profile service ID list.
461      *
462      * @return Returns vector of enabled profile services ID.
463      * @since 6
464      */
465     std::vector<uint32_t> GetProfileList() const;
466 
467     /**
468      * @brief Get max audio connected devices number.
469      *
470      * @return Returns max device number that audio can connect.
471      * @since 6
472      */
473     int GetMaxNumConnectedAudioDevices() const;
474 
475     /**
476      * @brief Get bluetooth connects state.
477      *
478      * @return Returns bluetooth connects state.
479      *         BTConnectState::CONNECTING;
480      *         BTConnectState::CONNECTED;
481      *         BTConnectState::DISCONNECTING;
482      *         BTConnectState::DISCONNECTED.
483      * @since 6
484      */
485     int GetBtConnectionState() const;
486 
487     /**
488      * @brief Get bluetooth connects state.
489      *
490      * @return Returns bluetooth connects state.
491      *         BTConnectState::CONNECTING;
492      *         BTConnectState::CONNECTED;
493      *         BTConnectState::DISCONNECTING;
494      *         BTConnectState::DISCONNECTED.
495      * @since 6
496      */
497     int GetBtConnectionState(int &state) const;
498 
499     /**
500      * @brief Get profile service connect state.
501      *
502      * @param profileID Profile service ID.
503      * @return Returns connect state for designated profile service.
504      *         BTConnectState::CONNECTING;
505      *         BTConnectState::CONNECTED;
506      *         BTConnectState::DISCONNECTING;
507      *         BTConnectState::DISCONNECTED.
508      * @since 6
509      */
510     int GetBtProfileConnState(uint32_t profileId, int &state) const;
511 
512     /**
513      * @brief Get local device supported uuids.
514      *
515      * @param[out] Vector which use to return support uuids.
516      * @since 6
517      */
518     void GetLocalSupportedUuids(std::vector<ParcelUuid> &uuids);
519 
520     /**
521      * @brief Start adapter manager, passthrough only.
522      *
523      * @return Returns <b>true</b> if the operation is successful;
524      *         returns <b>false</b> if the operation fails.
525      * @since 6
526      */
527     bool Start();
528 
529     /**
530      * @brief Stop adapter manager, passthrough only.
531      *
532      * @since 6
533      */
534     void Stop();
535 
536     // gap
537     /**
538      * @brief Get local device class.
539      *
540      * @return Returns local device class.
541      * @since 6
542      */
543     BluetoothDeviceClass GetLocalDeviceClass() const;
544 
545     /**
546      * @brief Set local device class.
547      *
548      * @param deviceClass Device class.
549      * @return Returns <b>true</b> if the operation is successful;
550      *         returns <b>false</b> if the operation fails.
551      * @since 6
552      */
553     bool SetLocalDeviceClass(const BluetoothDeviceClass &deviceClass);
554 
555     /**
556      * @brief Get local device address.
557      *
558      * @param addr local address.
559      * @return Returns {@link BT_NO_ERROR} if the operation is successful;
560      *         returns an error code defined in {@link BtErrCode} otherwise.
561      * @since 6
562      */
563     int GetLocalAddress(std::string &addr) const;
564 
565     /**
566      * @brief Get local device name.
567      *
568      * @return Returns local device name.
569      * @since 6
570      */
571     std::string GetLocalName() const;
572 
573     /**
574      * @brief Get local device name.
575      *
576      * @return Returns local device name.
577      * @since 6
578      */
579     int GetLocalName(std::string &name) const;
580 
581     /**
582      * @brief Set local device name.
583      *
584      * @param name Device name.
585      * @return Returns <b>true</b> if the operation is successful;
586      *         returns <b>false</b> if the operation fails.
587      * @since 6
588      */
589     int SetLocalName(const std::string &name);
590 
591     /**
592      * @brief Get device scan mode.
593      *
594      * @return Returns bluetooth scan mode.
595      * @since 6
596      */
597     int GetBtScanMode(int32_t &scanMode) const;
598 
599     /**
600      * @brief Set device scan mode.
601      *
602      * @param mode Scan mode.
603      * @param duration Scan time.
604      * @return Returns <b>true</b> if the operation is successful;
605      *         returns <b>false</b> if the operation fails.
606      * @since 6
607      */
608     int SetBtScanMode(int mode, int duration);
609 
610     /**
611      * @brief Get local device bondable mode.
612      *
613      * @param transport Adapter transport.
614      * @return Returns local device bondable mode.
615      * @since 6
616      */
617     int GetBondableMode(int transport) const;
618 
619     /**
620      * @brief Set local device bondable mode.
621      *
622      * @param transport Adapter transport.
623      * @param mode Device bondable mode.
624      * @return Returns <b>true</b> if the operation is successful;
625      *         returns <b>false</b> if the operation fails.
626      * @since 6
627      */
628     bool SetBondableMode(int transport, int mode);
629 
630     /**
631      * @brief Get device address.
632      * @return Returns <b>true</b> if the operation is successful;
633      *         returns <b>false</b> if the operation fails.
634      * @since 6
635      */
636     int StartBtDiscovery();
637 
638     /**
639      * @brief Cancel device discovery.
640      *
641      * @return Returns <b>true</b> if the operation is successful;
642      *         returns <b>false</b> if the operation fails.
643      * @since 6
644      */
645     int CancelBtDiscovery();
646 
647     /**
648      * @brief Check if device is discovering.
649      *
650      * @return Returns <b>BT_NO_ERROR</b> if the operation is successful;
651      *         returns <b>false</b> if device is not discovering.
652      * @since 6
653      */
654     int IsBtDiscovering(bool &isDisCovering, int transport = BT_TRANSPORT_BREDR) const;
655 
656     /**
657      * @brief Get device discovery end time.
658      *
659      * @return Returns device discovery end time.
660      * @since 6
661      */
662     long GetBtDiscoveryEndMillis() const;
663 
664     /**
665      * @brief Get paired devices.
666      *
667      * @param transport Adapter transport.
668      * @return Returns paired devices vector.
669      * @since 6
670      */
671     int32_t GetPairedDevices(int transport, std::vector<BluetoothRemoteDevice> &pairedDevices) const;
672 
673     /**
674      * @brief Remove pair.
675      *
676      * @param device Remote device address.
677      * @return Returns <b>true</b> if the operation is successful;
678      *         returns <b>false</b> if the operation fails.
679      * @since 6
680      */
681     int32_t RemovePair(const BluetoothRemoteDevice &device);
682 
683     /**
684      * @brief Remove all pairs.
685      *
686      * @return Returns <b>true</b> if the operation is successful;
687      *         returns <b>false</b> if the operation fails.
688      * @since 6
689      */
690     bool RemoveAllPairs();
691 
692     /**
693      * @brief Check if bluetooth address is valid.
694      *
695      * @param addr Bluetooth address.
696      * @return Returns <b>true</b> if bluetooth address is valid;
697      *         returns <b>false</b> if bluetooth address is not valid.
698      * @since 6
699      */
700     static bool IsValidBluetoothAddr(const std::string &addr);
701 
702     /**
703      * @brief Register remote device observer.
704      *
705      * @param observer Class BluetoothRemoteDeviceObserver pointer to register observer.
706      * @return Returns <b>true</b> if the operation is successful;
707      *         returns <b>false</b> if the operation fails.
708      * @since 6
709      */
710     void RegisterRemoteDeviceObserver(std::shared_ptr<BluetoothRemoteDeviceObserver> observer);
711 
712     /**
713      * @brief Deregister remote device observer.
714      *
715      * @param observer Class BluetoothRemoteDeviceObserver pointer to deregister observer.
716      * @return Returns <b>true</b> if the operation is successful;
717      *         returns <b>false</b> if the operation fails.
718      * @since 6
719      */
720     void DeregisterRemoteDeviceObserver(std::shared_ptr<BluetoothRemoteDeviceObserver> observer);
721 
722     /**
723      * @brief Get max advertising data length.
724      *
725      * @return Returns max advertising data length.
726      * @since 6
727      */
728     int GetBleMaxAdvertisingDataLength() const;
729 
730     void LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject);
731 
732     void LoadSystemAbilityFail();
733 
734     void OnRemoveBluetoothSystemAbility();
735 
736     /**
737      * @brief Get local profile uuids.
738      *
739      * @return Returns local profile uuids.
740      * @since 10
741      */
742     int32_t GetLocalProfileUuids(std::vector<std::string> &uuids);
743 
744     /**
745     * @brief Set fast scan enable or disable.
746     * @param isEnable set fast scan status flag.
747     * @return Returns <b>true</b> if the operation is successful;
748     *         returns <b>false</b> if the operation fails.
749     */
750     int SetFastScan(bool isEnable);
751 
752     /**
753     * @brief Get the random address of a device.
754     * If the address carried in the bluetooth interface is not obtained from the bluetooth,
755     * the interface needs to be used for address translation.
756     * @param realAddr real address.
757     * @param[out] randomAddr random address.
758     * @param tokenId tokenId.
759     * @return Returns {@link BT_NO_ERROR} if get random address success;
760     * returns an error code defined in {@link BtErrCode} otherwise.
761     */
762     int GetRandomAddress(const std::string &realAddr, std::string &randomAddr, uint64_t tokenId = 0) const;
763 
764     /**
765     * @brief Connects all allowed bluetooth profiles between the local and remote device.
766     *
767     * @param remoteAddr remote device addr.
768     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
769     *         returns an error code defined in {@link BtErrCode} otherwise.
770     * @since 11
771     */
772     int ConnectAllowedProfiles(const std::string &remoteAddr) const;
773 
774     /**
775     * @brief Disconnects all allowed bluetooth profiles between the local and remote device.
776     *
777     * @param remoteAddr remote device addr.
778     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
779     *         returns an error code defined in {@link BtErrCode} otherwise.
780     * @since 11
781     */
782     int DisconnectAllowedProfiles(const std::string &remoteAddr) const;
783 
784     /**
785     * @brief Restrict Bluetooth BR/EDR ability, just BLE ability available.
786     *
787     * @param remoteAddr remote device addr.
788     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
789     *         returns an error code defined in {@link BtErrCode} otherwise.
790     * @since 12
791     */
792     int RestrictBluetooth();
793     /**
794     * @brief update virtual device
795     *
796     * @param action add or delete virtual device.
797     * @param device device need to be operator.
798     * @since 12
799     */
800     void UpdateVirtualDevice(int32_t action, const std::string &address);
801 
802     /**
803     * @brief Restrict Bluetooth BR/EDR ability, just BLE ability available.
804     *
805     * @param type satellite control type.
806     * @param state satellite state.
807     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
808     *         returns an error code defined in {@link BtErrCode} otherwise.
809     * @since 12
810     */
811     int SatelliteControl(int type, int state);
812 
813     /**
814      * @brief Register bluetooth resource manager observer.
815      *
816      * @param observer Class RegisterBtResourceManagerObserver pointer to register observer.
817      * @since 12
818      */
819     void RegisterBtResourceManagerObserver(std::shared_ptr<BluetoothResourceManagerObserver> observer);
820 
821     /**
822      * @brief Deregister bluetooth resource manager observer.
823      *
824      * @param observer Class RegisterBtResourceManagerObserver pointer to deregister observer.
825      * @since 12
826      */
827     void DeregisterBtResourceManagerObserver(std::shared_ptr<BluetoothResourceManagerObserver> observer);
828 
829     /**
830      * @brief Set local adapter scan level.
831      *
832      * @param level Scan level.
833      * @return Returns <b>true</b> if the operation is successful;
834      *         returns <b>false</b> if the operation fails.
835      * @since 12
836      */
837     int SetFastScanLevel(int level);
838 
839     /**
840      * @brief Close the bluetooth host to release resources, only called before the process exits.
841      *
842      * @since 13
843      */
844     void Close(void);
845 
846     int32_t UpdateCloudBluetoothDevice(const std::vector<TrustPairDeviceParam> &cloudDevices);
847 
848     /**
849      * @brief Update Refuse Policy
850      *
851      * @param protocolType protocol type
852      * @param pid process PID
853      * @param prohibitedSecondsTime Boot start time + Control duration
854      * @return Returns {@link BT_NO_ERROR} if the operation is successful;
855      *         returns an error code defined in {@link BtErrCode} otherwise.
856      * @since 16
857      */
858     int UpdateRefusePolicy(const int32_t protocolType, const int32_t pid, const int64_t prohibitedSecondsTime);
859 
860     /**
861      * @brief get refuse policy prohibitedTime.
862      *
863      * @since 16
864      */
865     int64_t GetRefusePolicyProhibitedTime();
866 
867     int32_t ProcessRandomDeviceIdCommand(int32_t command, std::vector<std::string> &deviceIdVec, bool &isValid);
868 
869     int GetCarKeyDfxData(std::string &dfxData) const;
870 
871     int SetCarKeyCardData(const std::string &address, int32_t action);
872 
873     /**
874      * @brief Notify bluetooth the result of bluetooth dialog.
875      *
876      * @param dialogType The type of bluetooth dialog.
877      * @param dialogResult The result of bluetooth dialog.
878      * @return Returns {@link BT_NO_ERROR} if the operation is successful;
879      *         returns an error code defined in {@link BtErrCode} otherwise.
880      * @since 20
881      */
882     int NotifyDialogResult(uint32_t dialogType, bool dialogResult);
883 
884     /**
885      * @brief set the package name of calling app which is pairing or connecting remote bluetooth device.
886      *
887      * @param address The address of remote bluetooth device.
888      * @param packageName The package name of calling app.
889      * @return Returns {@link BT_NO_ERROR} if the operation is successful;
890      *         returns an error code defined in {@link BtErrCode} otherwise.
891      * @since 21
892      */
893     int32_t SetCallingPackageName(const std::string &address, const std::string &packageName);
894 private:
895     /**
896      * @brief A constructor used to create a <b>BluetoothHost</b> instance.
897      *
898      * @since 6
899      */
900     BluetoothHost();
901 
902     /**
903      * @brief A destructor used to delete the <b>BluetoothHost</b> instance.
904      *
905      * @since 6
906      */
907     ~BluetoothHost();
908 
909     /**
910     * @brief Check whether bluetooth is prohibited by EDM.
911     *
912     * @return Returns <b>true</b> if bluetooth is prohibited, returns <b>false</b> otherwise.
913     * @since 11
914     */
915     bool IsBtProhibitedByEdm(void);
916 
917     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(BluetoothHost);
918     BLUETOOTH_DECLARE_IMPL();
919 
920 #ifdef DTFUZZ_TEST
921     friend class BluetoothNoDestructor<BluetoothHost>;
922 #endif
923 };
924 } // namespace Bluetooth
925 } // namespace OHOS
926 
927 #endif  // BLUETOOTH_HOST_H
928