diff options
4 files changed, 301 insertions, 188 deletions
diff --git a/core/proto/android/server/powermanagerservice.proto b/core/proto/android/server/powermanagerservice.proto index 0d23946ebbb8..acb7429df5c3 100644 --- a/core/proto/android/server/powermanagerservice.proto +++ b/core/proto/android/server/powermanagerservice.proto @@ -58,6 +58,9 @@ message PowerManagerServiceDumpProto { optional bool is_screen_bright = 1; optional bool is_screen_dim = 2; optional bool is_screen_dream = 3; + optional int64 last_user_activity_time_ms = 4; + optional int64 last_user_activity_time_no_change_lights_ms = 5; + optional int32 display_group_id = 6; } // A com.android.server.power.PowerManagerService.UidState object. message UidStateProto { @@ -109,7 +112,7 @@ message PowerManagerServiceDumpProto { // The time we decided to do next long check. (In milliseconds timestamp) optional int64 notify_long_next_check_ms = 19; // Summarizes the effect of the user activity timer. - optional UserActivityProto user_activity = 20; + repeated UserActivityProto user_activity = 20; // If true, instructs the display controller to wait for the proximity // sensor to go negative before turning the screen on. optional bool is_request_wait_for_negative_proximity = 21; @@ -134,8 +137,8 @@ message PowerManagerServiceDumpProto { // Timestamp of the last time the device was put to sleep. optional int64 last_sleep_time_ms = 30; // Timestamp of the last call to user activity. - optional int64 last_user_activity_time_ms = 31; - optional int64 last_user_activity_time_no_change_lights_ms = 32; + optional int64 last_user_activity_time_ms = 31 [deprecated = true]; + optional int64 last_user_activity_time_no_change_lights_ms = 32 [deprecated = true]; // Timestamp of last interactive power hint. optional int64 last_interactive_power_hint_time_ms = 33; // Timestamp of the last screen brightness boost. diff --git a/services/core/java/com/android/server/power/DisplayGroupPowerStateMapper.java b/services/core/java/com/android/server/power/DisplayGroupPowerStateMapper.java index 2fcd178c3d15..9732eba33c22 100644 --- a/services/core/java/com/android/server/power/DisplayGroupPowerStateMapper.java +++ b/services/core/java/com/android/server/power/DisplayGroupPowerStateMapper.java @@ -248,6 +248,30 @@ public class DisplayGroupPowerStateMapper { return false; } + long getLastUserActivityTimeLocked(int groupId) { + return mDisplayGroupInfos.get(groupId).lastUserActivityTime; + } + + long getLastUserActivityTimeNoChangeLightsLocked(int groupId) { + return mDisplayGroupInfos.get(groupId).lastUserActivityTimeNoChangeLights; + } + + int getUserActivitySummaryLocked(int groupId) { + return mDisplayGroupInfos.get(groupId).userActivitySummary; + } + + void setLastUserActivityTimeLocked(int groupId, long time) { + mDisplayGroupInfos.get(groupId).lastUserActivityTime = time; + } + + void setLastUserActivityTimeNoChangeLightsLocked(int groupId, long time) { + mDisplayGroupInfos.get(groupId).lastUserActivityTimeNoChangeLights = time; + } + + void setUserActivitySummaryLocked(int groupId, int summary) { + mDisplayGroupInfos.get(groupId).userActivitySummary = summary; + } + /** * Interface through which an interested party may be informed of {@link DisplayGroup} events. */ @@ -265,6 +289,9 @@ public class DisplayGroupPowerStateMapper { public boolean ready; public long lastPowerOnTime; public boolean sandmanSummoned; + public long lastUserActivityTime; + public long lastUserActivityTimeNoChangeLights; + public int userActivitySummary; /** {@code true} if this DisplayGroup supports dreaming; otherwise {@code false}. */ public boolean supportsSandman; diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index d2a4cd604c01..54d5b7a8b67e 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -29,6 +29,7 @@ import static android.os.PowerManagerInternal.WAKEFULNESS_ASLEEP; import static android.os.PowerManagerInternal.WAKEFULNESS_AWAKE; import static android.os.PowerManagerInternal.WAKEFULNESS_DOZING; import static android.os.PowerManagerInternal.WAKEFULNESS_DREAMING; +import static android.os.PowerManagerInternal.wakefulnessToString; import android.annotation.IntDef; import android.annotation.NonNull; @@ -92,6 +93,7 @@ import android.util.SparseArray; import android.util.TimeUtils; import android.util.proto.ProtoOutputStream; import android.view.Display; +import android.view.DisplayInfo; import android.view.KeyEvent; import com.android.internal.annotations.GuardedBy; @@ -180,8 +182,8 @@ public final class PowerManagerService extends SystemService private static final int DIRTY_VR_MODE_CHANGED = 1 << 13; // Dirty bit: attentive timer may have timed out private static final int DIRTY_ATTENTIVE = 1 << 14; - // Dirty bit: display group power state has changed - private static final int DIRTY_DISPLAY_GROUP_POWER_UPDATED = 1 << 16; + // Dirty bit: display group wakefulness has changed + private static final int DIRTY_DISPLAY_GROUP_WAKEFULNESS = 1 << 16; // Summarizes the state of all active wakelocks. private static final int WAKE_LOCK_CPU = 1 << 0; @@ -338,10 +340,6 @@ public final class PowerManagerService extends SystemService private @WakeReason int mLastWakeReason; private int mLastSleepReason; - // Timestamp of the last call to user activity. - private long mLastUserActivityTime; - private long mLastUserActivityTimeNoChangeLights; - // Timestamp of last time power boost interaction was sent. private long mLastInteractivePowerHintTime; @@ -349,9 +347,6 @@ public final class PowerManagerService extends SystemService private long mLastScreenBrightnessBoostTime; private boolean mScreenBrightnessBoostInProgress; - // A bitfield that summarizes the effect of the user activity timer. - private int mUserActivitySummary; - // Manages the desired power state of displays. The actual state may lag behind the // requested because it is updated asynchronously by the display power controller. private DisplayGroupPowerStateMapper mDisplayGroupPowerStateMapper; @@ -634,6 +629,13 @@ public final class PowerManagerService extends SystemService public void onDisplayGroupEventLocked(int event, int groupId) { final int oldWakefulness = getWakefulnessLocked(); final int newWakefulness = mDisplayGroupPowerStateMapper.getGlobalWakefulnessLocked(); + + if (event == DISPLAY_GROUP_ADDED && newWakefulness == WAKEFULNESS_AWAKE) { + // Kick user activity to prevent newly added group from timing out instantly. + userActivityNoUpdateLocked(groupId, mClock.uptimeMillis(), + PowerManager.USER_ACTIVITY_EVENT_OTHER, /* flags= */ 0, Process.SYSTEM_UID); + } + if (oldWakefulness != newWakefulness) { final int reason; switch (newWakefulness) { @@ -656,7 +658,7 @@ public final class PowerManagerService extends SystemService mContext.getOpPackageName(), "groupId: " + groupId); } - mDirty |= DIRTY_DISPLAY_GROUP_POWER_UPDATED; + mDirty |= DIRTY_DISPLAY_GROUP_WAKEFULNESS; updatePowerStateLocked(); } } @@ -1059,6 +1061,10 @@ public final class PowerManagerService extends SystemService private void onFlip(boolean isFaceDown) { long millisUntilNormalTimeout = 0; synchronized (mLock) { + if (!mBootCompleted) { + return; + } + mIsFaceDown = isFaceDown; if (isFaceDown) { final long currentTime = mClock.uptimeMillis(); @@ -1066,8 +1072,9 @@ public final class PowerManagerService extends SystemService final long sleepTimeout = getSleepTimeoutLocked(-1L); final long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, -1L); millisUntilNormalTimeout = - mLastUserActivityTime + screenOffTimeout - mClock.uptimeMillis(); - userActivityInternal(mClock.uptimeMillis(), + mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked( + Display.DEFAULT_DISPLAY_GROUP) + screenOffTimeout - currentTime; + userActivityInternal(Display.DEFAULT_DISPLAY, currentTime, PowerManager.USER_ACTIVITY_EVENT_FACE_DOWN, /* flags= */0, Process.SYSTEM_UID); } @@ -1645,12 +1652,28 @@ public final class PowerManagerService extends SystemService // Called from native code. private void userActivityFromNative(long eventTime, int event, int displayId, int flags) { - userActivityInternal(eventTime, event, flags, Process.SYSTEM_UID); + userActivityInternal(displayId, eventTime, event, flags, Process.SYSTEM_UID); } - private void userActivityInternal(long eventTime, int event, int flags, int uid) { + private void userActivityInternal(int displayId, long eventTime, int event, int flags, + int uid) { synchronized (mLock) { - if (userActivityNoUpdateLocked(eventTime, event, flags, uid)) { + if (displayId == Display.INVALID_DISPLAY) { + if (userActivityNoUpdateLocked(eventTime, event, flags, uid)) { + updatePowerStateLocked(); + } + return; + } + + final DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(displayId); + if (displayInfo == null) { + return; + } + final int groupId = displayInfo.displayGroupId; + if (groupId == Display.INVALID_DISPLAY_GROUP) { + return; + } + if (userActivityNoUpdateLocked(groupId, eventTime, event, flags, uid)) { updatePowerStateLocked(); } } @@ -1658,7 +1681,7 @@ public final class PowerManagerService extends SystemService private void onUserAttention() { synchronized (mLock) { - if (userActivityNoUpdateLocked(mClock.uptimeMillis(), + if (userActivityNoUpdateLocked(Display.DEFAULT_DISPLAY_GROUP, mClock.uptimeMillis(), PowerManager.USER_ACTIVITY_EVENT_ATTENTION, 0 /* flags */, Process.SYSTEM_UID)) { updatePowerStateLocked(); @@ -1667,10 +1690,22 @@ public final class PowerManagerService extends SystemService } private boolean userActivityNoUpdateLocked(long eventTime, int event, int flags, int uid) { + boolean updatePowerState = false; + for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + if (userActivityNoUpdateLocked(id, eventTime, event, flags, uid)) { + updatePowerState = true; + } + } + + return updatePowerState; + } + + private boolean userActivityNoUpdateLocked(int groupId, long eventTime, int event, int flags, + int uid) { if (DEBUG_SPEW) { - Slog.d(TAG, "userActivityNoUpdateLocked: eventTime=" + eventTime - + ", event=" + event + ", flags=0x" + Integer.toHexString(flags) - + ", uid=" + uid); + Slog.d(TAG, "userActivityNoUpdateLocked: groupId=" + groupId + + ", eventTime=" + eventTime + ", event=" + event + + ", flags=0x" + Integer.toHexString(flags) + ", uid=" + uid); } if (eventTime < mLastSleepTime || eventTime < mLastWakeTime || !mSystemReady) { @@ -1692,8 +1727,9 @@ public final class PowerManagerService extends SystemService mOverriddenTimeout = -1; } - if (getWakefulnessLocked() == WAKEFULNESS_ASLEEP - || getWakefulnessLocked() == WAKEFULNESS_DOZING + final int wakefulness = mDisplayGroupPowerStateMapper.getWakefulnessLocked(groupId); + if (wakefulness == WAKEFULNESS_ASLEEP + || wakefulness == WAKEFULNESS_DOZING || (flags & PowerManager.USER_ACTIVITY_FLAG_INDIRECT) != 0) { return false; } @@ -1701,9 +1737,13 @@ public final class PowerManagerService extends SystemService maybeUpdateForegroundProfileLastActivityLocked(eventTime); if ((flags & PowerManager.USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS) != 0) { - if (eventTime > mLastUserActivityTimeNoChangeLights - && eventTime > mLastUserActivityTime) { - mLastUserActivityTimeNoChangeLights = eventTime; + if (eventTime + > mDisplayGroupPowerStateMapper.getLastUserActivityTimeNoChangeLightsLocked( + groupId) + && eventTime > mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked( + groupId)) { + mDisplayGroupPowerStateMapper.setLastUserActivityTimeNoChangeLightsLocked( + groupId, eventTime); mDirty |= DIRTY_USER_ACTIVITY; if (event == PowerManager.USER_ACTIVITY_EVENT_BUTTON) { mDirty |= DIRTY_QUIESCENT; @@ -1712,8 +1752,9 @@ public final class PowerManagerService extends SystemService return true; } } else { - if (eventTime > mLastUserActivityTime) { - mLastUserActivityTime = eventTime; + if (eventTime > mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked( + groupId)) { + mDisplayGroupPowerStateMapper.setLastUserActivityTimeLocked(groupId, eventTime); mDirty |= DIRTY_USER_ACTIVITY; if (event == PowerManager.USER_ACTIVITY_EVENT_BUTTON) { mDirty |= DIRTY_QUIESCENT; @@ -1778,7 +1819,6 @@ public final class PowerManagerService extends SystemService setWakefulnessLocked(groupId, WAKEFULNESS_AWAKE, eventTime, uid, reason, opUid, opPackageName, details); mDisplayGroupPowerStateMapper.setLastPowerOnTimeLocked(groupId, eventTime); - mDirty |= DIRTY_DISPLAY_GROUP_POWER_UPDATED; } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); } @@ -1829,7 +1869,6 @@ public final class PowerManagerService extends SystemService if ((flags & PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE) != 0) { reallySleepDisplayGroupNoUpdateLocked(groupId, eventTime, uid); } - mDirty |= DIRTY_DISPLAY_GROUP_POWER_UPDATED; } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); } @@ -1862,7 +1901,6 @@ public final class PowerManagerService extends SystemService mDisplayGroupPowerStateMapper.setSandmanSummoned(groupId, true); setWakefulnessLocked(groupId, WAKEFULNESS_DREAMING, eventTime, uid, /* reason= */ 0, /* opUid= */ 0, /* opPackageName= */ null, /* details= */ null); - mDirty |= DIRTY_DISPLAY_GROUP_POWER_UPDATED; } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); @@ -1890,7 +1928,6 @@ public final class PowerManagerService extends SystemService setWakefulnessLocked(groupId, WAKEFULNESS_ASLEEP, eventTime, uid, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, /* opUid= */ 0, /* opPackageName= */ null, /* details= */ null); - mDirty |= DIRTY_DISPLAY_GROUP_POWER_UPDATED; } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); } @@ -1901,8 +1938,14 @@ public final class PowerManagerService extends SystemService void setWakefulnessLocked(int groupId, int wakefulness, long eventTime, int uid, int reason, int opUid, String opPackageName, String details) { if (mDisplayGroupPowerStateMapper.setWakefulnessLocked(groupId, wakefulness)) { + mDirty |= DIRTY_DISPLAY_GROUP_WAKEFULNESS; setGlobalWakefulnessLocked(mDisplayGroupPowerStateMapper.getGlobalWakefulnessLocked(), eventTime, reason, uid, opUid, opPackageName, details); + if (wakefulness == WAKEFULNESS_AWAKE) { + // Kick user activity to prevent newly awake group from timing out instantly. + userActivityNoUpdateLocked( + groupId, eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, uid); + } } } @@ -1972,8 +2015,6 @@ public final class PowerManagerService extends SystemService switch (wakefulness) { case WAKEFULNESS_AWAKE: mNotifier.onWakeUp(reason, details, uid, opPackageName, opUid); - userActivityNoUpdateLocked( - eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, uid); if (sQuiescent) { mDirty |= DIRTY_QUIESCENT; } @@ -2163,8 +2204,9 @@ public final class PowerManagerService extends SystemService "android.server.power:PLUGGED:" + mIsPowered, Process.SYSTEM_UID, mContext.getOpPackageName(), Process.SYSTEM_UID); } - userActivityNoUpdateLocked( - now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); + + userActivityNoUpdateLocked(Display.DEFAULT_DISPLAY_GROUP, now, + PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); // only play charging sounds if boot is completed so charging sounds don't play // with potential notification sounds @@ -2407,106 +2449,123 @@ public final class PowerManagerService extends SystemService */ private void updateUserActivitySummaryLocked(long now, int dirty) { // Update the status of the user activity timeout timer. - if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY - | DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) != 0) { - mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT); - - long nextTimeout = 0; - if (getWakefulnessLocked() == WAKEFULNESS_AWAKE - || getWakefulnessLocked() == WAKEFULNESS_DREAMING - || getWakefulnessLocked() == WAKEFULNESS_DOZING) { - final long attentiveTimeout = getAttentiveTimeoutLocked(); - final long sleepTimeout = getSleepTimeoutLocked(attentiveTimeout); - long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, - attentiveTimeout); - final long screenDimDuration = getScreenDimDurationLocked(screenOffTimeout); - screenOffTimeout = - getScreenOffTimeoutWithFaceDownLocked(screenOffTimeout, screenDimDuration); - final boolean userInactiveOverride = mUserInactiveOverrideFromWindowManager; - final long nextProfileTimeout = getNextProfileTimeoutLocked(now); - - mUserActivitySummary = 0; - if (mLastUserActivityTime >= mLastWakeTime) { - nextTimeout = mLastUserActivityTime - + screenOffTimeout - screenDimDuration; - if (now < nextTimeout) { - mUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT; + if ((dirty & (DIRTY_DISPLAY_GROUP_WAKEFULNESS | DIRTY_WAKE_LOCKS + | DIRTY_USER_ACTIVITY | DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) == 0) { + return; + } + mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT); + + final long attentiveTimeout = getAttentiveTimeoutLocked(); + final long sleepTimeout = getSleepTimeoutLocked(attentiveTimeout); + long screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout, + attentiveTimeout); + final long screenDimDuration = getScreenDimDurationLocked(screenOffTimeout); + screenOffTimeout = + getScreenOffTimeoutWithFaceDownLocked(screenOffTimeout, screenDimDuration); + final boolean userInactiveOverride = mUserInactiveOverrideFromWindowManager; + long nextTimeout = -1; + boolean hasUserActivitySummary = false; + for (int groupId : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + int groupUserActivitySummary = 0; + long groupNextTimeout = 0; + if (mDisplayGroupPowerStateMapper.getWakefulnessLocked(groupId) != WAKEFULNESS_ASLEEP) { + final long lastUserActivityTime = + mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked(groupId); + final long lastUserActivityTimeNoChangeLights = + mDisplayGroupPowerStateMapper.getLastUserActivityTimeNoChangeLightsLocked( + groupId); + if (lastUserActivityTime >= mLastWakeTime) { + groupNextTimeout = lastUserActivityTime + screenOffTimeout - screenDimDuration; + if (now < groupNextTimeout) { + groupUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT; } else { - nextTimeout = mLastUserActivityTime + screenOffTimeout; - if (now < nextTimeout) { - mUserActivitySummary = USER_ACTIVITY_SCREEN_DIM; + groupNextTimeout = lastUserActivityTime + screenOffTimeout; + if (now < groupNextTimeout) { + groupUserActivitySummary = USER_ACTIVITY_SCREEN_DIM; } } } - if (mUserActivitySummary == 0 - && mLastUserActivityTimeNoChangeLights >= mLastWakeTime) { - nextTimeout = mLastUserActivityTimeNoChangeLights + screenOffTimeout; - if (now < nextTimeout) { + if (groupUserActivitySummary == 0 + && lastUserActivityTimeNoChangeLights >= mLastWakeTime) { + groupNextTimeout = lastUserActivityTimeNoChangeLights + screenOffTimeout; + if (now < groupNextTimeout) { final DisplayPowerRequest displayPowerRequest = - mDisplayGroupPowerStateMapper.getPowerRequestLocked( - Display.DEFAULT_DISPLAY_GROUP); + mDisplayGroupPowerStateMapper.getPowerRequestLocked(groupId); if (displayPowerRequest.policy == DisplayPowerRequest.POLICY_BRIGHT || displayPowerRequest.policy == DisplayPowerRequest.POLICY_VR) { - mUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT; + groupUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT; } else if (displayPowerRequest.policy == DisplayPowerRequest.POLICY_DIM) { - mUserActivitySummary = USER_ACTIVITY_SCREEN_DIM; + groupUserActivitySummary = USER_ACTIVITY_SCREEN_DIM; } } } - if (mUserActivitySummary == 0) { + if (groupUserActivitySummary == 0) { if (sleepTimeout >= 0) { - final long anyUserActivity = Math.max(mLastUserActivityTime, - mLastUserActivityTimeNoChangeLights); + final long anyUserActivity = Math.max(lastUserActivityTime, + lastUserActivityTimeNoChangeLights); if (anyUserActivity >= mLastWakeTime) { - nextTimeout = anyUserActivity + sleepTimeout; - if (now < nextTimeout) { - mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; + groupNextTimeout = anyUserActivity + sleepTimeout; + if (now < groupNextTimeout) { + groupUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; } } } else { - mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; - nextTimeout = -1; + groupUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; + groupNextTimeout = -1; } } - if (mUserActivitySummary != USER_ACTIVITY_SCREEN_DREAM && userInactiveOverride) { - if ((mUserActivitySummary & + if (groupUserActivitySummary != USER_ACTIVITY_SCREEN_DREAM + && userInactiveOverride) { + if ((groupUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0) { // Device is being kept awake by recent user activity - if (nextTimeout >= now && mOverriddenTimeout == -1) { + if (mOverriddenTimeout == -1) { // Save when the next timeout would have occurred - mOverriddenTimeout = nextTimeout; + mOverriddenTimeout = groupNextTimeout; } } - mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; - nextTimeout = -1; + groupUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; + groupNextTimeout = -1; } - if ((mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0 + if ((groupUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0 && (mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) == 0) { - nextTimeout = mAttentionDetector.updateUserActivity(nextTimeout, + groupNextTimeout = mAttentionDetector.updateUserActivity(groupNextTimeout, screenDimDuration); } - if (nextProfileTimeout > 0) { - nextTimeout = Math.min(nextTimeout, nextProfileTimeout); - } + hasUserActivitySummary |= groupUserActivitySummary != 0; - if (mUserActivitySummary != 0 && nextTimeout >= 0) { - scheduleUserInactivityTimeout(nextTimeout); + if (nextTimeout == -1) { + nextTimeout = groupNextTimeout; + } else if (groupNextTimeout != -1) { + nextTimeout = Math.min(nextTimeout, groupNextTimeout); } - } else { - mUserActivitySummary = 0; } + mDisplayGroupPowerStateMapper.setUserActivitySummaryLocked(groupId, + groupUserActivitySummary); + if (DEBUG_SPEW) { - Slog.d(TAG, "updateUserActivitySummaryLocked: mWakefulness=" - + PowerManagerInternal.wakefulnessToString(getWakefulnessLocked()) - + ", mUserActivitySummary=0x" + Integer.toHexString(mUserActivitySummary) - + ", nextTimeout=" + TimeUtils.formatUptime(nextTimeout)); + Slog.d(TAG, "updateUserActivitySummaryLocked: groupId=" + groupId + + ", mWakefulness=" + wakefulnessToString( + mDisplayGroupPowerStateMapper.getWakefulnessLocked(groupId)) + + ", mUserActivitySummary=0x" + Integer.toHexString( + groupUserActivitySummary) + + ", nextTimeout=" + TimeUtils.formatUptime(groupNextTimeout)); } } + + final long nextProfileTimeout = getNextProfileTimeoutLocked(now); + if (nextProfileTimeout > 0) { + nextTimeout = Math.min(nextTimeout, nextProfileTimeout); + } + + if (hasUserActivitySummary && nextTimeout >= 0) { + scheduleUserInactivityTimeout(nextTimeout); + } } private void scheduleUserInactivityTimeout(long timeMs) { @@ -2539,15 +2598,20 @@ public final class PowerManagerService extends SystemService private void updateAttentiveStateLocked(long now, int dirty) { long attentiveTimeout = getAttentiveTimeoutLocked(); - long goToSleepTime = mLastUserActivityTime + attentiveTimeout; + if (attentiveTimeout < 0) { + return; + } + // Attentive state only applies to the default display group. + long goToSleepTime = mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked( + Display.DEFAULT_DISPLAY_GROUP) + attentiveTimeout; long showWarningTime = goToSleepTime - mAttentiveWarningDurationConfig; boolean warningDismissed = maybeHideInattentiveSleepWarningLocked(now, showWarningTime); - if (attentiveTimeout >= 0 && (warningDismissed - || (dirty & (DIRTY_ATTENTIVE | DIRTY_STAY_ON | DIRTY_SCREEN_BRIGHTNESS_BOOST - | DIRTY_PROXIMITY_POSITIVE | DIRTY_WAKEFULNESS | DIRTY_BOOT_COMPLETED - | DIRTY_SETTINGS)) != 0)) { + if (warningDismissed || + (dirty & (DIRTY_ATTENTIVE | DIRTY_STAY_ON | DIRTY_SCREEN_BRIGHTNESS_BOOST + | DIRTY_PROXIMITY_POSITIVE | DIRTY_WAKEFULNESS | DIRTY_BOOT_COMPLETED + | DIRTY_SETTINGS)) != 0) { if (DEBUG_SPEW) { Slog.d(TAG, "Updating attentive state"); } @@ -2601,9 +2665,12 @@ public final class PowerManagerService extends SystemService return false; } - private boolean isAttentiveTimeoutExpired(long now) { + private boolean isAttentiveTimeoutExpired(int groupId, long now) { long attentiveTimeout = getAttentiveTimeoutLocked(); - return attentiveTimeout >= 0 && now >= mLastUserActivityTime + attentiveTimeout; + // Attentive state only applies to the default display group. + return groupId == Display.DEFAULT_DISPLAY_GROUP && attentiveTimeout >= 0 + && now >= mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked(groupId) + + attentiveTimeout; } /** @@ -2703,26 +2770,20 @@ public final class PowerManagerService extends SystemService | DIRTY_WAKEFULNESS | DIRTY_STAY_ON | DIRTY_PROXIMITY_POSITIVE | DIRTY_DOCK_STATE | DIRTY_ATTENTIVE | DIRTY_SETTINGS | DIRTY_SCREEN_BRIGHTNESS_BOOST)) != 0) { - if (getWakefulnessLocked() == WAKEFULNESS_AWAKE && isItBedTimeYetLocked()) { - if (DEBUG_SPEW) { - Slog.d(TAG, "updateWakefulnessLocked: Bed time..."); - } - final long time = mClock.uptimeMillis(); - if (isAttentiveTimeoutExpired(time)) { - // TODO (b/175764389): Support per-display timeouts. - for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + final long time = mClock.uptimeMillis(); + for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + if (mDisplayGroupPowerStateMapper.getWakefulnessLocked(id) == WAKEFULNESS_AWAKE + && isItBedTimeYetLocked(id)) { + if (DEBUG_SPEW) { + Slog.d(TAG, "updateWakefulnessLocked: Bed time for group " + id); + } + if (isAttentiveTimeoutExpired(id, time)) { changed = sleepDisplayGroupNoUpdateLocked(id, time, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE, Process.SYSTEM_UID); - } - } else if (shouldNapAtBedTimeLocked()) { - // TODO (b/175764389): Support per-display timeouts. - for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + } else if (shouldNapAtBedTimeLocked()) { changed = dreamDisplayGroupNoUpdateLocked(id, time, Process.SYSTEM_UID); - } - } else { - // TODO (b/175764389): Support per-display timeouts. - for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + } else { changed = sleepDisplayGroupNoUpdateLocked(id, time, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0, Process.SYSTEM_UID); } @@ -2743,51 +2804,50 @@ public final class PowerManagerService extends SystemService } /** - * Returns true if the device should go to sleep now. - * Also used when exiting a dream to determine whether we should go back - * to being fully awake or else go to sleep for good. + * Returns true if the DisplayGroup with the provided {@code groupId} should go to sleep now. + * Also used when exiting a dream to determine whether we should go back to being fully awake or + * else go to sleep for good. */ - private boolean isItBedTimeYetLocked() { + private boolean isItBedTimeYetLocked(int groupId) { if (!mBootCompleted) { return false; } long now = mClock.uptimeMillis(); - if (isAttentiveTimeoutExpired(now)) { - return !isBeingKeptFromInattentiveSleepLocked(); + if (isAttentiveTimeoutExpired(groupId, now)) { + return !isBeingKeptFromInattentiveSleepLocked(groupId); } else { - return !isBeingKeptAwakeLocked(); + return !isBeingKeptAwakeLocked(groupId); } } /** - * Returns true if the device is being kept awake by a wake lock, user activity - * or the stay on while powered setting. We also keep the phone awake when - * the proximity sensor returns a positive result so that the device does not - * lock while in a phone call. This function only controls whether the device - * will go to sleep or dream which is independent of whether it will be allowed - * to suspend. + * Returns true if the DisplayGroup with the provided {@code groupId} is being kept awake by a + * wake lock, user activity or the stay on while powered setting. We also keep the phone awake + * when the proximity sensor returns a positive result so that the device does not lock while in + * a phone call. This function only controls whether the device will go to sleep or dream which + * is independent of whether it will be allowed to suspend. */ - private boolean isBeingKeptAwakeLocked() { + private boolean isBeingKeptAwakeLocked(int groupId) { return mStayOn || mProximityPositive || (mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) != 0 - || (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT - | USER_ACTIVITY_SCREEN_DIM)) != 0 + || (mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(groupId) & ( + USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0 || mScreenBrightnessBoostInProgress; } /** - * Returns true if the device is prevented from going into inattentive sleep by the stay on - * while powered setting. We also keep the device awake when the proximity sensor returns a - * positive result so that the device does not lock while in a phone call. This function only - * controls whether the device will go to sleep which is independent of whether it will be - * allowed to suspend. + * Returns true if the DisplayGroup with the provided {@code groupId} is prevented from going + * into inattentive sleep by the stay on while powered setting. We also keep the device awake + * when the proximity sensor returns a positive result so that the device does not lock while in + * a phone call. This function only controls whether the device will go to sleep which is + * independent of whether it will be allowed to suspend. */ - private boolean isBeingKeptFromInattentiveSleepLocked() { + private boolean isBeingKeptFromInattentiveSleepLocked(int groupId) { return mStayOn || mScreenBrightnessBoostInProgress || mProximityPositive - || (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT - | USER_ACTIVITY_SCREEN_DIM)) != 0; + || (mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(groupId) & ( + USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0; } private boolean isBeingKeptFromShowingInattentiveSleepWarningLocked() { @@ -2902,7 +2962,7 @@ public final class PowerManagerService extends SystemService if (mDreamsBatteryLevelDrainCutoffConfig >= 0 && mBatteryLevel < mBatteryLevelWhenDreamStarted - mDreamsBatteryLevelDrainCutoffConfig - && !isBeingKeptAwakeLocked()) { + && !isBeingKeptAwakeLocked(groupId)) { // If the user activity timeout expired and the battery appears // to be draining faster than it is charging then stop dreaming // and go to sleep. @@ -2917,18 +2977,17 @@ public final class PowerManagerService extends SystemService } // Dream has ended or will be stopped. Update the power state. - if (isItBedTimeYetLocked()) { - final int flags = isAttentiveTimeoutExpired(now) + if (isItBedTimeYetLocked(groupId)) { + final int flags = isAttentiveTimeoutExpired(groupId, now) ? PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE : 0; sleepDisplayGroupNoUpdateLocked(groupId, now, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, flags, Process.SYSTEM_UID); - updatePowerStateLocked(); } else { wakeDisplayGroupNoUpdateLocked(groupId, now, PowerManager.WAKE_REASON_UNKNOWN, "android.server.power:DREAM_FINISHED", Process.SYSTEM_UID, mContext.getOpPackageName(), Process.SYSTEM_UID); - updatePowerStateLocked(); } + updatePowerStateLocked(); } else if (wakefulness == WAKEFULNESS_DOZING) { if (isDreaming) { return; // continue dozing @@ -2952,17 +3011,18 @@ public final class PowerManagerService extends SystemService private boolean canDreamLocked(int groupId) { final DisplayPowerRequest displayPowerRequest = mDisplayGroupPowerStateMapper.getPowerRequestLocked(groupId); - if (getWakefulnessLocked() != WAKEFULNESS_DREAMING + if (!mBootCompleted + || getWakefulnessLocked() != WAKEFULNESS_DREAMING || !mDreamsSupportedConfig || !mDreamsEnabledSetting || !displayPowerRequest.isBrightOrDim() || displayPowerRequest.isVr() - || (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT - | USER_ACTIVITY_SCREEN_DIM | USER_ACTIVITY_SCREEN_DREAM)) == 0 - || !mBootCompleted) { + || (mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(groupId) & ( + USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM + | USER_ACTIVITY_SCREEN_DREAM)) == 0) { return false; } - if (!isBeingKeptAwakeLocked()) { + if (!isBeingKeptAwakeLocked(groupId)) { if (!mIsPowered && !mDreamsEnabledOnBatteryConfig) { return false; } @@ -2971,11 +3031,9 @@ public final class PowerManagerService extends SystemService && mBatteryLevel < mDreamsBatteryLevelMinimumWhenNotPoweredConfig) { return false; } - if (mIsPowered - && mDreamsBatteryLevelMinimumWhenPoweredConfig >= 0 - && mBatteryLevel < mDreamsBatteryLevelMinimumWhenPoweredConfig) { - return false; - } + return !mIsPowered + || mDreamsBatteryLevelMinimumWhenPoweredConfig < 0 + || mBatteryLevel >= mDreamsBatteryLevelMinimumWhenPoweredConfig; } return true; } @@ -3002,7 +3060,7 @@ public final class PowerManagerService extends SystemService if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY | DIRTY_WAKEFULNESS | DIRTY_ACTUAL_DISPLAY_POWER_STATE_UPDATED | DIRTY_BOOT_COMPLETED | DIRTY_SETTINGS | DIRTY_SCREEN_BRIGHTNESS_BOOST | DIRTY_VR_MODE_CHANGED | - DIRTY_QUIESCENT | DIRTY_DISPLAY_GROUP_POWER_UPDATED)) != 0) { + DIRTY_QUIESCENT | DIRTY_DISPLAY_GROUP_WAKEFULNESS)) != 0) { if ((dirty & DIRTY_QUIESCENT) != 0) { if (mDisplayGroupPowerStateMapper.areAllDisplaysReadyLocked()) { sQuiescent = false; @@ -3072,7 +3130,7 @@ public final class PowerManagerService extends SystemService mDisplayGroupPowerStateMapper.getWakefulnessLocked(groupId)) + ", mWakeLockSummary=0x" + Integer.toHexString(mWakeLockSummary) + ", mUserActivitySummary=0x" + Integer.toHexString( - mUserActivitySummary) + mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(groupId)) + ", mBootCompleted=" + mBootCompleted + ", screenBrightnessOverride=" + displayPowerRequest.screenBrightnessOverride @@ -3156,8 +3214,9 @@ public final class PowerManagerService extends SystemService } if ((mWakeLockSummary & WAKE_LOCK_SCREEN_BRIGHT) != 0 - || (mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0 || !mBootCompleted + || (mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(groupId) + & USER_ACTIVITY_SCREEN_BRIGHT) != 0 || mScreenBrightnessBoostInProgress) { return DisplayPowerRequest.POLICY_BRIGHT; } @@ -3190,7 +3249,7 @@ public final class PowerManagerService extends SystemService synchronized (mLock) { mProximityPositive = false; mDirty |= DIRTY_PROXIMITY_POSITIVE; - userActivityNoUpdateLocked(mClock.uptimeMillis(), + userActivityNoUpdateLocked(Display.DEFAULT_DISPLAY_GROUP, mClock.uptimeMillis(), PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); updatePowerStateLocked(); } @@ -3758,7 +3817,7 @@ public final class PowerManagerService extends SystemService mScreenBrightnessBoostInProgress = true; mDirty |= DIRTY_SCREEN_BRIGHTNESS_BOOST; - userActivityNoUpdateLocked(eventTime, + userActivityNoUpdateLocked(Display.DEFAULT_DISPLAY_GROUP, eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, uid); updatePowerStateLocked(); } @@ -3863,14 +3922,16 @@ public final class PowerManagerService extends SystemService @VisibleForTesting boolean wasDeviceIdleForInternal(long ms) { synchronized (mLock) { - return mLastUserActivityTime + ms < mClock.uptimeMillis(); + return mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked( + Display.DEFAULT_DISPLAY_GROUP) + ms < mClock.uptimeMillis(); } } @VisibleForTesting void onUserActivity() { synchronized (mLock) { - mLastUserActivityTime = mClock.uptimeMillis(); + mDisplayGroupPowerStateMapper.setLastUserActivityTimeLocked( + Display.DEFAULT_DISPLAY_GROUP, mClock.uptimeMillis()); } } @@ -4024,7 +4085,6 @@ public final class PowerManagerService extends SystemService TimeUtils.formatDuration(mNotifyLongNextCheck, mClock.uptimeMillis(), pw); } pw.println(); - pw.println(" mUserActivitySummary=0x" + Integer.toHexString(mUserActivitySummary)); pw.println(" mRequestWaitForNegativeProximity=" + mRequestWaitForNegativeProximity); pw.println(" mSandmanScheduled=" + mSandmanScheduled); pw.println(" mBatteryLevelLow=" + mBatteryLevelLow); @@ -4035,9 +4095,6 @@ public final class PowerManagerService extends SystemService pw.println(" mLastWakeTime=" + TimeUtils.formatUptime(mLastWakeTime)); pw.println(" mLastSleepTime=" + TimeUtils.formatUptime(mLastSleepTime)); pw.println(" mLastSleepReason=" + PowerManager.sleepReasonToString(mLastSleepReason)); - pw.println(" mLastUserActivityTime=" + TimeUtils.formatUptime(mLastUserActivityTime)); - pw.println(" mLastUserActivityTimeNoChangeLights=" - + TimeUtils.formatUptime(mLastUserActivityTimeNoChangeLights)); pw.println(" mLastInteractivePowerHintTime=" + TimeUtils.formatUptime(mLastInteractivePowerHintTime)); pw.println(" mLastScreenBrightnessBoostTime=" @@ -4181,6 +4238,18 @@ public final class PowerManagerService extends SystemService pw.println(profile.mLockingNotified); } + pw.println("Display Group User Activity:"); + for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + pw.println(" displayGroupId=" + id); + pw.println(" userActivitySummary=0x" + Integer.toHexString( + mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(id))); + pw.println(" lastUserActivityTime=" + TimeUtils.formatUptime( + mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked(id))); + pw.println(" lastUserActivityTimeNoChangeLights=" + TimeUtils.formatUptime( + mDisplayGroupPowerStateMapper.getLastUserActivityTimeNoChangeLightsLocked( + id))); + } + wcd = mWirelessChargerDetector; } @@ -4266,17 +4335,27 @@ public final class PowerManagerService extends SystemService proto.write(PowerManagerServiceDumpProto.NOTIFY_LONG_DISPATCHED_MS, mNotifyLongDispatched); proto.write(PowerManagerServiceDumpProto.NOTIFY_LONG_NEXT_CHECK_MS, mNotifyLongNextCheck); - final long userActivityToken = proto.start(PowerManagerServiceDumpProto.USER_ACTIVITY); - proto.write( - PowerManagerServiceDumpProto.UserActivityProto.IS_SCREEN_BRIGHT, - (mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0); - proto.write( - PowerManagerServiceDumpProto.UserActivityProto.IS_SCREEN_DIM, - (mUserActivitySummary & USER_ACTIVITY_SCREEN_DIM) != 0); - proto.write( - PowerManagerServiceDumpProto.UserActivityProto.IS_SCREEN_DREAM, - (mUserActivitySummary & USER_ACTIVITY_SCREEN_DREAM) != 0); - proto.end(userActivityToken); + for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + final long userActivityToken = proto.start( + PowerManagerServiceDumpProto.USER_ACTIVITY); + proto.write(PowerManagerServiceDumpProto.UserActivityProto.DISPLAY_GROUP_ID, id); + final long userActivitySummary = + mDisplayGroupPowerStateMapper.getUserActivitySummaryLocked(id); + proto.write(PowerManagerServiceDumpProto.UserActivityProto.IS_SCREEN_BRIGHT, + (userActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0); + proto.write(PowerManagerServiceDumpProto.UserActivityProto.IS_SCREEN_DIM, + (userActivitySummary & USER_ACTIVITY_SCREEN_DIM) != 0); + proto.write(PowerManagerServiceDumpProto.UserActivityProto.IS_SCREEN_DREAM, + (userActivitySummary & USER_ACTIVITY_SCREEN_DREAM) != 0); + proto.write( + PowerManagerServiceDumpProto.UserActivityProto.LAST_USER_ACTIVITY_TIME_MS, + mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked(id)); + proto.write( + PowerManagerServiceDumpProto.UserActivityProto.LAST_USER_ACTIVITY_TIME_NO_CHANGE_LIGHTS_MS, + mDisplayGroupPowerStateMapper.getLastUserActivityTimeNoChangeLightsLocked( + id)); + proto.end(userActivityToken); + } proto.write( PowerManagerServiceDumpProto.IS_REQUEST_WAIT_FOR_NEGATIVE_PROXIMITY, @@ -4295,10 +4374,6 @@ public final class PowerManagerService extends SystemService proto.write(PowerManagerServiceDumpProto.LAST_WAKE_TIME_MS, mLastWakeTime); proto.write(PowerManagerServiceDumpProto.LAST_SLEEP_TIME_MS, mLastSleepTime); - proto.write(PowerManagerServiceDumpProto.LAST_USER_ACTIVITY_TIME_MS, mLastUserActivityTime); - proto.write( - PowerManagerServiceDumpProto.LAST_USER_ACTIVITY_TIME_NO_CHANGE_LIGHTS_MS, - mLastUserActivityTimeNoChangeLights); proto.write( PowerManagerServiceDumpProto.LAST_INTERACTIVE_POWER_HINT_TIME_MS, mLastInteractivePowerHintTime); @@ -5102,7 +5177,7 @@ public final class PowerManagerService extends SystemService final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { - userActivityInternal(eventTime, event, flags, uid); + userActivityInternal(displayId, eventTime, event, flags, uid); } finally { Binder.restoreCallingIdentity(ident); } diff --git a/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java index 6e5fbd0b6ed0..2df6c5ab80e8 100644 --- a/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/power/PowerManagerServiceTest.java @@ -71,6 +71,7 @@ import android.provider.Settings; import android.service.dreams.DreamManagerInternal; import android.test.mock.MockContentResolver; import android.view.Display; +import android.view.DisplayInfo; import androidx.test.InstrumentationRegistry; @@ -594,6 +595,8 @@ public class PowerManagerServiceTest { public void testWasDeviceIdleFor_true() { int interval = 1000; createService(); + mService.systemReady(null); + mService.onBootPhase(SystemService.PHASE_BOOT_COMPLETED); mService.onUserActivity(); advanceTime(interval + 1 /* just a little more */); assertThat(mService.wasDeviceIdleForInternal(interval)).isTrue(); @@ -603,6 +606,8 @@ public class PowerManagerServiceTest { public void testWasDeviceIdleFor_false() { int interval = 1000; createService(); + mService.systemReady(null); + mService.onBootPhase(SystemService.PHASE_BOOT_COMPLETED); mService.onUserActivity(); assertThat(mService.wasDeviceIdleForInternal(interval)).isFalse(); } @@ -757,6 +762,9 @@ public class PowerManagerServiceTest { @Test public void testInattentiveSleep_userActivityDismissesWarning() throws Exception { + final DisplayInfo info = new DisplayInfo(); + info.displayGroupId = Display.DEFAULT_DISPLAY_GROUP; + when(mDisplayManagerInternalMock.getDisplayInfo(Display.DEFAULT_DISPLAY)).thenReturn(info); setMinimumScreenOffTimeoutConfig(5); setAttentiveWarningDuration(1900); setAttentiveTimeout(2000); |