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

Commit a3467673 authored by Martijn Coenen's avatar Martijn Coenen Committed by Android (Google) Code Review
Browse files

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

parents 1637159b 876ab66e
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,