Update checking of flag MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS
Update the logic in PackageParser to avoid unistalled system app
can't be found.
Test: follow steps on b/80444486 and can add account normally
Test: PackageManagerTest
Bug: 80444486
Change-Id: Ifafac34111d883e51563018be793655c25d09fba
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index b8eb074..cfa7af8 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -95,6 +95,7 @@
import com.android.internal.os.ClassLoaderFactory;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.XmlUtils;
+import com.android.server.SystemConfig;
import libcore.io.IoUtils;
import libcore.util.EmptyArray;
@@ -640,9 +641,12 @@
private static boolean checkUseInstalledOrHidden(int flags, PackageUserState state,
ApplicationInfo appInfo) {
// Returns false if the package is hidden system app until installed.
- if ((flags & PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS) == 0
- && !state.installed
- && appInfo != null && appInfo.isSystemApp()) {
+ final ArraySet<String> hiddenSystemApps =
+ SystemConfig.getInstance().getDisabledUntilUsedPreinstalledCarrierApps();
+ if (!state.installed
+ && appInfo != null && appInfo.isSystemApp()
+ && hiddenSystemApps.contains(appInfo.packageName)
+ && (flags & PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS) == 0) {
return false;
}