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 #include "bluetooth_proxy_manager.h"
17
18 #include "bluetooth_ble_central_manager.h"
19 #include "bluetooth_def.h"
20 #include "bluetooth_host.h"
21 #include "bluetooth_log.h"
22 #include "bluetooth_profile_manager.h"
23 #include "i_bluetooth_ble_central_manager.h"
24
25 namespace OHOS {
26 namespace Bluetooth {
GetInstance()27 BluetoothProxyManager& BluetoothProxyManager::GetInstance()
28 {
29 #ifdef DTFUZZ_TEST
30 static BluetoothNoDestructor<BluetoothProxyManager> instance;
31 return *instance;
32 #else
33 static BluetoothProxyManager instance;
34 return instance;
35 #endif
36 }
37
FreezeByRss(std::set<int> pidSet, bool isProxy)38 bool BluetoothProxyManager::FreezeByRss(std::set<int> pidSet, bool isProxy)
39 {
40 if (!IS_BLE_ENABLED()) {
41 HILOGD("bluetooth is off.");
42 return false;
43 }
44 sptr<IBluetoothBleCentralManager> proxy =
45 GetRemoteProxy<IBluetoothBleCentralManager>(BLE_CENTRAL_MANAGER_SERVER);
46 CHECK_AND_RETURN_LOG_RET(proxy, false, "failed: no proxy");
47 return proxy->FreezeByRss(pidSet, isProxy);
48 }
49
ResetAllProxy()50 bool BluetoothProxyManager::ResetAllProxy()
51 {
52 HILOGI("ResetAllProxy start.");
53 if (!IS_BLE_ENABLED()) {
54 HILOGD("bluetooth is off.");
55 return false;
56 }
57 sptr<IBluetoothBleCentralManager> proxy =
58 GetRemoteProxy<IBluetoothBleCentralManager>(BLE_CENTRAL_MANAGER_SERVER);
59 CHECK_AND_RETURN_LOG_RET(proxy, false, "failed: no proxy");
60 return proxy->ResetAllProxy();
61 }
62 } // namespace Bluetooth
63 } // namespace OHOS