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 "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 int32_t EnableBt() override; 35 int32_t DisableBt() override; 36 sptr<IRemoteObject> GetProfile(const std::string &name) override; 37 sptr<IRemoteObject> GetBleRemote(const std::string &name) override; 38 int32_t BluetoothFactoryReset() override; 39 int32_t GetBtState(int &state) override; 40 int32_t GetLocalAddress(std::string &addr) override; 41 int32_t DisableBle() override; 42 int32_t EnableBle() override; 43 bool IsBrEnabled() override; 44 bool IsBleEnabled() override; 45 std::vector<uint32_t> GetProfileList() override; 46 int32_t GetMaxNumConnectedAudioDevices() override; 47 int32_t GetBtConnectionState(int &state) override; 48 int32_t GetBtProfileConnState(uint32_t profileId, int &state) override; 49 int32_t GetLocalDeviceClass() override; 50 bool SetLocalDeviceClass(const int32_t &deviceClass) override; 51 int32_t GetLocalName(std::string &name) override; 52 int32_t SetLocalName(const std::string &name) override; 53 int32_t GetBtScanMode(int32_t &scanMode) override; 54 int32_t SetBtScanMode(int32_t mode, int32_t duration) override; 55 int32_t GetBondableMode(const int32_t transport) override; 56 bool SetBondableMode(int32_t transport, int32_t mode) override; 57 int32_t StartBtDiscovery() override; 58 int32_t CancelBtDiscovery() override; 59 int32_t IsBtDiscovering(bool &isDisCovering, const int32_t transport) override; 60 long GetBtDiscoveryEndMillis() override; 61 int32_t GetPairedDevices(std::vector<BluetoothRawAddress> &pairedAddr) override; 62 int32_t RemovePair(const int32_t transport, const sptr<BluetoothRawAddress> &device) override; 63 bool RemoveAllPairs() override; 64 void RegisterRemoteDeviceObserver(const sptr<IBluetoothRemoteDeviceObserver> &observer) override; 65 void DeregisterRemoteDeviceObserver(const sptr<IBluetoothRemoteDeviceObserver> &observer) override; 66 int32_t GetBleMaxAdvertisingDataLength() override; 67 int32_t GetDeviceType(int32_t transport, const std::string &address) override; 68 int32_t GetPhonebookPermission(const std::string &address) override; 69 bool SetPhonebookPermission(const std::string &address, int32_t permission) override; 70 int32_t GetMessagePermission(const std::string &address) override; 71 bool SetMessagePermission(const std::string &address, int32_t permission) override; 72 int32_t GetPowerMode(const std::string &address) override; 73 int32_t GetDeviceName(int32_t transport, const std::string &address, std::string &name) override; 74 std::string GetDeviceAlias(const std::string &address) override; 75 bool SetDeviceAlias(const std::string &address, const std::string &aliasName) override; 76 int32_t GetDeviceBatteryLevel(const std::string &address) override; 77 int32_t GetPairState(int32_t transport, const std::string &address, int32_t &pairState) override; 78 int32_t StartPair(int32_t transport, const std::string &address) override; 79 int32_t StartCrediblePair(int32_t transport, const std::string &address) override; 80 bool CancelPairing(int32_t transport, const std::string &address) override; 81 bool IsBondedFromLocal(int32_t transport, const std::string &address) override; 82 bool IsAclConnected(int32_t transport, const std::string &address) override; 83 bool IsAclEncrypted(int32_t transport, const std::string &address) override; 84 int32_t GetDeviceClass(const std::string &address, int &cod) override; 85 int32_t SetDevicePin(const std::string &address, const std::string &pin) override; 86 int32_t SetDevicePairingConfirmation(int32_t transport, const std::string &address, bool accept) override; 87 bool SetDevicePasskey(int32_t transport, const std::string &address, int32_t passkey, bool accept) override; 88 bool PairRequestReply(int32_t transport, const std::string &address, bool accept) override; 89 bool ReadRemoteRssiValue(const std::string &address) override; 90 void GetLocalSupportedUuids(std::vector<std::string> &uuids) override; 91 int32_t GetDeviceUuids(const std::string &address, std::vector<std::string> &uuids) override; 92 int32_t GetLocalProfileUuids(std::vector<std::string> &uuids) override; 93 void RegisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) override; 94 void DeregisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) override; 95 void RegisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) override; 96 void DeregisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) override; 97 int32_t SetFastScan(bool isEnable) override; 98 int32_t GetRandomAddress(const std::string &realAddr, std::string &randomAddr) override; 99 int32_t SyncRandomAddress(const std::string &realAddr, const std::string &randomAddr) override; 100 int32_t CountEnableTimes(bool enable) override; 101 int32_t ConnectAllowedProfiles(const std::string &remoteAddr) override; 102 int32_t DisconnectAllowedProfiles(const std::string &remoteAddr) override; 103 int32_t GetDeviceProductId(const std::string &address, std::string &prodcutId) override; 104 private: 105 int32_t InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply); 106 static inline BrokerDelegator<BluetoothHostProxy> delegator_; 107 }; 108 } // namespace Bluetooth 109 } // namespace OHOS 110 #endif // OHOS_BLUETOOTH_STANDARD_HOST_PROXY_H 111