Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d678dd9 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Check for the package stoppped state first before checking the flag.

To avoid accessing the trunk stable flag early in the boot cycle,
check for the package stopped state first.

Bug: 336723189
Bug: 332922400
Test: atest tests/app/src/android/app/cts/ForceStopTest.java
Flag: android.content.pm.stay_stopped
Change-Id: Ic8003c4093073d8ac5a90e971c4b7ddde61d0ef5
parent 44443335
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -4436,8 +4436,17 @@ public class ActivityManagerService extends IActivityManager.Stub
                        packageName, null, userId);
        }
        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) {
            final int cancelReason;
            if (packageName == null) {