Merge "Migrate from config.xml to SystemConfig for disabled carrier apps" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-27 21:48:06 +00:00
committed by Android (Google) Code Review
4 changed files with 55 additions and 32 deletions

View File

@@ -142,12 +142,24 @@ public class SystemConfig {
// Package names that are exempted from private API blacklisting
final ArraySet<String> mHiddenApiPackageWhitelist = new ArraySet<>();
// The list of carrier applications which should be disabled until used.
// This function suppresses update notifications for these pre-installed apps.
// In SubscriptionInfoUpdater, the listed applications are disabled until used when all of the
// following conditions are met.
// 1. Not currently carrier-privileged according to the inserted SIM
// 2. Pre-installed
// 3. In the default state (enabled but not explicitly)
// And SubscriptionInfoUpdater undoes this and marks the app enabled when a SIM is inserted
// that marks the app as carrier privileged. It also grants the app default permissions
// for Phone and Location. As such, apps MUST only ever be added to this list if they
// obtain user consent to access their location through other means.
final ArraySet<String> mDisabledUntilUsedPreinstalledCarrierApps = new ArraySet<>();
// These are the packages of carrier-associated apps which should be disabled until used until
// a SIM is inserted which grants carrier privileges to that carrier app.
final ArrayMap<String, List<String>> mDisabledUntilUsedPreinstalledCarrierAssociatedApps =
new ArrayMap<>();
final ArrayMap<String, ArraySet<String>> mPrivAppPermissions = new ArrayMap<>();
final ArrayMap<String, ArraySet<String>> mPrivAppDenyPermissions = new ArrayMap<>();
@@ -232,6 +244,10 @@ public class SystemConfig {
return mBackupTransportWhitelist;
}
public ArraySet<String> getDisabledUntilUsedPreinstalledCarrierApps() {
return mDisabledUntilUsedPreinstalledCarrierApps;
}
public ArrayMap<String, List<String>> getDisabledUntilUsedPreinstalledCarrierAssociatedApps() {
return mDisabledUntilUsedPreinstalledCarrierAssociatedApps;
}
@@ -630,6 +646,18 @@ public class SystemConfig {
associatedPkgs.add(pkgname);
}
XmlUtils.skipCurrentTag(parser);
} else if ("disabled-until-used-preinstalled-carrier-app".equals(name)
&& allowAppConfigs) {
String pkgname = parser.getAttributeValue(null, "package");
if (pkgname == null) {
Slog.w(TAG,
"<disabled-until-used-preinstalled-carrier-app> without "
+ "package in " + permFile + " at "
+ parser.getPositionDescription());
} else {
mDisabledUntilUsedPreinstalledCarrierApps.add(pkgname);
}
XmlUtils.skipCurrentTag(parser);
} else if ("privapp-permissions".equals(name) && allowPrivappPermissions) {
// privapp permissions from system, vendor and product partitions are stored
// separately. This is to prevent xml files in the vendor partition from

View File

@@ -2392,19 +2392,6 @@
<item>com.android.inputmethod.latin</item>
</string-array>
<!-- The list of carrier applications which should be disabled until used.
This function suppresses update notifications for these pre-installed apps.
In SubscriptionInfoUpdater, the listed applications are disabled until used when all of the
following conditions are met.
1. Not currently carrier-privileged according to the inserted SIM
2. Pre-installed
3. In the default state (enabled but not explicitly)
And SubscriptionInfoUpdater undoes this and marks the app enabled when a SIM is inserted
that marks the app as carrier privileged. It also grants the app default permissions
for Phone and Location. As such, apps MUST only ever be added to this list if they
obtain user consent to access their location through other means. -->
<string-array name="config_disabledUntilUsedPreinstalledCarrierApps" translatable="false" />
<!-- The list of classes that should be added to the notification ranking pipeline.
See {@link com.android.server.notification.NotificationSignalExtractor}
If you add a new extractor to this list make sure to update

View File

@@ -1233,7 +1233,6 @@
<java-symbol type="array" name="supported_locales" />
<java-symbol type="array" name="config_cdma_dun_supported_types" />
<java-symbol type="array" name="config_disabledUntilUsedPreinstalledImes" />
<java-symbol type="array" name="config_disabledUntilUsedPreinstalledCarrierApps" />
<java-symbol type="array" name="config_callBarringMMI" />
<java-symbol type="array" name="config_globalActionsList" />
<java-symbol type="array" name="config_telephonyEuiccDeviceCapabilities" />

View File

@@ -26,6 +26,7 @@ import android.os.RemoteException;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
@@ -49,10 +50,11 @@ public final class CarrierAppUtils {
/**
* Handle preinstalled carrier apps which should be disabled until a matching SIM is inserted.
*
* Evaluates the list of applications in config_disabledUntilUsedPreinstalledCarrierApps. We
* want to disable each such application which is present on the system image until the user
* inserts a SIM which causes that application to gain carrier privilege (indicating a "match"),
* without interfering with the user if they opt to enable/disable the app explicitly.
* Evaluates the list of applications in
* {@link SystemConfig#getDisabledUntilUsedPreinstalledCarrierApps()}. We want to disable each
* such application which is present on the system image until the user inserts a SIM which
* causes that application to gain carrier privilege (indicating a "match"), without interfering
* with the user if they opt to enable/disable the app explicitly.
*
* So, for each such app, we either disable until used IFF the app is not carrier privileged AND
* in the default state (e.g. not explicitly DISABLED/DISABLED_BY_USER/ENABLED), or we enable if
@@ -76,8 +78,8 @@ public final class CarrierAppUtils {
Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
}
SystemConfig config = SystemConfig.getInstance();
String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(
com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
ArraySet<String> systemCarrierAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierApps();
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
disableCarrierAppsUntilPrivileged(callingPackage, packageManager, telephonyManager,
@@ -102,8 +104,10 @@ public final class CarrierAppUtils {
Slog.d(TAG, "disableCarrierAppsUntilPrivileged");
}
SystemConfig config = SystemConfig.getInstance();
String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(
com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
ArraySet<String> systemCarrierAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierApps();
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
disableCarrierAppsUntilPrivileged(callingPackage, packageManager,
@@ -116,7 +120,7 @@ public final class CarrierAppUtils {
public static void disableCarrierAppsUntilPrivileged(String callingPackage,
IPackageManager packageManager, @Nullable TelephonyManager telephonyManager,
ContentResolver contentResolver, int userId,
String[] systemCarrierAppsDisabledUntilUsed,
ArraySet<String> systemCarrierAppsDisabledUntilUsed,
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper(packageManager,
userId, systemCarrierAppsDisabledUntilUsed);
@@ -286,8 +290,8 @@ public final class CarrierAppUtils {
*/
public static List<ApplicationInfo> getDefaultCarrierAppCandidates(
IPackageManager packageManager, int userId) {
String[] systemCarrierAppsDisabledUntilUsed = Resources.getSystem().getStringArray(
com.android.internal.R.array.config_disabledUntilUsedPreinstalledCarrierApps);
ArraySet<String> systemCarrierAppsDisabledUntilUsed =
SystemConfig.getInstance().getDisabledUntilUsedPreinstalledCarrierApps();
return getDefaultCarrierAppCandidatesHelper(packageManager, userId,
systemCarrierAppsDisabledUntilUsed);
}
@@ -295,14 +299,19 @@ public final class CarrierAppUtils {
private static List<ApplicationInfo> getDefaultCarrierAppCandidatesHelper(
IPackageManager packageManager,
int userId,
String[] systemCarrierAppsDisabledUntilUsed) {
if (systemCarrierAppsDisabledUntilUsed == null
|| systemCarrierAppsDisabledUntilUsed.length == 0) {
ArraySet<String> systemCarrierAppsDisabledUntilUsed) {
if (systemCarrierAppsDisabledUntilUsed == null) {
return null;
}
List<ApplicationInfo> apps = new ArrayList<>(systemCarrierAppsDisabledUntilUsed.length);
for (int i = 0; i < systemCarrierAppsDisabledUntilUsed.length; i++) {
String packageName = systemCarrierAppsDisabledUntilUsed[i];
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 =
getApplicationInfoIfSystemApp(packageManager, userId, packageName);
if (ai != null) {