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

Commit 5b2e6e7c authored by Martijn Coenen's avatar Martijn Coenen Committed by Automerger Merge Worker
Browse files

Merge "Exclude headless packages from being scanned as stopped." into udc-dev...

Merge "Exclude headless packages from being scanned as stopped." into udc-dev am: a3467673 am: dfcef7d0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22425570



Change-Id: Id18ae2de22b61a701b5bdd4f8ff00bdeec560ff5
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8fb87ff2 dfcef7d0
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.SharedLibraryInfo;
import android.content.pm.Signature;
import android.content.pm.SigningDetails;
@@ -3975,6 +3976,24 @@ final class InstallPackageHelper {
                mPm.mSettings.disableSystemPackageLPw(parsedPackage.getPackageName(), true);
            }
        }

        // If this is a system app we hadn't seen before, and this is a first boot or OTA,
        // we need to unstop it if it doesn't have a launcher entry.
        if (mPm.mShouldStopSystemPackagesByDefault && scanResult.mRequest.mPkgSetting == null
                && ((scanFlags & SCAN_FIRST_BOOT_OR_UPGRADE) != 0)
                && ((scanFlags & SCAN_AS_SYSTEM) != 0)) {
            final Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
            launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
            launcherIntent.setPackage(parsedPackage.getPackageName());
            final List<ResolveInfo> launcherActivities =
                    mPm.snapshotComputer().queryIntentActivitiesInternal(launcherIntent, null,
                            PackageManager.MATCH_DIRECT_BOOT_AWARE
                            | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, 0);
            if (launcherActivities.isEmpty()) {
                scanResult.mPkgSetting.setStopped(false, 0);
            }
        }

        if (mIncrementalManager != null && isIncrementalPath(parsedPackage.getPath())) {
            if (scanResult.mPkgSetting != null && scanResult.mPkgSetting.isLoading()) {
                // Continue monitoring loading progress of active incremental packages
+14 −1
Original line number Diff line number Diff line
@@ -4293,10 +4293,23 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile

                // Non-Apex system apps, that are not included in the allowlist in
                // initialNonStoppedSystemPackages, should be marked as stopped by default.
                final boolean shouldBeStopped = service.mShouldStopSystemPackagesByDefault
                boolean shouldBeStopped = service.mShouldStopSystemPackagesByDefault
                        && ps.isSystem()
                        && !ps.isApex()
                        && !service.mInitialNonStoppedSystemPackages.contains(ps.getPackageName());
                if (shouldBeStopped) {
                    final Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
                    launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                    launcherIntent.setPackage(ps.getPackageName());
                    final List<ResolveInfo> launcherActivities =
                            service.snapshotComputer().queryIntentActivitiesInternal(launcherIntent,
                                    null,
                                    PackageManager.MATCH_DIRECT_BOOT_AWARE
                                    | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, 0);
                    if (launcherActivities.isEmpty()) {
                        shouldBeStopped = false;
                    }
                }
                ps.setStopped(shouldBeStopped, userHandle);

                // If userTypeInstallablePackages is the *only* reason why we're not installing,