Udostępnij za pośrednictwem


PackageInstaller.SessionParams.SetWhitelistedRestrictedPermissions Method

Definition

Sets which restricted permissions to be allowlisted for the app.

[Android.Runtime.Register("setWhitelistedRestrictedPermissions", "(Ljava/util/Set;)V", "GetSetWhitelistedRestrictedPermissions_Ljava_util_Set_Handler", ApiSince=29)]
public virtual void SetWhitelistedRestrictedPermissions (System.Collections.Generic.ICollection<string>? permissions);
[<Android.Runtime.Register("setWhitelistedRestrictedPermissions", "(Ljava/util/Set;)V", "GetSetWhitelistedRestrictedPermissions_Ljava_util_Set_Handler", ApiSince=29)>]
abstract member SetWhitelistedRestrictedPermissions : System.Collections.Generic.ICollection<string> -> unit
override this.SetWhitelistedRestrictedPermissions : System.Collections.Generic.ICollection<string> -> unit

Parameters

permissions
ICollection<String>
Attributes

Remarks

Sets which restricted permissions to be allowlisted for the app. Allowlisting is not granting the permissions, rather it allows the app to hold permissions which are otherwise restricted. Allowlisting a non restricted permission has no effect.

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. Allowlisting a hard restricted permission allows the app to hold that permission and allowlisting a soft restricted permission allows the app to hold the permission in its full, unrestricted form.

Permissions can also be immutably restricted which means that the allowlist state of the permission can be determined only at install time and cannot be changed on updated or at a later point via the package manager APIs.

Initially, all restricted permissions are allowlisted but you can change which ones are allowlisted by calling this method or the corresponding ones on the PackageManager. Only soft or hard restricted permissions on the current Android version are supported and any invalid entries will be removed.

Java documentation for android.content.pm.PackageInstaller.SessionParams.setWhitelistedRestrictedPermissions(java.util.Set<java.lang.String>).

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