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

Commit 06cc78a4 authored by Jim Miller's avatar Jim Miller
Browse files

Fix 4518876: Disable lock screen rotation on phones.

This reverts commit e28016c2
that enabled lockscreen rotation always and works around a
race condition caused by KeyguardViewManager not following
onConfigurationChanged events.  It now checks
R.bool.config_enableLockScreenRotation each time it is shown.

There's still some work to be done, but this change makes the
phone usable.  KeyguardViewManager needs to track config
changes and update the layout parameters to be correct.

Change-Id: I7c9f2402c960d5bd72a4b73118a66e27a05777cf
parent f30c23d7
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.internal.R;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.graphics.Canvas;
import android.util.Log;
@@ -94,6 +95,8 @@ public class KeyguardViewManager implements KeyguardWindowController {
    public synchronized void show() {
        if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView);

        Resources res = mContext.getResources();
        boolean enableScreenRotation = res.getBoolean(R.bool.config_enableLockScreenRotation);
        if (mKeyguardHost == null) {
            if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");

@@ -116,18 +119,22 @@ public class KeyguardViewManager implements KeyguardWindowController {
            lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
            lp.windowAnimations = com.android.internal.R.style.Animation_LockScreen;

            // TODO: Sometimes we get the wrong value for the sensor resource we use to configure
            // this.  However, the current UI design has LockScreen always respond to orientation so
            // we don't need this for the time-being.
            //
            // For reference, the configuration variable is R.bool.config_enableLockScreenRotation
            lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
            lp.setTitle("Keyguard");
            mWindowLayoutParams = lp;

            mViewManager.addView(mKeyguardHost, lp);
        }

        if (enableScreenRotation) {
            Log.d(TAG, "Rotation sensor for lock screen On!");
            mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
        } else {
            Log.d(TAG, "Rotation sensor for lock screen Off!");
            mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
        }

        mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);

        if (mKeyguardView == null) {
            if (DEBUG) Log.d(TAG, "keyguard view is null, creating it...");
            mKeyguardView = mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this);