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

Commit ce01e0df authored by Tiger's avatar Tiger
Browse files

Call updateKidsModeSettings without holding mLock

This CL stops holding PhoneWindowManager.mLock before calling the
WindowManagerInternal method to avoid the dead lock while trying to
acquire WindowManagerService.mGlobalLock.

Fix: 346153851
Flag: NA
Test: presubmit
Change-Id: If90f4d7071a6c95479c79e0c89c1ac26c8a9deed
parent 412a1d55
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -2881,6 +2881,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        ContentResolver resolver = mContext.getContentResolver();
        boolean updateRotation = false;
        boolean updateKidsModeSettings = false;
        final boolean kidsModeEnabled;
        synchronized (mLock) {
            mEndcallBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.END_BUTTON_BEHAVIOR,
@@ -2994,20 +2996,23 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Secure.STYLUS_BUTTONS_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
            mInputManagerInternal.setStylusButtonMotionEventsEnabled(mStylusButtonsEnabled);

            final boolean kidsModeEnabled = Settings.Secure.getIntForUser(resolver,
            kidsModeEnabled = Settings.Secure.getIntForUser(resolver,
                    Settings.Secure.NAV_BAR_KIDS_MODE, 0, UserHandle.USER_CURRENT) == 1;
            if (mKidsModeEnabled != kidsModeEnabled) {
                mKidsModeEnabled = kidsModeEnabled;
                updateKidsModeSettings();
                updateKidsModeSettings = true;
            }
        }
        if (updateKidsModeSettings) {
            updateKidsModeSettings(kidsModeEnabled);
        }
        if (updateRotation) {
            updateRotation(true);
        }
    }

    private void updateKidsModeSettings() {
        if (mKidsModeEnabled) {
    private void updateKidsModeSettings(boolean kidsModeEnabled) {
        if (kidsModeEnabled) {
            // Needed since many Kids apps aren't optimised to support both orientations and it
            // will be hard for kids to understand the app compat mode.
            // TODO(229961548): Remove ignoreOrientationRequest exception for Kids Mode once