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

Commit 4db80507 authored by Stas Zakrevskyi's avatar Stas Zakrevskyi Committed by Android (Google) Code Review
Browse files

Merge changes from topic "minmode-sysui" into main

* changes:
  Integrate MinMode with Keyguard
  MinMode: SystemUI new AOD state
parents 056ace3d 19402168
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ Device is awake, showing docking UI and listening for enabled pulsing and wake-u

[DozeDockHandler][11] listens for Dock state changes from [DockManager][10] and updates the doze docking state.

### DOZE_AOD_MINMODE
Device is awake, start showing minmode UI. The default MinModeManager is provided by an empty interface at [MinModeManagerImpl][21]. SystemUI should override the MinModeManager for the DozeService to handle minmode events.

[DozeMinMode][23] listens for MinMode state changes from [MinModeManager][22] and updates the doze MinMode state.

## Wake-up gestures
Doze sensors are registered in [DozeTriggers][8] via [DozeSensors][12]. Sensors can be configured per posture for foldable devices.

@@ -105,3 +110,6 @@ Other helpful dumpsys commands (`adb shell dumpsys <service>`):
[18]: /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
[19]: /frameworks/base/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/StatusBarStateController.java
[20]: /frameworks/base/packages/SystemUI/docs/clock-plugins.md
[21]: frameworks/base/packages/SystemUI/src/com/android/systemui/minmode/MinModeManagerImpl.java
[22]: frameworks/base/packages/SystemUI/src/com/android/systemui/minmode/MinModeManager.kt
[23]: frameworks/base/packages/SystemUI/src/com/android/systemui/doze/DozeMinMode.java
+19 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ 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;
@@ -48,6 +49,7 @@ 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;

