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

Commit fc6f9149 authored by Edgar Arriaga García's avatar Edgar Arriaga García Committed by Android (Google) Code Review
Browse files

Merge "RESTRICT AUTOMERGE: Disable file compaction by default" into tm-qpr-dev

parents a908dde9 854e613a
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ public final class CachedAppOptimizer {

    private static final String ATRACE_COMPACTION_TRACK = "Compaction";

    @VisibleForTesting static final boolean ENABLE_FILE_COMPACT = false;

    // Defaults for phenotype flags.
    @VisibleForTesting static final Boolean DEFAULT_USE_COMPACTION = false;
    @VisibleForTesting static final Boolean DEFAULT_USE_FREEZER = true;
@@ -515,10 +517,12 @@ public final class CachedAppOptimizer {

    @GuardedBy("mProcLock")
    void compactAppSome(ProcessRecord app, boolean force) {
        if (ENABLE_FILE_COMPACT) {
            app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_SOME);
            ++mSomeCompactRequest;
            compactApp(app, force, "some");
        }
    }

    // This method returns true only if requirements are met. Note, that requirements are different
    // from throttles applied at the time a compaction is trying to be executed in the sense that
@@ -1278,6 +1282,15 @@ public final class CachedAppOptimizer {
            }
        }

        if (!ENABLE_FILE_COMPACT) {
            // Turn off file compaction
            if (resolvedAction == COMPACT_ACTION_FULL) {
                resolvedAction = COMPACT_ACTION_ANON;
            } else if (resolvedAction == COMPACT_ACTION_FILE) {
                resolvedAction = COMPACT_ACTION_NONE;
            }
        }

        return resolvedAction;
    }

@@ -1545,6 +1558,9 @@ public final class CachedAppOptimizer {
                    }

                    int resolvedAction = resolveCompactionAction(requestedAction);
                    if (resolvedAction == COMPACT_ACTION_NONE) {
                        return;
                    }
                    action = compactActionIntToString(resolvedAction);

                    try {
+8 −6
Original line number Diff line number Diff line
@@ -1079,6 +1079,7 @@ public final class CachedAppOptimizerTest {

        mCachedAppOptimizerUnderTest.mLastCompactionStats.clear();

        if (CachedAppOptimizer.ENABLE_FILE_COMPACT) {
            // We force a some compaction
            mCachedAppOptimizerUnderTest.compactAppSome(processRecord, true);
            waitForHandler();
@@ -1088,6 +1089,7 @@ public final class CachedAppOptimizerTest {
            assertThat(executedCompactAction)
                .isEqualTo(mCachedAppOptimizerUnderTest.mCompactActionSome);
        }
    }

    private void setFlag(String key, String value, boolean defaultValue) throws Exception {
        mCountDown = new CountDownLatch(1);