summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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
commitafb292a23cd56e6f328164ede81522afe7ef1f89 (patch)
tree335ac9c4b89ebda8b2a0fc3bc273a95c5d10e680
parent0cab330e0737960c4612791a2e15087f4d49ff02 (diff)
parente51cf7aeb6157017801a802b4c1d74cbf51b7a01 (diff)
Merge "Simplify wake management code in keyguard."
-rw-r--r--core/java/com/android/internal/policy/IKeyguardService.aidl2
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java43
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardService.java8
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java20
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java21
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java171
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java22
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java14
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java (renamed from policy/src/com/android/internal/policy/impl/KeyguardServiceWrapper.java)18
9 files changed, 32 insertions, 287 deletions
diff --git a/core/java/com/android/internal/policy/IKeyguardService.aidl b/core/java/com/android/internal/policy/IKeyguardService.aidl
index 880464d8c453..d1f7fa3b2394 100644
--- a/core/java/com/android/internal/policy/IKeyguardService.aidl
+++ b/core/java/com/android/internal/policy/IKeyguardService.aidl
@@ -30,8 +30,6 @@ interface IKeyguardService {
oneway void keyguardDone(boolean authenticated, boolean wakeup);
oneway void setHidden(boolean isHidden);
oneway void dismiss();
- oneway void onWakeKeyWhenKeyguardShowing(int keyCode);
- oneway void onWakeMotionWhenKeyguardShowing();
oneway void onDreamingStarted();
oneway void onDreamingStopped();
oneway void onScreenTurnedOff(int reason);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index 09702480c7e1..2904f4c6fb86 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 f89ad65c83e1..a70e5bdc44d8 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 200fb3cc17a4..714dfbdf7f97 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 b6c35bd54c39..a1d11cd7f2b9 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 4ce0dcd3241d..597fb3bf7638 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
*/
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 56d0ec00cbeb..0b8b0284555e 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -3523,11 +3523,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
updateRotation(true);
if (lidOpen) {
- if (keyguardIsShowingTq()) {
- mKeyguardDelegate.onWakeKeyWhenKeyguardShowingTq(KeyEvent.KEYCODE_POWER);
- } else {
- mPowerManager.wakeUp(SystemClock.uptimeMillis());
- }
+ mPowerManager.wakeUp(SystemClock.uptimeMillis());
} else if (!mLidControlsSleep) {
mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
}
@@ -3745,13 +3741,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// to wake the device but don't pass the key to the application.
result = 0;
if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) {
- if (keyguardActive) {
- // If the keyguard is showing, let it wake the device when ready.
- mKeyguardDelegate.onWakeKeyWhenKeyguardShowingTq(keyCode);
- } else {
- // Otherwise, wake the device ourselves.
- result |= ACTION_WAKE_UP;
- }
+ result |= ACTION_WAKE_UP;
}
}
@@ -4017,13 +4007,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final boolean isWakeMotion = (policyFlags
& (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
if (isWakeMotion) {
- if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) {
- // If the keyguard is showing, let it decide what to do with the wake motion.
- mKeyguardDelegate.onWakeMotionWhenKeyguardShowing();
- } else {
- // Otherwise, wake the device ourselves.
- result |= ACTION_WAKE_UP;
- }
+ result |= ACTION_WAKE_UP;
}
return result;
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
index 2bb94bea1258..874076a9dfae 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
@@ -12,6 +12,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import android.util.Slog;
+import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
@@ -21,7 +22,6 @@ import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.policy.IKeyguardService;
import com.android.internal.widget.LockPatternUtils;
-import com.android.internal.policy.impl.KeyguardServiceWrapper;
/**
* A local class that keeps a cache of keyguard state that can be restored in the event
@@ -178,18 +178,6 @@ public class KeyguardServiceDelegate {
return mKeyguardState.secure;
}
- public void onWakeKeyWhenKeyguardShowingTq(int keycodePower) {
- if (mKeyguardService != null) {
- mKeyguardService.onWakeKeyWhenKeyguardShowing(keycodePower);
- }
- }
-
- public void onWakeMotionWhenKeyguardShowing() {
- if (mKeyguardService != null) {
- mKeyguardService.onWakeMotionWhenKeyguardShowing();
- }
- }
-
public void onDreamingStarted() {
if (mKeyguardService != null) {
mKeyguardService.onDreamingStarted();
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardServiceWrapper.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
index e649125ffa52..6b9c7df79e30 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardServiceWrapper.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.internal.policy.impl;
+package com.android.internal.policy.impl.keyguard;
import android.os.Bundle;
import android.os.IBinder;
@@ -115,22 +115,6 @@ public class KeyguardServiceWrapper implements IKeyguardService {
}
}
- public void onWakeKeyWhenKeyguardShowing(int keyCode) {
- try {
- mService.onWakeKeyWhenKeyguardShowing(keyCode);
- } catch (RemoteException e) {
- Slog.w(TAG , "Remote Exception", e);
- }
- }
-
- public void onWakeMotionWhenKeyguardShowing() {
- try {
- mService.onWakeMotionWhenKeyguardShowing();
- } catch (RemoteException e) {
- Slog.w(TAG , "Remote Exception", e);
- }
- }
-
public void onDreamingStarted() {
try {
mService.onDreamingStarted();