summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 7f5a865935b4..e322e0e005e7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4451,8 +4451,17 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- final boolean clearPendingIntentsForStoppedApp = (android.content.pm.Flags.stayStopped()
- && packageStateStopped);
+ boolean clearPendingIntentsForStoppedApp = false;
+ try {
+ clearPendingIntentsForStoppedApp = (packageStateStopped
+ && android.content.pm.Flags.stayStopped());
+ } catch (IllegalStateException e) {
+ // It's unlikely for a package to be force-stopped early in the boot cycle. So, if we
+ // check for 'packageStateStopped' which should evaluate to 'false', then this should
+ // ensure we are not accessing the flag early in the boot cycle. As an additional
+ // safety measure, catch the exception and ignore to avoid causing a device restart.
+ clearPendingIntentsForStoppedApp = false;
+ }
if (packageName == null || uninstalling || clearPendingIntentsForStoppedApp) {
didSomething |= mPendingIntentController.removePendingIntentsForPackage(
packageName, userId, appId, doit);