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

Commit deea0b5d authored by Jing Ji's avatar Jing Ji
Browse files

Skip background memory trim if the app is in the foreground state

Bug: 308927629
Test: Manual
Change-Id: I96792546c073176d6ce90769bf52f16790565178
parent d99ad6f8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import static android.app.ActivityManager.PROCESS_STATE_UNKNOWN;
import static android.app.ConfigurationController.createNewConfigAndUpdateIfNotNull;
import static android.app.Flags.skipBgMemTrimOnFgApp;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.servertransaction.ActivityLifecycleItem.ON_CREATE;
@@ -7078,6 +7079,11 @@ public final class ActivityThread extends ClientTransactionHandler
        if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Trimming memory to level: " + level);

        try {
            if (skipBgMemTrimOnFgApp()
                    && mLastProcessState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND
                    && level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) {
                return;
            }
            if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
                PropertyInvalidatedCache.onTrimMemory();
            }
+11 −0
Original line number Diff line number Diff line
@@ -70,3 +70,14 @@ flag {
         purpose: PURPOSE_BUGFIX
     }
}

flag {
     namespace: "backstage_power"
     name: "skip_bg_mem_trim_on_fg_app"
     description: "Skip background memory trim event on foreground processes."
     is_fixed_read_only: true
     bug: "308927629"
     metadata {
         purpose: PURPOSE_BUGFIX
     }
}