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

Commit 2c01b6ca authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

Grant default permissions to TextClassifier app.

Bug: 72746494
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Change-Id: I92ab3a7d3041c7db521c49c0090e6813691341bd
parent 1d84b173
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.app.ActivityManager;
import android.app.DownloadManager;
import android.app.admin.DevicePolicyManager;
import android.companion.CompanionDeviceManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -52,6 +53,7 @@ import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.provider.Telephony.Sms.Intents;
import android.security.Credentials;
import android.service.textclassifier.TextClassifierService;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -826,6 +828,24 @@ public final class DefaultPermissionGrantPolicy {
                    STORAGE_PERMISSIONS, true, userId);
        }

        // TextClassifier Service
        ComponentName textClassifierComponent =
                TextClassifierService.getServiceComponentName(mContext);
        if (textClassifierComponent != null) {
            Intent textClassifierServiceIntent = new Intent(TextClassifierService.SERVICE_INTERFACE)
                    .setComponent(textClassifierComponent);
            PackageParser.Package textClassifierPackage =
                    getDefaultSystemHandlerServicePackage(textClassifierServiceIntent, userId);
            if (textClassifierPackage != null
                    && doesPackageSupportRuntimePermissions(textClassifierPackage)) {
                grantRuntimePermissions(textClassifierPackage, PHONE_PERMISSIONS, true, userId);
                grantRuntimePermissions(textClassifierPackage, SMS_PERMISSIONS, true, userId);
                grantRuntimePermissions(textClassifierPackage, CALENDAR_PERMISSIONS, true, userId);
                grantRuntimePermissions(textClassifierPackage, LOCATION_PERMISSIONS, true, userId);
                grantRuntimePermissions(textClassifierPackage, CONTACTS_PERMISSIONS, true, userId);
            }
        }

        if (mPermissionGrantedCallback != null) {
            mPermissionGrantedCallback.onDefaultRuntimePermissionsGranted(userId);
        }