Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0693775 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Gerrit Code Review
Browse files

Merge "le_scanning_manager: Fix for scanning operations"

parents efcc37ed d498d3d9
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -162,14 +162,15 @@ void BleScannerInterfaceImpl::Unregister(int scanner_id) {
void BleScannerInterfaceImpl::Scan(bool start) {
  LOG(INFO) << __func__ << " in shim layer " <<  ((start) ? "started" : "stopped");
  bluetooth::shim::GetScanning()->Scan(start);
  if (start) {
  if (start && !btm_cb.ble_ctr_cb.is_ble_observe_active()) {
    btm_cb.neighbor.le_scan = {
        .start_time_ms = timestamper_in_milliseconds.GetTimestamp(),
        .results = 0,
    };
    BTM_LogHistory(kBtmLogTag, RawAddress::kEmpty, "Le scan started");
    btm_cb.ble_ctr_cb.set_ble_observe_active();
  } else {  // stopped
  } else if (!start && btm_cb.ble_ctr_cb.is_ble_observe_active()) {
    // stopped
    const unsigned long long duration_timestamp =
        timestamper_in_milliseconds.GetTimestamp() -
        btm_cb.neighbor.le_scan.start_time_ms;
@@ -179,6 +180,10 @@ void BleScannerInterfaceImpl::Scan(bool start) {
                                      btm_cb.neighbor.le_scan.results));
    btm_cb.ble_ctr_cb.reset_ble_observe();
    btm_cb.neighbor.le_scan = {};
  } else {
    LOG_WARN("Invalid state: start:%d, current scan state: %d", start,
             btm_cb.ble_ctr_cb.is_ble_observe_active());
    return;
  }

  do_in_jni_thread(FROM_HERE,