diff options
author | Jim Miller <jaggies@google.com> | 2013-06-27 23:05:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-06-27 23:05:19 +0000 |
commit | afb292a23cd56e6f328164ede81522afe7ef1f89 (patch) | |
tree | 335ac9c4b89ebda8b2a0fc3bc273a95c5d10e680 /packages/Keyguard | |
parent | 0cab330e0737960c4612791a2e15087f4d49ff02 (diff) | |
parent | e51cf7aeb6157017801a802b4c1d74cbf51b7a01 (diff) | |
download | frameworks_base-afb292a23cd56e6f328164ede81522afe7ef1f89.zip frameworks_base-afb292a23cd56e6f328164ede81522afe7ef1f89.tar.gz frameworks_base-afb292a23cd56e6f328164ede81522afe7ef1f89.tar.bz2 |
Merge "Simplify wake management code in keyguard."
Diffstat (limited to 'packages/Keyguard')
5 files changed, 27 insertions, 236 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index 0970248..2904f4c 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -119,6 +119,8 @@ public class KeyguardHostView extends KeyguardViewBase { protected int mClientGeneration; + protected boolean mShowSecurityWhenReturn; + /*package*/ interface UserSwitcherCallback { void hideSecurityView(int duration); void showSecurityView(); @@ -872,14 +874,6 @@ public class KeyguardHostView extends KeyguardViewBase { } }; - protected boolean mShowSecurityWhenReturn; - - @Override - public void reset() { - mIsVerifyUnlockOnly = false; - mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_status_view)); - } - /** * Sets an action to perform when keyguard is dismissed. * @param action @@ -1029,39 +1023,6 @@ public class KeyguardHostView extends KeyguardViewBase { showPrimarySecurityScreen(false); } - private boolean isSecure() { - SecurityMode mode = mSecurityModel.getSecurityMode(); - switch (mode) { - case Pattern: - return mLockPatternUtils.isLockPatternEnabled(); - case Password: - case PIN: - return mLockPatternUtils.isLockPasswordEnabled(); - case SimPin: - case SimPuk: - case Account: - return true; - case None: - return false; - default: - throw new IllegalStateException("Unknown security mode " + mode); - } - } - - @Override - public void wakeWhenReadyTq(int keyCode) { - if (DEBUG) Log.d(TAG, "onWakeKey"); - if (keyCode == KeyEvent.KEYCODE_MENU && isSecure()) { - if (DEBUG) Log.d(TAG, "switching screens to unlock screen because wake key was MENU"); - showSecurityScreen(SecurityMode.None); - } else { - if (DEBUG) Log.d(TAG, "poking wake lock immediately"); - } - if (mViewMediatorCallback != null) { - mViewMediatorCallback.wakeUp(); - } - } - @Override public void verifyUnlock() { SecurityMode securityMode = mSecurityModel.getSecurityMode(); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java index f89ad65..a70e5bd 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java @@ -93,14 +93,6 @@ public class KeyguardService extends Service { public void dismiss() { mKeyguardViewMediator.dismiss(); } - public void onWakeKeyWhenKeyguardShowing(int keyCode) { - checkPermission(); - mKeyguardViewMediator.onWakeKeyWhenKeyguardShowing(keyCode); - } - public void onWakeMotionWhenKeyguardShowing() { - checkPermission(); - mKeyguardViewMediator.onWakeMotionWhenKeyguardShowing(); - } public void onDreamingStarted() { checkPermission(); mKeyguardViewMediator.onDreamingStarted(); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java index 200fb3c..714dfbd 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java @@ -90,11 +90,6 @@ public abstract class KeyguardViewBase extends FrameLayout { } /** - * Called when you need to reset the state of your view. - */ - abstract public void reset(); - - /** * Called when the screen turned off. */ abstract public void onScreenTurnedOff(); @@ -110,21 +105,6 @@ public abstract class KeyguardViewBase extends FrameLayout { abstract public void show(); /** - * Called when a key has woken the device to give us a chance to adjust our - * state according the the key. We are responsible for waking the device - * (by poking the wake lock) once we are ready. - * - * The 'Tq' suffix is per the documentation in {@link android.view.WindowManagerPolicy}. - * Be sure not to take any action that takes a long time; any significant - * action should be posted to a handler. - * - * @param keyCode The wake key, which may be relevant for configuring the - * keyguard. May be {@link KeyEvent#KEYCODE_UNKNOWN} if waking for a reason - * other than a key press. - */ - abstract public void wakeWhenReadyTq(int keyCode); - - /** * Verify that the user can get past the keyguard securely. This is called, * for example, when the phone disables the keyguard but then wants to launch * something else that requires secure access. diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java index b6c35bd..a1d11cd 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java @@ -384,27 +384,6 @@ public class KeyguardViewManager { } /** - * A key has woken the device. We use this to potentially adjust the state - * of the lock screen based on the key. - * - * The 'Tq' suffix is per the documentation in {@link android.view.WindowManagerPolicy}. - * Be sure not to take any action that takes a long time; any significant - * action should be posted to a handler. - * - * @param keyCode The wake key. May be {@link KeyEvent#KEYCODE_UNKNOWN} if waking - * for a reason other than a key press. - */ - public boolean wakeWhenReadyTq(int keyCode) { - if (DEBUG) Log.d(TAG, "wakeWhenReady(" + keyCode + ")"); - if (mKeyguardView != null) { - mKeyguardView.wakeWhenReadyTq(keyCode); - return true; - } - Log.w(TAG, "mKeyguardView is null in wakeWhenReadyTq"); - return false; - } - - /** * Hides the keyguard view */ public synchronized void hide() { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java index 4ce0dcd..597fb3b 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java @@ -114,7 +114,6 @@ public class KeyguardViewMediator { private static final int VERIFY_UNLOCK = 5; private static final int NOTIFY_SCREEN_OFF = 6; private static final int NOTIFY_SCREEN_ON = 7; - private static final int WAKE_WHEN_READY = 8; private static final int KEYGUARD_DONE = 9; private static final int KEYGUARD_DONE_DRAWING = 10; private static final int KEYGUARD_DONE_AUTHENTICATING = 11; @@ -180,14 +179,6 @@ public class KeyguardViewMediator { */ private PowerManager.WakeLock mShowKeyguardWakeLock; - /** - * Does not turn on screen, held while a call to {@link KeyguardViewManager#wakeWhenReadyTq(int)} - * is called to make sure the device doesn't sleep before it has a chance to poke - * the wake lock. - * @see #wakeWhenReady(int) - */ - private PowerManager.WakeLock mWakeAndHandOff; - private KeyguardViewManager mKeyguardViewManager; // these are protected by synchronized (this) @@ -268,12 +259,6 @@ public class KeyguardViewMediator { * various things. */ public interface ViewMediatorCallback { - - /** - * Wake the device immediately. - */ - void wakeUp(); - /** * Reports user activity and requests that the screen stay on. */ @@ -439,10 +424,6 @@ public class KeyguardViewMediator { }; ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { - public void wakeUp() { - KeyguardViewMediator.this.wakeUp(); - } - public void userActivity() { KeyguardViewMediator.this.userActivity(); } @@ -475,10 +456,6 @@ public class KeyguardViewMediator { } }; - public void wakeUp() { - mPM.wakeUp(SystemClock.uptimeMillis()); - } - private void userActivity() { userActivity(AWAKE_INTERVAL_DEFAULT_MS); } @@ -501,9 +478,6 @@ public class KeyguardViewMediator { mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); mShowKeyguardWakeLock.setReferenceCounted(false); - mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff"); - mWakeAndHandOff.setReferenceCounted(false); - mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION)); mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); @@ -981,27 +955,6 @@ public class KeyguardViewMediator { } /** - * Send message to keyguard telling it about a wake key so it can adjust - * its state accordingly and then poke the wake lock when it is ready. - * @param keyCode The wake key. - * @see #handleWakeWhenReady - * @see #onWakeKeyWhenKeyguardShowing(int) - */ - private void wakeWhenReady(int keyCode) { - if (DBG_WAKE) Log.d(TAG, "wakeWhenReady(" + keyCode + ")"); - - /** - * acquire the handoff lock that will keep the cpu running. this will - * be released once the keyguard has set itself up and poked the other wakelock - * in {@link #handleWakeWhenReady(int)} - */ - mWakeAndHandOff.acquire(); - - Message msg = mHandler.obtainMessage(WAKE_WHEN_READY, keyCode, 0); - mHandler.sendMessage(msg); - } - - /** * Send message to keyguard telling it to show itself * @see #handleShow() */ @@ -1056,74 +1009,14 @@ public class KeyguardViewMediator { } }; - /** - * When a key is received when the screen is off and the keyguard is showing, - * we need to decide whether to actually turn on the screen, and if so, tell - * the keyguard to prepare itself and poke the wake lock when it is ready. - * - * The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}. - * Be sure not to take any action that takes a long time; any significant - * action should be posted to a handler. - * - * @param keyCode The keycode of the key that woke the device - */ - public void onWakeKeyWhenKeyguardShowing(int keyCode) { - if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")"); - - // give the keyguard view manager a chance to adjust the state of the - // keyguard based on the key that woke the device before poking - // the wake lock - wakeWhenReady(keyCode); - } - - /** - * When a wake motion such as an external mouse movement is received when the screen - * is off and the keyguard is showing, we need to decide whether to actually turn - * on the screen, and if so, tell the keyguard to prepare itself and poke the wake - * lock when it is ready. - * - * The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}. - * Be sure not to take any action that takes a long time; any significant - * action should be posted to a handler. - */ - public void onWakeMotionWhenKeyguardShowing() { - if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()"); - - // give the keyguard view manager a chance to adjust the state of the - // keyguard based on the key that woke the device before poking - // the wake lock - wakeWhenReady(KeyEvent.KEYCODE_UNKNOWN); - } - public void keyguardDone(boolean authenticated, boolean wakeup) { mKeyguardDonePending = false; synchronized (this) { EventLog.writeEvent(70000, 2); if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")"); - Message msg = mHandler.obtainMessage(KEYGUARD_DONE); - msg.arg1 = wakeup ? 1 : 0; + Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0, + wakeup ? 1 : 0); mHandler.sendMessage(msg); - - if (authenticated) { - mUpdateMonitor.clearFailedUnlockAttempts(); - } - - if (mExitSecureCallback != null) { - try { - mExitSecureCallback.onKeyguardExitResult(authenticated); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(" + authenticated + ")", e); - } - - mExitSecureCallback = null; - - if (authenticated) { - // after succesfully exiting securely, no need to reshow - // the keyguard when they've released the lock - mExternallyEnabled = true; - mNeedToReshowWhenReenabled = false; - } - } } } @@ -1156,11 +1049,8 @@ public class KeyguardViewMediator { case NOTIFY_SCREEN_ON: handleNotifyScreenOn((IKeyguardShowCallback) msg.obj); return; - case WAKE_WHEN_READY: - handleWakeWhenReady(msg.arg1); - return; case KEYGUARD_DONE: - handleKeyguardDone(msg.arg1 != 0); + handleKeyguardDone(msg.arg1 != 0, msg.arg2 != 0); return; case KEYGUARD_DONE_DRAWING: handleKeyguardDoneDrawing(); @@ -1187,13 +1077,31 @@ public class KeyguardViewMediator { * @see #keyguardDone * @see #KEYGUARD_DONE */ - private void handleKeyguardDone(boolean wakeup) { + private void handleKeyguardDone(boolean authenticated, boolean wakeup) { if (DEBUG) Log.d(TAG, "handleKeyguardDone"); - handleHide(); - if (wakeup) { - wakeUp(); + + if (authenticated) { + mUpdateMonitor.clearFailedUnlockAttempts(); } + if (mExitSecureCallback != null) { + try { + mExitSecureCallback.onKeyguardExitResult(authenticated); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to call onKeyguardExitResult(" + authenticated + ")", e); + } + + mExitSecureCallback = null; + + if (authenticated) { + // after succesfully exiting securely, no need to reshow + // the keyguard when they've released the lock + mExternallyEnabled = true; + mNeedToReshowWhenReenabled = false; + } + } + + handleHide(); sendUserPresentBroadcast(); } @@ -1296,10 +1204,6 @@ public class KeyguardViewMediator { private void handleHide() { synchronized (KeyguardViewMediator.this) { if (DEBUG) Log.d(TAG, "handleHide"); - if (mWakeAndHandOff.isHeld()) { - Log.w(TAG, "attempt to hide the keyguard while waking, ignored"); - return; - } // only play "unlock" noises if not on a call (since the incall UI // disables the keyguard) @@ -1375,31 +1279,6 @@ public class KeyguardViewMediator { } /** - * Handle message sent by {@link #wakeWhenReady(int)} - * @param keyCode The key that woke the device. - * @see #WAKE_WHEN_READY - */ - private void handleWakeWhenReady(int keyCode) { - synchronized (KeyguardViewMediator.this) { - if (DBG_WAKE) Log.d(TAG, "handleWakeWhenReady(" + keyCode + ")"); - - // this should result in a call to 'poke wakelock' which will set a timeout - // on releasing the wakelock - if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) { - // poke wakelock ourselves if keyguard is no longer active - Log.w(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves"); - userActivity(); - } - - /** - * Now that the keyguard is ready and has poked the wake lock, we can - * release the handoff wakelock - */ - mWakeAndHandOff.release(); - } - } - - /** * Handle message sent by {@link #resetStateLocked(Bundle)} * @see #RESET */ |