Add PermissionManager exposing SPLIT_PERMISSIONS
The Permission Controller app (a mainline module) needs to be able to
read the SPLIT_PERMISSIONS. Hence this array needs to be exposed at
least as system-api. We need to make sure that the PackageParser,
PackageManager and Permission Controller app agree on which permissions
are split, hence it is best to define them at a single location.
I think exposing the split permissions to developers is useless and
potentially confusing. The app should never request a permission that
was split. The app should just behave as if split permissions do not
exist. The Permission Controller / Package Manager deal with the
split permissions and add them when needed. Hence I don't think we
should expose this data to 3rd parties.
Bug: 110953302
Test: requested permissions
Change-Id: I6951c52979c89ee5c13a4a14da125e1a01f2e234
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 3c9dd63..6f644dd 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -34,7 +34,6 @@
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageManagerInternal.PackagesProvider;
import android.content.pm.PackageManagerInternal.SyncAdapterPackagesProvider;
-import android.content.pm.PackageParser;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.media.RingtoneManager;
@@ -48,6 +47,7 @@
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.storage.StorageManager;
+import android.permission.PermissionManager;
import android.print.PrintManager;
import android.provider.CalendarContract;
import android.provider.ContactsContract;
@@ -1024,15 +1024,17 @@
ApplicationInfo applicationInfo = pkg.applicationInfo;
// Automatically attempt to grant split permissions to older APKs
- final int numSplitPerms = PackageParser.SPLIT_PERMISSIONS.length;
+ final List<PermissionManager.SplitPermissionInfo> splitPermissions =
+ mContext.getSystemService(PermissionManager.class).getSplitPermissions();
+ final int numSplitPerms = splitPermissions.size();
for (int splitPermNum = 0; splitPermNum < numSplitPerms; splitPermNum++) {
- final PackageParser.SplitPermissionInfo splitPerm =
- PackageParser.SPLIT_PERMISSIONS[splitPermNum];
+ final PermissionManager.SplitPermissionInfo splitPerm =
+ splitPermissions.get(splitPermNum);
if (applicationInfo != null
- && applicationInfo.targetSdkVersion < splitPerm.targetSdk
- && permissionsWithoutSplits.contains(splitPerm.rootPerm)) {
- Collections.addAll(permissions, splitPerm.newPerms);
+ && applicationInfo.targetSdkVersion < splitPerm.getTargetSdk()
+ && permissionsWithoutSplits.contains(splitPerm.getRootPermission())) {
+ Collections.addAll(permissions, splitPerm.getNewPermissions());
}
}