summaryrefslogtreecommitdiff
path: root/framework-s/java
diff options
context:
space:
mode:
author Jay Thomas Sullivan <jaysullivan@google.com> 2023-11-09 19:40:17 -0800
committer Jay Thomas Sullivan <jaysullivan@google.com> 2023-11-17 16:44:39 -0800
commitd188c50e8d9b019ef1e46b327e8cde34822d3952 (patch)
tree8e3e73c3c05a9551016113236837ddff2b9af8c8 /framework-s/java
parent7473cf54743e3a3315aed29de29739a98b13a0d3 (diff)
[Role Logic Move] Call SS, not PC
Currently, the methods: - RoleManager::isRoleVisible - RoleManager::isApplicationVisibleForRole ...directly call corresponding RoleControllerManager methods. These are the only two methods in RoleManager that call RoleControllerManager. But, RoleControllerManager calls the RoleControllerService API which runs in PermissionController, and, we want to invoke this logic in System Server. So, call RoleService instead, and have RoleService conditionally route to either System Server or PermissionController depending on the flag state. Bug: 309139048 Test: atest CtsRoleTestCases Change-Id: I417637269d70e28bd2bebcabc85f9ac6a033b0f8
Diffstat (limited to 'framework-s/java')
-rw-r--r--framework-s/java/android/app/role/IRoleManager.aidl5
-rw-r--r--framework-s/java/android/app/role/RoleManager.java36
2 files changed, 38 insertions, 3 deletions
diff --git a/framework-s/java/android/app/role/IRoleManager.aidl b/framework-s/java/android/app/role/IRoleManager.aidl
index 581bb20fa..0aef871e6 100644
--- a/framework-s/java/android/app/role/IRoleManager.aidl
+++ b/framework-s/java/android/app/role/IRoleManager.aidl
@@ -73,4 +73,9 @@ interface IRoleManager {
boolean setBrowserRoleHolder(String packageName, int userId);
String getSmsRoleHolder(int userId);
+
+ boolean isRoleVisibleAsUser(in String roleName, int userId);
+
+ boolean isApplicationVisibleForRoleAsUser(in String roleName, in String packageName,
+ int userId);
}
diff --git a/framework-s/java/android/app/role/RoleManager.java b/framework-s/java/android/app/role/RoleManager.java
index c441d72b6..231c72c2c 100644
--- a/framework-s/java/android/app/role/RoleManager.java
+++ b/framework-s/java/android/app/role/RoleManager.java
@@ -47,6 +47,7 @@ import androidx.annotation.RequiresApi;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
+import com.android.modules.utils.build.SdkLevel;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -975,10 +976,29 @@ public final class RoleManager {
*/
@RequiresApi(Build.VERSION_CODES.S)
@RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
+ @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
@SystemApi
public void isRoleVisible(@NonNull String roleName,
@NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
- getRoleControllerManager().isRoleVisible(roleName, executor, callback);
+ if (SdkLevel.isAtLeastV() && Flags.roleControllerInSystemServer()) {
+ int userId = getContextUserIfAppropriate().getIdentifier();
+ boolean visible;
+ try {
+ visible = mService.isRoleVisibleAsUser(roleName, userId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ executor.execute(() -> {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ callback.accept(visible);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ });
+ } else {
+ getRoleControllerManager().isRoleVisible(roleName, executor, callback);
+ }
}
/**
@@ -997,11 +1017,21 @@ public final class RoleManager {
*/
@RequiresApi(Build.VERSION_CODES.S)
@RequiresPermission(Manifest.permission.MANAGE_ROLE_HOLDERS)
+ @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
@SystemApi
public void isApplicationVisibleForRole(@NonNull String roleName, @NonNull String packageName,
@NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Boolean> callback) {
- getRoleControllerManager().isApplicationVisibleForRole(roleName, packageName, executor,
- callback);
+ if (SdkLevel.isAtLeastV() && Flags.roleControllerInSystemServer()) {
+ int userId = getContextUserIfAppropriate().getIdentifier();
+ try {
+ mService.isApplicationVisibleForRoleAsUser(roleName, packageName, userId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ } else {
+ getRoleControllerManager().isApplicationVisibleForRole(roleName, packageName, executor,
+ callback);
+ }
}
@NonNull