[Mainline] Use isActiveSubscriptionId instead of isActiveSubId for mainline

Bug: 147206736
Test: make RunSettingsRoboTests ROBOTEST_FILTER=DisabledSubscriptionControllerTest
      make RunSettingsRoboTests ROBOTEST_FILTER=MobileNetworkSwitchControllerTest
      make RunSettingsRoboTests ROBOTEST_FILTER=SimSelectNotificationTest

Merged-In: If740c2d7ea2c1392d5fe538091ea6e5c4575ad26
Change-Id: Idca7a76c591448a45ecc33cb392f416c70d32f91
This commit is contained in:
changbetty
2020-01-08 15:24:20 +08:00
committed by Bonian Chen
parent e24a23f9ab
commit f1a52da792
4 changed files with 11 additions and 13 deletions

View File

@@ -83,7 +83,7 @@ public class MobileNetworkSwitchController extends BasePreferenceController impl
mSwitchBar.addOnSwitchChangeListener((switchView, isChecked) -> { mSwitchBar.addOnSwitchChangeListener((switchView, isChecked) -> {
// TODO b/135222940: re-evaluate whether to use // TODO b/135222940: re-evaluate whether to use
// mSubscriptionManager#isSubscriptionEnabled // mSubscriptionManager#isSubscriptionEnabled
if (mSubscriptionManager.isActiveSubId(mSubId) != isChecked if (mSubscriptionManager.isActiveSubscriptionId(mSubId) != isChecked
&& (!mSubscriptionManager.setSubscriptionEnabled(mSubId, isChecked))) { && (!mSubscriptionManager.setSubscriptionEnabled(mSubId, isChecked))) {
mSwitchBar.setChecked(!isChecked); mSwitchBar.setChecked(!isChecked);
} }
@@ -110,9 +110,7 @@ public class MobileNetworkSwitchController extends BasePreferenceController impl
mSwitchBar.hide(); mSwitchBar.hide();
} else { } else {
mSwitchBar.show(); mSwitchBar.show();
// TODO b/135222940: re-evaluate whether to use mSwitchBar.setChecked(mSubscriptionManager.isActiveSubscriptionId(mSubId));
// mSubscriptionManager#isSubscriptionEnabled
mSwitchBar.setChecked(mSubscriptionManager.isActiveSubId(mSubId));
} }
} }

View File

@@ -103,7 +103,7 @@ public class SimSelectNotification extends BroadcastReceiver {
SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService( SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
Context.TELEPHONY_SUBSCRIPTION_SERVICE)); Context.TELEPHONY_SUBSCRIPTION_SERVICE));
if (!subscriptionManager.isActiveSubId(subId)) { if (!subscriptionManager.isActiveSubscriptionId(subId)) {
Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId); Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
return; return;
} }

View File

@@ -109,7 +109,7 @@ public class MobileNetworkSwitchControllerTest {
@Test @Test
public void displayPreference_oneEnabledSubscription_switchBarNotHidden() { public void displayPreference_oneEnabledSubscription_switchBarNotHidden() {
doReturn(true).when(mSubscriptionManager).isActiveSubId(mSubId); doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(mSubId);
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription)); SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription));
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
@@ -117,7 +117,7 @@ public class MobileNetworkSwitchControllerTest {
@Test @Test
public void displayPreference_oneDisabledSubscription_switchBarNotHidden() { public void displayPreference_oneDisabledSubscription_switchBarNotHidden() {
doReturn(false).when(mSubscriptionManager).isActiveSubId(mSubId); doReturn(false).when(mSubscriptionManager).isActiveSubscriptionId(mSubId);
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription)); SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSubscription));
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
@@ -125,7 +125,7 @@ public class MobileNetworkSwitchControllerTest {
@Test @Test
public void displayPreference_subscriptionEnabled_switchIsOn() { public void displayPreference_subscriptionEnabled_switchIsOn() {
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isTrue(); assertThat(mSwitchBar.isChecked()).isTrue();
@@ -133,7 +133,7 @@ public class MobileNetworkSwitchControllerTest {
@Test @Test
public void displayPreference_subscriptionDisabled_switchIsOff() { public void displayPreference_subscriptionDisabled_switchIsOff() {
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(false); when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(false);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isFalse(); assertThat(mSwitchBar.isChecked()).isFalse();
@@ -141,7 +141,7 @@ public class MobileNetworkSwitchControllerTest {
@Test @Test
public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledCalledCorrectly() { public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledCalledCorrectly() {
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isTrue(); assertThat(mSwitchBar.isChecked()).isTrue();
@@ -153,7 +153,7 @@ public class MobileNetworkSwitchControllerTest {
public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledFailed() { public void switchChangeListener_fromEnabledToDisabled_setSubscriptionEnabledFailed() {
when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean())) when(mSubscriptionManager.setSubscriptionEnabled(eq(mSubId), anyBoolean()))
.thenReturn(false); .thenReturn(false);
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isTrue(); assertThat(mSwitchBar.isChecked()).isTrue();
@@ -164,7 +164,7 @@ public class MobileNetworkSwitchControllerTest {
@Test @Test
public void switchChangeListener_fromDisabledToEnabled_setSubscriptionEnabledCalledCorrectly() { public void switchChangeListener_fromDisabledToEnabled_setSubscriptionEnabledCalledCorrectly() {
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(false); when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(false);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
assertThat(mSwitchBar.isShowing()).isTrue(); assertThat(mSwitchBar.isShowing()).isTrue();
assertThat(mSwitchBar.isChecked()).isFalse(); assertThat(mSwitchBar.isChecked()).isFalse();

View File

@@ -117,7 +117,7 @@ public class SimSelectNotificationTest {
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager); when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(false); when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(false);
when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true); when(mSubscriptionManager.isActiveSubscriptionId(mSubId)).thenReturn(true);
when(mSubscriptionManager.getActiveSubscriptionInfo(mSubId)).thenReturn(mSubInfo); when(mSubscriptionManager.getActiveSubscriptionInfo(mSubId)).thenReturn(mSubInfo);
when(mSubInfo.getDisplayName()).thenReturn(mFakeDisplayName); when(mSubInfo.getDisplayName()).thenReturn(mFakeDisplayName);
when(mContext.getResources()).thenReturn(mResources); when(mContext.getResources()).thenReturn(mResources);