From 8164361792d5ce684dbd18b9ed4526cf3d03f39c Mon Sep 17 00:00:00 2001 From: Lei Yu Date: Mon, 15 Apr 2019 12:28:53 -0700 Subject: [PATCH] Disable Mobile settings in one condition. If there is no active subscription and esim is unsupported, disable this preference. Bug: 129143739 Test: RunSettingsRoboTests Change-Id: I5f8b0d95df8764a3a505aae5e26df42e9412c021 --- .../network/MobileNetworkSummaryController.java | 2 ++ .../network/MobileNetworkSummaryControllerTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java index 463d7ae3420..df743b3cee4 100644 --- a/src/com/android/settings/network/MobileNetworkSummaryController.java +++ b/src/com/android/settings/network/MobileNetworkSummaryController.java @@ -137,6 +137,8 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController startAddSimFlow(); return true; }); + } else { + mPreference.setEnabled(false); } } else { // We have one or more existing subscriptions, so we want the plus button if eSIM is diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java index 8bcf8b62525..ad66a8f43d1 100644 --- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java @@ -282,6 +282,18 @@ public class MobileNetworkSummaryControllerTest { assertThat(captor.getValue()).isFalse(); } + @Test + public void onResume_noSubscriptionEsimDisabled_isDisabled() { + Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0); + SubscriptionUtil.setAvailableSubscriptionsForTesting(null); + when(mEuiccManager.isEnabled()).thenReturn(false); + mController.displayPreference(mPreferenceScreen); + + mController.onResume(); + + assertThat(mPreference.isEnabled()).isFalse(); + } + @Test public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOn_isDisabled() { final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);