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

Commit 81af34b1 authored by Edgar Arriaga's avatar Edgar Arriaga
Browse files

Avoid trying to cancel compactions when compaction is disabled

Bug: 284330055
Test: disable compaction and lock and unlock and no log
Change-Id: I6181ed742228acb64f5b4a8caa3e8f8fe290d957
parent 6c4e7e51
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -1537,15 +1537,22 @@ public final class CachedAppOptimizer {


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


    void cancelAllCompactions(CancelCompactReason reason) {
    void cancelAllCompactions(CancelCompactReason reason) {
        synchronized (mProcLock) {
        synchronized (mProcLock) {
            while(!mPendingCompactionProcesses.isEmpty()) {
            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);
                cancelCompactionForProcess(mPendingCompactionProcesses.get(0), reason);
            }
            }
            mPendingCompactionProcesses.clear();
            mPendingCompactionProcesses.clear();