From cfb47001df54c1ae3e3e4a5b53af7d55aa22831e Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Mon, 20 Sep 2021 16:08:05 -0700 Subject: [PATCH] No need to post FGS notifications after process death If the app dies during the deferral, we don't actually need to post the FGS notification. Since some of the service-related bookkeeping gets reset as part of teardown, this avoids potential invalid accesses. Bug: 197070543 Bug: 200555680 Test: atest CtsAppTestCases:android.app.cts.ServiceTest Test: atest CtsAppTestCases:android.app.cts.NotificationManagerTest Change-Id: I8a5eb91bb6070910ac973c195d118962265aec05 --- services/core/java/com/android/server/am/ServiceRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java index 3e59eeac1d4e2..91ee4eb4297f6 100644 --- a/services/core/java/com/android/server/am/ServiceRecord.java +++ b/services/core/java/com/android/server/am/ServiceRecord.java @@ -947,7 +947,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN } public void postNotification() { - if (isForeground && foregroundNoti != null) { + if (isForeground && foregroundNoti != null && app != null) { final int appUid = appInfo.uid; final int appPid = app.getPid(); // Do asynchronous communication with notification manager to