Loading packages/SystemUI/aconfig/systemui.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -35,16 +35,6 @@ flag { } } flag { name: "remove_aod_car_mode" namespace: "systemui" description: "Remove functionality of car mode disabling AOD." bug: "297462331" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "user_encrypted_source" namespace: "systemui" Loading packages/SystemUI/multivalentTests/src/com/android/systemui/doze/DozeMachineTest.java +2 −110 Original line number Diff line number Diff line Loading @@ -16,16 +16,12 @@ package com.android.systemui.doze; import static android.content.res.Configuration.UI_MODE_NIGHT_YES; import static android.content.res.Configuration.UI_MODE_TYPE_CAR; import static com.android.systemui.doze.DozeMachine.State.DOZE; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_DOCKED; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_MINMODE; import static com.android.systemui.doze.DozeMachine.State.DOZE_PULSE_DONE; import static com.android.systemui.doze.DozeMachine.State.DOZE_PULSING; import static com.android.systemui.doze.DozeMachine.State.DOZE_PULSING_BRIGHT; import static com.android.systemui.doze.DozeMachine.State.DOZE_REQUEST_PULSE; import static com.android.systemui.doze.DozeMachine.State.DOZE_SUSPEND_TRIGGERS; import static com.android.systemui.doze.DozeMachine.State.FINISH; Loading @@ -42,18 +38,14 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.content.res.Configuration; import android.hardware.display.AmbientDisplayConfiguration; import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.DisableFlags; import android.view.Display; import androidx.annotation.NonNull; import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; Loading @@ -67,13 +59,14 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.wakelock.WakeLockFake; import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.Optional; @SmallTest @RunWith(AndroidJUnit4.class) @UiThreadTest Loading Loading @@ -516,109 +509,8 @@ public class DozeMachineTest extends SysuiTestCase { assertEquals(Display.STATE_ON, DOZE_REQUEST_PULSE.screenState(dozeParameters)); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testTransitionToInitialized_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); verify(mPartMock).transitionTo(UNINITIALIZED, INITIALIZED); verify(mPartMock).transitionTo(INITIALIZED, DOZE_SUSPEND_TRIGGERS); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testTransitionToFinish_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(FINISH); assertEquals(FINISH, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeToDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeAoDToDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_AOD); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozePulsingBrightDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_PULSING_BRIGHT); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeAodDockedDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_AOD_DOCKED); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test public void testOnConfigurationChanged_propagatesUiModeTypeToParts() { Configuration newConfig = configWithCarNightUiMode(); mMachine.onConfigurationChanged(newConfig); verify(mPartMock).onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mAnotherPartMock).onUiModeTypeChanged(UI_MODE_TYPE_CAR); } @Test public void testOnConfigurationChanged_propagatesOnlyUiModeChangesToParts() { Configuration newConfig = configWithCarNightUiMode(); mMachine.onConfigurationChanged(newConfig); mMachine.onConfigurationChanged(newConfig); verify(mPartMock, times(1)).onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mAnotherPartMock, times(1)).onUiModeTypeChanged(UI_MODE_TYPE_CAR); } @Test public void testDozeSuppressTriggers_screenState() { assertEquals(Display.STATE_OFF, DOZE_SUSPEND_TRIGGERS.screenState(null)); } @NonNull private Configuration configWithCarNightUiMode() { Configuration configuration = Configuration.EMPTY; configuration.uiMode = UI_MODE_TYPE_CAR | UI_MODE_NIGHT_YES; return configuration; } } packages/SystemUI/multivalentTests/src/com/android/systemui/doze/DozeSuppressorTest.java +0 −110 Original line number Diff line number Diff line Loading @@ -16,35 +16,24 @@ package com.android.systemui.doze; import static android.content.res.Configuration.UI_MODE_TYPE_CAR; import static android.content.res.Configuration.UI_MODE_TYPE_NORMAL; import static com.android.systemui.doze.DozeMachine.State.DOZE; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD; import static com.android.systemui.doze.DozeMachine.State.DOZE_SUSPEND_TRIGGERS; import static com.android.systemui.doze.DozeMachine.State.FINISH; import static com.android.systemui.doze.DozeMachine.State.INITIALIZED; import static com.android.systemui.doze.DozeMachine.State.UNINITIALIZED; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.hardware.display.AmbientDisplayConfiguration; import android.platform.test.annotations.DisableFlags; import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.systemui.Flags; import com.android.systemui.SysuiTestCase; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.phone.BiometricUnlockController; Loading @@ -55,7 +44,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.AdditionalMatchers; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; Loading Loading @@ -123,104 +111,6 @@ public class DozeSuppressorTest extends SysuiTestCase { verify(mDozeHost).removeCallback(mDozeHostCallback); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testSuspendTriggersDoze_carMode() { // GIVEN car mode mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); // WHEN dozing begins mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); // THEN doze continues with all doze triggers disabled. verify(mDozeMachine, atLeastOnce()).requestState(DOZE_SUSPEND_TRIGGERS); verify(mDozeMachine, never()) .requestState(AdditionalMatchers.not(eq(DOZE_SUSPEND_TRIGGERS))); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testSuspendTriggersDoze_enterCarMode() { // GIVEN currently dozing mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); mDozeSuppressor.transitionTo(INITIALIZED, DOZE); // WHEN car mode entered mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); // THEN doze continues with all doze triggers disabled. verify(mDozeMachine).requestState(DOZE_SUSPEND_TRIGGERS); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeResume_exitCarMode() { // GIVEN currently suspended, with AOD not enabled mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false); mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); mDozeSuppressor.transitionTo(INITIALIZED, DOZE_SUSPEND_TRIGGERS); // WHEN exiting car mode mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_NORMAL); // THEN doze is resumed verify(mDozeMachine).requestState(DOZE); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeAoDResume_exitCarMode() { // GIVEN currently suspended, with AOD not enabled mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(true); mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); mDozeSuppressor.transitionTo(INITIALIZED, DOZE_SUSPEND_TRIGGERS); // WHEN exiting car mode mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_NORMAL); // THEN doze AOD is resumed verify(mDozeMachine).requestState(DOZE_AOD); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testUiModeDoesNotChange_noStateTransition() { mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); clearInvocations(mDozeMachine); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mDozeMachine, times(1)).requestState(DOZE_SUSPEND_TRIGGERS); verify(mDozeMachine, never()) .requestState(AdditionalMatchers.not(eq(DOZE_SUSPEND_TRIGGERS))); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testUiModeTypeChange_whenDozeMachineIsNotReady_doesNotDoAnything() { when(mDozeMachine.isUninitializedOrFinished()).thenReturn(true); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mDozeMachine, never()).requestState(any()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testUiModeTypeChange_CarModeEnabledAndDozeMachineNotReady_suspendsTriggersAfter() { when(mDozeMachine.isUninitializedOrFinished()).thenReturn(true); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mDozeMachine, never()).requestState(any()); mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); verify(mDozeMachine, times(1)).requestState(DOZE_SUSPEND_TRIGGERS); } @Test public void testEndDoze_unprovisioned() { // GIVEN device unprovisioned Loading packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +0 −14 Original line number Diff line number Diff line Loading @@ -409,20 +409,6 @@ public class DozeLog implements Dumpable { mLogger.logImmediatelyEndDoze(reason); } /** * Logs the car mode started event. */ public void traceCarModeStarted() { mLogger.logCarModeStarted(); } /** * Logs the car mode ended event. */ public void traceCarModeEnded() { mLogger.logCarModeEnded(); } /** * Appends power save changes that may cause a new doze state * @param powerSaveActive true if power saving is active Loading packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +1 −39 Original line number Diff line number Diff line Loading @@ -16,13 +16,11 @@ package com.android.systemui.doze; import static com.android.systemui.Flags.removeAodCarMode; import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE; import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING; import android.annotation.MainThread; import android.annotation.Nullable; import android.content.res.Configuration; import android.hardware.display.AmbientDisplayConfiguration; import android.util.Log; import android.view.Display; Loading Loading @@ -180,7 +178,6 @@ public class DozeMachine { private State mState = State.UNINITIALIZED; private int mPulseReason; private boolean mWakeLockHeldForCurrentState = false; private int mUiModeType = Configuration.UI_MODE_TYPE_NORMAL; @Inject public DozeMachine(@WrappedService Service service, Loading Loading @@ -212,18 +209,6 @@ public class DozeMachine { } } /** * Notifies the {@link DozeMachine} that {@link Configuration} has changed. */ public void onConfigurationChanged(Configuration newConfiguration) { int newUiModeType = newConfiguration.uiMode & Configuration.UI_MODE_TYPE_MASK; if (mUiModeType == newUiModeType) return; mUiModeType = newUiModeType; for (Part part : mParts) { part.onUiModeTypeChanged(mUiModeType); } } /** * Requests transitioning to {@code requestedState}. * Loading Loading @@ -421,16 +406,7 @@ public class DozeMachine { if (mState == State.FINISH) { return State.FINISH; } if (mUiModeType == Configuration.UI_MODE_TYPE_CAR && (requestedState.canPulse() || requestedState.staysAwake())) { if (removeAodCarMode()) { Log.d(TAG, "skip applying car mode"); } else { Log.i(TAG, "Doze is suppressed with all triggers disabled as car mode is active"); mDozeLog.traceCarModeStarted(); return State.DOZE_SUSPEND_TRIGGERS; } } if (mDozeHost.isAlwaysOnSuppressed() && requestedState.isAlwaysOn()) { Log.i(TAG, "Doze is suppressed by an app. Suppressing state: " + requestedState); mDozeLog.traceAlwaysOnSuppressed(requestedState, "app"); Loading Loading @@ -498,7 +474,6 @@ public class DozeMachine { /** Dumps the current state */ public void dump(PrintWriter pw) { pw.print(" state="); pw.println(mState); pw.print(" mUiModeType="); pw.println(mUiModeType); pw.print(" wakeLockHeldForCurrentState="); pw.println(mWakeLockHeldForCurrentState); pw.print(" wakeLock="); pw.println(mWakeLock); pw.println("Parts:"); Loading Loading @@ -531,19 +506,6 @@ public class DozeMachine { /** Sets the {@link DozeMachine} when this Part is associated with one. */ default void setDozeMachine(DozeMachine dozeMachine) {} /** * Notifies the Part about a change in {@link Configuration#uiMode}. * * @param newUiModeType {@link Configuration#UI_MODE_TYPE_NORMAL}, * {@link Configuration#UI_MODE_TYPE_DESK}, * {@link Configuration#UI_MODE_TYPE_CAR}, * {@link Configuration#UI_MODE_TYPE_TELEVISION}, * {@link Configuration#UI_MODE_TYPE_APPLIANCE}, * {@link Configuration#UI_MODE_TYPE_WATCH}, * or {@link Configuration#UI_MODE_TYPE_VR_HEADSET} */ default void onUiModeTypeChanged(int newUiModeType) {} } /** A wrapper interface for {@link android.service.dreams.DreamService} */ Loading Loading
packages/SystemUI/aconfig/systemui.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -35,16 +35,6 @@ flag { } } flag { name: "remove_aod_car_mode" namespace: "systemui" description: "Remove functionality of car mode disabling AOD." bug: "297462331" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "user_encrypted_source" namespace: "systemui" Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/doze/DozeMachineTest.java +2 −110 Original line number Diff line number Diff line Loading @@ -16,16 +16,12 @@ package com.android.systemui.doze; import static android.content.res.Configuration.UI_MODE_NIGHT_YES; import static android.content.res.Configuration.UI_MODE_TYPE_CAR; import static com.android.systemui.doze.DozeMachine.State.DOZE; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_DOCKED; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_MINMODE; import static com.android.systemui.doze.DozeMachine.State.DOZE_PULSE_DONE; import static com.android.systemui.doze.DozeMachine.State.DOZE_PULSING; import static com.android.systemui.doze.DozeMachine.State.DOZE_PULSING_BRIGHT; import static com.android.systemui.doze.DozeMachine.State.DOZE_REQUEST_PULSE; import static com.android.systemui.doze.DozeMachine.State.DOZE_SUSPEND_TRIGGERS; import static com.android.systemui.doze.DozeMachine.State.FINISH; Loading @@ -42,18 +38,14 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.content.res.Configuration; import android.hardware.display.AmbientDisplayConfiguration; import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.DisableFlags; import android.view.Display; import androidx.annotation.NonNull; import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; Loading @@ -67,13 +59,14 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.wakelock.WakeLockFake; import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.Optional; @SmallTest @RunWith(AndroidJUnit4.class) @UiThreadTest Loading Loading @@ -516,109 +509,8 @@ public class DozeMachineTest extends SysuiTestCase { assertEquals(Display.STATE_ON, DOZE_REQUEST_PULSE.screenState(dozeParameters)); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testTransitionToInitialized_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); verify(mPartMock).transitionTo(UNINITIALIZED, INITIALIZED); verify(mPartMock).transitionTo(INITIALIZED, DOZE_SUSPEND_TRIGGERS); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testTransitionToFinish_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(FINISH); assertEquals(FINISH, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeToDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeAoDToDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_AOD); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozePulsingBrightDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_PULSING_BRIGHT); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeAodDockedDozeSuspendTriggers_carModeIsEnabled() { Configuration configuration = configWithCarNightUiMode(); mMachine.onConfigurationChanged(configuration); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_AOD_DOCKED); assertEquals(DOZE_SUSPEND_TRIGGERS, mMachine.getState()); } @Test public void testOnConfigurationChanged_propagatesUiModeTypeToParts() { Configuration newConfig = configWithCarNightUiMode(); mMachine.onConfigurationChanged(newConfig); verify(mPartMock).onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mAnotherPartMock).onUiModeTypeChanged(UI_MODE_TYPE_CAR); } @Test public void testOnConfigurationChanged_propagatesOnlyUiModeChangesToParts() { Configuration newConfig = configWithCarNightUiMode(); mMachine.onConfigurationChanged(newConfig); mMachine.onConfigurationChanged(newConfig); verify(mPartMock, times(1)).onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mAnotherPartMock, times(1)).onUiModeTypeChanged(UI_MODE_TYPE_CAR); } @Test public void testDozeSuppressTriggers_screenState() { assertEquals(Display.STATE_OFF, DOZE_SUSPEND_TRIGGERS.screenState(null)); } @NonNull private Configuration configWithCarNightUiMode() { Configuration configuration = Configuration.EMPTY; configuration.uiMode = UI_MODE_TYPE_CAR | UI_MODE_NIGHT_YES; return configuration; } }
packages/SystemUI/multivalentTests/src/com/android/systemui/doze/DozeSuppressorTest.java +0 −110 Original line number Diff line number Diff line Loading @@ -16,35 +16,24 @@ package com.android.systemui.doze; import static android.content.res.Configuration.UI_MODE_TYPE_CAR; import static android.content.res.Configuration.UI_MODE_TYPE_NORMAL; import static com.android.systemui.doze.DozeMachine.State.DOZE; import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD; import static com.android.systemui.doze.DozeMachine.State.DOZE_SUSPEND_TRIGGERS; import static com.android.systemui.doze.DozeMachine.State.FINISH; import static com.android.systemui.doze.DozeMachine.State.INITIALIZED; import static com.android.systemui.doze.DozeMachine.State.UNINITIALIZED; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.hardware.display.AmbientDisplayConfiguration; import android.platform.test.annotations.DisableFlags; import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.systemui.Flags; import com.android.systemui.SysuiTestCase; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.phone.BiometricUnlockController; Loading @@ -55,7 +44,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.AdditionalMatchers; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; Loading Loading @@ -123,104 +111,6 @@ public class DozeSuppressorTest extends SysuiTestCase { verify(mDozeHost).removeCallback(mDozeHostCallback); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testSuspendTriggersDoze_carMode() { // GIVEN car mode mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); // WHEN dozing begins mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); // THEN doze continues with all doze triggers disabled. verify(mDozeMachine, atLeastOnce()).requestState(DOZE_SUSPEND_TRIGGERS); verify(mDozeMachine, never()) .requestState(AdditionalMatchers.not(eq(DOZE_SUSPEND_TRIGGERS))); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testSuspendTriggersDoze_enterCarMode() { // GIVEN currently dozing mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); mDozeSuppressor.transitionTo(INITIALIZED, DOZE); // WHEN car mode entered mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); // THEN doze continues with all doze triggers disabled. verify(mDozeMachine).requestState(DOZE_SUSPEND_TRIGGERS); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeResume_exitCarMode() { // GIVEN currently suspended, with AOD not enabled mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false); mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); mDozeSuppressor.transitionTo(INITIALIZED, DOZE_SUSPEND_TRIGGERS); // WHEN exiting car mode mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_NORMAL); // THEN doze is resumed verify(mDozeMachine).requestState(DOZE); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testDozeAoDResume_exitCarMode() { // GIVEN currently suspended, with AOD not enabled mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(true); mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); mDozeSuppressor.transitionTo(INITIALIZED, DOZE_SUSPEND_TRIGGERS); // WHEN exiting car mode mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_NORMAL); // THEN doze AOD is resumed verify(mDozeMachine).requestState(DOZE_AOD); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testUiModeDoesNotChange_noStateTransition() { mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); clearInvocations(mDozeMachine); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mDozeMachine, times(1)).requestState(DOZE_SUSPEND_TRIGGERS); verify(mDozeMachine, never()) .requestState(AdditionalMatchers.not(eq(DOZE_SUSPEND_TRIGGERS))); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testUiModeTypeChange_whenDozeMachineIsNotReady_doesNotDoAnything() { when(mDozeMachine.isUninitializedOrFinished()).thenReturn(true); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mDozeMachine, never()).requestState(any()); } @Test @DisableFlags(Flags.FLAG_REMOVE_AOD_CAR_MODE) public void testUiModeTypeChange_CarModeEnabledAndDozeMachineNotReady_suspendsTriggersAfter() { when(mDozeMachine.isUninitializedOrFinished()).thenReturn(true); mDozeSuppressor.onUiModeTypeChanged(UI_MODE_TYPE_CAR); verify(mDozeMachine, never()).requestState(any()); mDozeSuppressor.transitionTo(UNINITIALIZED, INITIALIZED); verify(mDozeMachine, times(1)).requestState(DOZE_SUSPEND_TRIGGERS); } @Test public void testEndDoze_unprovisioned() { // GIVEN device unprovisioned Loading
packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +0 −14 Original line number Diff line number Diff line Loading @@ -409,20 +409,6 @@ public class DozeLog implements Dumpable { mLogger.logImmediatelyEndDoze(reason); } /** * Logs the car mode started event. */ public void traceCarModeStarted() { mLogger.logCarModeStarted(); } /** * Logs the car mode ended event. */ public void traceCarModeEnded() { mLogger.logCarModeEnded(); } /** * Appends power save changes that may cause a new doze state * @param powerSaveActive true if power saving is active Loading
packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +1 −39 Original line number Diff line number Diff line Loading @@ -16,13 +16,11 @@ package com.android.systemui.doze; import static com.android.systemui.Flags.removeAodCarMode; import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE; import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING; import android.annotation.MainThread; import android.annotation.Nullable; import android.content.res.Configuration; import android.hardware.display.AmbientDisplayConfiguration; import android.util.Log; import android.view.Display; Loading Loading @@ -180,7 +178,6 @@ public class DozeMachine { private State mState = State.UNINITIALIZED; private int mPulseReason; private boolean mWakeLockHeldForCurrentState = false; private int mUiModeType = Configuration.UI_MODE_TYPE_NORMAL; @Inject public DozeMachine(@WrappedService Service service, Loading Loading @@ -212,18 +209,6 @@ public class DozeMachine { } } /** * Notifies the {@link DozeMachine} that {@link Configuration} has changed. */ public void onConfigurationChanged(Configuration newConfiguration) { int newUiModeType = newConfiguration.uiMode & Configuration.UI_MODE_TYPE_MASK; if (mUiModeType == newUiModeType) return; mUiModeType = newUiModeType; for (Part part : mParts) { part.onUiModeTypeChanged(mUiModeType); } } /** * Requests transitioning to {@code requestedState}. * Loading Loading @@ -421,16 +406,7 @@ public class DozeMachine { if (mState == State.FINISH) { return State.FINISH; } if (mUiModeType == Configuration.UI_MODE_TYPE_CAR && (requestedState.canPulse() || requestedState.staysAwake())) { if (removeAodCarMode()) { Log.d(TAG, "skip applying car mode"); } else { Log.i(TAG, "Doze is suppressed with all triggers disabled as car mode is active"); mDozeLog.traceCarModeStarted(); return State.DOZE_SUSPEND_TRIGGERS; } } if (mDozeHost.isAlwaysOnSuppressed() && requestedState.isAlwaysOn()) { Log.i(TAG, "Doze is suppressed by an app. Suppressing state: " + requestedState); mDozeLog.traceAlwaysOnSuppressed(requestedState, "app"); Loading Loading @@ -498,7 +474,6 @@ public class DozeMachine { /** Dumps the current state */ public void dump(PrintWriter pw) { pw.print(" state="); pw.println(mState); pw.print(" mUiModeType="); pw.println(mUiModeType); pw.print(" wakeLockHeldForCurrentState="); pw.println(mWakeLockHeldForCurrentState); pw.print(" wakeLock="); pw.println(mWakeLock); pw.println("Parts:"); Loading Loading @@ -531,19 +506,6 @@ public class DozeMachine { /** Sets the {@link DozeMachine} when this Part is associated with one. */ default void setDozeMachine(DozeMachine dozeMachine) {} /** * Notifies the Part about a change in {@link Configuration#uiMode}. * * @param newUiModeType {@link Configuration#UI_MODE_TYPE_NORMAL}, * {@link Configuration#UI_MODE_TYPE_DESK}, * {@link Configuration#UI_MODE_TYPE_CAR}, * {@link Configuration#UI_MODE_TYPE_TELEVISION}, * {@link Configuration#UI_MODE_TYPE_APPLIANCE}, * {@link Configuration#UI_MODE_TYPE_WATCH}, * or {@link Configuration#UI_MODE_TYPE_VR_HEADSET} */ default void onUiModeTypeChanged(int newUiModeType) {} } /** A wrapper interface for {@link android.service.dreams.DreamService} */ Loading