• 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      */
338     int EnableBt();
339 
340     /**
341      * @brief Disable classic.
342      *
343      * @return Returns <b>true</b> if the operation is accepted;
344      *         returns <b>false</b> if the operation is rejected.
345      * @since 6
346      */
347     int DisableBt();
348 
349     /**
350      * @brief Get classic enable/disable state.
351      *
352      * @return Returns classic enable/disable state.
353      *         BTStateID::STATE_TURNING_ON;
354      *         BTStateID::STATE_TURN_ON;
355      *         BTStateID::STATE_TURNING_OFF;
356      *         BTStateID::STATE_TURN_OFF.
357      * @since 6
358      * @deprecated since 14
359      * @useinstead BluetoothHost#GetBluetoothState
360      */
361     int GetBtState() const;
362 
363     /**
364      * @brief Get classic enable/disable state.
365      *
366      * @param Returns classic enable/disable state.
367      *         BTStateID::STATE_TURNING_ON;
368      *         BTStateID::STATE_TURN_ON;
369      *         BTStateID::STATE_TURNING_OFF;
370      *         BTStateID::STATE_TURN_OFF.
371      * @since 6
372      * @deprecated since 14
373      * @useinstead BluetoothHost#GetBluetoothState
374      */
375     int GetBtState(int &state) const;
376 
377     /**
378      * @brief Get the current state of the local Bluetooth adapter.
379      *
380      * @return current state of Bluetooth adapter.
381      *         BluetoothState::STATE_TURN_OFF.
382      *         BluetoothState::STATE_TURNING_ON;
383      *         BluetoothState::STATE_TURN_ON;
384      *         BluetoothState::STATE_TURNING_OFF;
385      *         BluetoothState::STATE_BLE_TURNING_ON;
386      *         BluetoothState::STATE_BLE_ON;
387      *         BluetoothState::STATE_BLE_TURNING_OFF;
388      * @since 14
389      */
390     BluetoothState GetBluetoothState(void) const;
391 
392     /**
393      * @brief Disable ble.
394      *
395      * @return Returns <b>true</b> if the operation is accepted;
396      *         returns <b>false</b> if the operation is rejected.
397      * @since 6
398      */
399     int DisableBle();
400 
401     /**
402      * @brief Enable ble.
403      *
404      * @return Returns <b>true</b> if the operation is accepted;
405      *         returns <b>false</b> if the operation is rejected.
406      * @since 6
407      */
408     int EnableBle();
409 
410     /**
411      * @brief Enable bluetooth without AutoConnect.
412      *
413      * @return Returns <b>true</b> if the operation is accepted;
414      *         returns <b>false</b> if the operation is rejected.
415      * @since 16
416      */
417     int EnableBluetoothNoAutoConnect();
418 
419     /**
420      * @brief Enable bluetooth to restrict mode.
421      *
422      * @return Returns BT_NO_ERROR if the operation is accepted;
423      *         returns others if the operation is rejected.
424      * @since 12
425      */
426     int EnableBluetoothToRestrictMode(void);
427 
428     /**
429      * @brief Get br/edr enable/disable state.
430      *
431      * @return Returns <b>true</b> if br is enabled;
432      *         returns <b>false</b> if br is not enabled.
433      * @since 6
434      */
435     bool IsBrEnabled() const;
436 
437     /**
438      * @brief Get ble enable/disable state.
439      *
440      * @return Returns <b>true</b> if ble is enabled;
441      *         returns <b>false</b> if ble is not enabled.
442      * @since 6
443      */
444     bool IsBleEnabled() const;
445 
446     /**
447      * @brief Factory reset bluetooth service.
448      *
449      * @return Returns <b>true</b> if the operation is successful;
450      *         returns <b>false</b> if the operation fails.
451      * @since 6
452      */
453     int BluetoothFactoryReset();
454 
455     /**
456      * @brief Get profile service ID list.
457      *
458      * @return Returns vector of enabled profile services ID.
459      * @since 6
460      */
461     std::vector<uint32_t> GetProfileList() const;
462 
463     /**
464      * @brief Get max audio connected devices number.
465      *
466      * @return Returns max device number that audio can connect.
467      * @since 6
468      */
469     int GetMaxNumConnectedAudioDevices() const;
470 
471     /**
472      * @brief Get bluetooth connects state.
473      *
474      * @return Returns bluetooth connects state.
475      *         BTConnectState::CONNECTING;
476      *         BTConnectState::CONNECTED;
477      *         BTConnectState::DISCONNECTING;
478      *         BTConnectState::DISCONNECTED.
479      * @since 6
480      */
481     int GetBtConnectionState() const;
482 
483     /**
484      * @brief Get bluetooth connects state.
485      *
486      * @return Returns bluetooth connects state.
487      *         BTConnectState::CONNECTING;
488      *         BTConnectState::CONNECTED;
489      *         BTConnectState::DISCONNECTING;
490      *         BTConnectState::DISCONNECTED.
491      * @since 6
492      */
493     int GetBtConnectionState(int &state) const;
494 
495     /**
496      * @brief Get profile service connect state.
497      *
498      * @param profileID Profile service ID.
499      * @return Returns connect state for designated profile service.
500      *         BTConnectState::CONNECTING;
501      *         BTConnectState::CONNECTED;
502      *         BTConnectState::DISCONNECTING;
503      *         BTConnectState::DISCONNECTED.
504      * @since 6
505      */
506     int GetBtProfileConnState(uint32_t profileId, int &state) const;
507 
508     /**
509      * @brief Get local device supported uuids.
510      *
511      * @param[out] Vector which use to return support uuids.
512      * @since 6
513      */
514     void GetLocalSupportedUuids(std::vector<ParcelUuid> &uuids);
515 
516     /**
517      * @brief Start adapter manager, passthrough only.
518      *
519      * @return Returns <b>true</b> if the operation is successful;
520      *         returns <b>false</b> if the operation fails.
521      * @since 6
522      */
523     bool Start();
524 
525     /**
526      * @brief Stop adapter manager, passthrough only.
527      *
528      * @since 6
529      */
530     void Stop();
531 
532     // gap
533     /**
534      * @brief Get local device class.
535      *
536      * @return Returns local device class.
537      * @since 6
538      */
539     BluetoothDeviceClass GetLocalDeviceClass() const;
540 
541     /**
542      * @brief Set local device class.
543      *
544      * @param deviceClass Device class.
545      * @return Returns <b>true</b> if the operation is successful;
546      *         returns <b>false</b> if the operation fails.
547      * @since 6
548      */
549     bool SetLocalDeviceClass(const BluetoothDeviceClass &deviceClass);
550 
551     /**
552      * @brief Get local device address.
553      *
554      * @param addr local address.
555      * @return Returns {@link BT_NO_ERROR} if the operation is successful;
556      *         returns an error code defined in {@link BtErrCode} otherwise.
557      * @since 6
558      */
559     int GetLocalAddress(std::string &addr) const;
560 
561     /**
562      * @brief Get local device name.
563      *
564      * @return Returns local device name.
565      * @since 6
566      */
567     std::string GetLocalName() const;
568 
569     /**
570      * @brief Get local device name.
571      *
572      * @return Returns local device name.
573      * @since 6
574      */
575     int GetLocalName(std::string &name) const;
576 
577     /**
578      * @brief Set local device name.
579      *
580      * @param name Device name.
581      * @return Returns <b>true</b> if the operation is successful;
582      *         returns <b>false</b> if the operation fails.
583      * @since 6
584      */
585     int SetLocalName(const std::string &name);
586 
587     /**
588      * @brief Get device scan mode.
589      *
590      * @return Returns bluetooth scan mode.
591      * @since 6
592      */
593     int GetBtScanMode(int32_t &scanMode) const;
594 
595     /**
596      * @brief Set device scan mode.
597      *
598      * @param mode Scan mode.
599      * @param duration Scan time.
600      * @return Returns <b>true</b> if the operation is successful;
601      *         returns <b>false</b> if the operation fails.
602      * @since 6
603      */
604     int SetBtScanMode(int mode, int duration);
605 
606     /**
607      * @brief Get local device bondable mode.
608      *
609      * @param transport Adapter transport.
610      * @return Returns local device bondable mode.
611      * @since 6
612      */
613     int GetBondableMode(int transport) const;
614 
615     /**
616      * @brief Set local device bondable mode.
617      *
618      * @param transport Adapter transport.
619      * @param mode Device bondable mode.
620      * @return Returns <b>true</b> if the operation is successful;
621      *         returns <b>false</b> if the operation fails.
622      * @since 6
623      */
624     bool SetBondableMode(int transport, int mode);
625 
626     /**
627      * @brief Get device address.
628      * @return Returns <b>true</b> if the operation is successful;
629      *         returns <b>false</b> if the operation fails.
630      * @since 6
631      */
632     int StartBtDiscovery();
633 
634     /**
635      * @brief Cancel device discovery.
636      *
637      * @return Returns <b>true</b> if the operation is successful;
638      *         returns <b>false</b> if the operation fails.
639      * @since 6
640      */
641     int CancelBtDiscovery();
642 
643     /**
644      * @brief Check if device is discovering.
645      *
646      * @return Returns <b>BT_NO_ERROR</b> if the operation is successful;
647      *         returns <b>false</b> if device is not discovering.
648      * @since 6
649      */
650     int IsBtDiscovering(bool &isDisCovering, int transport = BT_TRANSPORT_BREDR) const;
651 
652     /**
653      * @brief Get device discovery end time.
654      *
655      * @return Returns device discovery end time.
656      * @since 6
657      */
658     long GetBtDiscoveryEndMillis() const;
659 
660     /**
661      * @brief Get paired devices.
662      *
663      * @param transport Adapter transport.
664      * @return Returns paired devices vector.
665      * @since 6
666      */
667     int32_t GetPairedDevices(int transport, std::vector<BluetoothRemoteDevice> &pairedDevices) const;
668 
669     /**
670      * @brief Remove pair.
671      *
672      * @param device Remote device address.
673      * @return Returns <b>true</b> if the operation is successful;
674      *         returns <b>false</b> if the operation fails.
675      * @since 6
676      */
677     int32_t RemovePair(const BluetoothRemoteDevice &device);
678 
679     /**
680      * @brief Remove all pairs.
681      *
682      * @return Returns <b>true</b> if the operation is successful;
683      *         returns <b>false</b> if the operation fails.
684      * @since 6
685      */
686     bool RemoveAllPairs();
687 
688     /**
689      * @brief Check if bluetooth address is valid.
690      *
691      * @param addr Bluetooth address.
692      * @return Returns <b>true</b> if bluetooth address is valid;
693      *         returns <b>false</b> if bluetooth address is not valid.
694      * @since 6
695      */
696     static bool IsValidBluetoothAddr(const std::string &addr);
697 
698     /**
699      * @brief Register remote device observer.
700      *
701      * @param observer Class BluetoothRemoteDeviceObserver pointer to register observer.
702      * @return Returns <b>true</b> if the operation is successful;
703      *         returns <b>false</b> if the operation fails.
704      * @since 6
705      */
706     void RegisterRemoteDeviceObserver(std::shared_ptr<BluetoothRemoteDeviceObserver> observer);
707 
708     /**
709      * @brief Deregister remote device observer.
710      *
711      * @param observer Class BluetoothRemoteDeviceObserver pointer to deregister observer.
712      * @return Returns <b>true</b> if the operation is successful;
713      *         returns <b>false</b> if the operation fails.
714      * @since 6
715      */
716     void DeregisterRemoteDeviceObserver(std::shared_ptr<BluetoothRemoteDeviceObserver> observer);
717 
718     /**
719      * @brief Get max advertising data length.
720      *
721      * @return Returns max advertising data length.
722      * @since 6
723      */
724     int GetBleMaxAdvertisingDataLength() const;
725 
726     void LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject);
727 
728     void LoadSystemAbilityFail();
729 
730     void OnRemoveBluetoothSystemAbility();
731 
732     /**
733      * @brief Get local profile uuids.
734      *
735      * @return Returns local profile uuids.
736      * @since 10
737      */
738     int32_t GetLocalProfileUuids(std::vector<std::string> &uuids);
739 
740     /**
741     * @brief Set fast scan enable or disable.
742     * @param isEnable set fast scan status flag.
743     * @return Returns <b>true</b> if the operation is successful;
744     *         returns <b>false</b> if the operation fails.
745     */
746     int SetFastScan(bool isEnable);
747 
748     /**
749     * @brief Get the random address of a device.
750     * If the address carried in the bluetooth interface is not obtained from the bluetooth,
751     * the interface needs to be used for address translation.
752     * @param realAddr real address.
753     * @param[out] randomAddr random address.
754     * @return Returns {@link BT_NO_ERROR} if get random address success;
755     * returns an error code defined in {@link BtErrCode} otherwise.
756     */
757     int GetRandomAddress(const std::string &realAddr, std::string &randomAddr) const;
758 
759     /**
760     * @brief Connects all allowed bluetooth profiles between the local and remote device.
761     *
762     * @param remoteAddr remote device addr.
763     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
764     *         returns an error code defined in {@link BtErrCode} otherwise.
765     * @since 11
766     */
767     int ConnectAllowedProfiles(const std::string &remoteAddr) const;
768 
769     /**
770     * @brief Disconnects all allowed bluetooth profiles between the local and remote device.
771     *
772     * @param remoteAddr remote device addr.
773     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
774     *         returns an error code defined in {@link BtErrCode} otherwise.
775     * @since 11
776     */
777     int DisconnectAllowedProfiles(const std::string &remoteAddr) const;
778 
779     /**
780     * @brief Restrict Bluetooth BR/EDR ability, just BLE ability available.
781     *
782     * @param remoteAddr remote device addr.
783     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
784     *         returns an error code defined in {@link BtErrCode} otherwise.
785     * @since 12
786     */
787     int RestrictBluetooth();
788     /**
789     * @brief update virtual device
790     *
791     * @param action add or delete virtual device.
792     * @param device device need to be operator.
793     * @since 12
794     */
795     void UpdateVirtualDevice(int32_t action, const std::string &address);
796 
797     /**
798     * @brief Restrict Bluetooth BR/EDR ability, just BLE ability available.
799     *
800     * @param type satellite control type.
801     * @param state satellite state.
802     * @return Returns {@link BT_NO_ERROR} if the operation is successful;
803     *         returns an error code defined in {@link BtErrCode} otherwise.
804     * @since 12
805     */
806     int SatelliteControl(int type, int state);
807 
808     /**
809      * @brief Register bluetooth resource manager observer.
810      *
811      * @param observer Class RegisterBtResourceManagerObserver pointer to register observer.
812      * @since 12
813      */
814     void RegisterBtResourceManagerObserver(std::shared_ptr<BluetoothResourceManagerObserver> observer);
815 
816     /**
817      * @brief Deregister bluetooth resource manager observer.
818      *
819      * @param observer Class RegisterBtResourceManagerObserver pointer to deregister observer.
820      * @since 12
821      */
822     void DeregisterBtResourceManagerObserver(std::shared_ptr<BluetoothResourceManagerObserver> observer);
823 
824     /**
825      * @brief Set local adapter scan level.
826      *
827      * @param level Scan level.
828      * @return Returns <b>true</b> if the operation is successful;
829      *         returns <b>false</b> if the operation fails.
830      * @since 12
831      */
832     int SetFastScanLevel(int level);
833 
834     /**
835      * @brief Close the bluetooth host to release resources, only called before the process exits.
836      *
837      * @since 13
838      */
839     void Close(void);
840 
841     int32_t UpdateCloudBluetoothDevice(const std::vector<TrustPairDeviceParam> &cloudDevices);
842 
843     /**
844      * @brief refuse policy
845      *
846      * @since 16
847      */
848     int UpdateRefusePolicy(const int32_t pid, const int64_t prohibitedSecondsTime);
849 
850     /**
851      * @brief get refuse policy prohibitedTime.
852      *
853      * @since 16
854      */
855     int64_t GetRefusePolicyProhibitedTime();
856 
857     int32_t ProcessRandomDeviceIdCommand(int32_t command, std::vector<std::string> &deviceIdVec, bool &isValid);
858 private:
859     /**
860      * @brief A constructor used to create a <b>BluetoothHost</b> instance.
861      *
862      * @since 6
863      */
864     BluetoothHost();
865 
866     /**
867      * @brief A destructor used to delete the <b>BluetoothHost</b> instance.
868      *
869      * @since 6
870      */
871     ~BluetoothHost();
872 
873     /**
874     * @brief Check whether bluetooth is prohibited by EDM.
875     *
876     * @return Returns <b>true</b> if bluetooth is prohibited, returns <b>false</b> otherwise.
877     * @since 11
878     */
879     bool IsBtProhibitedByEdm(void);
880 
881     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(BluetoothHost);
882     BLUETOOTH_DECLARE_IMPL();
883 
884 #ifdef DTFUZZ_TEST
885     friend class BluetoothNoDestructor<BluetoothHost>;
886 #endif
887 };
888 } // namespace Bluetooth
889 } // namespace OHOS
890 
891 #endif  // BLUETOOTH_HOST_H
892