Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00dcff88 authored by Sean Stout's avatar Sean Stout Committed by Android (Google) Code Review
Browse files

Merge "Enable per-DisplayGroup timeouts" into sc-dev

parents a070a64f 072eb8de
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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.
+27 −0
Original line number Diff line number Diff line
@@ -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;
+260 −185

File changed.

Preview size limit exceeded, changes collapsed.

+8 −0
Original line number Diff line number Diff line
@@ -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);