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/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 int32_t 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(int &state) override; 40 std::string GetLocalAddress() 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 bool IsBtDiscovering(const int32_t transport) override; 60 long GetBtDiscoveryEndMillis() override; 61 int32_t GetPairedDevices(const int32_t transport, 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) override; 78 int32_t StartPair(int32_t transport, const std::string &address) override; 79 bool CancelPairing(int32_t transport, const std::string &address) override; 80 bool IsBondedFromLocal(int32_t transport, const std::string &address) override; 81 bool IsAclConnected(int32_t transport, const std::string &address) override; 82 bool IsAclEncrypted(int32_t transport, const std::string &address) override; 83 int32_t GetDeviceClass(const std::string &address, int &cod) override; 84 bool SetDevicePin(const std::string &address, const std::string &pin) override; 85 int32_t SetDevicePairingConfirmation(int32_t transport, const std::string &address, bool accept) override; 86 bool SetDevicePasskey(int32_t transport, const std::string &address, int32_t passkey, bool accept) override; 87 bool PairRequestReply(int32_t transport, const std::string &address, bool accept) override; 88 bool ReadRemoteRssiValue(const std::string &address) override; 89 void GetLocalSupportedUuids(std::vector<std::string> &uuids) override; 90 std::vector<bluetooth::Uuid> GetDeviceUuids(int32_t transport, const std::string &address) override; 91 void RegisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) override; 92 void DeregisterBleAdapterObserver(const sptr<IBluetoothHostObserver> &observer) override; 93 void RegisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) override; 94 void DeregisterBlePeripheralCallback(const sptr<IBluetoothBlePeripheralObserver> &observer) override; 95 96 private: 97 int32_t InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply); 98 static inline BrokerDelegator<BluetoothHostProxy> delegator_; 99 }; 100 } // namespace Bluetooth 101 } // namespace OHOS 102 #endif // OHOS_BLUETOOTH_STANDARD_HOST_PROXY_H 103