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

Commit 3f7016ae authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Protect concurrent access to local state used during BLE scanning

Make sure that all access happens on jni thread

Bug: 38298938
Test: Code compilation
Change-Id: I38246626d2c6390586b314b27889dd9ba905f406
(cherry picked from commit e1462884)
parent 37e480c3
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ struct equal_to<bt_bdaddr_t> {

namespace {

// all access to this variable should be done on the jni thread
std::unordered_set<bt_bdaddr_t> p_dev_cb;

void btif_gattc_add_remote_bdaddr(BD_ADDR p_bda, uint8_t addr_type) {
@@ -258,8 +259,11 @@ class BleScannerInterfaceImpl : public BleScannerInterface {
  }

  void Scan(bool start) override {
    do_in_jni_thread(Bind(
        [](bool start) {
          if (!start) {
      do_in_bta_thread(FROM_HERE, Bind(&BTA_DmBleObserve, false, 0, nullptr));
            do_in_bta_thread(FROM_HERE,
                             Bind(&BTA_DmBleObserve, false, 0, nullptr));
            return;
          }

@@ -267,6 +271,8 @@ class BleScannerInterfaceImpl : public BleScannerInterface {
          do_in_bta_thread(FROM_HERE,
                           Bind(&BTA_DmBleObserve, true, 0,
                                (tBTA_DM_SEARCH_CBACK*)bta_scan_results_cb));
        },
        start));
  }

  void ScanFilterParamSetup(