Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05461f70 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Add null check for forbiddenPlmns"

parents 76b70687 6b242d94
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -132,7 +132,8 @@ public class NetworkSelectSettings extends DashboardFragment {
    @Override
    public void onStart() {
        super.onStart();
        mForbiddenPlmns = Arrays.asList(mTelephonyManager.getForbiddenPlmns());

        updateForbiddenPlmns();
        setProgressBarVisible(true);

        mNetworkScanHelper.startNetworkScan(
@@ -141,6 +142,17 @@ public class NetworkSelectSettings extends DashboardFragment {
                        : NetworkScanHelper.NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS);
    }

    /**
     * Update forbidden PLMNs from the USIM App
     */
    @VisibleForTesting
    void updateForbiddenPlmns() {
        final String[] forbiddenPlmns = mTelephonyManager.getForbiddenPlmns();
        mForbiddenPlmns = forbiddenPlmns != null
                ? Arrays.asList(forbiddenPlmns)
                : new ArrayList<>();
    }

    @Override
    public void onStop() {
        super.onStop();
+8 −0
Original line number Diff line number Diff line
@@ -102,4 +102,12 @@ public class NetworkSelectSettingsTest {
                (NetworkOperatorPreference) mPreferenceCategory.getPreference(0);
        assertThat(preference.getCellInfo()).isEqualTo(mCellInfo2);
    }

    @Test
    public void updateForbiddenPlmns_forbiddenPlmnsNull_shouldNotCrash() {
        when(mTelephonyManager.getForbiddenPlmns()).thenReturn(null);

        // Should not Crash
        mNetworkSelectSettings.updateForbiddenPlmns();
    }
}