Don't reset OOM adjType to cch-empty during recomputing on cycles

The first pass should have an equivalent or better value for it.
During oom recomputing on cycles, if the result of recomputation
is no better than the given 'cachedAdj', its adjType won't be updated,
therefore we'd need to keep its current value as is.

Bug: 156123244
Test: atest MockingOomAdjusterTests
Test: atest FrameworksServicesTests:ActivityManagerServiceTest
Test: atest CtsAppTestCases:ActivityManagerProcessStateTest
Test: Manual - adb shell dumpsys activity oom
Change-Id: Ic4adf76656575926d16c0a037d955795061116e3
This commit is contained in:
Jing Ji
2020-05-28 21:45:21 -07:00
parent 851415b693
commit ea036c8416
2 changed files with 14 additions and 3 deletions

View File

@@ -1260,9 +1260,11 @@ public final class OomAdjuster {
// value that the caller wants us to.
adj = cachedAdj;
procState = PROCESS_STATE_CACHED_EMPTY;
app.setCached(true);
app.empty = true;
app.adjType = "cch-empty";
if (!app.containsCycle) {
app.setCached(true);
app.empty = true;
app.adjType = "cch-empty";
}
if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
reportOomAdjMessageLocked(TAG_OOM_ADJ, "Making empty: " + app);
}

View File

@@ -1387,6 +1387,15 @@ public class MockingOomAdjusterTests {
SCHED_GROUP_DEFAULT);
assertProcStates(app3, PROCESS_STATE_FOREGROUND_SERVICE, PERCEPTIBLE_APP_ADJ,
SCHED_GROUP_DEFAULT);
assertEquals("service", app.adjType);
assertEquals("service", app2.adjType);
assertEquals("fg-service", app3.adjType);
assertEquals(false, app.isCached());
assertEquals(false, app2.isCached());
assertEquals(false, app3.isCached());
assertEquals(false, app.empty);
assertEquals(false, app2.empty);
assertEquals(false, app3.empty);
}
@SuppressWarnings("GuardedBy")