• 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 #ifndef OHOS_BLUETOOTH_STANDARD_HOST_INTERFACE_H
17 #define OHOS_BLUETOOTH_STANDARD_HOST_INTERFACE_H
18 
19 #include "bluetooth_raw_address.h"
20 #include "bluetooth_service_ipc_interface_code.h"
21 #include "parcel_bt_uuid.h"
22 #include "i_bluetooth_ble_peripheral_observer.h"
23 #include "i_bluetooth_host_observer.h"
24 #include "i_bluetooth_remote_device_observer.h"
25 #include "iremote_broker.h"
26 
27 namespace OHOS {
28 namespace Bluetooth {
29 namespace {
30 const std::string PROFILE_GATT_CLIENT = "GattClientServer";
31 const std::string PROFILE_GATT_SERVER = "GattServerServer";
32 const std::string PROFILE_A2DP_SRC = "A2dpSrcServer";
33 const std::string PROFILE_A2DP_SINK = "A2dpSnkServer";
34 const std::string PROFILE_AVRCP_CT = "AvrcpCtServer";
35 const std::string PROFILE_AVRCP_TG = "AvrcpTgServer";
36 const std::string PROFILE_HFP_AG = "HfpAgServer";
37 const std::string PROFILE_HFP_HF = "HfpHfServer";
38 const std::string PROFILE_MAP_MCE = "MapMceServer";
39 const std::string PROFILE_MAP_MSE = "MapMseServer";
40 const std::string PROFILE_PBAP_PCE = "PbapPceServer";
41 const std::string PROFILE_PBAP_PSE = "PbapPseServer";
42 const std::string PROFILE_SOCKET = "SocketServer";
43 const std::string PROFILE_DI = "DIServer";
44 const std::string BLE_ADVERTISER_SERVER = "BleAdvertiserServer";
45 const std::string BLE_CENTRAL_MANAGER_SERVER = "BleCentralMangerServer";
46 const std::string PROFILE_HID_HOST_SERVER = "BluetoothHidHostServer";
47 const std::string PROFILE_PAN_SERVER = "BluetoothPanServer";
48 const std::string PROFILE_OPP_SERVER = "BluetoothOppServer";
49 const std::string PROFILE_AUDIO_MANAGER = "BluetoothAudioManagerServer";
50 }  // namespace
51 
52 class IBluetoothHost : public OHOS::IRemoteBroker {
53 public:
54     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ipc.IBluetoothHost");
55 
56     virtual void RegisterObserver(const sptr<IBluetoothHostObserver> &observer) = 0;
57     virtual void DeregisterObserver(const sptr<IBluetoothHostObserver> &observer) = 0;
58     virtual int32_t EnableBt() = 0;
59     virtual int32_t DisableBt() = 0;
60     virtual sptr<IRemoteObject> GetProfile(const std::string &name) = 0;
61     virtual sptr<IRemoteObject> GetBleRemote(const std::string &name) = 0;
62     virtual int32_t BluetoothFactoryReset() = 0;
63     virtual int32_t GetBtState(int &state) = 0;
64     virtual int32_t GetLocalAddress(std::string &addr) = 0;
65     virtual int32_t DisableBle() = 0;
66     virtual int32_t EnableBle() = 0;
67     virtual bool IsBrEnabled() = 0;
68     virtual bool IsBleEnabled() = 0;
69     virtual std::vector<uint32_t> GetProfileList() = 0;
70     virtual int32_t GetMaxNumConnectedAudioDevices() = 0;
71     virtual int32_t GetBtConnectionState(int &state) = 0;
72     virtual int32_t GetBtProfileConnState(uint32_t profileId, int &state) = 0;
73     virtual int32_t GetLocalDeviceClass() = 0;
74     virtual bool SetLocalDeviceClass(const int32_t &deviceClass) = 0;
75     virtual int32_t GetLocalName(std::string &name) = 0;
76     virtual int32_t SetLocalName(const std::string &name) = 0;
77     virtual int32_t GetBtScanMode(int32_t &scanMode) = 0;
78     virtual int32_t SetBtScanMode(int32_t mode, int32_t duration) = 0;
79     virtual int32_t GetBondableMode(const int32_t transport) = 0;
80     virtual bool SetBondableMode(int32_t transport, int32_t mode) = 0;
81     virtual int32_t StartBtDiscovery() = 0;
82     virtual int32_t CancelBtDiscovery() = 0;
83     virtual int32_t IsBtDiscovering(bool &isDisCovering, const int32_t transport) = 0;
84     virtual long GetBtDiscoveryEndMillis() = 0;
85     virtual int32_t GetPairedDevices(std::vector<BluetoothRawAddress> &pairedAddr) = 0;
86     virtual int32_t RemovePair(const int32_t transport, const sptr<BluetoothRawAddress> &device) = 0;
87     virtual bool RemoveAllPairs() = 0;
88     virtual void RegisterRemoteDeviceObserver(const sptr<IBluetoothRemoteDeviceObserver> &observer) = 0;
89     virtual void DeregisterRemoteDeviceObserver(const sptr<IBluetoothRemoteDeviceObserver> &observer) = 0;
90     virtual int32_t GetBleMaxAdvertisingDataLength() = 0;
91     virtual int32_t GetDeviceType(int32_t transport, const std::string &address) = 0;
92     virtual int32_t GetPhonebookPermission(const std::string &address) = 0;
93     virtual bool SetPhonebookPermission(const std::string &address, int32_t permission) = 0;
94     virtual int32_t GetMessagePermission(const std::string &address) = 0;
95     virtual bool SetMessagePermission(const std::string &address, int32_t permission) = 0;
96     virtual int32_t GetPowerMode(const std::string &address) = 0;
97     virtual int32_t GetDeviceName(int32_t transport, const std::string &address, std::string &name) = 0;
98     virtual std::string GetDeviceAlias(const std::string &address) = 0;
99     virtual bool SetDeviceAlias(const std::string &address, const std::string &aliasName) = 0;
100     virtual int32_t GetDeviceBatteryLevel(const std::string &address) = 0;
101     virtual int32_t GetPairState(int32_t transport, const std::string &address, int32_t &pairState) = 0;
102     virtual int32_t StartPair(int32_t transport, const std::string &address) = 0;
103     virtual int32_t StartCrediblePair(int32_t transport, const std::string &address) = 0;
104     virtual bool CancelPairing(int32_t transport, const std::string &address) = 0;
105     virtual bool IsBondedFromLocal(int32_t transport, const std::string &address) = 0;
106     virtual bool IsAclConnected(int32_t transport, const std::string &address) = 0;
107     virtual bool IsAclEncrypted(int32_t transport, const std::string &address) = 0;
108     virtual int32_t GetDeviceClass(const std::string &address, int &cod) = 0;
109     virtual int32_t SetDevicePin(const std::string &address, const std::string &pin) = 0;
110     virtual int32_t SetDevicePairingConfirmation(int32_t transport, const std::string &address, bool accept) = 0;
111     virtual bool SetDevicePasskey(int32_t transport, const std::string &address, int32_t passkey, bool accept) = 0;
112     virtual bool PairRequestReply(int32_t transport, const std::string &address, bool accept) = 0;
113     virtual bool ReadRemoteRssiValue(const std::string &address) = 0;
114     virtual void GetLocalSupportedUuids(std::vector<std::string> &uuids) = 0;
115     virtual int32_t GetDeviceUuids(const std::string &address, std::vector<std::string> &uuids) = 0;
116     virtual int32_t GetLocalProfileUuids(std::vector<std::string> &uuids) = 0;
117     virtual void RegisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) = 0;
118     virtual void DeregisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) = 0;
119     virtual void RegisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) = 0;
120     virtual void DeregisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) = 0;
121     virtual int32_t SetFastScan(bool isEnable) = 0;
122     virtual int32_t GetRandomAddress(const std::string &realAddr, std::string &randomAddr) = 0;
123     virtual int32_t SyncRandomAddress(const std::string &realAddr, const std::string &randomAddr) = 0;
124     virtual int32_t CountEnableTimes(bool enable) = 0;
125     virtual int32_t ConnectAllowedProfiles(const std::string &remoteAddr) = 0;
126     virtual int32_t DisconnectAllowedProfiles(const std::string &remoteAddr) = 0;
127     virtual int32_t GetDeviceProductId(const std::string &address, std::string &prodcutId) = 0;
128 };
129 }  // namespace Bluetooth
130 }  // namespace OHOS
131 #endif  // OHOS_BLUETOOTH_STANDARD_HOST_INTERFACE_H
132