summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2014-09-20 02:44:14 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-20 02:44:14 +0000
commit4df057c98b99ac2962771a800665399aa72c9d4c (patch)
treed8e374b08aaf1b3cfff80dea9372ceaa15c9772e /policy
parenta9c0b9ba3ff227a81ffcbfc5f5dda8192eadd97a (diff)
parentbdd4e4af793875ac82f362503c69c6a50ce1d6c3 (diff)
downloadframeworks_base-4df057c98b99ac2962771a800665399aa72c9d4c.zip
frameworks_base-4df057c98b99ac2962771a800665399aa72c9d4c.tar.gz
frameworks_base-4df057c98b99ac2962771a800665399aa72c9d4c.tar.bz2
am 77e786ab: am 978272f4: am a94c9ccb: am 09395677: Merge "Decouple turning screen on from waking up in policy." into lmp-dev
* commit '77e786abd5f2dcb74de3cc083c1cc64c884fac9d': Decouple turning screen on from waking up in policy.
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java142
1 files changed, 85 insertions, 57 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 1bc77dc..36359f3 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -351,8 +351,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mLidControlsSleep;
int mShortPressOnPowerBehavior = -1;
int mLongPressOnPowerBehavior = -1;
- boolean mScreenOnEarly = false;
- boolean mScreenOnFully = false;
+ boolean mAwakeEarly = false;
+ boolean mAwakeFully = false;
boolean mOrientationSensorEnabled = false;
int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
boolean mHasSoftInput = false;
@@ -548,6 +548,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10;
private static final int MSG_HIDE_BOOT_MESSAGE = 11;
private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12;
+ private static final int MSG_SCREEN_TURNING_ON = 13;
private class PolicyHandler extends Handler {
@Override
@@ -573,22 +574,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
break;
case MSG_KEYGUARD_DRAWN_COMPLETE:
if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete");
- mKeyguardDrawComplete = true;
- finishScreenTurningOn();
+ finishKeyguardDrawn();
break;
case MSG_KEYGUARD_DRAWN_TIMEOUT:
Slog.w(TAG, "Keyguard drawn timeout. Setting mKeyguardDrawComplete");
- mKeyguardDrawComplete = true;
- finishScreenTurningOn();
+ finishKeyguardDrawn();
break;
case MSG_WINDOW_MANAGER_DRAWN_COMPLETE:
if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete");
- mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
- mWindowManagerDrawComplete = true;
- finishScreenTurningOn();
+ finishWindowsDrawn();
break;
case MSG_WAKING_UP:
- handleWakingUp((ScreenOnListener) msg.obj);
+ handleWakingUp();
break;
case MSG_HIDE_BOOT_MESSAGE:
handleHideBootMessage();
@@ -596,6 +593,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK:
launchVoiceAssistWithWakeLock(msg.arg1 != 0);
break;
+ case MSG_SCREEN_TURNING_ON:
+ handleScreenTurningOn((ScreenOnListener)msg.obj);
+ break;
}
}
}
@@ -766,11 +766,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
//Could have been invoked due to screen turning on or off or
//change of the currently visible window's orientation
- if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+
+ if (localLOGV) Slog.v(TAG, "Screen status="+mAwakeEarly+
", current orientation="+mCurrentAppOrientation+
", SensorEnabled="+mOrientationSensorEnabled);
boolean disable = true;
- if (mScreenOnEarly) {
+ if (mAwakeEarly) {
if (needSensorRunningLp()) {
disable = false;
//enable listener if not already enabled
@@ -1332,7 +1332,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
private boolean shouldEnableWakeGestureLp() {
- return mWakeGestureEnabledSetting && !mScreenOnEarly
+ return mWakeGestureEnabledSetting && !mAwakeEarly
&& (!mLidControlsSleep || mLidState != LID_CLOSED)
&& mWakeGestureListener.isSupported();
}
@@ -4731,9 +4731,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override
public void goingToSleep(int why) {
EventLog.writeEvent(70000, 0);
+ if (DEBUG_WAKEUP) Slog.i(TAG, "Going to sleep...");
synchronized (mLock) {
- mScreenOnEarly = false;
- mScreenOnFully = false;
+ mAwakeEarly = false;
+ mAwakeFully = false;
}
if (mKeyguardDelegate != null) {
mKeyguardDelegate.onScreenTurnedOff(why);
@@ -4746,70 +4747,101 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
@Override
- public void wakingUp(final ScreenOnListener screenOnListener) {
+ public void wakingUp() {
EventLog.writeEvent(70000, 1);
- if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...",
- new RuntimeException("here").fillInStackTrace());
- mHandler.obtainMessage(MSG_WAKING_UP, screenOnListener).sendToTarget();
+ if (DEBUG_WAKEUP) Slog.i(TAG, "Waking up...");
+ mHandler.obtainMessage(MSG_WAKING_UP).sendToTarget();
}
// Called on the mHandler thread.
- private void handleWakingUp(final ScreenOnListener screenOnListener) {
- if (screenOnListener != null) {
- mScreenOnListener = screenOnListener;
- }
-
+ private void handleWakingUp() {
synchronized (mLock) {
- mScreenOnEarly = true;
+ mAwakeEarly = true;
updateWakeGestureListenerLp();
updateOrientationListenerLp();
updateLockScreenTimeout();
}
mKeyguardDrawComplete = false;
- mWindowManagerDrawComplete = false;
+ mWindowManagerDrawComplete = false; // wait for later call to screenTurningOn
if (mKeyguardDelegate != null) {
mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000);
mKeyguardDelegate.onScreenTurnedOn(mKeyguardDelegateCallback);
+ // ... eventually calls finishKeyguardDrawn
} else {
if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
+ finishKeyguardDrawn();
+ }
+ }
+
+ // Called on the mHandler thread.
+ private void finishKeyguardDrawn() {
+ if (!mKeyguardDrawComplete) {
mKeyguardDrawComplete = true;
+ mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
+ finishScreenTurningOn();
}
+ }
+
+ @Override
+ public void screenTurningOn(final ScreenOnListener screenOnListener) {
+ EventLog.writeEvent(70000, 1);
+ if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...");
+ mHandler.obtainMessage(MSG_SCREEN_TURNING_ON, screenOnListener).sendToTarget();
+ }
+
+ // Called on the mHandler thread.
+ private void handleScreenTurningOn(ScreenOnListener screenOnListener) {
+ mScreenOnListener = screenOnListener;
+
+ mWindowManagerDrawComplete = false;
mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback,
WAITING_FOR_DRAWN_TIMEOUT);
+ // ... eventually calls finishWindowsDrawn
+ }
+
+ // Called on the mHandler thread.
+ private void finishWindowsDrawn() {
+ if (!mWindowManagerDrawComplete) {
+ mWindowManagerDrawComplete = true;
+ finishScreenTurningOn();
+ }
}
// Called on the mHandler thread.
private void finishScreenTurningOn() {
if (DEBUG_WAKEUP) Slog.d(TAG,
- "finishScreenTurningOn: mKeyguardDrawComplete=" + mKeyguardDrawComplete
+ "finishScreenTurningOn: mAwakeEarly=" + mAwakeEarly
+ + " mKeyguardDrawComplete=" + mKeyguardDrawComplete
+ " mWindowManagerDrawComplete=" + mWindowManagerDrawComplete);
- if (!mKeyguardDrawComplete || !mWindowManagerDrawComplete) {
- return;
- }
-
- ScreenOnListener screenOnListener;
+ boolean awake;
synchronized (mLock) {
- mScreenOnFully = true;
- screenOnListener = mScreenOnListener;
- mScreenOnListener = null;
- }
+ if ((mAwakeEarly && !mKeyguardDrawComplete)
+ || !mWindowManagerDrawComplete) {
+ return;
+ }
- try {
- mWindowManager.setEventDispatching(true);
- } catch (RemoteException unhandled) {
+ if (mAwakeEarly) {
+ mAwakeFully = true;
+ }
+ awake = mAwakeFully;
}
- if (screenOnListener != null) {
- screenOnListener.onScreenOn();
+ if (DEBUG_WAKEUP) Slog.i(TAG, "Finished screen turning on...");
+
+ if (mScreenOnListener != null) {
+ mScreenOnListener.onScreenOn();
+ mScreenOnListener = null;
}
- setKeyguardDrawn();
+ if (awake) {
+ setKeyguardDrawnFirstTime();
- if (mBootMessageNeedsHiding) {
- handleHideBootMessage();
- mBootMessageNeedsHiding = false;
+ if (mBootMessageNeedsHiding) {
+ handleHideBootMessage();
+ mBootMessageNeedsHiding = false;
+ }
}
}
@@ -4829,13 +4861,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
@Override
- public boolean isScreenOnEarly() {
- return mScreenOnEarly;
- }
-
- @Override
- public boolean isScreenOnFully() {
- return mScreenOnFully;
+ public boolean isAwake() {
+ return mAwakeFully;
}
/** {@inheritDoc} */
@@ -4909,7 +4936,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
- private void setKeyguardDrawn() {
+ private void setKeyguardDrawnFirstTime() {
synchronized (mLock) {
mKeyguardDrawn = true;
}
@@ -5222,7 +5249,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
synchronized (mLock) {
mSystemBooted = true;
}
- wakingUp(null);
+ wakingUp();
+ screenTurningOn(null);
}
ProgressDialog mBootMsgDialog = null;
@@ -5352,7 +5380,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private void updateLockScreenTimeout() {
synchronized (mScreenLockTimeout) {
- boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly &&
+ boolean enable = (mAllowLockscreenWhenOn && mAwakeEarly &&
mKeyguardDelegate != null && mKeyguardDelegate.isSecure());
if (mLockScreenTimerActive != enable) {
if (enable) {
@@ -5890,8 +5918,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior);
pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior);
pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput);
- pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly);
- pw.print(" mScreenOnFully="); pw.print(mScreenOnFully);
+ pw.print(prefix); pw.print("mAwakeEarly="); pw.print(mAwakeEarly);
+ pw.print(" mAwakeFully="); pw.print(mAwakeFully);
pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled);
pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft);
pw.print(","); pw.print(mOverscanScreenTop);