@@ -60,10 +62,12 @@ import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.minmode.MinModeManager;
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;
@@ -92,6 +96,9 @@ public class DozeMachineTest extends SysuiTestCase {
    private DozeMachine.Part mAnotherPartMock;
    @Mock
    private UserTracker mUserTracker;
    @Mock
    private MinModeManager mMinModeManager;

    private DozeServiceFake mServiceFake;
    private WakeLockFake mWakeLockFake;
    private AmbientDisplayConfiguration mAmbientDisplayConfigMock;
@@ -112,6 +119,7 @@ public class DozeMachineTest extends SysuiTestCase {
                mWakefulnessLifecycle,
                mDozeLog,
                mDockManager,
                Optional.of(mMinModeManager),
                mHost,
                new DozeMachine.Part[]{mPartMock, mAnotherPartMock},
                mUserTracker);
@@ -154,6 +162,17 @@ public class DozeMachineTest extends SysuiTestCase {
        assertEquals(DOZE_AOD_DOCKED, mMachine.getState());
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_MINMODE)
    public void testInitialize_minModeEnabled_goesToMinModeAod() {
        when(mMinModeManager.isMinModeEnabled()).thenReturn(true);

        mMachine.requestState(INITIALIZED);

        verify(mPartMock).transitionTo(INITIALIZED, DOZE_AOD_MINMODE);
        assertEquals(DOZE_AOD_MINMODE, mMachine.getState());
    }

    @Test
    public void testInitialize_afterDockPaused_goesToDoze() {
        when(mAmbientDisplayConfigMock.alwaysOnEnabled(anyInt())).thenReturn(true);
+38 −1
Original line number Diff line number Diff line
@@ -33,12 +33,14 @@ import android.content.res.Resources;
import android.hardware.display.AmbientDisplayConfiguration;
import android.os.Handler;
import android.os.PowerManager;
import android.platform.test.annotations.EnableFlags;
import android.provider.Settings;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
import com.android.systemui.doze.DozeScreenState;
@@ -46,6 +48,7 @@ import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.domain.interactor.DozeInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.minmode.MinModeManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -91,6 +94,7 @@ public class DozeParametersTest extends SysuiTestCase {
    @Mock private ConfigurationController mConfigurationController;
    @Mock private UserTracker mUserTracker;
    @Mock private DozeInteractor mDozeInteractor;
    @Mock private MinModeManager mMinModeManager;
    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    @Captor private ArgumentCaptor<BatteryStateChangeCallback> mBatteryStateChangeCallback;
@@ -119,6 +123,7 @@ public class DozeParametersTest extends SysuiTestCase {
        when(mSysUIUnfoldComponent.getFoldAodAnimationController())
                .thenReturn(mFoldAodAnimationController);
        when(mUserTracker.getUserId()).thenReturn(ActivityManager.getCurrentUser());
        when(mMinModeManager.isMinModeEnabled()).thenReturn(false);

        SecureSettings secureSettings = new FakeSettings();
        mDozeParameters = new DozeParameters(
@@ -140,7 +145,8 @@ public class DozeParametersTest extends SysuiTestCase {
            mUserTracker,
            mDozeInteractor,
            mKeyguardTransitionInteractor,
            secureSettings
            secureSettings,
            Optional.of(mMinModeManager)
        );

        verify(mBatteryController).addCallback(mBatteryStateChangeCallback.capture());
@@ -328,6 +334,37 @@ public class DozeParametersTest extends SysuiTestCase {
        assertTrue(mDozeParameters.shouldControlScreenOff());
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_MINMODE)
    public void testIsMinModeEnabled_proxiesToManager() {
        when(mMinModeManager.isMinModeEnabled()).thenReturn(true);
        assertThat(mDozeParameters.isMinModeActive()).isTrue();

        when(mMinModeManager.isMinModeEnabled()).thenReturn(false);
        assertThat(mDozeParameters.isMinModeActive()).isFalse();
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_MINMODE)
    public void testGetAlwaysOn_falseWhenMinModeEnabled() {
        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
        mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
        when(mBatteryController.isAodPowerSave()).thenReturn(false);

        when(mMinModeManager.isMinModeEnabled()).thenReturn(true);

        assertThat(mDozeParameters.getAlwaysOn()).isFalse();
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_MINMODE)
    public void testShouldAnimateDozingChange_falseWhenMinModeEnabled() {
        when(mScreenOffAnimationController.shouldAnimateDozingChange()).thenReturn(true);
        when(mMinModeManager.isMinModeEnabled()).thenReturn(true);

        assertThat(mDozeParameters.shouldAnimateDozingChange()).isFalse();
    }

    private void setDisplayNeedsBlankingForTest(boolean needsBlanking) {
        when(mResources.getBoolean(
                com.android.internal.R.bool.config_displayBlanksAfterDoze)).thenReturn(
+2 −1
Original line number Diff line number Diff line
@@ -196,7 +196,8 @@ public class DozeServiceHostTest extends SysuiTestCase {
                        DozeLog.REASON_SENSOR_WAKE_UP_PRESENCE,
                        DozeLog.REASON_SENSOR_QUICK_PICKUP,
                        DozeLog.PULSE_REASON_FINGERPRINT_ACTIVATED,
                        DozeLog.REASON_SENSOR_TAP));
                        DozeLog.REASON_SENSOR_TAP,
                        DozeLog.PULSE_REASON_MINMODE));
        HashSet<Integer> reasonsThatDontPulse = new HashSet<>(
                Arrays.asList(DozeLog.REASON_SENSOR_PICKUP,
                        DozeLog.REASON_SENSOR_DOUBLE_TAP,
+15 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManagerImpl;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.education.dagger.ContextualEducationModule;
import com.android.systemui.Flags;
import com.android.systemui.minmode.MinModeManager;
import com.android.systemui.minmode.MinModeManagerImpl;
import com.android.systemui.emergency.EmergencyGestureModule;
import com.android.systemui.inputdevice.tutorial.KeyboardTouchpadTutorialModule;
import com.android.systemui.keyboard.shortcut.ShortcutHelperModule;
@@ -107,9 +110,11 @@ import dagger.Provides;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;

import java.util.Optional;
import java.util.Set;

import javax.inject.Named;
import javax.inject.Provider;

/**
 * A dagger module for injecting default implementations of components of System UI.
@@ -220,6 +225,16 @@ public abstract class ReferenceSystemUIModule {
    @Binds
    abstract DockManager bindDockManager(DockManagerImpl dockManager);

    @Provides
    @SysUISingleton
    static Optional<MinModeManager> bindMinModeManager(Provider<MinModeManagerImpl> minModeManager) {
      if (Flags.enableMinmode()) {
        return Optional.of(minModeManager.get());
      } else {
        return Optional.empty();
      }
    }

    @SysUISingleton
    @Provides
    @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
Loading