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

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

Merge "Avoid trying to cancel compactions when compaction is disabled"

parents 6b26d4e7 81af34b1
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -1537,15 +1537,22 @@ public final class CachedAppOptimizer {

    void onWakefulnessChanged(int wakefulness) {
        if(wakefulness == PowerManagerInternal.WAKEFULNESS_AWAKE) {
            // Remove any pending compaction we may have scheduled to happen while screen was off
            Slog.e(TAG_AM, "Cancel pending or running compactions as system is awake");
            if (useCompaction()) {
                // Remove any pending compaction we may have scheduled to happen while screen was
                // off
                cancelAllCompactions(CancelCompactReason.SCREEN_ON);
            }
        }
    }

    void cancelAllCompactions(CancelCompactReason reason) {
        synchronized (mProcLock) {
            while(!mPendingCompactionProcesses.isEmpty()) {
                if (DEBUG_COMPACTION) {
                    Slog.e(TAG_AM,
                            "Cancel pending compaction as system is awake for process="
                                    + mPendingCompactionProcesses.get(0).processName);
                }
                cancelCompactionForProcess(mPendingCompactionProcesses.get(0), reason);
            }
            mPendingCompactionProcesses.clear();