From fd68370074fab549f569d8b9a5bf3d7c535c47bc Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Mon, 26 Jun 2017 14:34:38 -0700 Subject: [PATCH 1/2] healthd: notify listeners using local copy of list, drop lock Binder currently may service an incoming oneway transaction whenever an outbound oneway call is made (if there is already a pending incoming oneway call waiting). The unexpected nested method call blocks forever on a recursive mutex acquire because healthd is single- threaded. The binder behavior is considered a bug and may change in the future. For now, work around this in healthd. Make a local copy of the listeners list, then drop the lock and perform the outbound calls on the local copy of the list. Bug: 38201220 Test: Marlin with modified client calling scheduleUpdate() repeatedly Change-Id: If35c2847556245921e2aff808ff747bb60356811 --- healthd/BatteryPropertiesRegistrar.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp index 523e1f136..e51a06d5e 100644 --- a/healthd/BatteryPropertiesRegistrar.cpp +++ b/healthd/BatteryPropertiesRegistrar.cpp @@ -36,9 +36,19 @@ void BatteryPropertiesRegistrar::publish( } void BatteryPropertiesRegistrar::notifyListeners(const struct BatteryProperties& props) { - Mutex::Autolock _l(mRegistrationLock); - for (size_t i = 0; i < mListeners.size(); i++) { - mListeners[i]->batteryPropertiesChanged(props); + Vector > listenersCopy; + + // Binder currently may service an incoming oneway transaction whenever an + // outbound oneway call is made (if there is already a pending incoming + // oneway call waiting). This is considered a bug and may change in the + // future. For now, avoid recursive mutex lock while making outbound + // calls by making a local copy of the current list of listeners. + { + Mutex::Autolock _l(mRegistrationLock); + listenersCopy = mListeners; + } + for (size_t i = 0; i < listenersCopy.size(); i++) { + listenersCopy[i]->batteryPropertiesChanged(props); } } From 2e06a0ff6ed54d12b80f1c14fdfb67b30362f568 Mon Sep 17 00:00:00 2001 From: Christine Hallstrom Date: Thu, 27 Jul 2017 11:14:36 -0700 Subject: [PATCH 2/2] DO NOT MERGE ANYWHERE make /data/misc/bluetooth owner to be bluetooth Bug: 62410937 Change-Id: Ic6ddba03ee6316dc54d5d41b35c90fe3d9057723 --- rootdir/init.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index a22d5c130..60d9104cb 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -371,7 +371,7 @@ on post-fs-data # Fix the access permissions and group ownership for 'bt_config.conf' chmod 0660 /data/misc/bluedroid/bt_config.conf chown bluetooth net_bt_stack /data/misc/bluedroid/bt_config.conf - mkdir /data/misc/bluetooth 0770 system system + mkdir /data/misc/bluetooth 0770 bluetooth bluetooth mkdir /data/misc/keystore 0700 keystore keystore mkdir /data/misc/gatekeeper 0700 system system mkdir /data/misc/keychain 0771 system system