Merge "Fix dim duration on flip to screen off." into sc-dev

This commit is contained in:
Brian Quezada
2021-03-11 19:52:40 +00:00
committed by Android (Google) Code Review
4 changed files with 18 additions and 9 deletions

View File

@@ -322,6 +322,13 @@ public final class PowerManager {
*/ */
public static final int USER_ACTIVITY_EVENT_ATTENTION = 4; public static final int USER_ACTIVITY_EVENT_ATTENTION = 4;
/**
* User activity event type: {@link com.android.server.power.FaceDownDetector} taking action
* on behalf of user.
* @hide
*/
public static final int USER_ACTIVITY_EVENT_FACE_DOWN = 5;
/** /**
* User activity flag: If already dimmed, extend the dim timeout * User activity flag: If already dimmed, extend the dim timeout
* but do not brighten. This flag is useful for keeping the screen on * but do not brighten. This flag is useful for keeping the screen on

View File

@@ -291,8 +291,10 @@ public class FaceDownDetector implements SensorEventListener {
* The user interacted with the screen while face down, indicated the phone is in use. * The user interacted with the screen while face down, indicated the phone is in use.
* We log this event and temporarily make this detector inactive. * We log this event and temporarily make this detector inactive.
*/ */
public void userActivity() { public void userActivity(int event) {
mHandler.post(mUserActivityRunnable); if (event != PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN) {
mHandler.post(mUserActivityRunnable);
}
} }
private void exitFaceDown(int resultType, long millisSinceFlip) { private void exitFaceDown(int resultType, long millisSinceFlip) {

View File

@@ -549,6 +549,7 @@ public class Notifier {
if (!mUserActivityPending) { if (!mUserActivityPending) {
mUserActivityPending = true; mUserActivityPending = true;
Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY); Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY);
msg.arg1 = event;
msg.setAsynchronous(true); msg.setAsynchronous(true);
mHandler.sendMessage(msg); mHandler.sendMessage(msg);
} }
@@ -647,7 +648,7 @@ public class Notifier {
mSuspendBlocker.release(); mSuspendBlocker.release();
} }
private void sendUserActivity() { private void sendUserActivity(int event) {
synchronized (mLock) { synchronized (mLock) {
if (!mUserActivityPending) { if (!mUserActivityPending) {
return; return;
@@ -657,7 +658,7 @@ public class Notifier {
TelephonyManager tm = mContext.getSystemService(TelephonyManager.class); TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
tm.notifyUserActivity(); tm.notifyUserActivity();
mPolicy.userActivity(); mPolicy.userActivity();
mFaceDownDetector.userActivity(); mFaceDownDetector.userActivity(event);
} }
void postEnhancedDischargePredictionBroadcast(long delayMs) { void postEnhancedDischargePredictionBroadcast(long delayMs) {
@@ -833,7 +834,7 @@ public class Notifier {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
switch (msg.what) { switch (msg.what) {
case MSG_USER_ACTIVITY: case MSG_USER_ACTIVITY:
sendUserActivity(); sendUserActivity(msg.arg1);
break; break;
case MSG_BROADCAST: case MSG_BROADCAST:
sendNextBroadcast(); sendNextBroadcast();

View File

@@ -180,8 +180,6 @@ public final class PowerManagerService extends SystemService
private static final int DIRTY_VR_MODE_CHANGED = 1 << 13; private static final int DIRTY_VR_MODE_CHANGED = 1 << 13;
// Dirty bit: attentive timer may have timed out // Dirty bit: attentive timer may have timed out
private static final int DIRTY_ATTENTIVE = 1 << 14; private static final int DIRTY_ATTENTIVE = 1 << 14;
// Dirty bit: phone flipped to face down
private static final int DIRTY_FACE_DOWN = 1 << 15;
// Dirty bit: display group power state has changed // Dirty bit: display group power state has changed
private static final int DIRTY_DISPLAY_GROUP_POWER_UPDATED = 1 << 16; private static final int DIRTY_DISPLAY_GROUP_POWER_UPDATED = 1 << 16;
@@ -1069,8 +1067,9 @@ public final class PowerManagerService extends SystemService
final long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, -1L); final long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, -1L);
millisUntilNormalTimeout = millisUntilNormalTimeout =
mLastUserActivityTime + screenOffTimeout - mClock.uptimeMillis(); mLastUserActivityTime + screenOffTimeout - mClock.uptimeMillis();
mDirty |= DIRTY_FACE_DOWN; userActivityInternal(mClock.uptimeMillis(),
updatePowerStateLocked(); PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN, /* flags= */0,
Process.SYSTEM_UID);
} }
} }
if (isFaceDown) { if (isFaceDown) {