am 678c2e35: Merge change I9ef88863 into eclair
Merge commit '678c2e35768a5426b4ad8f67c836008e7751a353' into eclair-mr2 * commit '678c2e35768a5426b4ad8f67c836008e7751a353': Add WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR to indicate screen was turned off by the proximity sensor.
This commit is contained in:
@@ -361,6 +361,8 @@ public interface WindowManagerPolicy {
|
|||||||
public final int OFF_BECAUSE_OF_USER = 1;
|
public final int OFF_BECAUSE_OF_USER = 1;
|
||||||
/** Screen turned off because of timeout */
|
/** Screen turned off because of timeout */
|
||||||
public final int OFF_BECAUSE_OF_TIMEOUT = 2;
|
public final int OFF_BECAUSE_OF_TIMEOUT = 2;
|
||||||
|
/** Screen turned off because of proximity sensor */
|
||||||
|
public final int OFF_BECAUSE_OF_PROX_SENSOR = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic constant to {@link IWindowManager#setRotation} to not actually
|
* Magic constant to {@link IWindowManager#setRotation} to not actually
|
||||||
|
|||||||
@@ -161,7 +161,9 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
private int[] mBroadcastWhy = new int[3];
|
private int[] mBroadcastWhy = new int[3];
|
||||||
private int mPartialCount = 0;
|
private int mPartialCount = 0;
|
||||||
private int mPowerState;
|
private int mPowerState;
|
||||||
private boolean mOffBecauseOfUser;
|
// mScreenOffReason can be WindowManagerPolicy.OFF_BECAUSE_OF_USER,
|
||||||
|
// WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT or WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR
|
||||||
|
private int mScreenOffReason;
|
||||||
private int mUserState;
|
private int mUserState;
|
||||||
private boolean mKeyboardVisible = false;
|
private boolean mKeyboardVisible = false;
|
||||||
private boolean mUserActivityAllowed = true;
|
private boolean mUserActivityAllowed = true;
|
||||||
@@ -919,7 +921,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
+ " " + ((mNextTimeout-now)/1000) + "s from now");
|
+ " " + ((mNextTimeout-now)/1000) + "s from now");
|
||||||
pw.println(" mDimScreen=" + mDimScreen
|
pw.println(" mDimScreen=" + mDimScreen
|
||||||
+ " mStayOnConditions=" + mStayOnConditions);
|
+ " mStayOnConditions=" + mStayOnConditions);
|
||||||
pw.println(" mOffBecauseOfUser=" + mOffBecauseOfUser
|
pw.println(" mScreenOffReason=" + mScreenOffReason
|
||||||
+ " mUserState=" + mUserState);
|
+ " mUserState=" + mUserState);
|
||||||
pw.println(" mBroadcastQueue={" + mBroadcastQueue[0] + ',' + mBroadcastQueue[1]
|
pw.println(" mBroadcastQueue={" + mBroadcastQueue[0] + ',' + mBroadcastQueue[1]
|
||||||
+ ',' + mBroadcastQueue[2] + "}");
|
+ ',' + mBroadcastQueue[2] + "}");
|
||||||
@@ -1384,10 +1386,10 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
|
|
||||||
private void setPowerState(int state)
|
private void setPowerState(int state)
|
||||||
{
|
{
|
||||||
setPowerState(state, false, false);
|
setPowerState(state, false, WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPowerState(int newState, boolean noChangeLights, boolean becauseOfUser)
|
private void setPowerState(int newState, boolean noChangeLights, int reason)
|
||||||
{
|
{
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
int err;
|
int err;
|
||||||
@@ -1395,7 +1397,8 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
if (mSpew) {
|
if (mSpew) {
|
||||||
Log.d(TAG, "setPowerState: mPowerState=0x" + Integer.toHexString(mPowerState)
|
Log.d(TAG, "setPowerState: mPowerState=0x" + Integer.toHexString(mPowerState)
|
||||||
+ " newState=0x" + Integer.toHexString(newState)
|
+ " newState=0x" + Integer.toHexString(newState)
|
||||||
+ " noChangeLights=" + noChangeLights);
|
+ " noChangeLights=" + noChangeLights
|
||||||
|
+ " reason=" + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noChangeLights) {
|
if (noChangeLights) {
|
||||||
@@ -1489,7 +1492,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
mLastTouchDown = 0;
|
mLastTouchDown = 0;
|
||||||
mTotalTouchDownTime = 0;
|
mTotalTouchDownTime = 0;
|
||||||
mTouchCycles = 0;
|
mTouchCycles = 0;
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 1, becauseOfUser ? 1 : 0,
|
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 1, reason,
|
||||||
mTotalTouchDownTime, mTouchCycles);
|
mTotalTouchDownTime, mTouchCycles);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
mPowerState |= SCREEN_ON_BIT;
|
mPowerState |= SCREEN_ON_BIT;
|
||||||
@@ -1508,10 +1511,10 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
}
|
}
|
||||||
mPowerState &= ~SCREEN_ON_BIT;
|
mPowerState &= ~SCREEN_ON_BIT;
|
||||||
|
mScreenOffReason = reason;
|
||||||
if (!mScreenBrightness.animating) {
|
if (!mScreenBrightness.animating) {
|
||||||
err = screenOffFinishedAnimatingLocked(becauseOfUser);
|
err = screenOffFinishedAnimatingLocked(reason);
|
||||||
} else {
|
} else {
|
||||||
mOffBecauseOfUser = becauseOfUser;
|
|
||||||
err = 0;
|
err = 0;
|
||||||
mLastTouchDown = 0;
|
mLastTouchDown = 0;
|
||||||
}
|
}
|
||||||
@@ -1520,19 +1523,16 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int screenOffFinishedAnimatingLocked(boolean becauseOfUser) {
|
private int screenOffFinishedAnimatingLocked(int reason) {
|
||||||
// I don't think we need to check the current state here because all of these
|
// I don't think we need to check the current state here because all of these
|
||||||
// Power.setScreenState and sendNotificationLocked can both handle being
|
// Power.setScreenState and sendNotificationLocked can both handle being
|
||||||
// called multiple times in the same state. -joeo
|
// called multiple times in the same state. -joeo
|
||||||
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 0, becauseOfUser ? 1 : 0,
|
EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 0, reason, mTotalTouchDownTime, mTouchCycles);
|
||||||
mTotalTouchDownTime, mTouchCycles);
|
|
||||||
mLastTouchDown = 0;
|
mLastTouchDown = 0;
|
||||||
int err = setScreenStateLocked(false);
|
int err = setScreenStateLocked(false);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
int why = becauseOfUser
|
mScreenOffReason = reason;
|
||||||
? WindowManagerPolicy.OFF_BECAUSE_OF_USER
|
sendNotificationLocked(false, reason);
|
||||||
: WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT;
|
|
||||||
sendNotificationLocked(false, why);
|
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -1808,7 +1808,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
animating = more;
|
animating = more;
|
||||||
if (!more) {
|
if (!more) {
|
||||||
if (mask == SCREEN_BRIGHT_BIT && curIntValue == Power.BRIGHTNESS_OFF) {
|
if (mask == SCREEN_BRIGHT_BIT && curIntValue == Power.BRIGHTNESS_OFF) {
|
||||||
screenOffFinishedAnimatingLocked(mOffBecauseOfUser);
|
screenOffFinishedAnimatingLocked(mScreenOffReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return more;
|
return more;
|
||||||
@@ -1994,7 +1994,8 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
mWakeLockState = mLocks.reactivateScreenLocksLocked();
|
mWakeLockState = mLocks.reactivateScreenLocksLocked();
|
||||||
setPowerState(mUserState | mWakeLockState, noChangeLights, true);
|
setPowerState(mUserState | mWakeLockState, noChangeLights,
|
||||||
|
WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
||||||
setTimeoutLocked(time, SCREEN_BRIGHT);
|
setTimeoutLocked(time, SCREEN_BRIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2125,7 +2126,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
{
|
{
|
||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
|
||||||
synchronized (mLocks) {
|
synchronized (mLocks) {
|
||||||
goToSleepLocked(time);
|
goToSleepLocked(time, WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2143,7 +2144,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goToSleepLocked(long time) {
|
private void goToSleepLocked(long time, int reason) {
|
||||||
|
|
||||||
if (mLastEventTime <= time) {
|
if (mLastEventTime <= time) {
|
||||||
mLastEventTime = time;
|
mLastEventTime = time;
|
||||||
@@ -2161,7 +2162,7 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
EventLog.writeEvent(LOG_POWER_SLEEP_REQUESTED, numCleared);
|
EventLog.writeEvent(LOG_POWER_SLEEP_REQUESTED, numCleared);
|
||||||
mStillNeedSleepNotification = true;
|
mStillNeedSleepNotification = true;
|
||||||
mUserState = SCREEN_OFF;
|
mUserState = SCREEN_OFF;
|
||||||
setPowerState(SCREEN_OFF, false, true);
|
setPowerState(SCREEN_OFF, false, reason);
|
||||||
cancelTimerLocked();
|
cancelTimerLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2517,7 +2518,8 @@ class PowerManagerService extends IPowerManager.Stub
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (active) {
|
if (active) {
|
||||||
goToSleepLocked(SystemClock.uptimeMillis());
|
goToSleepLocked(SystemClock.uptimeMillis(),
|
||||||
|
WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR);
|
||||||
mProximitySensorActive = true;
|
mProximitySensorActive = true;
|
||||||
} else {
|
} else {
|
||||||
// proximity sensor negative events trigger as user activity.
|
// proximity sensor negative events trigger as user activity.
|
||||||
|
|||||||
Reference in New Issue
Block a user