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

Commit a71984f3 authored by Jim Miller's avatar Jim Miller
Browse files

Cleanup keyguard signals

- remove redundant signals that were causing keyguard to be rebuilt unnecessarily.
- add a check to ensure we only handle configuration changes if the view is actually showing
- only reconstruct view if screen is turning off or if the configuration changes.

Change-Id: Ia9c7830e370feed6af36cc139d4cd3c5ca0be4fd
parent 1254f2f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
    public boolean stop() {
        if (DEBUG) Log.d(TAG, "stop()");
        if (mHandler.getLooper() != Looper.myLooper()) {
            Log.e(TAG, "stop() called off of the UI thread");
            Log.e(TAG, "stop() called from non-UI thread");
        }

        boolean mWasRunning = mIsRunning;
+10 −10
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class KeyguardHostView extends KeyguardViewBase {
    private static final String TAG = "KeyguardViewHost";

    // Use this to debug all of keyguard
    public static boolean DEBUG;
    public static boolean DEBUG = KeyguardViewMediator.DEBUG;

    // also referenced in SecuritySettings.java
    static final int APPWIDGET_HOST_ID = 0x4B455947;
@@ -618,8 +618,6 @@ public class KeyguardHostView extends KeyguardViewBase {
                break;
            }
        }
        boolean simPukFullScreen = getResources().getBoolean(
                com.android.internal.R.bool.kg_sim_puk_account_full_screen);
        int layoutId = getLayoutIdFor(securityMode);
        if (view == null && layoutId != 0) {
            final LayoutInflater inflater = LayoutInflater.from(mContext);
@@ -642,13 +640,6 @@ public class KeyguardHostView extends KeyguardViewBase {
            }
        }

        if (securityMode == SecurityMode.SimPin || securityMode == SecurityMode.SimPuk ||
            securityMode == SecurityMode.Account) {
            if (simPukFullScreen) {
                mAppWidgetContainer.setVisibility(View.GONE);
            }
        }

        if (view instanceof KeyguardSelectorView) {
            KeyguardSelectorView selectorView = (KeyguardSelectorView) view;
            View carrierText = selectorView.findViewById(R.id.keyguard_selector_fade_container);
@@ -672,6 +663,15 @@ public class KeyguardHostView extends KeyguardViewBase {
        KeyguardSecurityView oldView = getSecurityView(mCurrentSecuritySelection);
        KeyguardSecurityView newView = getSecurityView(securityMode);

        // Enter full screen mode if we're in SIM or Account screen
        boolean fullScreenEnabled = getResources().getBoolean(
                com.android.internal.R.bool.kg_sim_puk_account_full_screen);
        boolean isSimOrAccount = securityMode == SecurityMode.SimPin
                || securityMode == SecurityMode.SimPuk
                || securityMode == SecurityMode.Account;
        mAppWidgetContainer.setVisibility(
                isSimOrAccount && fullScreenEnabled ? View.GONE : View.VISIBLE);

        // Emulate Activity life cycle
        if (oldView != null) {
            oldView.onPause();
+15 −14
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ import com.android.internal.widget.LockPatternUtils;
 * reported to this class by the current {@link KeyguardViewBase}.
 */
public class KeyguardViewManager {
    private final static boolean DEBUG = false;
    private final static boolean DEBUG = KeyguardViewMediator.DEBUG;
    private static String TAG = "KeyguardViewManager";
    public static boolean USE_UPPER_CASE = true;

@@ -65,7 +65,6 @@ public class KeyguardViewManager {
    private FrameLayout mKeyguardHost;
    private KeyguardHostView mKeyguardView;

    private boolean mScreenOn = false;
    private LockPatternUtils mLockPatternUtils;

    public interface ShowListener {
@@ -96,7 +95,7 @@ public class KeyguardViewManager {

        boolean enableScreenRotation = shouldEnableScreenRotation();

        maybeCreateKeyguardLocked(enableScreenRotation, options);
        maybeCreateKeyguardLocked(enableScreenRotation, false, options);
        maybeEnableScreenRotation(enableScreenRotation);

        // Disable common aspects of the system/status/navigation bars that are not appropriate or
@@ -104,7 +103,7 @@ public class KeyguardViewManager {
        // activities. Other disabled bits are handled by the KeyguardViewMediator talking
        // directly to the status bar service.
        final int visFlags = View.STATUS_BAR_DISABLE_HOME;
        if (DEBUG) Log.v(TAG, "KGVM: Set visibility on " + mKeyguardHost + " to " + visFlags);
        if (DEBUG) Log.v(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags)+")");
        mKeyguardHost.setSystemUiVisibility(visFlags);

        mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);
@@ -127,7 +126,12 @@ public class KeyguardViewManager {
        @Override
        protected void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
            maybeCreateKeyguardLocked(shouldEnableScreenRotation(), null);
            if (mKeyguardHost.getVisibility() == View.VISIBLE) {
                // only propagate configuration messages if we're currently showing
                maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, null);
            } else {
                if (DEBUG) Log.v(TAG, "onConfigurationChanged: view not visible");
            }
        }

        @Override
@@ -145,7 +149,8 @@ public class KeyguardViewManager {

    SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>();

    private void maybeCreateKeyguardLocked(boolean enableScreenRotation, Bundle options) {
    private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean force,
            Bundle options) {
        final boolean isActivity = (mContext instanceof Activity); // for test activity

        if (mKeyguardHost != null) {
@@ -189,7 +194,9 @@ public class KeyguardViewManager {
            mViewManager.addView(mKeyguardHost, lp);
        }

        if (force || mKeyguardView == null) {
            inflateKeyguardView(options);
        }
        updateUserActivityTimeoutInWindowLayoutParams();
        mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);

@@ -230,10 +237,6 @@ public class KeyguardViewManager {
                mKeyguardView.showNextSecurityScreenIfPresent();
            }
        }

        if (mScreenOn) {
            mKeyguardView.show();
        }
    }

    public void updateUserActivityTimeout() {
@@ -294,12 +297,11 @@ public class KeyguardViewManager {
        if (DEBUG) Log.d(TAG, "reset()");
        // User might have switched, check if we need to go back to keyguard
        // TODO: It's preferable to stay and show the correct lockscreen or unlock if none
        maybeCreateKeyguardLocked(shouldEnableScreenRotation(), options);
        maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, options);
    }

    public synchronized void onScreenTurnedOff() {
        if (DEBUG) Log.d(TAG, "onScreenTurnedOff()");
        mScreenOn = false;
        if (mKeyguardView != null) {
            mKeyguardView.onScreenTurnedOff();
        }
@@ -308,7 +310,6 @@ public class KeyguardViewManager {
    public synchronized void onScreenTurnedOn(
            final KeyguardViewManager.ShowListener showListener) {
        if (DEBUG) Log.d(TAG, "onScreenTurnedOn()");
        mScreenOn = true;
        if (mKeyguardView != null) {
            mKeyguardView.onScreenTurnedOn();

+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ import com.android.internal.widget.LockPatternUtils;
 */
public class KeyguardViewMediator {
    private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000;
    private final static boolean DEBUG = false;
    final static boolean DEBUG = true;
    private final static boolean DBG_WAKE = false;

    private final static String TAG = "KeyguardViewMediator";