From a71984f3da47c6e6e3164c170735362a3222d3ad Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 24 Oct 2012 22:08:49 -0700 Subject: [PATCH] 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 --- .../internal/policy/impl/keyguard/FaceUnlock.java | 2 +- .../policy/impl/keyguard/KeyguardHostView.java | 20 +++++++-------- .../policy/impl/keyguard/KeyguardViewManager.java | 29 +++++++++++----------- .../policy/impl/keyguard/KeyguardViewMediator.java | 2 +- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java b/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java index 3fe16cf0f4ea..000acb19b902 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java @@ -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; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index b14faebb18ec..e54e02c17311 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -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(); diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java index 452fbca66327..9fa14f5f3692 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java @@ -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 mStateContainer = new SparseArray(); - 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); } - inflateKeyguardView(options); + 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(); diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java index 67e2b2d5bea9..af35021f3419 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java @@ -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"; -- 2.11.0