已合并
适配startScan新接口 #157
lizhihui创建于 2024年3月1日
适配startScan新接口 #157
已合并
从refs/pull/157/head合入到master
共 13 个文件变更+30-151
| @@ -27,7 +27,7 @@ public: | |||
| 27 | ~BluetoothBleCentralManagerCallBackProxy() override; | 27 | ~BluetoothBleCentralManagerCallBackProxy() override; |
| 28 | DISALLOW_COPY_AND_MOVE(BluetoothBleCentralManagerCallBackProxy); | 28 | DISALLOW_COPY_AND_MOVE(BluetoothBleCentralManagerCallBackProxy); |
| 29 | 29 | ||
| 30 | - void OnScanCallback(const BluetoothBleScanResult &result) override; | 30 | + void OnScanCallback(const BluetoothBleScanResult &result, uint8_t callbackType) override; |
| 31 | void OnBleBatchScanResultsEvent(std::vector<BluetoothBleScanResult> &results) override; | 31 | void OnBleBatchScanResultsEvent(std::vector<BluetoothBleScanResult> &results) override; |
| 32 | void OnStartOrStopScanEvent(int resultCode, bool isStartScan) override; | 32 | void OnStartOrStopScanEvent(int resultCode, bool isStartScan) override; |
| 33 | void OnNotifyMsgReportFromLpDevice(const bluetooth::Uuid &uuid, int msgType, | 33 | void OnNotifyMsgReportFromLpDevice(const bluetooth::Uuid &uuid, int msgType, |
| @@ -40,9 +40,7 @@ private: | |||
| 40 | ErrCode RegisterBleCentralManagerCallbackInner(MessageParcel &data, MessageParcel &reply); | 40 | ErrCode RegisterBleCentralManagerCallbackInner(MessageParcel &data, MessageParcel &reply); |
| 41 | ErrCode DeregisterBleCentralManagerCallbackInner(MessageParcel &data, MessageParcel &reply); | 41 | ErrCode DeregisterBleCentralManagerCallbackInner(MessageParcel &data, MessageParcel &reply); |
| 42 | ErrCode StartScanInner(MessageParcel &data, MessageParcel &reply); | 42 | ErrCode StartScanInner(MessageParcel &data, MessageParcel &reply); |
| 43 | - ErrCode StartScanWithSettingsInner(MessageParcel &data, MessageParcel &reply); | ||
| 44 | ErrCode StopScanInner(MessageParcel &data, MessageParcel &reply); | 43 | ErrCode StopScanInner(MessageParcel &data, MessageParcel &reply); |
| 45 | - ErrCode ConfigScanFilterInner(MessageParcel &data, MessageParcel &reply); | ||
| 46 | ErrCode RemoveScanFilterInner(MessageParcel &data, MessageParcel &reply); | 44 | ErrCode RemoveScanFilterInner(MessageParcel &data, MessageParcel &reply); |
| 47 | ErrCode FreezeByRssInner(MessageParcel &data, MessageParcel &reply); | 45 | ErrCode FreezeByRssInner(MessageParcel &data, MessageParcel &reply); |
| 48 | ErrCode ResetAllProxyInner(MessageParcel &data, MessageParcel &reply); | 46 | ErrCode ResetAllProxyInner(MessageParcel &data, MessageParcel &reply); |
| @@ -26,7 +26,8 @@ BluetoothBleCentralManagerCallBackProxy::BluetoothBleCentralManagerCallBackProxy | |||
| 26 | BluetoothBleCentralManagerCallBackProxy::~BluetoothBleCentralManagerCallBackProxy() | 26 | BluetoothBleCentralManagerCallBackProxy::~BluetoothBleCentralManagerCallBackProxy() |
| 27 | {} | 27 | {} |
| 28 | 28 | ||
| 29 | -void BluetoothBleCentralManagerCallBackProxy::OnScanCallback(const BluetoothBleScanResult &result) | 29 | +void BluetoothBleCentralManagerCallBackProxy::OnScanCallback(const BluetoothBleScanResult &result, |
| 30 | + uint8_t callbackType) | ||
| 30 | { | 31 | { |
| 31 | MessageParcel data; | 32 | MessageParcel data; |
| 32 | if (!data.WriteInterfaceToken(BluetoothBleCentralManagerCallBackProxy::GetDescriptor())) { | 33 | if (!data.WriteInterfaceToken(BluetoothBleCentralManagerCallBackProxy::GetDescriptor())) { |
| @@ -39,6 +40,8 @@ void BluetoothBleCentralManagerCallBackProxy::OnScanCallback(const BluetoothBleS | |||
| 39 | return; | 40 | return; |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 43 | + CHECK_AND_RETURN_LOG(data.WriteUint8(callbackType), "write callbackType failed"); | ||
| 44 | + | ||
| 42 | MessageParcel reply; | 45 | MessageParcel reply; |
| 43 | MessageOption option = {MessageOption::TF_ASYNC}; | 46 | MessageOption option = {MessageOption::TF_ASYNC}; |
| 44 | int error = InnerTransact( | 47 | int error = InnerTransact( |
| @@ -36,12 +36,6 @@ const std::map<uint32_t, std::function<ErrCode(BluetoothBleCentralManagerStub *, | |||
| 36 | {BluetoothBleCentralManagerInterfaceCode::BLE_START_SCAN, | 36 | {BluetoothBleCentralManagerInterfaceCode::BLE_START_SCAN, |
| 37 | std::bind(&BluetoothBleCentralManagerStub::StartScanInner, std::placeholders::_1, std::placeholders::_2, | 37 | std::bind(&BluetoothBleCentralManagerStub::StartScanInner, std::placeholders::_1, std::placeholders::_2, |
| 38 | std::placeholders::_3)}, | 38 | std::placeholders::_3)}, |
| 39 | - {BluetoothBleCentralManagerInterfaceCode::BLE_START_SCAN_WITH_SETTINGS, | ||
| 40 | - std::bind(&BluetoothBleCentralManagerStub::StartScanWithSettingsInner, std::placeholders::_1, | ||
| 41 | - std::placeholders::_2, std::placeholders::_3)}, | ||
| 42 | - {BluetoothBleCentralManagerInterfaceCode::BLE_CONFIG_SCAN_FILTER, | ||
| 43 | - std::bind(&BluetoothBleCentralManagerStub::ConfigScanFilterInner, std::placeholders::_1, | ||
| 44 | - std::placeholders::_2, std::placeholders::_3)}, | ||
| 45 | {BluetoothBleCentralManagerInterfaceCode::BLE_REMOVE_SCAN_FILTER, | 39 | {BluetoothBleCentralManagerInterfaceCode::BLE_REMOVE_SCAN_FILTER, |
| 46 | std::bind(&BluetoothBleCentralManagerStub::RemoveScanFilterInner, std::placeholders::_1, | 40 | std::bind(&BluetoothBleCentralManagerStub::RemoveScanFilterInner, std::placeholders::_1, |
| 47 | std::placeholders::_2, std::placeholders::_3)}, | 41 | std::placeholders::_2, std::placeholders::_3)}, |
| @@ -143,47 +137,15 @@ ErrCode BluetoothBleCentralManagerStub::DeregisterBleCentralManagerCallbackInner | |||
| 143 | } | 137 | } |
| 144 | 138 | ||
| 145 | ErrCode BluetoothBleCentralManagerStub::StartScanInner(MessageParcel &data, MessageParcel &reply) | 139 | ErrCode BluetoothBleCentralManagerStub::StartScanInner(MessageParcel &data, MessageParcel &reply) |
| 146 | -{ | ||
| 147 | - int32_t scannerId = data.ReadInt32(); | ||
| 148 | - int ret = StartScan(scannerId); | ||
| 149 | - if (!reply.WriteInt32(ret)) { | ||
| 150 | - HILOGE("reply writing failed"); | ||
| 151 | - return ERR_INVALID_VALUE; | ||
| 152 | - } | ||
| 153 | - return NO_ERROR; | ||
| 154 | -} | ||
| 155 | - | ||
| 156 | -ErrCode BluetoothBleCentralManagerStub::StartScanWithSettingsInner(MessageParcel &data, MessageParcel &reply) | ||
| 157 | { | 140 | { |
| 158 | int32_t scannerId = data.ReadInt32(); | 141 | int32_t scannerId = data.ReadInt32(); |
| 159 | std::shared_ptr<BluetoothBleScanSettings> settings(data.ReadParcelable<BluetoothBleScanSettings>()); | 142 | std::shared_ptr<BluetoothBleScanSettings> settings(data.ReadParcelable<BluetoothBleScanSettings>()); |
| 160 | if (settings == nullptr) { | 143 | if (settings == nullptr) { |
| 161 | - HILOGW("[StartScanWithSettingsInner] fail: read settings failed"); | 144 | + HILOGW("[StartScanInner] fail: read settings failed"); |
| 162 | return TRANSACTION_ERR; | 145 | return TRANSACTION_ERR; |
| 163 | } | 146 | } |
| 164 | 147 | ||
| 165 | - int ret = StartScan(scannerId, *settings); | ||
| 166 | - if (!reply.WriteInt32(ret)) { | ||
| 167 | - HILOGE("reply writing failed"); | ||
| 168 | - return ERR_INVALID_VALUE; | ||
| 169 | - } | ||
| 170 | - return NO_ERROR; | ||
| 171 | -} | ||
| 172 | - | ||
| 173 | -ErrCode BluetoothBleCentralManagerStub::StopScanInner(MessageParcel &data, MessageParcel &reply) | ||
| 174 | -{ | ||
| 175 | - int32_t scannerId = data.ReadInt32(); | ||
| 176 | - int ret = StopScan(scannerId); | ||
| 177 | - if (!reply.WriteInt32(ret)) { | ||
| 178 | - HILOGE("reply writing failed"); | ||
| 179 | - return ERR_INVALID_VALUE; | ||
| 180 | - } | ||
| 181 | - return NO_ERROR; | ||
| 182 | -} | ||
| 183 | -ErrCode BluetoothBleCentralManagerStub::ConfigScanFilterInner(MessageParcel &data, MessageParcel &reply) | ||
| 184 | -{ | ||
| 185 | std::vector<BluetoothBleScanFilter> filters {}; | 148 | std::vector<BluetoothBleScanFilter> filters {}; |
| 186 | - int32_t scannerId = data.ReadInt32(); | ||
| 187 | int32_t itemsSize = 0; | 149 | int32_t itemsSize = 0; |
| 188 | if (!data.ReadInt32(itemsSize) || itemsSize > BLE_CENTRAL_MANAGER_STUB_READ_DATA_SIZE_MAX_LEN) { | 150 | if (!data.ReadInt32(itemsSize) || itemsSize > BLE_CENTRAL_MANAGER_STUB_READ_DATA_SIZE_MAX_LEN) { |
| 189 | HILOGE("read Parcelable size failed."); | 151 | HILOGE("read Parcelable size failed."); |
| @@ -199,11 +161,20 @@ ErrCode BluetoothBleCentralManagerStub::ConfigScanFilterInner(MessageParcel &dat | |||
| 199 | filters.push_back(item); | 161 | filters.push_back(item); |
| 200 | } | 162 | } |
| 201 | 163 | ||
| 202 | - int result = ConfigScanFilter(scannerId, filters); | 164 | + int ret = StartScan(scannerId, *settings, filters); |
| 203 | - bool resultRet = reply.WriteInt32(result); | 165 | + if (!reply.WriteInt32(ret)) { |
| 204 | - bool idRet = reply.WriteInt32(scannerId); | 166 | + HILOGE("reply writing failed"); |
| 205 | - if (!(resultRet && idRet)) { | 167 | + return ERR_INVALID_VALUE; |
| 206 | - HILOGE("BluetoothBleCentralManagerStub: reply writing failed in: %{public}s.", __func__); | 168 | + } |
| 169 | + return NO_ERROR; | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +ErrCode BluetoothBleCentralManagerStub::StopScanInner(MessageParcel &data, MessageParcel &reply) | ||
| 173 | +{ | ||
| 174 | + int32_t scannerId = data.ReadInt32(); | ||
| 175 | + int ret = StopScan(scannerId); | ||
| 176 | + if (!reply.WriteInt32(ret)) { | ||
| 177 | + HILOGE("reply writing failed"); | ||
| 207 | return ERR_INVALID_VALUE; | 178 | return ERR_INVALID_VALUE; |
| 208 | } | 179 | } |
| 209 | return NO_ERROR; | 180 | return NO_ERROR; |
| @@ -37,10 +37,9 @@ public: | |||
| 37 | const sptr<IBluetoothBleCentralManagerCallback> &callback) override; | 37 | const sptr<IBluetoothBleCentralManagerCallback> &callback) override; |
| 38 | void DeregisterBleCentralManagerCallback(int32_t scannerId, | 38 | void DeregisterBleCentralManagerCallback(int32_t scannerId, |
| 39 | const sptr<IBluetoothBleCentralManagerCallback> &callback) override; | 39 | const sptr<IBluetoothBleCentralManagerCallback> &callback) override; |
| 40 | - int StartScan(int32_t scannerId) override; | 40 | + int StartScan(int32_t scannerId, const BluetoothBleScanSettings &settings, |
| 41 | - int StartScan(int32_t scannerId, const BluetoothBleScanSettings &settings) override; | 41 | + const std::vector<BluetoothBleScanFilter> &filters) override; |
| 42 | int StopScan(int32_t scannerId) override; | 42 | int StopScan(int32_t scannerId) override; |
| 43 | - int ConfigScanFilter(int32_t scannerId, const std::vector<BluetoothBleScanFilter> &filters) override; | ||
| 44 | void RemoveScanFilter(int32_t scannerId) override; | 43 | void RemoveScanFilter(int32_t scannerId) override; |
| 45 | bool FreezeByRss(int32_t uid, bool isProxy) override; | 44 | bool FreezeByRss(int32_t uid, bool isProxy) override; |
| 46 | bool ResetAllProxy() override; | 45 | bool ResetAllProxy() override; |
| @@ -64,6 +63,7 @@ private: | |||
| 64 | void SetWindowAndInterval(const int mode, uint16_t &window, uint16_t &interval); | 63 | void SetWindowAndInterval(const int mode, uint16_t &window, uint16_t &interval); |
| 65 | bool IsNewScanParams(); | 64 | bool IsNewScanParams(); |
| 66 | bool IsAllStop(); | 65 | bool IsAllStop(); |
| 66 | + int ConfigScanFilterInner(int32_t scannerId, const std::vector<BluetoothBleScanFilter> &filters); | ||
| 67 | }; | 67 | }; |
| 68 | } // namespace Bluetooth | 68 | } // namespace Bluetooth |
| 69 | } // namespace OHOS | 69 | } // namespace OHOS |
| @@ -343,11 +343,11 @@ bool BluetoothBleCentralManagerServer::IsProxyUid(int32_t uid) | |||
| 343 | return proxyUids_.find(uid) != proxyUids_.end(); | 343 | return proxyUids_.find(uid) != proxyUids_.end(); |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | -int BluetoothBleCentralManagerServer::StartScan(int32_t scannerId) | 346 | +int BluetoothBleCentralManagerServer::StartScan(int32_t scannerId, const BluetoothBleScanSettings &settings, |
| 347 | + const std::vector<BluetoothBleScanFilter> &filters) | ||
| 347 | { | 348 | { |
| 348 | int32_t pid = IPCSkeleton::GetCallingPid(); | 349 | int32_t pid = IPCSkeleton::GetCallingPid(); |
| 349 | int32_t uid = IPCSkeleton::GetCallingUid(); | 350 | int32_t uid = IPCSkeleton::GetCallingUid(); |
| 350 | - HILOGI("pid: %{public}d, uid: %{public}d", pid, uid); | ||
| 351 | if (PermissionUtils::VerifyDiscoverBluetoothPermission() == PERMISSION_DENIED || | 351 | if (PermissionUtils::VerifyDiscoverBluetoothPermission() == PERMISSION_DENIED || |
| 352 | PermissionUtils::VerifyManageBluetoothPermission() == PERMISSION_DENIED) { | 352 | PermissionUtils::VerifyManageBluetoothPermission() == PERMISSION_DENIED) { |
| 353 | HILOGE("check permission failed."); | 353 | HILOGE("check permission failed."); |
| @@ -359,54 +359,7 @@ int BluetoothBleCentralManagerServer::StartScan(int32_t scannerId) | |||
| 359 | return BT_ERR_PERMISSION_FAILED; | 359 | return BT_ERR_PERMISSION_FAILED; |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | - pimpl->eventHandler_->PostSyncTask([&]() { | 362 | + ConfigScanFilterInner(scannerId, filters); |
| 363 | - auto bleService = IAdapterManager::GetInstance()->GetBleAdapterInterface(); | ||
| 364 | - if (bleService == nullptr) { | ||
| 365 | - HILOGE("bleService is nullptr."); | ||
| 366 | - return; | ||
| 367 | - } | ||
| 368 | - | ||
| 369 | - for (auto iter = pimpl->scanCallbackInfo_.begin(); iter != pimpl->scanCallbackInfo_.end(); ++iter) { | ||
| 370 | - if (iter->pid == pid && iter->uid == uid) { | ||
| 371 | - iter->isStart = true; | ||
| 372 | - iter->param.reportDelayMillis = 0; | ||
| 373 | - iter->param.scanInterval = BLE_SCAN_MODE_LOW_POWER_INTERVAL_MS; | ||
| 374 | - iter->param.scanWindow = BLE_SCAN_MODE_LOW_POWER_WINDOW_MS; | ||
| 375 | - iter->param.scanMode = SCAN_MODE_LOW_POWER; | ||
| 376 | - iter->param.legacy = true; | ||
| 377 | - iter->param.phy = PHY_LE_ALL_SUPPORTED; | ||
| 378 | - break; | ||
| 379 | - } | ||
| 380 | - } | ||
| 381 | - | ||
| 382 | - if (!pimpl->isScanning) { | ||
| 383 | - HILOGI("start ble scan without params."); | ||
| 384 | - bleService->StartScan(); | ||
| 385 | - pimpl->isScanning = true; | ||
| 386 | - HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::BT_SERVICE, "BLE_SCAN_START", | ||
| 387 | - OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, "PID", pid, "UID", uid, "TYPE", 0); | ||
| 388 | - } else { | ||
| 389 | - HILOGI("scan is already started."); | ||
| 390 | - } | ||
| 391 | - }); | ||
| 392 | - return NO_ERROR; | ||
| 393 | -} | ||
| 394 | - | ||
| 395 | -int BluetoothBleCentralManagerServer::StartScan(int32_t scannerId, const BluetoothBleScanSettings &settings) | ||
| 396 | -{ | ||
| 397 | - int32_t pid = IPCSkeleton::GetCallingPid(); | ||
| 398 | - int32_t uid = IPCSkeleton::GetCallingUid(); | ||
| 399 | - HILOGI("pid: %{public}d, uid: %{public}d", pid, uid); | ||
| 400 | - if (PermissionUtils::VerifyDiscoverBluetoothPermission() == PERMISSION_DENIED || | ||
| 401 | - PermissionUtils::VerifyManageBluetoothPermission() == PERMISSION_DENIED) { | ||
| 402 | - HILOGE("check permission failed."); | ||
| 403 | - return BT_ERR_PERMISSION_FAILED; | ||
| 404 | - } | ||
| 405 | - if (PermissionUtils::VerifyApproximatelyPermission() == PERMISSION_DENIED && | ||
| 406 | - PermissionUtils::VerifyLocationPermission() == PERMISSION_DENIED) { | ||
| 407 | - HILOGE("No location permission"); | ||
| 408 | - return BT_ERR_PERMISSION_FAILED; | ||
| 409 | - } | ||
| 410 | 363 | ||
| 411 | pimpl->eventHandler_->PostSyncTask([&]() { | 364 | pimpl->eventHandler_->PostSyncTask([&]() { |
| 412 | auto bleService = IAdapterManager::GetInstance()->GetBleAdapterInterface(); | 365 | auto bleService = IAdapterManager::GetInstance()->GetBleAdapterInterface(); |
| @@ -487,7 +440,7 @@ int BluetoothBleCentralManagerServer::StopScan(int32_t scannerId) | |||
| 487 | return NO_ERROR; | 440 | return NO_ERROR; |
| 488 | } | 441 | } |
| 489 | 442 | ||
| 490 | -int BluetoothBleCentralManagerServer::ConfigScanFilter( | 443 | +int BluetoothBleCentralManagerServer::ConfigScanFilterInner( |
| 491 | int32_t scannerId, const std::vector<BluetoothBleScanFilter> &filters) | 444 | int32_t scannerId, const std::vector<BluetoothBleScanFilter> &filters) |
| 492 | { | 445 | { |
| 493 | HILOGI("enter, scannerId: %{public}d", scannerId); | 446 | HILOGI("enter, scannerId: %{public}d", scannerId); |
| @@ -412,13 +412,6 @@ public: | |||
| 412 | */ | 412 | */ |
| 413 | virtual void Close(uint8_t advHandle) const = 0; | 413 | virtual void Close(uint8_t advHandle) const = 0; |
| 414 | 414 | ||
| 415 | - /** | ||
| 416 | - * @brief Start scan | ||
| 417 | - * | ||
| 418 | - * @since 6 | ||
| 419 | - */ | ||
| 420 | - virtual void StartScan() const = 0; | ||
| 421 | - | ||
| 422 | /** | 415 | /** |
| 423 | * @brief Start scan | 416 | * @brief Start scan |
| 424 | * | 417 | * |
| @@ -1522,16 +1522,6 @@ void BleAdapter::Close(uint8_t advHandle) const | |||
| 1522 | } | 1522 | } |
| 1523 | } | 1523 | } |
| 1524 | 1524 | ||
| 1525 | -void BleAdapter::StartScan() const | ||
| 1526 | -{ | ||
| 1527 | - LOG_DEBUG("[BleAdapter] %{public}s", __func__); | ||
| 1528 | - | ||
| 1529 | - std::lock_guard<std::recursive_mutex> lk(pimpl->syncMutex_); | ||
| 1530 | - if (pimpl->bleCentralManager_ != nullptr) { | ||
| 1531 | - pimpl->bleCentralManager_->StartScan(); | ||
| 1532 | - } | ||
| 1533 | -} | ||
| 1534 | - | ||
| 1535 | void BleAdapter::StartScan(const BleScanSettingsImpl &setting) const | 1525 | void BleAdapter::StartScan(const BleScanSettingsImpl &setting) const |
| 1536 | { | 1526 | { |
| 1537 | LOG_DEBUG("[BleAdapter] %{public}s", __func__); | 1527 | LOG_DEBUG("[BleAdapter] %{public}s", __func__); |
| @@ -130,7 +130,6 @@ public: | |||
| 130 | const BleAdvertiserDataImpl &scanResponse, uint8_t advHandle) const override; | 130 | const BleAdvertiserDataImpl &scanResponse, uint8_t advHandle) const override; |
| 131 | void StopAdvertising(uint8_t advHandle) const override; | 131 | void StopAdvertising(uint8_t advHandle) const override; |
| 132 | void Close(uint8_t advHandle) const override; | 132 | void Close(uint8_t advHandle) const override; |
| 133 | - void StartScan() const override; | ||
| 134 | void StartScan(const BleScanSettingsImpl &setting) const override; | 133 | void StartScan(const BleScanSettingsImpl &setting) const override; |
| 135 | void StopScan() const override; | 134 | void StopScan() const override; |
| 136 | int ConfigScanFilter(int32_t scannerId, const std::vector<BleScanFilterImpl> &filters) override; | 135 | int ConfigScanFilter(int32_t scannerId, const std::vector<BleScanFilterImpl> &filters) override; |
| @@ -674,28 +674,6 @@ void BleCentralManagerImpl::ScanExSetEnableResultTask(uint8_t status) const | |||
| 674 | } | 674 | } |
| 675 | } | 675 | } |
| 676 | 676 | ||
| 677 | -void BleCentralManagerImpl::StartScan() const | ||
| 678 | -{ | ||
| 679 | - LOG_DEBUG("[BleCentralManagerImpl] %{public}s:<-- Start scan start", __func__); | ||
| 680 | - | ||
| 681 | - int status = AdapterManager::GetInstance()->GetState(BTTransport::ADAPTER_BLE); | ||
| 682 | - if (status != BTStateID::STATE_TURN_ON) { | ||
| 683 | - LOG_ERROR("[BleCentralManagerImpl] %{public}s:%{public}s", __func__, "Bluetooth adapter is invalid."); | ||
| 684 | - pimpl->scanStatus_ = SCAN_NOT_STARTED; | ||
| 685 | - centralManagerCallbacks_->OnStartOrStopScanEvent(SCAN_NOT_STARTED, true); | ||
| 686 | - return; | ||
| 687 | - } | ||
| 688 | - | ||
| 689 | - uint16_t interval = BLE_SCAN_MODE_LOW_POWER_INTERVAL_MS; | ||
| 690 | - SetInterval(interval); | ||
| 691 | - uint16_t window = BLE_SCAN_MODE_LOW_POWER_WINDOW_MS; | ||
| 692 | - SetWindow(window); | ||
| 693 | - pimpl->callBackType_ = CALLBACK_TYPE_FIRST_MATCH; | ||
| 694 | - Start(false); | ||
| 695 | - | ||
| 696 | - LOG_DEBUG("[BleCentralManagerImpl] %{public}s:<-- Start scan end", __func__); | ||
| 697 | -} | ||
| 698 | - | ||
| 699 | void BleCentralManagerImpl::StartScan(const BleScanSettingsImpl &setting) const | 677 | void BleCentralManagerImpl::StartScan(const BleScanSettingsImpl &setting) const |
| 700 | { | 678 | { |
| 701 | LOG_DEBUG("[BleCentralManagerImpl] %{public}s:<-- Start scan start", __func__); | 679 | LOG_DEBUG("[BleCentralManagerImpl] %{public}s:<-- Start scan start", __func__); |
| @@ -51,13 +51,6 @@ public: | |||
| 51 | */ | 51 | */ |
| 52 | ~BleCentralManagerImpl(); | 52 | ~BleCentralManagerImpl(); |
| 53 | 53 | ||
| 54 | - /** | ||
| 55 | - * @brief Start Bluetooth LE scan with filters. | ||
| 56 | - * | ||
| 57 | - * @param [in] for finding exact BLE devices. | ||
| 58 | - */ | ||
| 59 | - void StartScan() const; | ||
| 60 | - | ||
| 61 | /** | 54 | /** |
| 62 | * @brief Start Bluetooth LE scan with filters,dutyRatio and matching mode. | 55 | * @brief Start Bluetooth LE scan with filters,dutyRatio and matching mode. |
| 63 | * | 56 | * |
| @@ -268,8 +268,7 @@ HWTEST_F(BleTest, BLE_ModuleTest_StartCentralManager_00100, TestSize.Level1) | |||
| 268 | filters.push_back(filter); | 268 | filters.push_back(filter); |
| 269 | BleTest::bleInstance_->InitScanSettings(); | 269 | BleTest::bleInstance_->InitScanSettings(); |
| 270 | BleCentralManager bleCentralManager(bleCentralManagerCallbackTest_); | 270 | BleCentralManager bleCentralManager(bleCentralManagerCallbackTest_); |
| 271 | - bleCentralManager.ConfigScanFilter(filters); | 271 | + bleCentralManager.StartScan(BleTest::bleInstance_->bleScanSettings_, filters); |
| 272 | - bleCentralManager.StartScan(BleTest::bleInstance_->bleScanSettings_); | ||
| 273 | EXPECT_TRUE(host_->IsBtDiscovering(1)); | 272 | EXPECT_TRUE(host_->IsBtDiscovering(1)); |
| 274 | bleCentralManager.StopScan(); | 273 | bleCentralManager.StopScan(); |
| 275 | EXPECT_TRUE(DisableBle()); | 274 | EXPECT_TRUE(DisableBle()); |
| @@ -67,6 +67,8 @@ public: | |||
| 67 | private: | 67 | private: |
| 68 | void OnScanCallback(const Bluetooth::BleScanResult &result) | 68 | void OnScanCallback(const Bluetooth::BleScanResult &result) |
| 69 | {} | 69 | {} |
| 70 | + void OnFoundOrLostCallback(const BleScanResult &result, uint8_t callbackType) | ||
| 71 | + {} | ||
| 70 | void OnBleBatchScanResultsEvent(const std::vector<Bluetooth::BleScanResult> &results) | 72 | void OnBleBatchScanResultsEvent(const std::vector<Bluetooth::BleScanResult> &results) |
| 71 | {} | 73 | {} |
| 72 | void OnStartOrStopScanEvent(int resultCode, bool isStartScan) | 74 | void OnStartOrStopScanEvent(int resultCode, bool isStartScan) |