Loading services/core/java/com/android/server/am/AppCompactor.java +9 −1 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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: Loading @@ -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; } } Loading Loading @@ -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") Loading services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java +8 −8 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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, Loading Loading @@ -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)); Loading Loading
services/core/java/com/android/server/am/AppCompactor.java +9 −1 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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: Loading @@ -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; } } Loading Loading @@ -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") Loading
services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java +8 −8 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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, Loading Loading @@ -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)); Loading