Merge "Use FLAG_UPDATED_SYSTEM_APP"
This commit is contained in:
@@ -127,6 +127,14 @@ public final class CarrierAppUtils {
|
|||||||
return userContext.getContentResolver();
|
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
|
* Disable carrier apps until they are privileged
|
||||||
* Must be public b/c framework unit tests can't access package-private methods.
|
* Must be public b/c framework unit tests can't access package-private methods.
|
||||||
@@ -138,7 +146,7 @@ public final class CarrierAppUtils {
|
|||||||
ContentResolver contentResolver, int userId,
|
ContentResolver contentResolver, int userId,
|
||||||
ArraySet<String> systemCarrierAppsDisabledUntilUsed,
|
ArraySet<String> systemCarrierAppsDisabledUntilUsed,
|
||||||
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
|
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
|
||||||
List<ApplicationInfo> candidates = getDefaultNotUpdatedCarrierAppCandidatesHelper(
|
List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper(
|
||||||
packageManager, userId, systemCarrierAppsDisabledUntilUsed);
|
packageManager, userId, systemCarrierAppsDisabledUntilUsed);
|
||||||
if (candidates == null || candidates.isEmpty()) {
|
if (candidates == null || candidates.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@@ -180,7 +188,7 @@ public final class CarrierAppUtils {
|
|||||||
if (hasPrivileges) {
|
if (hasPrivileges) {
|
||||||
// Only update enabled state for the app on /system. Once it has been
|
// Only update enabled state for the app on /system. Once it has been
|
||||||
// updated we shouldn't touch it.
|
// updated we shouldn't touch it.
|
||||||
if (enabledSetting
|
if (!isUpdatedSystemApp(ai) && enabledSetting
|
||||||
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|
||||||
|| enabledSetting
|
|| enabledSetting
|
||||||
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
|
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
|
||||||
@@ -232,7 +240,7 @@ public final class CarrierAppUtils {
|
|||||||
} else { // No carrier privileges
|
} else { // No carrier privileges
|
||||||
// Only update enabled state for the app on /system. Once it has been
|
// Only update enabled state for the app on /system. Once it has been
|
||||||
// updated we shouldn't touch it.
|
// updated we shouldn't touch it.
|
||||||
if (enabledSetting
|
if (!isUpdatedSystemApp(ai) && enabledSetting
|
||||||
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|
||||||
&& (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
&& (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
||||||
Log.i(TAG, "Update state(" + packageName
|
Log.i(TAG, "Update state(" + packageName
|
||||||
@@ -363,31 +371,6 @@ public final class CarrierAppUtils {
|
|||||||
return apps;
|
return apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ApplicationInfo> getDefaultNotUpdatedCarrierAppCandidatesHelper(
|
|
||||||
IPackageManager packageManager,
|
|
||||||
int userId,
|
|
||||||
ArraySet<String> systemCarrierAppsDisabledUntilUsed) {
|
|
||||||
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(packageManager, userId, packageName);
|
|
||||||
if (ai != null) {
|
|
||||||
apps.add(ai);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return apps;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper(
|
private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper(
|
||||||
IPackageManager packageManager,
|
IPackageManager packageManager,
|
||||||
int userId,
|
int userId,
|
||||||
@@ -400,11 +383,11 @@ public final class CarrierAppUtils {
|
|||||||
systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i);
|
systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i);
|
||||||
for (int j = 0; j < associatedAppPackages.size(); j++) {
|
for (int j = 0; j < associatedAppPackages.size(); j++) {
|
||||||
ApplicationInfo ai =
|
ApplicationInfo ai =
|
||||||
getApplicationInfoIfNotUpdatedSystemApp(
|
getApplicationInfoIfSystemApp(
|
||||||
packageManager, userId, associatedAppPackages.get(j));
|
packageManager, userId, associatedAppPackages.get(j));
|
||||||
// Only update enabled state for the app on /system. Once it has been updated we
|
// Only update enabled state for the app on /system. Once it has been updated we
|
||||||
// shouldn't touch it.
|
// shouldn't touch it.
|
||||||
if (ai != null) {
|
if (ai != null && !isUpdatedSystemApp(ai)) {
|
||||||
List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage);
|
List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage);
|
||||||
if (appList == null) {
|
if (appList == null) {
|
||||||
appList = new ArrayList<>();
|
appList = new ArrayList<>();
|
||||||
@@ -417,26 +400,6 @@ public final class CarrierAppUtils {
|
|||||||
return associatedApps;
|
return associatedApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static ApplicationInfo getApplicationInfoIfNotUpdatedSystemApp(
|
|
||||||
IPackageManager packageManager,
|
|
||||||
int userId,
|
|
||||||
String packageName) {
|
|
||||||
try {
|
|
||||||
ApplicationInfo ai = packageManager.getApplicationInfo(packageName,
|
|
||||||
PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
|
|
||||||
| PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS
|
|
||||||
| PackageManager.MATCH_SYSTEM_ONLY
|
|
||||||
| PackageManager.MATCH_FACTORY_ONLY, userId);
|
|
||||||
if (ai != null) {
|
|
||||||
return ai;
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.w(TAG, "Could not reach PackageManager", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ApplicationInfo getApplicationInfoIfSystemApp(
|
private static ApplicationInfo getApplicationInfoIfSystemApp(
|
||||||
IPackageManager packageManager,
|
IPackageManager packageManager,
|
||||||
|
|||||||
Reference in New Issue
Block a user