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

Commit 5a4df243 authored by SongFerngWang's avatar SongFerngWang
Browse files

Fix the NullPointException

The subscriptionInfo.getCarrierName may be a null, so adding the null
checking.

Bug: 236064286
Test: build pass
Change-Id: I8f6f5ac725d6dd552ac2626725e44f52dcbf6c32
parent 73276b3c
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -201,7 +201,8 @@ public class ResetNetwork extends InstrumentedFragment {
                    name = record.getNumber();
                    name = record.getNumber();
                }
                }
                if (TextUtils.isEmpty(name)) {
                if (TextUtils.isEmpty(name)) {
                    name = record.getCarrierName().toString();
                    CharSequence carrierName = record.getCarrierName();
                    name = TextUtils.isEmpty(carrierName) ? "" : carrierName.toString();
                }
                }
                if (TextUtils.isEmpty(name)) {
                if (TextUtils.isEmpty(name)) {
                    name = String.format("MCC:%s MNC:%s Slot:%s Id:%s", record.getMcc(),
                    name = String.format("MCC:%s MNC:%s Slot:%s Id:%s", record.getMcc(),
+3 −2
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;


import androidx.preference.Preference;
import androidx.preference.Preference;
@@ -102,8 +103,8 @@ public class Enable2gPreferenceController extends TelephonyTogglePreferenceContr
        if (subInfo == null) {
        if (subInfo == null) {
            return "";
            return "";
        }
        }
        final String carrierName = subInfo.getCarrierName().toString();
        CharSequence carrierName = subInfo.getCarrierName();
        return carrierName;
        return TextUtils.isEmpty(carrierName) ? "" : carrierName.toString();
    }
    }


    @Override
    @Override