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

Commit 86e037e9 authored by Stas Zakrevskyi's avatar Stas Zakrevskyi
Browse files

MinMode: SystemUI new AOD state

Introducing a new AOD state. DozeMachine class and implementations of DozeMachine.Part changed according to the new state DOZE_AOD_MINMODE, based on MinModeManager. The default implementation of MinModeManager is MinModeManagerImpl.


Flag: com.android.systemui.enable_minmode
Bug: 411746510
Test: verified by manual tests and unit tests
Change-Id: I6e918675e89056d6c15702495b20ac9b933dc721
parent c5e8aa35
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);
+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)
+7 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.os.PowerManager.WAKE_REASON_BIOMETRIC;
import static android.os.PowerManager.WAKE_REASON_GESTURE;
import static android.os.PowerManager.WAKE_REASON_LIFT;
import static android.os.PowerManager.WAKE_REASON_PLUGGED_IN;
import static android.os.PowerManager.WAKE_REASON_POWER_BUTTON;
import static android.os.PowerManager.WAKE_REASON_TAP;

import android.annotation.IntDef;
@@ -568,6 +569,7 @@ public class DozeLog implements Dumpable {
            case REASON_SENSOR_QUICK_PICKUP: return "quickPickup";
            case PULSE_REASON_FINGERPRINT_ACTIVATED: return "fingerprint-triggered";
            case REASON_USUDFPS_PULSE: return "usudfps-pulse";
            case PULSE_REASON_MINMODE: return "minmode";
            default: throw new IllegalArgumentException("invalid reason: " + pulseReason);
        }
    }
@@ -586,6 +588,8 @@ public class DozeLog implements Dumpable {
                return WAKE_REASON_BIOMETRIC;
            case PULSE_REASON_DOCKING:
                return WAKE_REASON_PLUGGED_IN;
            case PULSE_REASON_MINMODE:
                return WAKE_REASON_POWER_BUTTON;
            default:
                return WAKE_REASON_GESTURE;
        }
@@ -597,7 +601,7 @@ public class DozeLog implements Dumpable {
            PULSE_REASON_SENSOR_LONG_PRESS, PULSE_REASON_DOCKING, REASON_SENSOR_WAKE_UP_PRESENCE,
            PULSE_REASON_SENSOR_WAKE_REACH, REASON_SENSOR_TAP,
            REASON_SENSOR_UDFPS_LONG_PRESS, REASON_SENSOR_QUICK_PICKUP,
            PULSE_REASON_FINGERPRINT_ACTIVATED, REASON_USUDFPS_PULSE,
            PULSE_REASON_FINGERPRINT_ACTIVATED, REASON_USUDFPS_PULSE, PULSE_REASON_MINMODE
    })
    public @interface Reason {}
    public static final int PULSE_REASON_NONE = -1;
@@ -615,6 +619,7 @@ public class DozeLog implements Dumpable {
    public static final int REASON_SENSOR_QUICK_PICKUP = 11;
    public static final int PULSE_REASON_FINGERPRINT_ACTIVATED = 12;
    public static final int REASON_USUDFPS_PULSE = 13;
    public static final int PULSE_REASON_MINMODE = 14;

    public static final int TOTAL_REASONS = 14;
    public static final int TOTAL_REASONS = 15;
}
Loading