diff options
| author | 2023-01-06 18:48:12 -0800 | |
|---|---|---|
| committer | 2023-01-07 04:13:12 -0800 | |
| commit | c90f85e70a86c4a3b4287097e08e8f3f727feb4b (patch) | |
| tree | 96943a630a205e4759728f94c7812a2972d08b40 /services/permission/java | |
| parent | ef3dd32c26dd0b7162c1dc5249193faf2f5ad92d (diff) | |
Compute PermissionInfo.FLAG_INSTALLED instead of mutating ParsedPermission.
PermissionInfo.FLAG_INSTALLED is about the current system state
instead of the permission definition itself as in its APK, so we
shouldn't be mutating the ParsedPermission object to return it.
Instead, we now follow what we did for granted permissions and gather
and pass installed permissions similarly, so that we return the right
flag in PackageInfo.permissions.
For other methods returning PermissionInfo, they are all returning
permission definitions that are registered in the system, so we can
just unconditionally add FLAG_INSTALLED to them.
This resolves the issue when the new subsystem is enabled that
PermissionController refuses to manage a permission if its definition
doesn't have FLAG_INSTALLED.
Bug: 263504888
Test: manual
Change-Id: I891fa8b3adf7095a3c09ac448e1e377d432dafdc
Diffstat (limited to 'services/permission/java')
| -rw-r--r-- | services/permission/java/com/android/server/permission/access/permission/PermissionService.kt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt index dd36c38c1bd4..acd0a3cbbb98 100644 --- a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt +++ b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt @@ -241,6 +241,9 @@ class PermissionService( ): PermissionInfo = @Suppress("DEPRECATION") PermissionInfo(permissionInfo).apply { + // All Permission objects are registered so the PermissionInfo generated for it should + // also have FLAG_INSTALLED. + this.flags = this.flags or PermissionInfo.FLAG_INSTALLED if (!flags.hasBits(PackageManager.GET_META_DATA)) { metaData = null } @@ -322,6 +325,21 @@ class PermissionService( return permission.getGidsForUser(userId) } + override fun getInstalledPermissions(packageName: String): Set<String> { + requireNotNull(packageName) { "packageName cannot be null" } + + val permissions = service.getState { + with(policy) { getPermissions() } + } + return permissions.mapNotNullIndexedToSet { _, _, permission -> + if (permission.packageName == packageName) { + permission.name + } else { + null + } + } + } + override fun addPermission(permissionInfo: PermissionInfo, async: Boolean): Boolean { val permissionName = permissionInfo.name requireNotNull(permissionName) { "permissionName cannot be null" } |