Fix default permission granting for system TextClassifier.
The original code calls TCS.getServiceComponentName to get the package
name of the configured system TextClassifier, which does not work before
user logs in. This fixes the problem by using the package name from the
configuration directly.
Test: Manually tested to confirm permissions were granted. Permission
section of the app info are gray.
Bug: 74779259
Change-Id: I6bff7119e174c0e0b17d9736d69075f6df2bc882
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 bf85f30..83fe1c9 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -55,6 +55,7 @@
import android.security.Credentials;
import android.service.textclassifier.TextClassifierService;
import android.telephony.TelephonyManager;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
@@ -829,13 +830,11 @@
}
// TextClassifier Service
- ComponentName textClassifierComponent =
- TextClassifierService.getServiceComponentName(mContext);
- if (textClassifierComponent != null) {
- Intent textClassifierServiceIntent = new Intent(TextClassifierService.SERVICE_INTERFACE)
- .setComponent(textClassifierComponent);
+ String textClassifierPackageName =
+ mContext.getPackageManager().getSystemTextClassifierPackageName();
+ if (!TextUtils.isEmpty(textClassifierPackageName)) {
PackageParser.Package textClassifierPackage =
- getDefaultSystemHandlerServicePackage(textClassifierServiceIntent, userId);
+ getSystemPackage(textClassifierPackageName);
if (textClassifierPackage != null
&& doesPackageSupportRuntimePermissions(textClassifierPackage)) {
grantRuntimePermissions(textClassifierPackage, PHONE_PERMISSIONS, true, userId);