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

Commit ae78184c authored by Stanley Wang's avatar Stanley Wang
Browse files

Fix Settings crashing while displaying phone number slice.

Check if the SubscriptionInfo list is empty to avoid the IndexOutOfBoundsException.

Fixes: 133258244
Test: maunal & robotest

Change-Id: I837f6761ba2b53823f0126f734f65875a30e34dd
parent ef0f8a4d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class PhoneNumberPreferenceController extends BasePreferenceController {
    private CharSequence getFirstPhoneNumber() {
        final List<SubscriptionInfo> subscriptionInfoList =
                mSubscriptionManager.getActiveSubscriptionInfoList(true);
        if (subscriptionInfoList == null) {
        if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
            return mContext.getText(R.string.device_info_default);
        }

+10 −0
Original line number Diff line number Diff line
@@ -149,6 +149,16 @@ public class PhoneNumberPreferenceControllerTest {
        assertThat(primaryNumber).isEqualTo(mContext.getString(R.string.device_info_default));
    }

    @Test
    public void getSummary_getEmptySubscriptionInfo_shouldShowUnknown() {
        List<SubscriptionInfo> infos = new ArrayList<>();
        when(mSubscriptionManager.getActiveSubscriptionInfoList(eq(true))).thenReturn(infos);

        CharSequence primaryNumber = mController.getSummary();

        assertThat(primaryNumber).isEqualTo(mContext.getString(R.string.device_info_default));
    }

    @Test
    public void isSliceable_shouldBeTrue() {
        assertThat(mController.isSliceable()).isTrue();