[Settings] Fix conflict of AOSP merge on wifi call
Merge for fixing conflict of Ib4b0e1191c83e23377ccf8ed013252728ef9dd95 Bug: 144960427 Test: build pass Change-Id: I2979a9a2ee1bc690486e25b7d470cf905cf02d17 Merged-In: Idb063bdab3d3b11c348804c1c0ecb268cca3068e
This commit is contained in:
@@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -58,6 +59,10 @@ public class MobileNetworkUtilsTest {
|
||||
private static final String PACKAGE_NAME = "com.android.app";
|
||||
private static final int SUB_ID_1 = 1;
|
||||
private static final int SUB_ID_2 = 2;
|
||||
private static final int SUB_ID_INVALID = -1;
|
||||
private static final String PLMN_FROM_TELEPHONY_MANAGER_API = "testPlmn";
|
||||
private static final String PLMN_FROM_SUB_ID_1 = "testPlmnSub1";
|
||||
private static final String PLMN_FROM_SUB_ID_2 = "testPlmnSub2";
|
||||
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@@ -89,6 +94,7 @@ public class MobileNetworkUtilsTest {
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
||||
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
||||
when(mTelephonyManager.createForSubscriptionId(SUB_ID_1)).thenReturn(mTelephonyManager);
|
||||
when(mTelephonyManager.createForSubscriptionId(SUB_ID_2)).thenReturn(mTelephonyManager2);
|
||||
@@ -102,10 +108,17 @@ public class MobileNetworkUtilsTest {
|
||||
when(mCarrierConfigManager.getConfigForSubId(SUB_ID_1)).thenReturn(mCarrierConfig);
|
||||
|
||||
when(mSubscriptionInfo1.getSubscriptionId()).thenReturn(SUB_ID_1);
|
||||
when(mSubscriptionInfo1.getCarrierName()).thenReturn(PLMN_FROM_SUB_ID_1);
|
||||
when(mSubscriptionInfo2.getSubscriptionId()).thenReturn(SUB_ID_2);
|
||||
when(mSubscriptionInfo2.getCarrierName()).thenReturn(PLMN_FROM_SUB_ID_2);
|
||||
|
||||
when(mSubscriptionManager.getActiveSubscriptionInfoList(eq(true))).thenReturn(
|
||||
Arrays.asList(mSubscriptionInfo1, mSubscriptionInfo2));
|
||||
when(mSubscriptionManager.getAccessibleSubscriptionInfoList()).thenReturn(
|
||||
Arrays.asList(mSubscriptionInfo1, mSubscriptionInfo2));
|
||||
|
||||
when(mTelephonyManager.getNetworkOperatorName()).thenReturn(
|
||||
PLMN_FROM_TELEPHONY_MANAGER_API);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -301,4 +314,24 @@ public class MobileNetworkUtilsTest {
|
||||
TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
|
||||
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentCarrierNameForDisplay_withoutValidSubId_returnNetworkOperatorName() {
|
||||
assertThat(MobileNetworkUtils.getCurrentCarrierNameForDisplay(
|
||||
mContext, SUB_ID_INVALID)).isEqualTo(PLMN_FROM_TELEPHONY_MANAGER_API);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentCarrierNameForDisplay_withValidSubId_returnCurrentCarrierName() {
|
||||
assertThat(MobileNetworkUtils.getCurrentCarrierNameForDisplay(
|
||||
mContext, SUB_ID_1)).isEqualTo(PLMN_FROM_SUB_ID_1);
|
||||
assertThat(MobileNetworkUtils.getCurrentCarrierNameForDisplay(
|
||||
mContext, SUB_ID_2)).isEqualTo(PLMN_FROM_SUB_ID_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentCarrierNameForDisplay_withoutSubId_returnNotNull() {
|
||||
assertThat(MobileNetworkUtils.getCurrentCarrierNameForDisplay(
|
||||
mContext)).isNotNull();
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.network.telephony;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -31,12 +30,11 @@ import android.telecom.PhoneAccountHandle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.ims.ImsMmTelManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.internal.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -60,6 +58,8 @@ public class WifiCallingPreferenceControllerTest {
|
||||
@Mock
|
||||
private ImsManager mImsManager;
|
||||
@Mock
|
||||
private ImsMmTelManager mImsMmTelManager;
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
|
||||
private WifiCallingPreferenceController mController;
|
||||
@@ -72,17 +72,22 @@ public class WifiCallingPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
|
||||
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
|
||||
|
||||
mPreference = new Preference(mContext);
|
||||
mController = new WifiCallingPreferenceController(mContext, "wifi_calling");
|
||||
mController = spy(new WifiCallingPreferenceController(mContext, "wifi_calling") {
|
||||
@Override
|
||||
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
||||
return mImsMmTelManager;
|
||||
}
|
||||
});
|
||||
mController.mCarrierConfigManager = mCarrierConfigManager;
|
||||
mController.init(SUB_ID);
|
||||
mController.mImsManager = mImsManager;
|
||||
mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
|
||||
when(mController.getTelephonyManager(mContext, SUB_ID)).thenReturn(mTelephonyManager);
|
||||
|
||||
mCarrierConfig = new PersistableBundle();
|
||||
when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(mCarrierConfig);
|
||||
|
||||
@@ -94,8 +99,10 @@ public class WifiCallingPreferenceControllerTest {
|
||||
public void updateState_noSimCallManager_setCorrectSummary() {
|
||||
mController.mSimCallManager = null;
|
||||
when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
|
||||
when(mImsManager.getWfcMode(anyBoolean())).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY);
|
||||
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_ONLY);
|
||||
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_ONLY);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -105,8 +112,7 @@ public class WifiCallingPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_notCallIdle_disable() {
|
||||
when(mTelephonyManager.getCallState(SUB_ID)).thenReturn(
|
||||
TelephonyManager.CALL_STATE_RINGING);
|
||||
mController.mCallState = TelephonyManager.CALL_STATE_RINGING;
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -129,10 +135,10 @@ public class WifiCallingPreferenceControllerTest {
|
||||
mController.init(SUB_ID);
|
||||
mController.mImsManager = mImsManager;
|
||||
|
||||
when(mImsManager.getWfcMode(true)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
|
||||
when(mImsManager.getWfcMode(false)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED);
|
||||
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
||||
when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
|
||||
when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
|
||||
|
||||
@@ -146,10 +152,10 @@ public class WifiCallingPreferenceControllerTest {
|
||||
assertNull(mController.mSimCallManager);
|
||||
// useWfcHomeModeForRoaming is false by default. In order to check wfc in roaming mode. We
|
||||
// need the device roaming, and not using home mode in roaming network.
|
||||
when(mImsManager.getWfcMode(true)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
|
||||
when(mImsManager.getWfcMode(false)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED);
|
||||
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||
when(mImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
||||
when(mImsManager.isWfcEnabledByUser()).thenReturn(true);
|
||||
when(mTelephonyManager.isNetworkRoaming()).thenReturn(true);
|
||||
|
||||
@@ -169,7 +175,7 @@ public class WifiCallingPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void displayPreference_available_setsSubscriptionIdOnIntent() {
|
||||
Intent intent = new Intent();
|
||||
final Intent intent = new Intent();
|
||||
mPreference.setIntent(intent);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
assertThat(intent.getIntExtra(Settings.EXTRA_SUB_ID,
|
||||
|
@@ -17,11 +17,12 @@
|
||||
package com.android.settings.wifi.calling;
|
||||
|
||||
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
@@ -42,6 +43,7 @@ import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.ims.ImsMmTelManager;
|
||||
import android.telephony.ims.ProvisioningManager;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -53,8 +55,7 @@ import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.ToggleSwitch;
|
||||
|
||||
@@ -66,8 +67,10 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WifiCallingSettingsForSubTest {
|
||||
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
|
||||
@@ -83,6 +86,7 @@ public class WifiCallingSettingsForSubTest {
|
||||
@Mock private static CarrierConfigManager sCarrierConfigManager;
|
||||
@Mock private CarrierConfigManager mMockConfigManager;
|
||||
@Mock private ImsManager mImsManager;
|
||||
@Mock private ImsMmTelManager mImsMmTelManager;
|
||||
@Mock private TelephonyManager mTelephonyManager;
|
||||
@Mock private PreferenceScreen mPreferenceScreen;
|
||||
@Mock private SettingsActivity mActivity;
|
||||
@@ -124,12 +128,15 @@ public class WifiCallingSettingsForSubTest {
|
||||
doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
|
||||
|
||||
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(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager).getWfcMode(anyBoolean());
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager).getVoWiFiModeSetting();
|
||||
doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED)
|
||||
.when(mImsMmTelManager).getVoWiFiRoamingModeSetting();
|
||||
|
||||
doReturn(mBundle).when(sCarrierConfigManager).getConfigForSubId(anyInt());
|
||||
setDefaultCarrierConfigValues();
|
||||
@@ -171,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
|
||||
@@ -248,15 +255,13 @@ public class WifiCallingSettingsForSubTest {
|
||||
|
||||
// Set the WFC home mode.
|
||||
mFragment.onPreferenceChange(mButtonWfcMode,
|
||||
String.valueOf(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
|
||||
String.valueOf(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
|
||||
|
||||
// Check that only WFC home mode is set.
|
||||
verify(mImsManager, times(1)).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(false));
|
||||
verify(mImsManager, never()).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(true));
|
||||
verify(mImsMmTelManager, times(1)).setVoWiFiModeSetting(
|
||||
eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
|
||||
verify(mImsMmTelManager, never()).setVoWiFiRoamingModeSetting(
|
||||
eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -269,34 +274,32 @@ public class WifiCallingSettingsForSubTest {
|
||||
|
||||
// Set the WFC home mode.
|
||||
mFragment.onPreferenceChange(mButtonWfcMode,
|
||||
String.valueOf(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
|
||||
String.valueOf(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
|
||||
|
||||
// Check that both WFC home mode and roaming mode are set.
|
||||
verify(mImsManager, times(1)).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(false));
|
||||
verify(mImsManager, times(1)).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(true));
|
||||
verify(mImsMmTelManager, times(1)).setVoWiFiModeSetting(
|
||||
eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
|
||||
verify(mImsMmTelManager, times(1)).setVoWiFiRoamingModeSetting(
|
||||
eq(ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchChanged_enableSetting_shouldLaunchWfcDisclaimerFragment() {
|
||||
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
mFragment.onSwitchChanged(null, true);
|
||||
|
||||
// Check the WFC disclaimer fragment is launched.
|
||||
verify(mFragment).startActivityForResult(intentCaptor.capture(),
|
||||
eq(WifiCallingSettingsForSub.REQUEST_CHECK_WFC_DISCLAIMER));
|
||||
Intent intent = intentCaptor.getValue();
|
||||
final Intent intent = intentCaptor.getValue();
|
||||
assertThat(intent.getStringExtra(EXTRA_SHOW_FRAGMENT))
|
||||
.isEqualTo(WifiCallingDisclaimerFragment.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityResult_finishWfcDisclaimerFragment_shouldLaunchCarrierActivity() {
|
||||
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
|
||||
// Emulate the WfcDisclaimerActivity finish.
|
||||
mFragment.onActivityResult(WifiCallingSettingsForSub.REQUEST_CHECK_WFC_DISCLAIMER,
|
||||
@@ -305,7 +308,7 @@ public class WifiCallingSettingsForSubTest {
|
||||
// Check the WFC emergency address activity is launched.
|
||||
verify(mFragment).startActivityForResult(intentCaptor.capture(),
|
||||
eq(WifiCallingSettingsForSub.REQUEST_CHECK_WFC_EMERGENCY_ADDRESS));
|
||||
Intent intent = intentCaptor.getValue();
|
||||
final Intent intent = intentCaptor.getValue();
|
||||
assertEquals(intent.getComponent(), ComponentName.unflattenFromString(
|
||||
TEST_EMERGENCY_ADDRESS_CARRIER_APP));
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ import static android.app.slice.SliceItem.FORMAT_TEXT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -32,6 +32,7 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.ims.ImsMmTelManager;
|
||||
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.SliceItem;
|
||||
@@ -44,7 +45,6 @@ import androidx.slice.widget.RowContent;
|
||||
import androidx.slice.widget.SliceContent;
|
||||
import androidx.slice.widget.SliceLiveData;
|
||||
|
||||
import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
@@ -76,6 +76,9 @@ public class WifiCallingSliceHelperTest {
|
||||
@Mock
|
||||
private ImsManager mMockImsManager;
|
||||
|
||||
@Mock
|
||||
private ImsMmTelManager mMockImsMmTelManager;
|
||||
|
||||
private FakeWifiCallingSliceHelper mWfcSliceHelper;
|
||||
private SettingsSliceProvider mProvider;
|
||||
private SliceBroadcastReceiver mReceiver;
|
||||
@@ -98,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);
|
||||
@@ -133,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);
|
||||
@@ -151,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);
|
||||
@@ -166,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);
|
||||
@@ -182,17 +185,17 @@ 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))
|
||||
.thenReturn(mWfcSliceHelper);
|
||||
mWfcSliceHelper.setActivationAppIntent(null);
|
||||
|
||||
ArgumentCaptor<Boolean> mWfcSettingCaptor = ArgumentCaptor.forClass(Boolean.class);
|
||||
final ArgumentCaptor<Boolean> mWfcSettingCaptor = ArgumentCaptor.forClass(Boolean.class);
|
||||
|
||||
// turn on Wifi calling setting
|
||||
Intent intent = new Intent(WifiCallingSliceHelper.ACTION_WIFI_CALLING_CHANGED);
|
||||
final Intent intent = new Intent(WifiCallingSliceHelper.ACTION_WIFI_CALLING_CHANGED);
|
||||
intent.putExtra(EXTRA_TOGGLE_STATE, true);
|
||||
|
||||
// change the setting
|
||||
@@ -207,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);
|
||||
@@ -222,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);
|
||||
@@ -239,11 +242,11 @@ 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(mMockImsManager.getWfcMode(false)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
|
||||
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
||||
|
||||
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
|
||||
@@ -257,11 +260,11 @@ 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(mMockImsManager.getWfcMode(false)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
|
||||
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
||||
.thenReturn(mWfcSliceHelper);
|
||||
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
||||
@@ -276,28 +279,29 @@ 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(mMockImsManager.getWfcMode(false)).thenReturn(
|
||||
ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED);
|
||||
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
|
||||
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
|
||||
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
|
||||
.thenReturn(mWfcSliceHelper);
|
||||
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
|
||||
|
||||
ArgumentCaptor<Integer> mWfcPreferenceCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
final ArgumentCaptor<Integer> mWfcPreferenceCaptor =
|
||||
ArgumentCaptor.forClass(Integer.class);
|
||||
|
||||
// Change preference to Cellular pref
|
||||
Intent intent = new Intent(
|
||||
final Intent intent = new Intent(
|
||||
WifiCallingSliceHelper.ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED);
|
||||
|
||||
mReceiver.onReceive(mContext, intent);
|
||||
|
||||
verify((mMockImsManager)).setWfcMode(mWfcPreferenceCaptor.capture(), eq(false));
|
||||
verify((mMockImsMmTelManager)).setVoWiFiModeSetting(mWfcPreferenceCaptor.capture());
|
||||
|
||||
// assert the change
|
||||
assertThat(mWfcPreferenceCaptor.getValue()).isEqualTo(
|
||||
ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED);
|
||||
ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED);
|
||||
}
|
||||
|
||||
private void testWifiCallingSettingsUnavailableSlice(Slice slice,
|
||||
@@ -400,7 +404,7 @@ public class WifiCallingSliceHelperTest {
|
||||
private void assertTitle(List<SliceItem> sliceItems, String title) {
|
||||
boolean hasTitle = false;
|
||||
for (SliceItem item : sliceItems) {
|
||||
List<SliceItem> titleItems = SliceQuery.findAll(item, FORMAT_TEXT, HINT_TITLE,
|
||||
final List<SliceItem> titleItems = SliceQuery.findAll(item, FORMAT_TEXT, HINT_TITLE,
|
||||
null /* non-hints */);
|
||||
if (titleItems == null) {
|
||||
continue;
|
||||
@@ -434,6 +438,11 @@ public class WifiCallingSliceHelperTest {
|
||||
return mMockImsManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImsMmTelManager getImsMmTelManager(int subId) {
|
||||
return mMockImsMmTelManager;
|
||||
}
|
||||
|
||||
protected int getDefaultVoiceSubId() {
|
||||
return mSubId;
|
||||
}
|
||||
@@ -442,6 +451,10 @@ public class WifiCallingSliceHelperTest {
|
||||
mSubId = id;
|
||||
}
|
||||
|
||||
boolean isWfcProvisionedOnDevice(int subId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent getWifiCallingCarrierActivityIntent(int subId) {
|
||||
return mActivationAppIntent;
|
||||
|
Reference in New Issue
Block a user