diff options
| -rw-r--r-- | services/core/java/com/android/server/am/AppCompactor.java | 10 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java | 16 |
2 files changed, 17 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/am/AppCompactor.java b/services/core/java/com/android/server/am/AppCompactor.java index 502f078b532e..c7e4fc78c013 100644 --- a/services/core/java/com/android/server/am/AppCompactor.java +++ b/services/core/java/com/android/server/am/AppCompactor.java @@ -55,6 +55,8 @@ public final class AppCompactor { private static final int COMPACT_ACTION_FILE_FLAG = 1; private static final int COMPACT_ACTION_ANON_FLAG = 2; private static final int COMPACT_ACTION_FULL_FLAG = 3; + private static final int COMPACT_ACTION_NONE_FLAG = 4; + private static final String COMPACT_ACTION_NONE = ""; private static final String COMPACT_ACTION_FILE = "file"; private static final String COMPACT_ACTION_ANON = "anon"; private static final String COMPACT_ACTION_FULL = "all"; @@ -320,6 +322,8 @@ public final class AppCompactor { @VisibleForTesting static String compactActionIntToString(int action) { switch(action) { + case COMPACT_ACTION_NONE_FLAG: + return COMPACT_ACTION_NONE; case COMPACT_ACTION_FILE_FLAG: return COMPACT_ACTION_FILE; case COMPACT_ACTION_ANON_FLAG: @@ -327,7 +331,7 @@ public final class AppCompactor { case COMPACT_ACTION_FULL_FLAG: return COMPACT_ACTION_FULL; default: - return COMPACT_ACTION_FILE; + return COMPACT_ACTION_NONE; } } @@ -398,6 +402,10 @@ public final class AppCompactor { action = mCompactActionFull; } + if (action.equals(COMPACT_ACTION_NONE)) { + return; + } + try { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Compact " + ((pendingAction == COMPACT_PROCESS_SOME) ? "some" : "full") diff --git a/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java b/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java index 2f8e5456a695..63015be6ef3f 100644 --- a/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java +++ b/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java @@ -147,10 +147,10 @@ public final class AppCompactorTest { KEY_USE_COMPACTION, "true", false); DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE, KEY_COMPACT_ACTION_1, - Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 3) + 1), false); + Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 4) + 1), false); DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE, KEY_COMPACT_ACTION_2, - Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 3) + 1), false); + Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 4) + 1), false); DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE, KEY_COMPACT_THROTTLE_1, Long.toString(AppCompactor.DEFAULT_COMPACT_THROTTLE_1 + 1), false); @@ -173,9 +173,9 @@ public final class AppCompactorTest { assertThat(mCompactorUnderTest.mCompactionThread.isAlive(), is(true)); assertThat(mCompactorUnderTest.mCompactActionSome, - is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 3) + 1))); + is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 4) + 1))); assertThat(mCompactorUnderTest.mCompactActionFull, - is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 3) + 1))); + is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 4) + 1))); assertThat(mCompactorUnderTest.mCompactThrottleSomeSome, is(AppCompactor.DEFAULT_COMPACT_THROTTLE_1 + 1)); assertThat(mCompactorUnderTest.mCompactThrottleSomeFull, @@ -233,13 +233,13 @@ public final class AppCompactorTest { // When we override new values for the compaction action with reasonable values... - // There are three possible values for compactAction[Some|Full]. - for (int i = 1; i < 4; i++) { + // There are four possible values for compactAction[Some|Full]. + for (int i = 1; i < 5; i++) { mCountDown = new CountDownLatch(2); - int expectedSome = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_1 + i) % 3 + 1; + int expectedSome = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_1 + i) % 4 + 1; DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE, KEY_COMPACT_ACTION_1, Integer.toString(expectedSome), false); - int expectedFull = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_2 + i) % 3 + 1; + int expectedFull = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_2 + i) % 4 + 1; DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE, KEY_COMPACT_ACTION_2, Integer.toString(expectedFull), false); assertThat(mCountDown.await(5, TimeUnit.SECONDS), is(true)); |