FakePermissionController


@ExperimentalTestingApi
public final class FakePermissionController implements PermissionController


A fake PermissionController that enables full control of permissions in tests for a HealthConnectClient.

Summary

Public constructors

FakePermissionController(boolean grantAll)

Public methods

@NonNull Set<@NonNull String>

Returns a fake set of permissions.

final void

Adds a permission to the set of granted permissions returned by getGrantedPermissions.

final void

Adds permissions to the set of granted permissions returned by getGrantedPermissions.

final void

Replaces the set of permissions returned by getGrantedPermissions with a new set.

void

Clears the set of permissions returned by getGrantedPermissions.

final void

Removes a permission from the set of granted permissions returned by getGrantedPermissions.

Public constructors

FakePermissionController

Added in 1.0.0-alpha01
public FakePermissionController(boolean grantAll)
Parameters
boolean grantAll

grants all permissions on creation

Public methods

getGrantedPermissions

public @NonNull Set<@NonNull StringgetGrantedPermissions()

Returns a fake set of permissions.

grantPermission

Added in 1.0.0-alpha01
public final void grantPermission(@NonNull String permission)

Adds a permission to the set of granted permissions returned by getGrantedPermissions.

grantPermissions

Added in 1.0.0-alpha01
public final void grantPermissions(@NonNull Set<@NonNull String> permission)

Adds permissions to the set of granted permissions returned by getGrantedPermissions.

replaceGrantedPermissions

Added in 1.0.0-alpha01
public final void replaceGrantedPermissions(@NonNull Set<@NonNull String> permissions)

Replaces the set of permissions returned by getGrantedPermissions with a new set.

revokeAllPermissions

Added in 1.0.0-alpha01
public void revokeAllPermissions()

Clears the set of permissions returned by getGrantedPermissions.

revokePermission

Added in 1.0.0-alpha01
public final void revokePermission(@NonNull String permission)

Removes a permission from the set of granted permissions returned by getGrantedPermissions.