• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 #ifndef OHOS_BLUETOOTH_STANDARD_BLE_CENTRAL_MANAGER_SERVER_H
16 #define OHOS_BLUETOOTH_STANDARD_BLE_CENTRAL_MANAGER_SERVER_H
17 
18 #include <cstdint>
19 #include <mutex>
20 #include <set>
21 
22 #include "bluetooth_ble_central_manager_stub.h"
23 #include "bluetooth_types.h"
24 #include "i_bluetooth_ble_central_manager.h"
25 #include "if_system_ability_manager.h"
26 #include "iservice_registry.h"
27 #include "system_ability.h"
28 
29 namespace OHOS {
30 namespace Bluetooth {
31 class BluetoothBleCentralManagerServer : public BluetoothBleCentralManagerStub {
32 public:
33     BluetoothBleCentralManagerServer();
34     ~BluetoothBleCentralManagerServer() override;
35 
36     virtual void RegisterBleCentralManagerCallback(const sptr<IBluetoothBleCentralManagerCallback> &callback) override;
37     virtual void DeregisterBleCentralManagerCallback(
38         const sptr<IBluetoothBleCentralManagerCallback> &callback) override;
39     virtual int StartScan() override;
40     virtual int StartScan(const BluetoothBleScanSettings &settings) override;
41     virtual int StopScan() override;
42     virtual int ConfigScanFilter(const int clientId, const std::vector<BluetoothBleScanFilter> &filters) override;
43     virtual void RemoveScanFilter(const int clientId) override;
44     virtual bool ProxyUid(int32_t uid, bool isProxy) override;
45     virtual bool ResetAllProxy() override;
46     static bool IsProxyUid(int32_t uid);
47 
48 private:
49     BLUETOOTH_DECLARE_IMPL();
50     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(BluetoothBleCentralManagerServer);
51     static std::mutex proxyMutex_;
52     static std::set<int32_t> proxyUids_;
53     void SetScanParams(const BluetoothBleScanSettings &settings);
54     void SetWindowAndInterval(const int mode, uint16_t &window, uint16_t &interval);
55     bool IsNewScanParams();
56     bool IsAllStop();
57 };
58 }  // namespace Bluetooth
59 }  // namespace OHOS
60 #endif  // OHOS_BLUETOOTH_STANDARD_BLE_CENTRAL_MANAGER_SERVER_H