Use role for App info default phone shortcut.

This change makes the default phone shortcut in App info launch the
new default app UI based on roles, since we've migrated default dialer
mechanism.

Bug: 110557011
Test: atest DefaultAppShortcutPreferenceControllerBaseTest
Change-Id: I3c2ac05386b46e574399f453c2869d1aca952332
diff --git a/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java b/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java
index c968d55..c19c367 100644
--- a/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceController.java
@@ -14,27 +14,15 @@
 
 package com.android.settings.applications.appinfo;
 
+import android.app.role.RoleManager;
 import android.content.Context;
 
-import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
-
 public class DefaultPhoneShortcutPreferenceController
         extends DefaultAppShortcutPreferenceControllerBase {
 
     private static final String KEY = "default_phone_app";
 
     public DefaultPhoneShortcutPreferenceController(Context context, String packageName) {
-        super(context, KEY, packageName);
+        super(context, KEY, RoleManager.ROLE_DIALER, packageName);
     }
-
-    @Override
-    protected boolean hasAppCapability() {
-        return DefaultPhonePreferenceController.hasPhonePreference(mPackageName, mContext);
-    }
-
-    @Override
-    protected boolean isDefaultApp() {
-        return DefaultPhonePreferenceController.isPhoneDefault(mPackageName, mContext);
-    }
-
 }
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 bdb7ba3..4e7a800 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
@@ -18,13 +18,8 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
 import android.content.Context;
-import android.content.pm.PackageManager;
-
-import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
+import android.permission.PermissionControllerManager;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -33,64 +28,30 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
+import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(RobolectricTestRunner.class)
 public class DefaultPhoneShortcutPreferenceControllerTest {
 
-    @Mock
-    private PackageManager mPackageManager;
+    private static final String TEST_PACKAGE_NAME = "TestPackage";
+    private static final String PREFERENCE_KEY = "default_phone_app";
 
-    private Context mContext;
+    @Mock
+    private PermissionControllerManager mPermissionControllerManager;
+
     private DefaultPhoneShortcutPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
-        when(mContext.getPackageManager()).thenReturn(mPackageManager);
-        mController = new DefaultPhoneShortcutPreferenceController(mContext, "Package1");
+        ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
+                mPermissionControllerManager);
+        mController = new DefaultPhoneShortcutPreferenceController(RuntimeEnvironment.application,
+                TEST_PACKAGE_NAME);
     }
 
     @Test
     public void getPreferenceKey_shouldReturnDefaultPhone() {
-        assertThat(mController.getPreferenceKey()).isEqualTo("default_phone_app");
-    }
-
-    @Test
-    @Config(shadows = ShadowDefaultPhonePreferenceController.class)
-    public void hasAppCapability_hasPhoneCapability_shouldReturnTrue() {
-        assertThat(mController.hasAppCapability()).isTrue();
-    }
-
-    @Test
-    public void hasAppCapability_noPhoneCapability_shouldReturnFalse() {
-        assertThat(mController.hasAppCapability()).isFalse();
-    }
-
-    @Test
-    @Config(shadows = ShadowDefaultPhonePreferenceController.class)
-    public void isDefaultApp_isDefaultPhone_shouldReturnTrue() {
-        assertThat(mController.isDefaultApp()).isTrue();
-    }
-
-    @Test
-    public void isDefaultApp_notDefaultPhone_shouldReturnFalse() {
-        assertThat(mController.isDefaultApp()).isFalse();
-    }
-
-    @Implements(DefaultPhonePreferenceController.class)
-    public static class ShadowDefaultPhonePreferenceController {
-        @Implementation
-        protected static boolean hasPhonePreference(String pkg, Context context) {
-            return true;
-        }
-
-        @Implementation
-        protected static boolean isPhoneDefault(String pkg, Context context) {
-            return true;
-        }
+        assertThat(mController.getPreferenceKey()).isEqualTo(PREFERENCE_KEY);
     }
 }