diff options
| author | 2019-12-23 05:49:00 +0000 | |
|---|---|---|
| committer | 2019-12-23 05:49:00 +0000 | |
| commit | e18ba47b781ffbaef48d4c42b8edadbefacfc7f7 (patch) | |
| tree | abdb5fbc706679cda8bef5887879dbacbbcd515f | |
| parent | bc189e7d113d0de5948a3b9f12cf0979159ab18e (diff) | |
| parent | 7d9ad18c8c533502958de7642ba001321fc52feb (diff) | |
Merge "Handle permission grant for TextClassifierService."
| -rw-r--r-- | core/res/res/values/config.xml | 11 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java | 12 |
2 files changed, 13 insertions, 10 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index f28f08b8abd1..9073a02e72d3 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3560,13 +3560,14 @@ set to empty string), a default textclassifier will be loaded in the calling app's process. See android.view.textclassifier.TextClassificationManager. --> + <!-- TODO(b/144896755) remove the config --> <string name="config_defaultTextClassifierPackage" translatable="false"></string> - <!-- A list of the default system textclassifier service package name. Only one of the packages - will be activated and the fist package is the default system textclassifier service. OS - only tries to bind the first trusted service and the others can be selected via device - config. These services must be trusted, as they can be activated without explicit consent - of the user. Example: "com.android.textclassifier" + <!-- A list of supported system textClassifier service package names. Only one of the packages + will be activated. The first package in the list is the default system textClassifier + service. OS only tries to bind and grant permissions to the first trusted service and the + others can be selected via device config. These services must be trusted, as they can be + activated without explicit consent of the user. Example: "com.android.textclassifier" --> <string-array name="config_defaultTextClassifierPackages" translatable="false"> <item>android.ext.services</item> diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java index 603b01a17e14..6d6ec250e4cc 100644 --- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java +++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java @@ -726,10 +726,12 @@ public final class DefaultPermissionGrantPolicy { userId, STORAGE_PERMISSIONS); // TextClassifier Service - String textClassifierPackageName = - mContext.getPackageManager().getSystemTextClassifierPackageName(); - if (!TextUtils.isEmpty(textClassifierPackageName)) { - grantPermissionsToSystemPackage(textClassifierPackageName, userId, + final String[] packages = mContext.getPackageManager().getSystemTextClassifierPackages(); + if (packages.length > 0) { + // We have a list of supported system TextClassifier package names, the first one + // package is the default system TextClassifier service. Grant permissions to default + // TextClassifier Service. + grantPermissionsToSystemPackage(packages[0], userId, COARSE_BACKGROUND_LOCATION_PERMISSIONS, CONTACTS_PERMISSIONS); } @@ -998,7 +1000,7 @@ public final class DefaultPermissionGrantPolicy { private void revokeRuntimePermissions(String packageName, Set<String> permissions, boolean systemFixed, int userId) { PackageInfo pkg = getSystemPackageInfo(packageName); - if (ArrayUtils.isEmpty(pkg.requestedPermissions)) { + if (pkg == null || ArrayUtils.isEmpty(pkg.requestedPermissions)) { return; } Set<String> revokablePermissions = new ArraySet<>(Arrays.asList(pkg.requestedPermissions)); |