[Settings] Remove isWfcProvisionedOnDevice API

Replace isWfcProvisionedOnDevice() by IMS's ProvisioningManager.

Bug: 140542283
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsForSubTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSliceHelperTest
make RunSettingsRoboTests -j ROBOTEST_FILTER=MobileNetworkUtilsTest

Change-Id: Idb063bdab3d3b11c348804c1c0ecb268cca3068e
This commit is contained in:
Bonian Chen
2019-11-14 13:29:18 +08:00
parent b22bbffe90
commit 2aafbd38e7
9 changed files with 118 additions and 66 deletions

View File

@@ -130,7 +130,7 @@ public class WifiCallingSettingsForSubTest {
doReturn(mImsManager).when(mFragment).getImsManager();
doReturn(mImsMmTelManager).when(mFragment).getImsMmTelManager();
doReturn(mImsConfig).when(mImsManager).getConfigInterface();
doReturn(true).when(mImsManager).isWfcProvisionedOnDevice();
doReturn(true).when(mFragment).isWfcProvisionedOnDevice();
doReturn(true).when(mImsManager).isWfcEnabledByUser();
doReturn(true).when(mImsManager).isNonTtyOrTtyOnVolteEnabled();
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
@@ -178,7 +178,7 @@ public class WifiCallingSettingsForSubTest {
@Test
public void onResume_provisioningDisallowed_shouldFinish() {
// Call onResume while provisioning is disallowed.
doReturn(false).when(mImsManager).isWfcProvisionedOnDevice();
doReturn(false).when(mFragment).isWfcProvisionedOnDevice();
mFragment.onResume();
// Verify that finish() is called

View File

@@ -64,72 +64,75 @@ public class WifiCallingSettingsTest {
@Test
public void setupFragment_oneSubscription_noCrash() {
SubscriptionInfo info = mock(SubscriptionInfo.class);
final SubscriptionInfo info = mock(SubscriptionInfo.class);
when(info.getSubscriptionId()).thenReturn(111);
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
Collections.singletonList(info)));
doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
doReturn(true).when(mFragment).isWfcProvisionedOnDevice(any(SubscriptionInfo.class));
Intent intent = new Intent();
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
FragmentController.of(mFragment, intent).create(0 /* containerViewId*/,
null /* bundle */).start().resume().visible().get();
View view = mFragment.getView();
RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
final View view = mFragment.getView();
final RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
final WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
(WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
assertThat(adapter.getCount()).isEqualTo(1);
}
@Test
public void setupFragment_twoSubscriptions_correctSelection() {
SubscriptionInfo info1 = mock(SubscriptionInfo.class);
SubscriptionInfo info2 = mock(SubscriptionInfo.class);
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(111);
when(info2.getSubscriptionId()).thenReturn(222);
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
Arrays.asList(info1, info2)));
doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
doReturn(true).when(mFragment).isWfcProvisionedOnDevice(any(SubscriptionInfo.class));
Intent intent = new Intent();
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, info2.getSubscriptionId());
FragmentController.of(mFragment, intent).create(0 /* containerViewId*/,
null /* bundle */).start().resume().visible().get();
View view = mFragment.getView();
RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
final View view = mFragment.getView();
final RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
assertThat(pager.getCurrentItem()).isEqualTo(1);
WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
final WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
(WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
assertThat(adapter.getCount()).isEqualTo(2);
}
@Test
public void setupFragment_twoSubscriptionsOneNotProvisionedOnDevice_oneResult() {
SubscriptionInfo info1 = mock(SubscriptionInfo.class);
SubscriptionInfo info2 = mock(SubscriptionInfo.class);
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(111);
when(info2.getSubscriptionId()).thenReturn(222);
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
Arrays.asList(info1, info2)));
doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
doReturn(true).when(mFragment).isWfcProvisionedOnDevice(eq(info1));
doReturn(false).when(mFragment).isWfcProvisionedOnDevice(eq(info2));
Intent intent = new Intent();
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, info1.getSubscriptionId());
FragmentController.of(mFragment, intent).create(0 /* containerViewId*/,
null /* bundle */).start().resume().visible().get();
View view = mFragment.getView();
RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
final View view = mFragment.getView();
final RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
assertThat(pager.getCurrentItem()).isEqualTo(0);
WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
final WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
(WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
assertThat(adapter.getCount()).isEqualTo(1);
}

View File

@@ -22,6 +22,7 @@ import static android.app.slice.SliceItem.FORMAT_TEXT;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -100,7 +101,7 @@ public class WifiCallingSliceHelperTest {
mFeatureFactory = FakeFeatureFactory.setupForTest();
mSlicesFeatureProvider = mFeatureFactory.getSlicesFeatureProvider();
mWfcSliceHelper = new FakeWifiCallingSliceHelper(mContext);
mWfcSliceHelper = spy(new FakeWifiCallingSliceHelper(mContext));
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -135,7 +136,7 @@ public class WifiCallingSliceHelperTest {
activity so the user can perform the activation there.(PrimaryAction)
*/
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(false);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(false);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -153,7 +154,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_CreateWifiCallingSlice_success() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -168,7 +169,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_SettingSliceProvider_getsRightSliceWifiCalling() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -184,7 +185,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_SliceBroadcastReceiver_toggleOnWifiCalling() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(false);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
@@ -209,7 +210,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_CreateWifiCallingPreferenceSlice_prefNotEditable() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
mWfcSliceHelper.setIsWifiCallingPrefEditable(false);
@@ -224,7 +225,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_CreateWifiCallingPreferenceSlice_wfcOff() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(false);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
@@ -241,7 +242,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_CreateWifiCallingPreferenceSlice_success() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
@@ -259,7 +260,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_SettingsSliceProvider_getWfcPreferenceSlice() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
@@ -278,7 +279,7 @@ public class WifiCallingSliceHelperTest {
@Test
public void test_SliceBroadcastReceiver_setWfcPrefCellularPref() {
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
when(mMockImsManager.isWfcProvisionedOnDevice()).thenReturn(true);
when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
when(mMockImsManager.isWfcEnabledByUser()).thenReturn(true);
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
@@ -450,6 +451,10 @@ public class WifiCallingSliceHelperTest {
mSubId = id;
}
boolean isWfcProvisionedOnDevice(int subId) {
return true;
}
@Override
protected Intent getWifiCallingCarrierActivityIntent(int subId) {
return mActivationAppIntent;