• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revision235e738f20c7c3c52828ff7ec1789be7237b6999 (tree)
Zeit2017-05-18 15:26:18
AutorJakub Pawlowski <jpawlowski@goog...>
CommiterJakub Pawlowski

Log Message

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 eb43e9cf12139aeb227e26a8201a80974129c553)

Ändern Zusammenfassung

Diff

--- a/btif/src/btif_ble_scanner.cc
+++ b/btif/src/btif_ble_scanner.cc
@@ -83,6 +83,7 @@ struct equal_to<bt_bdaddr_t> {
8383
8484 namespace {
8585
86+// all access to this variable should be done on the jni thread
8687 std::unordered_set<bt_bdaddr_t> p_dev_cb;
8788
8889 void btif_gattc_add_remote_bdaddr(BD_ADDR p_bda, uint8_t addr_type) {
@@ -258,15 +259,20 @@ class BleScannerInterfaceImpl : public BleScannerInterface {
258259 }
259260
260261 void Scan(bool start) override {
261- if (!start) {
262- do_in_bta_thread(FROM_HERE, Bind(&BTA_DmBleObserve, false, 0, nullptr));
263- return;
264- }
265-
266- btif_gattc_init_dev_cb();
267- do_in_bta_thread(FROM_HERE,
268- Bind(&BTA_DmBleObserve, true, 0,
269- (tBTA_DM_SEARCH_CBACK*)bta_scan_results_cb));
262+ do_in_jni_thread(Bind(
263+ [](bool start) {
264+ if (!start) {
265+ do_in_bta_thread(FROM_HERE,
266+ Bind(&BTA_DmBleObserve, false, 0, nullptr));
267+ return;
268+ }
269+
270+ btif_gattc_init_dev_cb();
271+ do_in_bta_thread(FROM_HERE,
272+ Bind(&BTA_DmBleObserve, true, 0,
273+ (tBTA_DM_SEARCH_CBACK*)bta_scan_results_cb));
274+ },
275+ start));
270276 }
271277
272278 void ScanFilterParamSetup(