1 /* 2 * Copyright (C) 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 BLUETOOTH_PROXY_MANAGER_H 17 #define BLUETOOTH_PROXY_MANAGER_H 18 19 #include <mutex> 20 21 #include "iremote_broker.h" 22 #include "refbase.h" 23 24 namespace OHOS { 25 namespace Bluetooth { 26 class IBluetoothBleCentralManager; 27 class BluetoothProxyManager { 28 public: 29 bool FreezeByRss(int32_t uid, bool isProxy); 30 bool ResetAllProxy(); 31 32 static BluetoothProxyManager& GetInstance(); 33 34 private: 35 BluetoothProxyManager() = default; 36 ~BluetoothProxyManager() = default; 37 BluetoothProxyManager(const BluetoothProxyManager& bleProxyManager); 38 const BluetoothProxyManager &operator=(const BluetoothProxyManager& bleProxyManager); 39 40 private: 41 class BleCentralManagerDeathRecipient : public IRemoteObject::DeathRecipient { 42 public: 43 explicit BleCentralManagerDeathRecipient(BluetoothProxyManager &bleProxyManager); 44 ~BleCentralManagerDeathRecipient() override; 45 46 void OnRemoteDied(const wptr<IRemoteObject> &object) override; 47 48 private: 49 BluetoothProxyManager &bleProxyManager_; 50 }; 51 52 private: 53 bool GetBleCentralManagerProxy(); 54 void ResetClient(); 55 sptr<IBluetoothBleCentralManager> proxy_; 56 sptr<BleCentralManagerDeathRecipient> recipient_; 57 std::mutex mutex_; 58 }; 59 } // namespace Bluetooth 60 } // namespace OHOS 61 #endif