Compartilhar via


PackageManager.GetWhitelistedRestrictedPermissions Method

Definition

Gets the restricted permissions that have been whitelisted and the app is allowed to have them granted in their full form.

[Android.Runtime.Register("getWhitelistedRestrictedPermissions", "(Ljava/lang/String;I)Ljava/util/Set;", "GetGetWhitelistedRestrictedPermissions_Ljava_lang_String_IHandler", ApiSince=29)]
[Android.Runtime.RequiresPermission("android.permission.WHITELIST_RESTRICTED_PERMISSIONS")]
public virtual System.Collections.Generic.ICollection<string> GetWhitelistedRestrictedPermissions (string packageName, Android.Content.PM.FlagPermission whitelistFlag);
[<Android.Runtime.Register("getWhitelistedRestrictedPermissions", "(Ljava/lang/String;I)Ljava/util/Set;", "GetGetWhitelistedRestrictedPermissions_Ljava_lang_String_IHandler", ApiSince=29)>]
[<Android.Runtime.RequiresPermission("android.permission.WHITELIST_RESTRICTED_PERMISSIONS")>]
abstract member GetWhitelistedRestrictedPermissions : string * Android.Content.PM.FlagPermission -> System.Collections.Generic.ICollection<string>
override this.GetWhitelistedRestrictedPermissions : string * Android.Content.PM.FlagPermission -> System.Collections.Generic.ICollection<string>

Parameters

packageName
String

The app for which to get whitelisted permissions.

whitelistFlag
FlagPermission

The flag to determine which whitelist to query. Only one flag can be passed.s

Returns

The whitelisted permissions that are on any of the whitelists you query for.

Attributes

Remarks

Gets the restricted permissions that have been whitelisted and the app is allowed to have them granted in their full form.

Permissions can be hard restricted which means that the app cannot hold them or soft restricted where the app can hold the permission but in a weaker form. Whether a permission is PermissionInfo#FLAG_HARD_RESTRICTED hard restricted or PermissionInfo#FLAG_SOFT_RESTRICTED soft restricted depends on the permission declaration. Whitelisting a hard restricted permission allows for the to hold that permission and whitelisting a soft restricted permission allows the app to hold the permission in its full, unrestricted form.

<ol>There are four allowlists:

<li>one for cases where the system permission policy whitelists a permission This list corresponds to the#FLAG_PERMISSION_WHITELIST_SYSTEM flag. Can only be accessed by pre-installed holders of a dedicated permission.

<li>one for cases where the system whitelists the permission when upgrading from an OS version in which the permission was not restricted to an OS version in which the permission is restricted. This list corresponds to the #FLAG_PERMISSION_WHITELIST_UPGRADE flag. Can be accessed by pre-installed holders of a dedicated permission or the installer on record.

<li>one for cases where the installer of the package whitelists a permission. This list corresponds to the #FLAG_PERMISSION_WHITELIST_INSTALLER flag. Can be accessed by pre-installed holders of a dedicated permission or the installer on record. </ol>

<strong>Note: </strong>In retrospect it would have been preferred to use more inclusive terminology when naming this API. Similar APIs added will refrain from using the term "whitelist".

Java documentation for android.content.pm.PackageManager.getWhitelistedRestrictedPermissions(java.lang.String, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to