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

Commit 8a054c32 authored by Edgar Arriaga's avatar Edgar Arriaga
Browse files

Fix for new compactions skipped after cancelling pending compactions

When new compactions are scheduled they are added to the pending
compaction process list however, they also maintain a flag that
indicates whether a compaction is pending on the record, previously,
when cancelling compactions we would remove the process from the list
but not clear the flag, leaving the process in an uncompactable state
as it would be skipped from being scheduled thinking there was a
compaction happening when there wasn't any.

Bug: 227502250
Test: Manual. Logging and dumpsys activity

Change-Id: Id9d712bd14ba83c4d647d3e9faa88e4ddbd1b697
parent b0ef1944
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -1146,12 +1146,25 @@ public final class CachedAppOptimizer {
        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");
            cancelAllCompactions();
        }
    }

    void cancelAllCompactions() {
        synchronized (mProcLock) {
            int size = mPendingCompactionProcesses.size();
            ProcessRecord record;
            for (int i=0; i < size; ++i) {
                record = mPendingCompactionProcesses.get(i);
                // The process record is kept alive after compactions are cleared,
                // so make sure to reset the compaction state to avoid skipping any future
                // compactions due to a stale value here.
                record.mOptRecord.setHasPendingCompact(false);
            }
            mPendingCompactionProcesses.clear();
        }
        cancelCompaction();
    }
    }

    @GuardedBy({"mService", "mProcLock"})
    void onOomAdjustChanged(int oldAdj, int newAdj, ProcessRecord app) {