Check isWfcProvisionedOnDevice in WifiCallingSettings

On the SIM details page, the preference leading to a page for
configuring wifi calling will appear based on the results of the
MobileNetworkUtils#isWifiCallingEnabled helper function. That helper
uses the ImsManager to check several conditions, among them both
isWfcEnabledByPlatform and isWfcProvisionedOnDevice.

The page for configuring wifi calling has a tabbed UX, with one tab for
each active subscription that supports it. The WifiCallingSettings class
gets a list of the active subscriptions to determine which tabs to show,
and removes any that don't support wifi calling, but was only using the
isWfcEnabledByPlatform test to do so. This is a problem because the code
for showing the contents inside the tab, in WifiCallingSettingsForSub,
includes a sanity check of isWfcProvisionedOnDevice and calls finish()
if that returns false.

What this meant in practice is that if you happened to have 2
subscriptions where one returns true for both isWfcEnabledByPlatform and
isWfcProvisionedOnDevice, but the other only returned true for
isWfcEnabledByPlatform, then you'd never be able to succesfully use the
wifi calling page at all because the tab for the subscription you
*aren't* trying to configure would always call finish() early.

The right long term solution to this problem is probably to remove the
tabbed UX entirely from this page, since we probably don't need it given
the overall new multi-SIM UX. But there may still be legacy uses and
that is likely a bigger change than we want to make right now.

As a stopgap, this CL just adds a check of isWfcProvisionedOnDevice to
the code for filtering out ineligible subscriptions from the tabbed
interface, which we should have always had anyway.

Fixes: 135591718
Test: make RunSettingsRoboTests
Change-Id: I656c3d3fb30cb6fabcb86685eae38c5f0cd0c6f2
This commit is contained in:
Antony Sargent
2019-06-25 14:01:36 -07:00
parent ab63fd3c25
commit 46d819272a
2 changed files with 35 additions and 1 deletions

View File

@@ -199,6 +199,12 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
return imsManager.isWfcEnabledByPlatform(); return imsManager.isWfcEnabledByPlatform();
} }
@VisibleForTesting
boolean isWfcProvisionedOnDevice(SubscriptionInfo info) {
ImsManager imsManager = ImsManager.getInstance(getActivity(), info.getSimSlotIndex());
return imsManager.isWfcProvisionedOnDevice();
}
private void updateSubList() { private void updateSubList() {
mSil = SubscriptionUtil.getActiveSubscriptions( mSil = SubscriptionUtil.getActiveSubscriptions(
getContext().getSystemService(SubscriptionManager.class)); getContext().getSystemService(SubscriptionManager.class));
@@ -208,7 +214,8 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
return; return;
} }
for (int i = 0; i < mSil.size(); ) { for (int i = 0; i < mSil.size(); ) {
if (!isWfcEnabledByPlatform(mSil.get(i))) { final SubscriptionInfo info = mSil.get(i);
if (!isWfcEnabledByPlatform(info) || !isWfcProvisionedOnDevice(info)) {
mSil.remove(i); mSil.remove(i);
} else { } else {
i++; i++;

View File

@@ -19,6 +19,7 @@ package com.android.settings.wifi.calling;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
@@ -106,4 +107,30 @@ public class WifiCallingSettingsTest {
(WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter(); (WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
assertThat(adapter.getCount()).isEqualTo(2); assertThat(adapter.getCount()).isEqualTo(2);
} }
@Test
public void setupFragment_twoSubscriptionsOneNotProvisionedOnDevice_oneResult() {
SubscriptionInfo info1 = mock(SubscriptionInfo.class);
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(false).when(mFragment).isWfcProvisionedOnDevice(eq(info2));
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);
assertThat(pager.getCurrentItem()).isEqualTo(0);
WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
(WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
assertThat(adapter.getCount()).isEqualTo(1);
}
} }