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

Commit c8dfa7d8 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Address exception thrown by PackageManager for newly installed app

Catch the IllegalArgumentException in case the app doesn't have
any history in PackageManager.

Bug: 307520819
Test: atest CtsPermissionUiTestCases
Change-Id: Ibf0c4df6b6f6fb3eb6f4b39295b495c43856216f
parent 2a9682ce
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -3259,13 +3259,18 @@ public final class ProcessList {

        // Check if we should mark the processrecord for first launch after force-stopping
        if ((r.getApplicationInfo().flags & ApplicationInfo.FLAG_STOPPED) != 0) {
            try {
                final boolean wasPackageEverLaunched = mService.getPackageManagerInternal()
                        .wasPackageEverLaunched(r.getApplicationInfo().packageName, r.userId);
                // If the package was launched in the past but is currently stopped, only then it
            // should be considered as stopped after use. Do not mark it if it's the first launch.
                // should be considered as stopped after use. Do not mark it if it's the
                // first launch.
                if (wasPackageEverLaunched) {
                    r.setWasForceStopped(true);
                }
            } catch (IllegalArgumentException e) {
                // App doesn't have state yet, so wasn't forcestopped
            }
        }

        if (!isolated && !isSdkSandbox