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

Commit 5c5f3b1b authored by Lucas Dupin's avatar Lucas Dupin Committed by Automerger Merge Worker
Browse files

Merge "Only act on event if something actually changed" into rvc-dev am: b80eb1ec am: 476a4e04

Change-Id: I4ea7c5f847a2f005ef63c0f3e7e7e9b207f38f7d
parents 1a489aee 476a4e04
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -75,6 +75,12 @@ public class DozeDockHandler implements DozeMachine.Part {
        public void onEvent(int dockState) {
            if (DEBUG) Log.d(TAG, "dock event = " + dockState);

            // Only act upon state changes, otherwise we might overwrite other transitions,
            // like proximity sensor initialization.
            if (mDockState == dockState) {
                return;
            }

            mDockState = dockState;
            if (isPulsing()) {
                return;
+12 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.doze;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -82,8 +83,17 @@ public class DozeDockHandlerTest extends SysuiTestCase {
        verify(mMachine).requestState(eq(State.DOZE_AOD_DOCKED));
    }

    @Test
    public void onEvent_noneWhileEnabledAod_ignoresIfAlreadyNone() {
        mDockManagerFake.setDockEvent(DockManager.STATE_NONE);

        verify(mMachine, never()).requestState(eq(State.DOZE_AOD));
    }

    @Test
    public void onEvent_noneWhileEnabledAod_requestsAodState() {
        mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED);
        clearInvocations(mMachine);
        mDockManagerFake.setDockEvent(DockManager.STATE_NONE);

        verify(mMachine).requestState(eq(State.DOZE_AOD));
@@ -91,6 +101,8 @@ public class DozeDockHandlerTest extends SysuiTestCase {

    @Test
    public void onEvent_noneWhileDisabledAod_requestsDozeState() {
        mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED);
        clearInvocations(mMachine);
        doReturn(false).when(mConfig).alwaysOnEnabled(anyInt());

        mDockManagerFake.setDockEvent(DockManager.STATE_NONE);