• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_PROXY_H
17 #define OHOS_BLUETOOTH_STANDARD_HOST_PROXY_H
18 
19 #include "../../../../services/bluetooth_standard/ipc/parcel/bluetooth_raw_address.h"
20 #include "i_bluetooth_host.h"
21 #include "iremote_proxy.h"
22 
23 namespace OHOS {
24 namespace Bluetooth {
25 class BluetoothHostProxy : public IRemoteProxy<IBluetoothHost> {
26 public:
BluetoothHostProxy(const sptr<IRemoteObject> & impl)27     explicit BluetoothHostProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IBluetoothHost>(impl)
28     {}
~BluetoothHostProxy()29     ~BluetoothHostProxy()
30     {}
31 
32     void RegisterObserver(const sptr<IBluetoothHostObserver> &observer) override;
33     void DeregisterObserver(const sptr<IBluetoothHostObserver> &observer) override;
34     bool EnableBt() override;
35     bool DisableBt() override;
36     sptr<IRemoteObject> GetProfile(const std::string &name) override;
37     sptr<IRemoteObject> GetBleRemote(const std::string &name) override;
38     bool BluetoothFactoryReset() override;
39     int32_t GetBtState() override;
40     std::string GetLocalAddress() override;
41     bool DisableBle() override;
42     bool EnableBle() override;
43     bool IsBleEnabled() override;
44     std::vector<uint32_t> GetProfileList() override;
45     int32_t GetMaxNumConnectedAudioDevices() override;
46     int32_t GetBtConnectionState() override;
47     int32_t GetBtProfileConnState(uint32_t profileId) override;
48     int32_t GetLocalDeviceClass() override;
49     bool SetLocalDeviceClass(const int32_t &deviceClass) override;
50     std::string GetLocalName() override;
51     bool SetLocalName(const std::string &name) override;
52     int32_t GetBtScanMode() override;
53     bool SetBtScanMode(int32_t mode, int32_t duration) override;
54     int32_t GetBondableMode(const int32_t transport) override;
55     bool SetBondableMode(int32_t transport, int32_t mode) override;
56     bool StartBtDiscovery() override;
57     bool CancelBtDiscovery() override;
58     bool IsBtDiscovering(const int32_t transport) override;
59     long GetBtDiscoveryEndMillis() override;
60     std::vector<sptr<BluetoothRawAddress>> GetPairedDevices(const int32_t transport) override;
61     bool RemovePair(const int32_t transport, const sptr<BluetoothRawAddress> &device) override;
62     bool RemoveAllPairs() override;
63     void RegisterRemoteDeviceObserver(const sptr<IBluetoothRemoteDeviceObserver> &observer) override;
64     void DeregisterRemoteDeviceObserver(const sptr<IBluetoothRemoteDeviceObserver> &observer) override;
65     int32_t GetBleMaxAdvertisingDataLength() override;
66     int32_t GetDeviceType(int32_t transport, const std::string &address) override;
67     int32_t GetPhonebookPermission(const std::string &address) override;
68     bool SetPhonebookPermission(const std::string &address, int32_t permission) override;
69     int32_t GetMessagePermission(const std::string &address) override;
70     bool SetMessagePermission(const std::string &address, int32_t permission) override;
71     int32_t GetPowerMode(const std::string &address) override;
72     std::string GetDeviceName(int32_t transport, const std::string &address) override;
73     std::string GetDeviceAlias(const std::string &address) override;
74     bool SetDeviceAlias(const std::string &address, const std::string &aliasName) override;
75     int32_t GetDeviceBatteryLevel(const std::string &address) override;
76     int32_t GetPairState(int32_t transport, const std::string &address) override;
77     bool StartPair(int32_t transport, const std::string &address) override;
78     bool CancelPairing(int32_t transport, const std::string &address) override;
79     bool IsBondedFromLocal(int32_t transport, const std::string &address) override;
80     bool IsAclConnected(int32_t transport, const std::string &address) override;
81     bool IsAclEncrypted(int32_t transport, const std::string &address) override;
82     int32_t GetDeviceClass(const std::string &address) override;
83     bool SetDevicePin(const std::string &address, const std::string &pin) override;
84     bool SetDevicePairingConfirmation(int32_t transport, const std::string &address, bool accept) override;
85     bool SetDevicePasskey(int32_t transport, const std::string &address, int32_t passkey, bool accept) override;
86     bool PairRequestReply(int32_t transport, const std::string &address, bool accept) override;
87     bool ReadRemoteRssiValue(const std::string &address) override;
88     void GetLocalSupportedUuids(std::vector<std::string> &uuids) override;
89     std::vector<bluetooth::Uuid> GetDeviceUuids(int32_t transport, const std::string &address) override;
90     void RegisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) override;
91     void DeregisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) override;
92     void RegisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) override;
93     void DeregisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) override;
94 
95 private:
96     ErrCode InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply);
97     static inline BrokerDelegator<BluetoothHostProxy> delegator_;
98 };
99 }  // namespace Bluetooth
100 }  // namespace OHOS
101 #endif  // OHOS_BLUETOOTH_STANDARD_HOST_PROXY_H
102