From cc6e1394e91d6f1c6da9d3380a9ce85593855901 Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Thu, 5 Dec 2019 22:46:16 -0800 Subject: [PATCH] Clamp the new oom adj to perceptible if the important caller requests In case the more important client of the binding requests to restrict the oom adj score of the service, make sure clamp it correctly. Bug: 145785052 Test: Manual - Launch app with notification listener, check oom adj score Change-Id: I596f53c6ac6bd5d342165cf8224d0d0844eb016e --- services/core/java/com/android/server/am/OomAdjuster.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java index 12f46569bd20c..0fc885a2e61fe 100644 --- a/services/core/java/com/android/server/am/OomAdjuster.java +++ b/services/core/java/com/android/server/am/OomAdjuster.java @@ -1541,12 +1541,12 @@ public final class OomAdjuster { trackedProcState = true; } } else if ((cr.flags & Context.BIND_NOT_PERCEPTIBLE) != 0 - && clientAdj < ProcessList.PERCEPTIBLE_APP_ADJ - && adj > ProcessList.PERCEPTIBLE_LOW_APP_ADJ) { + && clientAdj <= ProcessList.PERCEPTIBLE_APP_ADJ + && adj >= ProcessList.PERCEPTIBLE_LOW_APP_ADJ) { newAdj = ProcessList.PERCEPTIBLE_LOW_APP_ADJ; } else if ((cr.flags&Context.BIND_NOT_VISIBLE) != 0 && clientAdj < ProcessList.PERCEPTIBLE_APP_ADJ - && adj > ProcessList.PERCEPTIBLE_APP_ADJ) { + && adj >= ProcessList.PERCEPTIBLE_APP_ADJ) { newAdj = ProcessList.PERCEPTIBLE_APP_ADJ; } else if (clientAdj >= ProcessList.PERCEPTIBLE_APP_ADJ) { newAdj = clientAdj;