Merge "Add Executor to Permission Group methods in PermissionControllerManager" into sc-dev
This commit is contained in:
@@ -8831,8 +8831,8 @@ package android.permission {
|
||||
|
||||
public final class PermissionControllerManager {
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, android.Manifest.permission.RESTORE_RUNTIME_PERMISSIONS}) public void applyStagedRuntimePermissionBackup(@NonNull String, @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING) public void getGroupOfPlatformPermission(@NonNull String, @NonNull java.util.function.Consumer<java.lang.String>);
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING) public void getPlatformPermissionsForGroup(@NonNull String, @NonNull java.util.function.Consumer<java.util.List<java.lang.String>>);
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING) public void getGroupOfPlatformPermission(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.String>);
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING) public void getPlatformPermissionsForGroup(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.util.List<java.lang.String>>);
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSIONS) public void getRuntimePermissionBackup(@NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<byte[]>);
|
||||
method @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) public void revokeRuntimePermissions(@NonNull java.util.Map<java.lang.String,java.util.List<java.lang.String>>, boolean, int, @NonNull java.util.concurrent.Executor, @NonNull android.permission.PermissionControllerManager.OnRevokeRuntimePermissionsCallback);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, android.Manifest.permission.RESTORE_RUNTIME_PERMISSIONS}) public void stageAndApplyRuntimePermissionsBackup(@NonNull byte[], @NonNull android.os.UserHandle);
|
||||
|
||||
@@ -725,12 +725,14 @@ public final class PermissionControllerManager {
|
||||
* Get the platform permissions which belong to a particular permission group.
|
||||
*
|
||||
* @param permissionGroupName The permission group whose permissions are desired
|
||||
* @param executor Executor on which to invoke the callback
|
||||
* @param callback A callback which will receive a list of the platform permissions in the
|
||||
* group, or empty if the group is not a valid platform group, or there
|
||||
* was an exception.
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING)
|
||||
public void getPlatformPermissionsForGroup(@NonNull String permissionGroupName,
|
||||
@NonNull @CallbackExecutor Executor executor,
|
||||
@NonNull Consumer<List<String>> callback) {
|
||||
enforceSomePermissionsGrantedToSelf(
|
||||
Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING);
|
||||
@@ -738,14 +740,19 @@ public final class PermissionControllerManager {
|
||||
AndroidFuture<List<String>> future = new AndroidFuture<>();
|
||||
service.getPlatformPermissionsForGroup(permissionGroupName, future);
|
||||
return future;
|
||||
}).whenComplete((result, err) -> {
|
||||
if (err != null) {
|
||||
Log.e(TAG, "Failed to get permissions of " + permissionGroupName, err);
|
||||
callback.accept(new ArrayList<>());
|
||||
} else {
|
||||
callback.accept(result);
|
||||
}).whenCompleteAsync((result, err) -> {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
if (err != null) {
|
||||
Log.e(TAG, "Failed to get permissions of " + permissionGroupName, err);
|
||||
callback.accept(new ArrayList<>());
|
||||
} else {
|
||||
callback.accept(result);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
});
|
||||
}, executor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -753,26 +760,32 @@ public final class PermissionControllerManager {
|
||||
* permission.
|
||||
*
|
||||
* @param permissionName The permission name whose group is desired
|
||||
* @param executor Executor on which to invoke the callback
|
||||
* @param callback A callback which will receive the name of the permission group this
|
||||
* permission belongs to, or null if it has no group, is not a platform
|
||||
* permission, or there was an exception.
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING)
|
||||
public void getGroupOfPlatformPermission(@NonNull String permissionName,
|
||||
@NonNull Consumer<String> callback) {
|
||||
@NonNull @CallbackExecutor Executor executor, @NonNull Consumer<String> callback) {
|
||||
enforceSomePermissionsGrantedToSelf(
|
||||
Manifest.permission.GET_RUNTIME_PERMISSION_GROUP_MAPPING);
|
||||
mRemoteService.postAsync(service -> {
|
||||
AndroidFuture<String> future = new AndroidFuture<>();
|
||||
service.getGroupOfPlatformPermission(permissionName, future);
|
||||
return future;
|
||||
}).whenComplete((result, err) -> {
|
||||
if (err != null) {
|
||||
Log.e(TAG, "Failed to get group of " + permissionName, err);
|
||||
callback.accept(null);
|
||||
} else {
|
||||
callback.accept(result);
|
||||
}).whenCompleteAsync((result, err) -> {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
if (err != null) {
|
||||
Log.e(TAG, "Failed to get group of " + permissionName, err);
|
||||
callback.accept(null);
|
||||
} else {
|
||||
callback.accept(result);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
});
|
||||
}, executor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user