Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e18ba47b authored by Joanne Chung's avatar Joanne Chung Committed by Android (Google) Code Review
Browse files

Merge "Handle permission grant for TextClassifierService."

parents bc189e7d 7d9ad18c
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -3560,13 +3560,14 @@
         set to empty string), a default textclassifier will be loaded in the calling app's process.
         set to empty string), a default textclassifier will be loaded in the calling app's process.
         See android.view.textclassifier.TextClassificationManager.
         See android.view.textclassifier.TextClassificationManager.
    -->
    -->
    <!-- TODO(b/144896755) remove the config -->
    <string name="config_defaultTextClassifierPackage" translatable="false"></string>
    <string name="config_defaultTextClassifierPackage" translatable="false"></string>


    <!-- A list of the default system textclassifier service package name. Only one of the packages
    <!-- A list of supported system textClassifier service package names. Only one of the packages
         will be activated and the fist package is the default system textclassifier service. OS
         will be activated. The first package in the list is the default system textClassifier
         only tries to bind the first trusted service and the others can be selected via device
         service. OS only tries to bind and grant permissions to the first trusted service and the
         config. These services must be trusted, as they can be activated without explicit consent
         others can be selected via device config. These services must be trusted, as they can be
         of the user. Example: "com.android.textclassifier"
         activated without explicit consent of the user. Example: "com.android.textclassifier"
    -->
    -->
    <string-array name="config_defaultTextClassifierPackages" translatable="false">
    <string-array name="config_defaultTextClassifierPackages" translatable="false">
        <item>android.ext.services</item>
        <item>android.ext.services</item>
+7 −5
Original line number Original line Diff line number Diff line
@@ -726,10 +726,12 @@ public final class DefaultPermissionGrantPolicy {
                userId, STORAGE_PERMISSIONS);
                userId, STORAGE_PERMISSIONS);


        // TextClassifier Service
        // TextClassifier Service
        String textClassifierPackageName =
        final String[] packages = mContext.getPackageManager().getSystemTextClassifierPackages();
                mContext.getPackageManager().getSystemTextClassifierPackageName();
        if (packages.length > 0) {
        if (!TextUtils.isEmpty(textClassifierPackageName)) {
            // We have a list of supported system TextClassifier package names, the first one
            grantPermissionsToSystemPackage(textClassifierPackageName, userId,
            // package is the default system TextClassifier service. Grant permissions to default
            // TextClassifier Service.
            grantPermissionsToSystemPackage(packages[0], userId,
                    COARSE_BACKGROUND_LOCATION_PERMISSIONS, CONTACTS_PERMISSIONS);
                    COARSE_BACKGROUND_LOCATION_PERMISSIONS, CONTACTS_PERMISSIONS);
        }
        }


@@ -998,7 +1000,7 @@ public final class DefaultPermissionGrantPolicy {
    private void revokeRuntimePermissions(String packageName, Set<String> permissions,
    private void revokeRuntimePermissions(String packageName, Set<String> permissions,
            boolean systemFixed, int userId) {
            boolean systemFixed, int userId) {
        PackageInfo pkg = getSystemPackageInfo(packageName);
        PackageInfo pkg = getSystemPackageInfo(packageName);
        if (ArrayUtils.isEmpty(pkg.requestedPermissions)) {
        if (pkg == null || ArrayUtils.isEmpty(pkg.requestedPermissions)) {
            return;
            return;
        }
        }
        Set<String> revokablePermissions = new ArraySet<>(Arrays.asList(pkg.requestedPermissions));
        Set<String> revokablePermissions = new ArraySet<>(Arrays.asList(pkg.requestedPermissions));