Merge "Expose role API for Settings on RoleManager."
diff --git a/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java b/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
index 5df30c2..5a1883b 100644
--- a/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
+++ b/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
@@ -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 @@
 
         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();
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
index 7a4c610..74c0bb5 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
@@ -25,7 +25,6 @@
 import static org.robolectric.Shadows.shadowOf;
 
 import android.app.Activity;
-import android.app.role.RoleControllerManager;
 import android.app.role.RoleManager;
 import android.content.Context;
 import android.content.Intent;
@@ -63,8 +62,6 @@
     @Mock
     private RoleManager mRoleManager;
     @Mock
-    private RoleControllerManager mRoleControllerManager;
-    @Mock
     private Preference mPreference;
 
     private Activity mActivity;
@@ -77,7 +74,6 @@
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.ROLE_SERVICE, mRoleManager);
-        shadowApplication.setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager);
         mActivity = Robolectric.setupActivity(Activity.class);
         mShadowUserManager = shadowOf(mActivity.getSystemService(UserManager.class));
         mController = new TestRolePreferenceController(mActivity);
@@ -86,7 +82,7 @@
 
     @Test
     public void constructor_callsIsApplicationVisibleForRole() {
-        verify(mRoleControllerManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq(
+        verify(mRoleManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq(
                 TEST_PACKAGE_NAME), any(Executor.class), any(Consumer.class));
     }
 
@@ -153,7 +149,7 @@
     private void setRoleIsVisible(boolean visible) {
         final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
                 Consumer.class);
-        verify(mRoleControllerManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class),
+        verify(mRoleManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class),
                 callbackCaptor.capture());
         final Consumer<Boolean> callback = callbackCaptor.getValue();
         callback.accept(visible);
@@ -162,7 +158,7 @@
     private void setApplicationIsVisibleForRole(boolean visible) {
         final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
                 Consumer.class);
-        verify(mRoleControllerManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq(
+        verify(mRoleManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq(
                 TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture());
         final Consumer<Boolean> callback = callbackCaptor.getValue();
         callback.accept(visible);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java
index 5940d72..6d4186c 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java
@@ -18,7 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.app.role.RoleControllerManager;
+import android.app.role.RoleManager;
 import android.content.Context;
 
 import org.junit.Before;
@@ -34,15 +34,14 @@
 public class DefaultBrowserShortcutPreferenceControllerTest {
 
     @Mock
-    private RoleControllerManager mRoleControllerManager;
+    private RoleManager mRoleManager;
 
     private DefaultBrowserShortcutPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
-                mRoleControllerManager);
+        ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager);
         mController = new DefaultBrowserShortcutPreferenceController(RuntimeEnvironment.application,
                 "Package1");
     }
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java
index 8dcf530..0acd7bd 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java
@@ -18,7 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.app.role.RoleControllerManager;
+import android.app.role.RoleManager;
 import android.content.Context;
 
 import org.junit.Before;
@@ -34,15 +34,14 @@
 public class DefaultEmergencyShortcutPreferenceControllerTest {
 
     @Mock
-    private RoleControllerManager mRoleControllerManager;
+    private RoleManager mRoleManager;
 
     private DefaultEmergencyShortcutPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
-                mRoleControllerManager);
+        ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager);
         mController = new DefaultEmergencyShortcutPreferenceController(
                 RuntimeEnvironment.application, "Package1");
     }
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java
index 7071fec..1f0023a 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java
@@ -18,7 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.app.role.RoleControllerManager;
+import android.app.role.RoleManager;
 import android.content.Context;
 
 import org.junit.Before;
@@ -34,15 +34,14 @@
 public class DefaultHomeShortcutPreferenceControllerTest {
 
     @Mock
-    private RoleControllerManager mRoleControllerManager;
+    private RoleManager mRoleManager;
 
     private DefaultHomeShortcutPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
-                mRoleControllerManager);
+        ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager);
         mController = new DefaultHomeShortcutPreferenceController(RuntimeEnvironment.application,
                 "Package1");
     }
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
index d1b6aeb..c130665 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
@@ -18,7 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.app.role.RoleControllerManager;
+import android.app.role.RoleManager;
 import android.content.Context;
 
 import org.junit.Before;
@@ -37,15 +37,14 @@
     private static final String PREFERENCE_KEY = "default_phone_app";
 
     @Mock
-    private RoleControllerManager mRoleControllerManager;
+    private RoleManager mRoleManager;
 
     private DefaultPhoneShortcutPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
-                mRoleControllerManager);
+        ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager);
         mController = new DefaultPhoneShortcutPreferenceController(RuntimeEnvironment.application,
                 TEST_PACKAGE_NAME);
     }
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java
index 691ce5e..e9c238d 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.app.role.RoleControllerManager;
 import android.app.role.RoleManager;
 import android.content.Context;
 
@@ -39,8 +38,6 @@
 
     @Mock
     private RoleManager mRoleManager;
-    @Mock
-    private RoleControllerManager mRoleControllerManager;
 
     private DefaultSmsShortcutPreferenceController mController;
 
@@ -49,7 +46,6 @@
         MockitoAnnotations.initMocks(this);
         final ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.ROLE_SERVICE, mRoleManager);
-        shadowApplication.setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager);
         mController = new DefaultSmsShortcutPreferenceController(RuntimeEnvironment.application,
                 TEST_PACKAGE_NAME);
     }