Loading packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; */ public class DozeAuthRemover implements DozeMachine.Part { KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; public DozeAuthRemover(Context context) { mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context); Loading packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java +4 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; import com.android.systemui.dock.DockManager; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.DozeParameters; Loading @@ -47,6 +48,7 @@ public class DozeFactory { SensorManager sensorManager = Dependency.get(AsyncSensorManager.class); AlarmManager alarmManager = context.getSystemService(AlarmManager.class); DockManager dockManager = Dependency.get(DockManager.class); WakefulnessLifecycle wakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); DozeHost host = getHost(dozeService); AmbientDisplayConfiguration config = new AmbientDisplayConfiguration(context); Loading @@ -61,7 +63,8 @@ public class DozeFactory { wrappedService = DozeSuspendScreenStatePreventingAdapter.wrapIfNeeded(wrappedService, params); DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock); DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock, wakefulnessLifecycle); machine.setParts(new DozeMachine.Part[]{ new DozePauser(handler, machine, alarmManager, params.getPolicy()), new DozeFalsingManagerAdapter(falsingManager), Loading packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +17 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.util.Log; import android.view.Display; import com.android.internal.util.Preconditions; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.Assert; import com.android.systemui.util.wakelock.WakeLock; Loading Loading @@ -118,6 +120,7 @@ public class DozeMachine { private final Service mDozeService; private final WakeLock mWakeLock; private final AmbientDisplayConfiguration mConfig; private final WakefulnessLifecycle mWakefulnessLifecycle; private Part[] mParts; private final ArrayList<State> mQueuedRequests = new ArrayList<>(); Loading @@ -126,9 +129,10 @@ public class DozeMachine { private boolean mWakeLockHeldForCurrentState = false; public DozeMachine(Service service, AmbientDisplayConfiguration config, WakeLock wakeLock) { WakeLock wakeLock, WakefulnessLifecycle wakefulnessLifecycle) { mDozeService = service; mConfig = config; mWakefulnessLifecycle = wakefulnessLifecycle; mWakeLock = wakeLock; } Loading Loading @@ -334,9 +338,18 @@ public class DozeMachine { switch (state) { case INITIALIZED: case DOZE_PULSE_DONE: transitionTo(mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT) ? DozeMachine.State.DOZE_AOD : DozeMachine.State.DOZE, DozeLog.PULSE_REASON_NONE); final State nextState; @Wakefulness int wakefulness = mWakefulnessLifecycle.getWakefulness(); if (wakefulness == WakefulnessLifecycle.WAKEFULNESS_AWAKE || wakefulness == WakefulnessLifecycle.WAKEFULNESS_WAKING) { nextState = State.FINISH; } else if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) { nextState = State.DOZE_AOD; } else { nextState = State.DOZE; } transitionTo(nextState, DozeLog.PULSE_REASON_NONE); break; default: break; Loading packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java +14 −2 Original line number Diff line number Diff line Loading @@ -16,12 +16,15 @@ package com.android.systemui.keyguard; import android.annotation.IntDef; import android.os.Trace; import com.android.systemui.Dumpable; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import javax.inject.Inject; import javax.inject.Singleton; Loading @@ -33,6 +36,15 @@ import javax.inject.Singleton; public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observer> implements Dumpable { @IntDef(prefix = { "WAKEFULNESS_" }, value = { WAKEFULNESS_ASLEEP, WAKEFULNESS_WAKING, WAKEFULNESS_AWAKE, WAKEFULNESS_GOING_TO_SLEEP, }) @Retention(RetentionPolicy.SOURCE) public @interface Wakefulness {} public static final int WAKEFULNESS_ASLEEP = 0; public static final int WAKEFULNESS_WAKING = 1; public static final int WAKEFULNESS_AWAKE = 2; Loading @@ -44,7 +56,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe public WakefulnessLifecycle() { } public int getWakefulness() { public @Wakefulness int getWakefulness() { return mWakefulness; } Loading Loading @@ -86,7 +98,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe pw.println(" mWakefulness=" + mWakefulness); } private void setWakefulness(int wakefulness) { private void setWakefulness(@Wakefulness int wakefulness) { mWakefulness = wakefulness; Trace.traceCounter(Trace.TRACE_TAG_APP, "wakefulness", wakefulness); } Loading packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -45,11 +45,14 @@ import android.testing.UiThreadTest; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.util.wakelock.WakeLockFake; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) Loading @@ -58,6 +61,8 @@ public class DozeMachineTest extends SysuiTestCase { DozeMachine mMachine; @Mock private WakefulnessLifecycle mWakefulnessLifecycle; private DozeServiceFake mServiceFake; private WakeLockFake mWakeLockFake; private AmbientDisplayConfiguration mConfigMock; Loading @@ -65,12 +70,13 @@ public class DozeMachineTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); mServiceFake = new DozeServiceFake(); mWakeLockFake = new WakeLockFake(); mConfigMock = mock(AmbientDisplayConfiguration.class); mPartMock = mock(DozeMachine.Part.class); mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake); mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake, mWakefulnessLifecycle); mMachine.setParts(new DozeMachine.Part[]{mPartMock}); } Loading Loading
packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; */ public class DozeAuthRemover implements DozeMachine.Part { KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; public DozeAuthRemover(Context context) { mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context); Loading
packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java +4 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; import com.android.systemui.dock.DockManager; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.DozeParameters; Loading @@ -47,6 +48,7 @@ public class DozeFactory { SensorManager sensorManager = Dependency.get(AsyncSensorManager.class); AlarmManager alarmManager = context.getSystemService(AlarmManager.class); DockManager dockManager = Dependency.get(DockManager.class); WakefulnessLifecycle wakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); DozeHost host = getHost(dozeService); AmbientDisplayConfiguration config = new AmbientDisplayConfiguration(context); Loading @@ -61,7 +63,8 @@ public class DozeFactory { wrappedService = DozeSuspendScreenStatePreventingAdapter.wrapIfNeeded(wrappedService, params); DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock); DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock, wakefulnessLifecycle); machine.setParts(new DozeMachine.Part[]{ new DozePauser(handler, machine, alarmManager, params.getPolicy()), new DozeFalsingManagerAdapter(falsingManager), Loading
packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +17 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.util.Log; import android.view.Display; import com.android.internal.util.Preconditions; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle.Wakefulness; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.Assert; import com.android.systemui.util.wakelock.WakeLock; Loading Loading @@ -118,6 +120,7 @@ public class DozeMachine { private final Service mDozeService; private final WakeLock mWakeLock; private final AmbientDisplayConfiguration mConfig; private final WakefulnessLifecycle mWakefulnessLifecycle; private Part[] mParts; private final ArrayList<State> mQueuedRequests = new ArrayList<>(); Loading @@ -126,9 +129,10 @@ public class DozeMachine { private boolean mWakeLockHeldForCurrentState = false; public DozeMachine(Service service, AmbientDisplayConfiguration config, WakeLock wakeLock) { WakeLock wakeLock, WakefulnessLifecycle wakefulnessLifecycle) { mDozeService = service; mConfig = config; mWakefulnessLifecycle = wakefulnessLifecycle; mWakeLock = wakeLock; } Loading Loading @@ -334,9 +338,18 @@ public class DozeMachine { switch (state) { case INITIALIZED: case DOZE_PULSE_DONE: transitionTo(mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT) ? DozeMachine.State.DOZE_AOD : DozeMachine.State.DOZE, DozeLog.PULSE_REASON_NONE); final State nextState; @Wakefulness int wakefulness = mWakefulnessLifecycle.getWakefulness(); if (wakefulness == WakefulnessLifecycle.WAKEFULNESS_AWAKE || wakefulness == WakefulnessLifecycle.WAKEFULNESS_WAKING) { nextState = State.FINISH; } else if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) { nextState = State.DOZE_AOD; } else { nextState = State.DOZE; } transitionTo(nextState, DozeLog.PULSE_REASON_NONE); break; default: break; Loading
packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java +14 −2 Original line number Diff line number Diff line Loading @@ -16,12 +16,15 @@ package com.android.systemui.keyguard; import android.annotation.IntDef; import android.os.Trace; import com.android.systemui.Dumpable; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import javax.inject.Inject; import javax.inject.Singleton; Loading @@ -33,6 +36,15 @@ import javax.inject.Singleton; public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observer> implements Dumpable { @IntDef(prefix = { "WAKEFULNESS_" }, value = { WAKEFULNESS_ASLEEP, WAKEFULNESS_WAKING, WAKEFULNESS_AWAKE, WAKEFULNESS_GOING_TO_SLEEP, }) @Retention(RetentionPolicy.SOURCE) public @interface Wakefulness {} public static final int WAKEFULNESS_ASLEEP = 0; public static final int WAKEFULNESS_WAKING = 1; public static final int WAKEFULNESS_AWAKE = 2; Loading @@ -44,7 +56,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe public WakefulnessLifecycle() { } public int getWakefulness() { public @Wakefulness int getWakefulness() { return mWakefulness; } Loading Loading @@ -86,7 +98,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe pw.println(" mWakefulness=" + mWakefulness); } private void setWakefulness(int wakefulness) { private void setWakefulness(@Wakefulness int wakefulness) { mWakefulness = wakefulness; Trace.traceCounter(Trace.TRACE_TAG_APP, "wakefulness", wakefulness); } Loading
packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -45,11 +45,14 @@ import android.testing.UiThreadTest; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.util.wakelock.WakeLockFake; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) Loading @@ -58,6 +61,8 @@ public class DozeMachineTest extends SysuiTestCase { DozeMachine mMachine; @Mock private WakefulnessLifecycle mWakefulnessLifecycle; private DozeServiceFake mServiceFake; private WakeLockFake mWakeLockFake; private AmbientDisplayConfiguration mConfigMock; Loading @@ -65,12 +70,13 @@ public class DozeMachineTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); mServiceFake = new DozeServiceFake(); mWakeLockFake = new WakeLockFake(); mConfigMock = mock(AmbientDisplayConfiguration.class); mPartMock = mock(DozeMachine.Part.class); mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake); mMachine = new DozeMachine(mServiceFake, mConfigMock, mWakeLockFake, mWakefulnessLifecycle); mMachine.setParts(new DozeMachine.Part[]{mPartMock}); } Loading