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
This commit is contained in:
Christopher Tate
2021-06-03 09:30:03 -07:00
parent 10de71a380
commit 97a609b82c

View File

@@ -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;
}