From 97a609b82c7ee97cad0cdce853a8408a36b6ba78 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Thu, 3 Jun 2021 09:30:03 -0700 Subject: [PATCH] Fix false-positive matching of notification to FGS A combination of "uninitialized == 0 which is a valid and commonly used notification ID" with an incomplete check for "FGS with this notification." Bug: 189990824 Test: atest CtsAppTestCases:android.app.cts.ServiceTest Test: atest CtsAppTestCases:android.app.cts.NotificationManagerTest Change-Id: I845600325c4098e6b6af2f038de4c7aac9899694 --- services/core/java/com/android/server/am/ActiveServices.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 9e42900988432..e16a68d2167b3 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -2002,7 +2002,9 @@ public final class ActiveServices { for (int i = 0; i < smap.mServicesByInstanceName.size(); i++) { final ServiceRecord sr = smap.mServicesByInstanceName.valueAt(i); - if (id != sr.foregroundId || !pkg.equals(sr.appInfo.packageName)) { + if (!sr.isForeground + || id != sr.foregroundId + || !pkg.equals(sr.appInfo.packageName)) { // Not this one; keep looking continue; }