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

Commit c176e771 authored by Robert Horvath's avatar Robert Horvath Committed by Automerger Merge Worker
Browse files

Merge "Dismiss Inattentive Sleep Warning when inattentive sleep is disabled"...

Merge "Dismiss Inattentive Sleep Warning when inattentive sleep is disabled" into sc-dev am: 4c7368f7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15080841

Change-Id: I441a7ea98145ce40c6d5931f65034d2cf0826137
parents 5b87d0cc 4c7368f7
Loading
Loading
Loading
Loading
+6 −8
Original line number Original line Diff line number Diff line
@@ -1344,7 +1344,8 @@ public final class PowerManagerService extends SystemService
        mDirty |= DIRTY_SETTINGS;
        mDirty |= DIRTY_SETTINGS;
    }
    }


    private void handleSettingsChangedLocked() {
    @VisibleForTesting
    void handleSettingsChangedLocked() {
        updateSettingsLocked();
        updateSettingsLocked();
        updatePowerStateLocked();
        updatePowerStateLocked();
    }
    }
@@ -2651,9 +2652,6 @@ public final class PowerManagerService extends SystemService


    private void updateAttentiveStateLocked(long now, int dirty) {
    private void updateAttentiveStateLocked(long now, int dirty) {
        long attentiveTimeout = getAttentiveTimeoutLocked();
        long attentiveTimeout = getAttentiveTimeoutLocked();
        if (attentiveTimeout < 0) {
            return;
        }
        // Attentive state only applies to the default display group.
        // Attentive state only applies to the default display group.
        long goToSleepTime = mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked(
        long goToSleepTime = mDisplayGroupPowerStateMapper.getLastUserActivityTimeLocked(
                Display.DEFAULT_DISPLAY_GROUP) + attentiveTimeout;
                Display.DEFAULT_DISPLAY_GROUP) + attentiveTimeout;
@@ -2661,10 +2659,10 @@ public final class PowerManagerService extends SystemService


        boolean warningDismissed = maybeHideInattentiveSleepWarningLocked(now, showWarningTime);
        boolean warningDismissed = maybeHideInattentiveSleepWarningLocked(now, showWarningTime);


        if (warningDismissed ||
        if (attentiveTimeout >= 0 && (warningDismissed
                (dirty & (DIRTY_ATTENTIVE | DIRTY_STAY_ON | DIRTY_SCREEN_BRIGHTNESS_BOOST
                || (dirty & (DIRTY_ATTENTIVE | DIRTY_STAY_ON | DIRTY_SCREEN_BRIGHTNESS_BOOST
                | DIRTY_PROXIMITY_POSITIVE | DIRTY_WAKEFULNESS | DIRTY_BOOT_COMPLETED
                | DIRTY_PROXIMITY_POSITIVE | DIRTY_WAKEFULNESS | DIRTY_BOOT_COMPLETED
                        | DIRTY_SETTINGS)) != 0) {
                | DIRTY_SETTINGS)) != 0)) {
            if (DEBUG_SPEW) {
            if (DEBUG_SPEW) {
                Slog.d(TAG, "Updating attentive state");
                Slog.d(TAG, "Updating attentive state");
            }
            }
+19 −0
Original line number Original line Diff line number Diff line
@@ -760,6 +760,25 @@ public class PowerManagerServiceTest {
        verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).dismiss(true);
        verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).dismiss(true);
    }
    }


    @Test
    public void testInattentiveSleep_hideWarningIfInattentiveSleepIsDisabled() throws Exception {
        setMinimumScreenOffTimeoutConfig(5);
        setAttentiveWarningDuration(120);
        setAttentiveTimeout(100);

        createService();
        startSystem();

        verify(mInattentiveSleepWarningControllerMock, times(1)).show();
        verify(mInattentiveSleepWarningControllerMock, never()).dismiss(anyBoolean());
        when(mInattentiveSleepWarningControllerMock.isShown()).thenReturn(true);

        setAttentiveTimeout(-1);
        mService.handleSettingsChangedLocked();

        verify(mInattentiveSleepWarningControllerMock, atLeastOnce()).dismiss(true);
    }

    @Test
    @Test
    public void testInattentiveSleep_userActivityDismissesWarning() throws Exception {
    public void testInattentiveSleep_userActivityDismissesWarning() throws Exception {
        final DisplayInfo info = new DisplayInfo();
        final DisplayInfo info = new DisplayInfo();