Snap for 8010657 from a93796f7a3
to sc-v2-release
Change-Id: I7d83519296b972388bb6976c3f65278ee79672a9
This commit is contained in:
@@ -179,7 +179,8 @@ public class WifiCallingSliceHelper {
|
||||
.setTitle(res.getText(R.string.wifi_calling_settings_title))
|
||||
.addEndItem(
|
||||
SliceAction.createToggle(
|
||||
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
|
||||
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED,
|
||||
isWifiCallingEnabled),
|
||||
null /* actionTitle */, isWifiCallingEnabled))
|
||||
.setPrimaryAction(SliceAction.createDeeplink(
|
||||
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
|
||||
@@ -316,7 +317,7 @@ public class WifiCallingSliceHelper {
|
||||
final Resources res = getResourcesForSubId(subId);
|
||||
return new RowBuilder()
|
||||
.setTitle(res.getText(preferenceTitleResId))
|
||||
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
|
||||
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action, checked),
|
||||
icon, res.getText(preferenceTitleResId), checked));
|
||||
}
|
||||
|
||||
@@ -370,25 +371,31 @@ public class WifiCallingSliceHelper {
|
||||
public void handleWifiCallingChanged(Intent intent) {
|
||||
final int subId = getDefaultVoiceSubId();
|
||||
|
||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||
if (SubscriptionManager.isValidSubscriptionId(subId)
|
||||
&& intent.hasExtra(EXTRA_TOGGLE_STATE)) {
|
||||
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
||||
if (queryState.isWifiCallingProvisioned()) {
|
||||
final boolean currentValue = queryState.isEnabledByUser()
|
||||
&& queryState.isAllowUserControl();
|
||||
final boolean currentValue = isWifiCallingEnabled();
|
||||
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||
currentValue);
|
||||
final Intent activationAppIntent =
|
||||
getWifiCallingCarrierActivityIntent(subId);
|
||||
if (!newValue || activationAppIntent == null) {
|
||||
if ((newValue == currentValue) && activationAppIntent == null) {
|
||||
// If either the action is to turn off wifi calling setting
|
||||
// or there is no activation involved - Update the setting
|
||||
if (newValue != currentValue) {
|
||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||
imsMmTelManager.setVoWiFiSettingEnabled(newValue);
|
||||
}
|
||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||
imsMmTelManager.setVoWiFiSettingEnabled(!newValue);
|
||||
} else {
|
||||
Log.w(TAG, "action not taken: subId " + subId
|
||||
+ " from " + currentValue + " to " + newValue);
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "action not taken: subId " + subId + " needs provision");
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "action not taken: subId " + subId);
|
||||
}
|
||||
|
||||
// notify change in slice in any case to get re-queried. This would result in displaying
|
||||
// appropriate message with the updated setting.
|
||||
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
|
||||
@@ -541,10 +548,20 @@ public class WifiCallingSliceHelper {
|
||||
PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
|
||||
private PendingIntent getBroadcastIntent(String action) {
|
||||
/**
|
||||
* Create PendingIntent for Slice.
|
||||
* Note: SliceAction#createDeeplink() didn't support toggle status so far,
|
||||
* therefore, embedding toggle status within PendingIntent.
|
||||
*
|
||||
* @param action Slice action
|
||||
* @param isChecked Status when Slice created.
|
||||
* @return PendingIntent
|
||||
*/
|
||||
private PendingIntent getBroadcastIntent(String action, boolean isChecked) {
|
||||
final Intent intent = new Intent(action);
|
||||
intent.setClass(mContext, SliceBroadcastReceiver.class);
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
intent.putExtra(EXTRA_TOGGLE_STATE, isChecked);
|
||||
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
|
@@ -209,82 +209,6 @@ public class MobileNetworkSummaryControllerTest {
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID)).isEqualTo(sub1.getSubscriptionId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_twoSubscriptions_correctSummaryAndFragment() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
||||
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummaryAfterUpdate_twoSubscriptionsBecomesOne_correctSummaryAndFragment() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
||||
when(sub1.getDisplayName()).thenReturn("sub1");
|
||||
when(sub2.getDisplayName()).thenReturn("sub2");
|
||||
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
||||
|
||||
// Simulate sub2 having disappeared - the end result should change to be the same as
|
||||
// if there were just one subscription.
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
|
||||
mController.onSubscriptionsChanged();
|
||||
assertThat(mController.getSummary()).isEqualTo("sub1");
|
||||
assertThat(mPreference.getFragment()).isNull();
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
doNothing().when(mContext).startActivity(intentCaptor.capture());
|
||||
mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
|
||||
assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
|
||||
MobileNetworkActivity.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummaryAfterUpdate_oneSubscriptionBecomesTwo_correctSummaryAndFragment() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
||||
when(sub1.getDisplayName()).thenReturn("sub1");
|
||||
when(sub2.getDisplayName()).thenReturn("sub2");
|
||||
|
||||
when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
|
||||
Arrays.asList(sub1));
|
||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("sub1");
|
||||
assertThat(mPreference.getFragment()).isNull();
|
||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
doNothing().when(mContext).startActivity(intentCaptor.capture());
|
||||
mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
|
||||
assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
|
||||
MobileNetworkActivity.class.getName());
|
||||
|
||||
// Simulate sub2 appearing in the list of subscriptions and check the results.
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_providerModel_Enabled() {
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
@@ -296,15 +220,9 @@ public class MobileNetworkSummaryControllerTest {
|
||||
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
|
||||
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -153,7 +153,6 @@ public class NetworkProviderBackupCallingGroupTest {
|
||||
@Test
|
||||
public void
|
||||
shouldShowBackupCallingForSub_crossSimDisabled_returnFalse() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
doReturn(false).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
|
||||
mContext, SUB_ID_1);
|
||||
|
||||
@@ -163,7 +162,6 @@ public class NetworkProviderBackupCallingGroupTest {
|
||||
|
||||
@Test
|
||||
public void shouldBackupCallingForSub_crossSimEnabled_returnTrue() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
|
||||
mContext, SUB_ID_1);
|
||||
|
||||
|
@@ -147,7 +147,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
||||
@Test
|
||||
public void
|
||||
shouldShowWifiCallingForSub_wifiCallingDisabledWithWifiCallingNotReady_returnFalse() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
setWifiCallingEnabled(false);
|
||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||
|
||||
@@ -157,7 +156,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
||||
|
||||
@Test
|
||||
public void shouldShowWifiCallingForSub_wifiCallingEnabledWithWifiCallingIsReady_returnTrue() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
setWifiCallingEnabled(true);
|
||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||
|
||||
@@ -168,7 +166,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
||||
@Test
|
||||
public void
|
||||
shouldShowWifiCallingForSub_wifiCallingDisabledWithNoActivityHandleIntent_returnFalse() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
buildPhoneAccountConfigureIntent(false);
|
||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
|
||||
@@ -181,7 +178,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
||||
@Test
|
||||
public void
|
||||
shouldShowWifiCallingForSub_wifiCallingEnabledWithActivityHandleIntent_returnTrue() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
buildPhoneAccountConfigureIntent(true);
|
||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
|
||||
|
Reference in New Issue
Block a user