From 7d7ee57b4dbbe4723c19cf5308eee10d6c6cf2a6 Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Thu, 30 Jun 2022 16:15:46 -0700 Subject: Don't freeze apps in the power exemption allow list. Set the "should not freeze" flag in oom adjuster if the app is in the power exemption allow list, as it doesn't make sense to freeze such kind of apps. There is an existing call to update the oom adj when the power exemption list changes. Bug: 237178259 Bug: 231253560 Test: Manual - see b/237178259#comment20 Test: atest CachedAppOptimizerTest Change-Id: I5fd1e623f60680b34096f0e58a088f72bf1089cb (cherry picked from commit 60e35ca3df2a91923b62f3533bda1f10b671e46b) Merged-In: I5fd1e623f60680b34096f0e58a088f72bf1089cb --- services/core/java/com/android/server/am/OomAdjuster.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java index e7fcc5989467..f7fbbe4ebead 100644 --- a/services/core/java/com/android/server/am/OomAdjuster.java +++ b/services/core/java/com/android/server/am/OomAdjuster.java @@ -1482,7 +1482,9 @@ public class OomAdjuster { if (!cycleReEval) { // Don't reset this flag when doing cycles re-evaluation. state.setNoKillOnBgRestrictedAndIdle(false); - app.mOptRecord.setShouldNotFreeze(false); + // If this UID is currently allowlisted, it should not be frozen. + final UidRecord uidRec = app.getUidRecord(); + app.mOptRecord.setShouldNotFreeze(uidRec != null && uidRec.isCurAllowListed()); } final int appUid = app.info.uid; -- cgit v1.2.3-59-g8ed1b