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

Commit 7b8002a7 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda Committed by Gerrit Code Review
Browse files

frameworks/base: Fix for UI freeze issue with headset insert/removal

- UI freeze is observed while quick insertion and removal of headset
  for multiple times.
- notifyJackSwitchChanged() acquires mHeadsetLock and waits on
  phoneWindowManager lock to call update() as it is a synchronized
  function. sendIntents() is also "synchronized". This function also
  tries to acquire mHeadsetLock. So there is a dead lock, when the
  notifyJackSwitchChanged() acquires the mHeadsetLock before this
  function does.
- update() is called only from notifyJackSwitched() and need not be a
  synchronized function. Removed synchronization on the update() to
  fix the issue.

CRs-Fixed: 390784
(cherry picked from commit 04e683e79c3633e061c71b2ecff4f4c83624d1e0)

Change-Id: I6d274391b68c0a306128d7009bbb651a9b0554f4
parent 1b025fd8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3659,7 +3659,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        } // synchronized(mHeadsetLock)
    }

    private synchronized final void update() {
    private final void update() {

        // Retain only relevant bits
        int headsetState = mHeadsetJackState & SUPPORTED_HEADSETS;
@@ -3766,6 +3766,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Log.e(TAG, "sendIntent: couldn't get AudioManager reference");
                    return;
                }
                Slog.d(TAG,"sendIntent(): device "+device+" state "+state);
                am.setWiredDeviceConnectionState(device, state, headsetName);
            } else {
                Slog.d(TAG,"system not booted yet, call setWiredDeviceConnectionState later");