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

Commit a9c0e585 authored by louis_chang's avatar louis_chang Committed by Steve Kondik
Browse files

Avoid deadlock during device boot up

PowerManager invokes registerReceiver while holding mLock
when system ready. There have chances that the system_server
main thread will be blocked to wait for ActivityManagerService
object while the other thread was performing configuration
updates.

Solution:
Avoid holding locks while invokes registerReceiver()

Similar issue:
https://code.google.com/p/android/issues/detail?id=186872

Change-Id: I6f3db0758959bef5d8872c74e28e0491ee786ee6
parent 9714e26d
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -611,6 +611,7 @@ public final class PowerManagerService extends SystemService
            // Initialize proximity sensor
            mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
            mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
        }

        // Register for broadcasts from other components of the system.
        IntentFilter filter = new IntentFilter();
@@ -631,6 +632,7 @@ public final class PowerManagerService extends SystemService
        filter.addAction(Intent.ACTION_DOCK_EVENT);
        mContext.registerReceiver(new DockReceiver(), filter, null, mHandler);

        synchronized (mLock) {
            // Register for settings changes.
            final ContentResolver resolver = mContext.getContentResolver();
            resolver.registerContentObserver(Settings.Secure.getUriFor(