Loading apex/jobscheduler/service/aconfig/device_idle.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "enable_non_scheduled_exit_from_idle_pending" namespace: "backstage_power" description: "If the Device Idle state is IDLE_PENDING, allow directly going past the state if IDLE_AFTER_INACTIVE_TIMEOUT is 0." bug: "431873897" metadata { purpose: PURPOSE_BUGFIX } } apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +11 −3 Original line number Diff line number Diff line Loading @@ -3933,9 +3933,17 @@ public class DeviceIdleController extends SystemService // for motion and sleep some more while doing so. startMonitoringMotionLocked(); long delay = mConstants.IDLE_AFTER_INACTIVE_TIMEOUT; if (delay == 0 && Flags.enableNonScheduledExitFromIdlePending()) { moveToStateLocked(STATE_IDLE_PENDING, reason); if (DEBUG) { Slog.d(TAG, "Fall through IDLE_PENDING: IDLE_AFTER_INACTIVE_TIMEOUT is 0"); } // fall through } else { scheduleAlarmLocked(delay); moveToStateLocked(STATE_IDLE_PENDING, reason); break; } case STATE_IDLE_PENDING: cancelLocatingLocked(); mLocated = false; Loading services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import static com.android.server.DeviceIdleController.stateToString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; Loading @@ -61,6 +62,7 @@ import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.longThat; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.timeout; Loading Loading @@ -91,6 +93,7 @@ import android.os.PowerManagerInternal; import android.os.PowerSaveState; import android.os.SystemClock; import android.os.WearModeManagerInternal; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.DeviceConfig; Loading Loading @@ -833,6 +836,51 @@ public class DeviceIdleControllerTest { verifyLightStateConditions(LIGHT_STATE_INACTIVE); } @Test @EnableFlags(Flags.FLAG_ENABLE_NON_SCHEDULED_EXIT_FROM_IDLE_PENDING) public void testTransitionPastIdlePending_idleAfterInactiveIsZero() { setAlarmSoon(false); mConstants.IDLE_AFTER_INACTIVE_TIMEOUT = 0; enterDeepState(STATE_INACTIVE); clearInvocations(mDeviceIdleController); mDeviceIdleController.stepIdleStateLocked("testing"); // Expect that the step function above goes past STATE_IDLE_PENDING without scheduling // any alarm, because IDLE_AFTER_INACTIVE_TIMEOUT = 0. assertNotEquals(STATE_IDLE_PENDING, mDeviceIdleController.getState()); verify(mDeviceIdleController, never()).scheduleAlarmLocked(0); } @Test @DisableFlags(Flags.FLAG_ENABLE_NON_SCHEDULED_EXIT_FROM_IDLE_PENDING) public void testTransitionPastIdlePending_idleAfterInactiveIsZero_nonScheduledExitFlagOff() { setAlarmSoon(false); mConstants.IDLE_AFTER_INACTIVE_TIMEOUT = 0; enterDeepState(STATE_INACTIVE); clearInvocations(mDeviceIdleController); mDeviceIdleController.stepIdleStateLocked("testing"); verifyStateConditions(STATE_IDLE_PENDING); verify(mDeviceIdleController).scheduleAlarmLocked(0); } @Test public void testTransitionPastIdlePending_idleAfterInactiveIsNotZero() { setAlarmSoon(false); mConstants.IDLE_AFTER_INACTIVE_TIMEOUT = 352; enterDeepState(STATE_INACTIVE); clearInvocations(mDeviceIdleController); mDeviceIdleController.stepIdleStateLocked("testing"); // Because IDLE_AFTER_INACTIVE_TIMEOUT > 0, we expect the state to stay at // STATE_IDLE_PENDING, and an alarm to be scheduled to step past this state. verifyStateConditions(STATE_IDLE_PENDING); verify(mDeviceIdleController).scheduleAlarmLocked(352); } @Test public void testTransitionFromAnyStateToStateQuickDozeDelay() { setAlarmSoon(false); Loading Loading
apex/jobscheduler/service/aconfig/device_idle.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -27,3 +27,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "enable_non_scheduled_exit_from_idle_pending" namespace: "backstage_power" description: "If the Device Idle state is IDLE_PENDING, allow directly going past the state if IDLE_AFTER_INACTIVE_TIMEOUT is 0." bug: "431873897" metadata { purpose: PURPOSE_BUGFIX } }
apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +11 −3 Original line number Diff line number Diff line Loading @@ -3933,9 +3933,17 @@ public class DeviceIdleController extends SystemService // for motion and sleep some more while doing so. startMonitoringMotionLocked(); long delay = mConstants.IDLE_AFTER_INACTIVE_TIMEOUT; if (delay == 0 && Flags.enableNonScheduledExitFromIdlePending()) { moveToStateLocked(STATE_IDLE_PENDING, reason); if (DEBUG) { Slog.d(TAG, "Fall through IDLE_PENDING: IDLE_AFTER_INACTIVE_TIMEOUT is 0"); } // fall through } else { scheduleAlarmLocked(delay); moveToStateLocked(STATE_IDLE_PENDING, reason); break; } case STATE_IDLE_PENDING: cancelLocatingLocked(); mLocated = false; Loading
services/tests/mockingservicestests/src/com/android/server/DeviceIdleControllerTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import static com.android.server.DeviceIdleController.stateToString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; Loading @@ -61,6 +62,7 @@ import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.longThat; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.timeout; Loading Loading @@ -91,6 +93,7 @@ import android.os.PowerManagerInternal; import android.os.PowerSaveState; import android.os.SystemClock; import android.os.WearModeManagerInternal; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.DeviceConfig; Loading Loading @@ -833,6 +836,51 @@ public class DeviceIdleControllerTest { verifyLightStateConditions(LIGHT_STATE_INACTIVE); } @Test @EnableFlags(Flags.FLAG_ENABLE_NON_SCHEDULED_EXIT_FROM_IDLE_PENDING) public void testTransitionPastIdlePending_idleAfterInactiveIsZero() { setAlarmSoon(false); mConstants.IDLE_AFTER_INACTIVE_TIMEOUT = 0; enterDeepState(STATE_INACTIVE); clearInvocations(mDeviceIdleController); mDeviceIdleController.stepIdleStateLocked("testing"); // Expect that the step function above goes past STATE_IDLE_PENDING without scheduling // any alarm, because IDLE_AFTER_INACTIVE_TIMEOUT = 0. assertNotEquals(STATE_IDLE_PENDING, mDeviceIdleController.getState()); verify(mDeviceIdleController, never()).scheduleAlarmLocked(0); } @Test @DisableFlags(Flags.FLAG_ENABLE_NON_SCHEDULED_EXIT_FROM_IDLE_PENDING) public void testTransitionPastIdlePending_idleAfterInactiveIsZero_nonScheduledExitFlagOff() { setAlarmSoon(false); mConstants.IDLE_AFTER_INACTIVE_TIMEOUT = 0; enterDeepState(STATE_INACTIVE); clearInvocations(mDeviceIdleController); mDeviceIdleController.stepIdleStateLocked("testing"); verifyStateConditions(STATE_IDLE_PENDING); verify(mDeviceIdleController).scheduleAlarmLocked(0); } @Test public void testTransitionPastIdlePending_idleAfterInactiveIsNotZero() { setAlarmSoon(false); mConstants.IDLE_AFTER_INACTIVE_TIMEOUT = 352; enterDeepState(STATE_INACTIVE); clearInvocations(mDeviceIdleController); mDeviceIdleController.stepIdleStateLocked("testing"); // Because IDLE_AFTER_INACTIVE_TIMEOUT > 0, we expect the state to stay at // STATE_IDLE_PENDING, and an alarm to be scheduled to step past this state. verifyStateConditions(STATE_IDLE_PENDING); verify(mDeviceIdleController).scheduleAlarmLocked(352); } @Test public void testTransitionFromAnyStateToStateQuickDozeDelay() { setAlarmSoon(false); Loading