Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f96451b4 authored by Tim Murray's avatar Tim Murray
Browse files

compaction: add null action

Test: atest FrameworksServicesTests:AppCompactorTest
bug 119988524

Change-Id: Idebd8687a330f6bfacb98f2175e93dd48c20b86c
parent 0a796c10
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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")
+8 −8
Original line number Diff line number Diff line
@@ -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));