Loading telephony/common/com/android/internal/telephony/CarrierAppUtils.java +13 −48 Original line number Diff line number Diff line Loading @@ -123,6 +123,14 @@ public final class CarrierAppUtils { return userContext.getContentResolver(); } private static boolean isUpdatedSystemApp(ApplicationInfo ai) { if ((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { return true; } return false; } /** * Disable carrier apps until they are privileged * Must be public b/c framework unit tests can't access package-private methods. Loading @@ -137,7 +145,7 @@ public final class CarrierAppUtils { PackageManager packageManager = context.getPackageManager(); PermissionManager permissionManager = (PermissionManager) context.getSystemService(Context.PERMISSION_SERVICE); List<ApplicationInfo> candidates = getDefaultNotUpdatedCarrierAppCandidatesHelper( List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper( userId, systemCarrierAppsDisabledUntilUsed, context); if (candidates == null || candidates.isEmpty()) { return; Loading Loading @@ -176,7 +184,7 @@ public final class CarrierAppUtils { if (hasPrivileges) { // Only update enabled state for the app on /system. Once it has been // updated we shouldn't touch it. if (enabledSetting if (!isUpdatedSystemApp(ai) && enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT || enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED Loading Loading @@ -230,7 +238,7 @@ public final class CarrierAppUtils { } else { // No carrier privileges // Only update enabled state for the app on /system. Once it has been // updated we shouldn't touch it. if (enabledSetting if (!isUpdatedSystemApp(ai) && enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) { Log.i(TAG, "Update state(" + packageName Loading Loading @@ -361,29 +369,6 @@ public final class CarrierAppUtils { return apps; } private static List<ApplicationInfo> getDefaultNotUpdatedCarrierAppCandidatesHelper( int userId, ArraySet<String> systemCarrierAppsDisabledUntilUsed, Context context) { if (systemCarrierAppsDisabledUntilUsed == null) { return null; } int size = systemCarrierAppsDisabledUntilUsed.size(); if (size == 0) { return null; } List<ApplicationInfo> apps = new ArrayList<>(size); for (int i = 0; i < size; i++) { String packageName = systemCarrierAppsDisabledUntilUsed.valueAt(i); ApplicationInfo ai = getApplicationInfoIfNotUpdatedSystemApp(userId, packageName, context); if (ai != null) { apps.add(ai); } } return apps; } private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper( int userId, ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed, Context context) { Loading @@ -395,11 +380,11 @@ public final class CarrierAppUtils { systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i); for (int j = 0; j < associatedAppPackages.size(); j++) { ApplicationInfo ai = getApplicationInfoIfNotUpdatedSystemApp( getApplicationInfoIfSystemApp( userId, associatedAppPackages.get(j), context); // Only update enabled state for the app on /system. Once it has been updated we // shouldn't touch it. if (ai != null) { if (ai != null && !isUpdatedSystemApp(ai)) { List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage); if (appList == null) { appList = new ArrayList<>(); Loading @@ -412,26 +397,6 @@ public final class CarrierAppUtils { return associatedApps; } @Nullable private static ApplicationInfo getApplicationInfoIfNotUpdatedSystemApp( int userId, String packageName, Context context) { try { ApplicationInfo ai = context.createContextAsUser(UserHandle.of(userId), 0) .getPackageManager() .getApplicationInfo(packageName, PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS | PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_FACTORY_ONLY); if (ai != null) { return ai; } } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Could not reach PackageManager", e); } return null; } @Nullable private static ApplicationInfo getApplicationInfoIfSystemApp( int userId, String packageName, Context context) { Loading Loading
telephony/common/com/android/internal/telephony/CarrierAppUtils.java +13 −48 Original line number Diff line number Diff line Loading @@ -123,6 +123,14 @@ public final class CarrierAppUtils { return userContext.getContentResolver(); } private static boolean isUpdatedSystemApp(ApplicationInfo ai) { if ((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { return true; } return false; } /** * Disable carrier apps until they are privileged * Must be public b/c framework unit tests can't access package-private methods. Loading @@ -137,7 +145,7 @@ public final class CarrierAppUtils { PackageManager packageManager = context.getPackageManager(); PermissionManager permissionManager = (PermissionManager) context.getSystemService(Context.PERMISSION_SERVICE); List<ApplicationInfo> candidates = getDefaultNotUpdatedCarrierAppCandidatesHelper( List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper( userId, systemCarrierAppsDisabledUntilUsed, context); if (candidates == null || candidates.isEmpty()) { return; Loading Loading @@ -176,7 +184,7 @@ public final class CarrierAppUtils { if (hasPrivileges) { // Only update enabled state for the app on /system. Once it has been // updated we shouldn't touch it. if (enabledSetting if (!isUpdatedSystemApp(ai) && enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT || enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED Loading Loading @@ -230,7 +238,7 @@ public final class CarrierAppUtils { } else { // No carrier privileges // Only update enabled state for the app on /system. Once it has been // updated we shouldn't touch it. if (enabledSetting if (!isUpdatedSystemApp(ai) && enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) { Log.i(TAG, "Update state(" + packageName Loading Loading @@ -361,29 +369,6 @@ public final class CarrierAppUtils { return apps; } private static List<ApplicationInfo> getDefaultNotUpdatedCarrierAppCandidatesHelper( int userId, ArraySet<String> systemCarrierAppsDisabledUntilUsed, Context context) { if (systemCarrierAppsDisabledUntilUsed == null) { return null; } int size = systemCarrierAppsDisabledUntilUsed.size(); if (size == 0) { return null; } List<ApplicationInfo> apps = new ArrayList<>(size); for (int i = 0; i < size; i++) { String packageName = systemCarrierAppsDisabledUntilUsed.valueAt(i); ApplicationInfo ai = getApplicationInfoIfNotUpdatedSystemApp(userId, packageName, context); if (ai != null) { apps.add(ai); } } return apps; } private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper( int userId, ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed, Context context) { Loading @@ -395,11 +380,11 @@ public final class CarrierAppUtils { systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i); for (int j = 0; j < associatedAppPackages.size(); j++) { ApplicationInfo ai = getApplicationInfoIfNotUpdatedSystemApp( getApplicationInfoIfSystemApp( userId, associatedAppPackages.get(j), context); // Only update enabled state for the app on /system. Once it has been updated we // shouldn't touch it. if (ai != null) { if (ai != null && !isUpdatedSystemApp(ai)) { List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage); if (appList == null) { appList = new ArrayList<>(); Loading @@ -412,26 +397,6 @@ public final class CarrierAppUtils { return associatedApps; } @Nullable private static ApplicationInfo getApplicationInfoIfNotUpdatedSystemApp( int userId, String packageName, Context context) { try { ApplicationInfo ai = context.createContextAsUser(UserHandle.of(userId), 0) .getPackageManager() .getApplicationInfo(packageName, PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS | PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_FACTORY_ONLY); if (ai != null) { return ai; } } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Could not reach PackageManager", e); } return null; } @Nullable private static ApplicationInfo getApplicationInfoIfSystemApp( int userId, String packageName, Context context) { Loading