OSDN Git Service

Disable Mobile settings in one condition.
authorLei Yu <jackqdyulei@google.com>
Mon, 15 Apr 2019 19:28:53 +0000 (12:28 -0700)
committerLei Yu <jackqdyulei@google.com>
Mon, 15 Apr 2019 19:28:53 +0000 (12:28 -0700)
If there is no active subscription and esim is unsupported, disable
this preference.

Bug: 129143739
Test: RunSettingsRoboTests
Change-Id: I5f8b0d95df8764a3a505aae5e26df42e9412c021

src/com/android/settings/network/MobileNetworkSummaryController.java
tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java

index 463d7ae..df743b3 100644 (file)
@@ -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
index 8bcf8b6..ad66a8f 100644 (file)
@@ -283,6 +283,18 @@ public class MobileNetworkSummaryControllerTest {
     }
 
     @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);
         SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));