diff options
| author | 2023-07-18 16:33:32 -0700 | |
|---|---|---|
| committer | 2023-07-18 16:45:01 -0700 | |
| commit | a1c1f2e29f0fbb6f7ea61db445906c4bfc5e4f33 (patch) | |
| tree | 8378fa7154ed88bba60764835b62370432244af4 | |
| parent | c3415b9f2ff755cde0403eb121e99de924007edd (diff) | |
[pm] do not stop system apps with disabled a launcher activity
If an app has a disabled/unexported launcher activity, it is effectively
the same as not having a launcher activity. We should not stop such
system apps by default.
BUG: 286459841
Test: manual with a system app that has disabled launcher activity and
verify that it is in the `stopped=false` state after first boot
Test: also tested updating such a system app and verified that it
remains in the un-stopped state after the update is uninstalled
Change-Id: Ie865aba7325e3442c6610ef962fce3a3a65f0b70
| -rw-r--r-- | services/core/java/com/android/server/pm/InstallPackageHelper.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index cc0cf48d486c..4f919deb9642 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -4315,7 +4315,8 @@ final class InstallPackageHelper { // - It's an APEX or overlay package since stopped state does not affect them. // - It is enumerated with a <initial-package-state> tag having the stopped attribute // set to false - // - It doesn't have a launcher entry which means the user doesn't have a way to unstop it + // - It doesn't have an enabled and exported launcher activity, which means the user + // wouldn't have a way to un-stop it final boolean isApexPkg = (scanFlags & SCAN_AS_APEX) != 0; if (mPm.mShouldStopSystemPackagesByDefault && scanSystemPartition @@ -4341,7 +4342,11 @@ final class InstallPackageHelper { categories.add(Intent.CATEGORY_LAUNCHER); final List<ParsedActivity> activities = parsedPackage.getActivities(); for (int indexActivity = 0; indexActivity < activities.size(); indexActivity++) { - final List<ParsedIntentInfo> intents = activities.get(indexActivity).getIntents(); + final ParsedActivity activity = activities.get(indexActivity); + if (!activity.isEnabled() || !activity.isExported()) { + continue; + } + final List<ParsedIntentInfo> intents = activity.getIntents(); for (int indexIntent = 0; indexIntent < intents.size(); indexIntent++) { final IntentFilter intentFilter = intents.get(indexIntent).getIntentFilter(); if (intentFilter != null && intentFilter.matchCategories(categories) == null) { |