diff options
| author | Hai Zhang <zhanghai@google.com> | 2019-08-26 14:18:55 -0700 |
|---|---|---|
| committer | Hai Zhang <zhanghai@google.com> | 2019-08-26 15:05:06 -0700 |
| commit | aedc3ab3cf62dc05379ef855ffc42bec646fb5ec (patch) | |
| tree | 201e925c67a2bfdad7f3daaa23e8939523b606d5 /core/java/android | |
| parent | ce81d325256c391ebcaf96a95c5ddaddc49a36f7 (diff) | |
Add RoleControllerManager.isApplicationVisibleForRole().
Settings doesn't actually need to know whether an application
qualifies for a role, but only whether the default app setting should
be visible for an application. Qualification and visibility differs in
cases such as FallbackHome inside Settings which is a qualifying home
activity but should never be shown in default apps UI.
Fixes: 138636320
Test: manual
Change-Id: I216195c64a7b106e2769b11c1a998741a77fdce2
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/role/IRoleController.aidl | 3 | ||||
| -rw-r--r-- | core/java/android/app/role/RoleControllerManager.java | 18 | ||||
| -rw-r--r-- | core/java/android/app/role/RoleControllerService.java | 29 |
3 files changed, 50 insertions, 0 deletions
diff --git a/core/java/android/app/role/IRoleController.aidl b/core/java/android/app/role/IRoleController.aidl index 19762e0841b1..8a43d7fa9036 100644 --- a/core/java/android/app/role/IRoleController.aidl +++ b/core/java/android/app/role/IRoleController.aidl @@ -36,5 +36,8 @@ oneway interface IRoleController { void isApplicationQualifiedForRole(in String roleName, in String packageName, in RemoteCallback callback); + void isApplicationVisibleForRole(in String roleName, in String packageName, + in RemoteCallback callback); + void isRoleVisible(in String roleName, in RemoteCallback callback); } diff --git a/core/java/android/app/role/RoleControllerManager.java b/core/java/android/app/role/RoleControllerManager.java index 98b11a7b1a9b..16ddbc147d82 100644 --- a/core/java/android/app/role/RoleControllerManager.java +++ b/core/java/android/app/role/RoleControllerManager.java @@ -183,6 +183,9 @@ public class RoleControllerManager { /** * @see RoleControllerService#onIsApplicationQualifiedForRole(String, String) + * + * @deprecated Use {@link #isApplicationVisibleForRole(String, String, Executor, Consumer)} + * instead. */ @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS) public void isApplicationQualifiedForRole(@NonNull String roleName, @NonNull String packageName, @@ -197,6 +200,21 @@ public class RoleControllerManager { } /** + * @see RoleControllerService#onIsApplicationVisibleForRole(String, String) + */ + @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS) + public void isApplicationVisibleForRole(@NonNull String roleName, @NonNull String packageName, + @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) { + AndroidFuture<Bundle> operation = mRemoteService.postAsync(service -> { + AndroidFuture<Bundle> future = new AndroidFuture<>(); + service.isApplicationVisibleForRole(roleName, packageName, + new RemoteCallback(future::complete)); + return future; + }); + propagateCallback(operation, "isApplicationVisibleForRole", executor, callback); + } + + /** * @see RoleControllerService#onIsRoleVisible(String) */ @RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS) diff --git a/core/java/android/app/role/RoleControllerService.java b/core/java/android/app/role/RoleControllerService.java index 2bc94560edd7..85db6a45a1bd 100644 --- a/core/java/android/app/role/RoleControllerService.java +++ b/core/java/android/app/role/RoleControllerService.java @@ -153,6 +153,20 @@ public abstract class RoleControllerService extends Service { } @Override + public void isApplicationVisibleForRole(String roleName, String packageName, + RemoteCallback callback) { + enforceCallingPermission(Manifest.permission.MANAGE_ROLE_HOLDERS, null); + + Preconditions.checkStringNotEmpty(roleName, "roleName cannot be null or empty"); + Preconditions.checkStringNotEmpty(packageName, + "packageName cannot be null or empty"); + Preconditions.checkNotNull(callback, "callback cannot be null"); + + boolean visible = onIsApplicationVisibleForRole(roleName, packageName); + callback.sendResult(visible ? Bundle.EMPTY : null); + } + + @Override public void isRoleVisible(String roleName, RemoteCallback callback) { enforceCallingPermission(Manifest.permission.MANAGE_ROLE_HOLDERS, null); @@ -256,11 +270,26 @@ public abstract class RoleControllerService extends Service { * @param packageName package name of the application to check for * * @return whether the application is qualified for the role + * + * @deprecated Implement {@link #onIsApplicationVisibleForRole(String, String)} instead. */ public abstract boolean onIsApplicationQualifiedForRole(@NonNull String roleName, @NonNull String packageName); /** + * Check whether an application is visible for a role. + * + * @param roleName name of the role to check for + * @param packageName package name of the application to check for + * + * @return whether the application is visible for the role + */ + public boolean onIsApplicationVisibleForRole(@NonNull String roleName, + @NonNull String packageName) { + return onIsApplicationQualifiedForRole(roleName, packageName); + } + + /** * Check whether a role should be visible to user. * * @param roleName name of the role to check for |
