From e8d7c840ea91f0199573d89b3e4e700c576617c1 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java index 804e442bc8dea..17930ea9c93cc 100644 --- a/services/core/java/com/android/server/am/ServiceRecord.java +++ b/services/core/java/com/android/server/am/ServiceRecord.java @@ -927,9 +927,9 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN } public void postNotification() { - final int appUid = appInfo.uid; - final int appPid = app.getPid(); - 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 // avoid deadlocks. final String localPackageName = packageName;