Loading services/core/java/com/android/server/display/WakelockController.java +4 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ public final class WakelockController { public static final int WAKE_LOCK_STATE_CHANGED = 4; public static final int WAKE_LOCK_UNFINISHED_BUSINESS = 5; private static final int WAKE_LOCK_MAX = WAKE_LOCK_UNFINISHED_BUSINESS; @VisibleForTesting static final int WAKE_LOCK_MAX = WAKE_LOCK_UNFINISHED_BUSINESS; private static final boolean DEBUG = false; @IntDef(flag = true, prefix = "WAKE_LOCK_", value = { Loading Loading @@ -132,7 +134,7 @@ public final class WakelockController { * A utility to release all the wakelock acquired by the system */ public void releaseAll() { for (int i = WAKE_LOCK_PROXIMITY_POSITIVE; i < WAKE_LOCK_MAX; i++) { for (int i = WAKE_LOCK_PROXIMITY_POSITIVE; i <= WAKE_LOCK_MAX; i++) { releaseWakelockInternal(i); } } Loading services/tests/mockingservicestests/src/com/android/server/display/WakelockControllerTest.java +9 −2 Original line number Diff line number Diff line Loading @@ -244,6 +244,15 @@ public final class WakelockControllerTest { verifyZeroInteractions(mDisplayPowerCallbacks); } @Test public void testReleaseAll() throws Exception { // Use WAKE_LOCK_MAX to verify it has been correctly set and used in releaseAll(). verifyWakelockAcquisition(WakelockController.WAKE_LOCK_MAX, () -> mWakelockController.hasUnfinishedBusiness()); mWakelockController.releaseAll(); assertFalse(mWakelockController.hasUnfinishedBusiness()); } private void verifyWakelockAcquisitionAndReaquisition(int wakelockId, Callable<Boolean> isWakelockAcquiredCallable) throws Exception { Loading Loading @@ -284,6 +293,4 @@ public final class WakelockControllerTest { assertFalse(mWakelockController.releaseWakelock(wakelockId)); assertFalse(isWakelockAcquiredCallable.call()); } } Loading
services/core/java/com/android/server/display/WakelockController.java +4 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ public final class WakelockController { public static final int WAKE_LOCK_STATE_CHANGED = 4; public static final int WAKE_LOCK_UNFINISHED_BUSINESS = 5; private static final int WAKE_LOCK_MAX = WAKE_LOCK_UNFINISHED_BUSINESS; @VisibleForTesting static final int WAKE_LOCK_MAX = WAKE_LOCK_UNFINISHED_BUSINESS; private static final boolean DEBUG = false; @IntDef(flag = true, prefix = "WAKE_LOCK_", value = { Loading Loading @@ -132,7 +134,7 @@ public final class WakelockController { * A utility to release all the wakelock acquired by the system */ public void releaseAll() { for (int i = WAKE_LOCK_PROXIMITY_POSITIVE; i < WAKE_LOCK_MAX; i++) { for (int i = WAKE_LOCK_PROXIMITY_POSITIVE; i <= WAKE_LOCK_MAX; i++) { releaseWakelockInternal(i); } } Loading
services/tests/mockingservicestests/src/com/android/server/display/WakelockControllerTest.java +9 −2 Original line number Diff line number Diff line Loading @@ -244,6 +244,15 @@ public final class WakelockControllerTest { verifyZeroInteractions(mDisplayPowerCallbacks); } @Test public void testReleaseAll() throws Exception { // Use WAKE_LOCK_MAX to verify it has been correctly set and used in releaseAll(). verifyWakelockAcquisition(WakelockController.WAKE_LOCK_MAX, () -> mWakelockController.hasUnfinishedBusiness()); mWakelockController.releaseAll(); assertFalse(mWakelockController.hasUnfinishedBusiness()); } private void verifyWakelockAcquisitionAndReaquisition(int wakelockId, Callable<Boolean> isWakelockAcquiredCallable) throws Exception { Loading Loading @@ -284,6 +293,4 @@ public final class WakelockControllerTest { assertFalse(mWakelockController.releaseWakelock(wakelockId)); assertFalse(isWakelockAcquiredCallable.call()); } }