Expose role API for Settings on RoleManager.

Settings is a platform app so the role APIs for it wasn't system APIs,
but just @hide. Now that we are moving role into module, we need to
create system APIs for them.

RoleControllerManager is an implementation detail and may change in
soon when we move role logic into system server and leave only UI in
PermissionController, so we shouldn't expose it. Instead, we can
expose the new system APIs on RoleManager, and delegate to
RoleControllerManager internally.

Bug: 158736025
Test: presubmit
Test: atest DefaultSmsShortcutPreferenceControllerTest
Change-Id: Iafe1d24601a32799e04d9aa385ec2fbce833a02e
This commit is contained in:
Hai Zhang
2020-12-22 21:17:33 -08:00
parent af1fbb77e3
commit a8bd0d263f
7 changed files with 17 additions and 33 deletions

View File

@@ -14,9 +14,7 @@
package com.android.settings.applications.appinfo;
import android.app.role.RoleControllerManager;
import android.app.role.RoleManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.os.UserManager;
@@ -58,14 +56,12 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
mRoleManager = context.getSystemService(RoleManager.class);
final RoleControllerManager roleControllerManager =
mContext.getSystemService(RoleControllerManager.class);
final Executor executor = mContext.getMainExecutor();
roleControllerManager.isRoleVisible(mRoleName, executor, visible -> {
mRoleManager.isRoleVisible(mRoleName, executor, visible -> {
mRoleVisible = visible;
refreshAvailability();
});
roleControllerManager.isApplicationVisibleForRole(mRoleName, mPackageName, executor,
mRoleManager.isApplicationVisibleForRole(mRoleName, mPackageName, executor,
visible -> {
mAppVisible = visible;
refreshAvailability();