summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-09-30 19:49:11 -0700
committerJeff Brown <jeffbrown@google.com>2012-10-01 14:27:34 -0700
commit3dc524bc31a1578693ca958ef442dfa092b7aa7f (patch)
treeecc333703c210cf5860009fd357bf5ecb41db058 /policy
parent1e3b98d47df596d0c4eadbdf60143709f8465b28 (diff)
downloadframeworks_base-3dc524bc31a1578693ca958ef442dfa092b7aa7f.zip
frameworks_base-3dc524bc31a1578693ca958ef442dfa092b7aa7f.tar.gz
frameworks_base-3dc524bc31a1578693ca958ef442dfa092b7aa7f.tar.bz2
Use new API to override user activity timeout from keyguard.
This now replaces the internal user activity timer that keyguard maintained. We can probably simplify things a great deal further now. Bug: 7165399 Change-Id: Ia0d5a156a4ff0c339bbd094380b9f7ab3cec5d9b
Diffstat (limited to 'policy')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java2
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java4
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java2
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java2
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java93
5 files changed, 29 insertions, 74 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index c94c6c4..c50fb5c 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -775,7 +775,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (keyguardShowing) {
// since it took two seconds of long press to bring this up,
// poke the wake lock so they have some time to see the dialog.
- mKeyguardMediator.pokeWakelock();
+ mKeyguardMediator.userActivity();
}
}
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 14633c4..4d56700 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -234,7 +234,7 @@ public class KeyguardHostView extends KeyguardViewBase {
public void userActivity(long timeout) {
if (mViewMediatorCallback != null) {
- mViewMediatorCallback.pokeWakelock(timeout);
+ mViewMediatorCallback.userActivity(timeout);
}
}
@@ -638,7 +638,7 @@ public class KeyguardHostView extends KeyguardViewBase {
if (DEBUG) Log.d(TAG, "poking wake lock immediately");
}
if (mViewMediatorCallback != null) {
- mViewMediatorCallback.pokeWakelock();
+ mViewMediatorCallback.wakeUp();
}
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
index 8714276..1977b52 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
@@ -76,6 +76,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
case com.android.internal.R.drawable.ic_lockscreen_unlock_phantom:
case com.android.internal.R.drawable.ic_lockscreen_unlock:
+ mCallback.userActivity(0);
mCallback.dismiss(false);
break;
}
@@ -86,6 +87,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
}
public void onGrabbed(View v, int handle) {
+ mCallback.userActivity(0);
doTransition(mFadeView, 0.0f);
}
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 1abcc10..a3a9c5f 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -155,6 +155,8 @@ public class KeyguardViewManager {
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
}
lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY;
+ lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
+ lp.userActivityTimeout = KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS;
lp.setTitle(isActivity ? "KeyguardMock" : "Keyguard");
mWindowLayoutParams = lp;
mViewManager.addView(mKeyguardHost, lp);
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 212a6bb..2c415db 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -104,7 +104,6 @@ public class KeyguardViewMediator {
"com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD";
// used for handler messages
- private static final int TIMEOUT = 1;
private static final int SHOW = 2;
private static final int HIDE = 3;
private static final int RESET = 4;
@@ -167,12 +166,6 @@ public class KeyguardViewMediator {
private UserManager mUserManager;
/**
- * Used to keep the device awake while the keyguard is showing, i.e for
- * calls to {@link #pokeWakelock()}
- */
- private PowerManager.WakeLock mWakeLock;
-
- /**
* Used to keep the device awake while to ensure the keyguard finishes opening before
* we sleep.
*/
@@ -215,8 +208,6 @@ public class KeyguardViewMediator {
*/
private int mDelayedShowingSequence;
- private int mWakelockSequence;
-
/**
* If the user has disabled the keyguard, then requests to exit, this is
* how we'll ultimately let them know whether it was successful. We use this
@@ -262,15 +253,16 @@ public class KeyguardViewMediator {
public interface ViewMediatorCallback {
/**
- * Request the wakelock to be poked for the default amount of time.
+ * Wake the device immediately.
*/
- void pokeWakelock();
+ void wakeUp();
/**
- * Request the wakelock to be poked for a specific amount of time.
+ * Reports user activity and requests that the screen stay on for the specified
+ * amount of time.
* @param millis The amount of time in millis.
*/
- void pokeWakelock(long millis);
+ void userActivity(long millis);
/**
* Report that the keyguard is done.
@@ -402,12 +394,12 @@ public class KeyguardViewMediator {
};
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
- public void pokeWakelock() {
- KeyguardViewMediator.this.pokeWakelock();
+ public void wakeUp() {
+ KeyguardViewMediator.this.wakeUp();
}
- public void pokeWakelock(long holdMs) {
- KeyguardViewMediator.this.pokeWakelock(holdMs);
+ public void userActivity(long holdMs) {
+ KeyguardViewMediator.this.userActivity(holdMs);
}
public void keyguardDone(boolean authenticated) {
@@ -424,19 +416,18 @@ public class KeyguardViewMediator {
}
};
- public void pokeWakelock() {
- pokeWakelock(AWAKE_INTERVAL_DEFAULT_MS);
+ public void wakeUp() {
+ mPM.wakeUp(SystemClock.uptimeMillis());
}
- public void pokeWakelock(long holdMs) {
- synchronized (this) {
- if (DBG_WAKE) Log.d(TAG, "pokeWakelock(" + holdMs + ")");
- mWakeLock.acquire();
- mHandler.removeMessages(TIMEOUT);
- mWakelockSequence++;
- Message msg = mHandler.obtainMessage(TIMEOUT, mWakelockSequence, 0);
- mHandler.sendMessageDelayed(msg, holdMs);
- }
+ public void userActivity() {
+ userActivity(AWAKE_INTERVAL_DEFAULT_MS);
+ }
+
+ public void userActivity(long holdMs) {
+ // We ignore the hold time. Eventually we should remove it.
+ // Instead, the keyguard window has an explicit user activity timeout set on it.
+ mPM.userActivity(SystemClock.uptimeMillis(), false);
}
/**
@@ -448,9 +439,6 @@ public class KeyguardViewMediator {
mContext = context;
mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- mWakeLock = mPM.newWakeLock(
- PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
- mWakeLock.setReferenceCounted(false);
mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false);
@@ -737,7 +725,6 @@ public class KeyguardViewMediator {
if (mHidden != isHidden) {
mHidden = isHidden;
updateActivityLockScreenState();
- adjustUserActivityLocked();
adjustStatusBarLocked();
}
}
@@ -1050,9 +1037,6 @@ public class KeyguardViewMediator {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
- case TIMEOUT:
- handleTimeout(msg.arg1);
- return ;
case SHOW:
handleShow();
return ;
@@ -1103,9 +1087,8 @@ public class KeyguardViewMediator {
if (DEBUG) Log.d(TAG, "handleKeyguardDone");
handleHide();
if (wakeup) {
- mPM.wakeUp(SystemClock.uptimeMillis());
+ wakeUp();
}
- mWakeLock.release();
sendUserPresentBroadcast();
}
@@ -1137,21 +1120,6 @@ public class KeyguardViewMediator {
}
}
- /**
- * Handles the message sent by {@link #pokeWakelock}
- * @param seq used to determine if anything has changed since the message
- * was sent.
- * @see #TIMEOUT
- */
- private void handleTimeout(int seq) {
- synchronized (KeyguardViewMediator.this) {
- if (DEBUG) Log.d(TAG, "handleTimeout");
- if (seq == mWakelockSequence) {
- mWakeLock.release();
- }
- }
- }
-
private void playSounds(boolean locked) {
// User feedback for keyguard.
@@ -1200,8 +1168,8 @@ public class KeyguardViewMediator {
mKeyguardViewManager.show();
mShowing = true;
updateActivityLockScreenState();
- adjustUserActivityLocked();
adjustStatusBarLocked();
+ userActivity();
try {
ActivityManagerNative.getDefault().closeSystemDialogs("lock");
} catch (RemoteException e) {
@@ -1235,23 +1203,10 @@ public class KeyguardViewMediator {
mKeyguardViewManager.hide();
mShowing = false;
updateActivityLockScreenState();
- adjustUserActivityLocked();
adjustStatusBarLocked();
}
}
- private void adjustUserActivityLocked() {
- // disable user activity if we are shown and not hidden
- if (DEBUG) Log.d(TAG, "adjustUserActivityLocked mShowing: " + mShowing + " mHidden: " + mHidden);
- boolean enabled = !mShowing || mHidden;
- // FIXME: Replace this with a new timeout control mechanism.
- //mRealPowerManager.enableUserActivity(enabled);
- if (!enabled && mScreenOn) {
- // reinstate our short screen timeout policy
- pokeWakelock();
- }
- }
-
private void adjustStatusBarLocked() {
if (mStatusBarManager == null) {
mStatusBarManager = (StatusBarManager)
@@ -1320,7 +1275,7 @@ public class KeyguardViewMediator {
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");
- pokeWakelock();
+ userActivity();
}
/**
@@ -1328,10 +1283,6 @@ public class KeyguardViewMediator {
* release the handoff wakelock
*/
mWakeAndHandOff.release();
-
- if (!mWakeLock.isHeld()) {
- Log.w(TAG, "mWakeLock not held in mKeyguardViewManager.wakeWhenReadyTq");
- }
}
}