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

Commit 34f35aff authored by SongFerngWang's avatar SongFerngWang Committed by Automerger Merge Worker
Browse files

Fix NullPointerException, TelephonyManager.getServiceState is null am: a12327b5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12468773

Change-Id: I5baab79d81bd127d8bf1a5092c0821a576b21852
parents bc4f38d3 a12327b5
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -475,8 +476,9 @@ public class MobileNetworkUtils {
        if (carrierConfig.getBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL)) {
            return true;
        }

        final String operatorNumeric = telephonyManager.getServiceState().getOperatorNumeric();
        final ServiceState serviceState = telephonyManager.getServiceState();
        final String operatorNumeric =
                (serviceState != null) ? serviceState.getOperatorNumeric() : null;
        final String[] numericArray = carrierConfig.getStringArray(
                CarrierConfigManager.KEY_SUPPORT_TDSCDMA_ROAMING_NETWORKS_STRING_ARRAY);
        if (numericArray == null || operatorNumeric == null) {
+3 −0
Original line number Diff line number Diff line
@@ -405,6 +405,9 @@ public class NetworkSelectSettings extends DashboardFragment {
        if (mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED) {
            // Try to get the network registration states
            final ServiceState ss = mTelephonyManager.getServiceState();
            if (ss == null) {
                return;
            }
            final List<NetworkRegistrationInfo> networkList =
                    ss.getNetworkRegistrationInfoListForTransportType(
                            AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
        final TextView operatorName = view.findViewById(R.id.operator_name_value);
        mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
        final ServiceState serviceState = mTelephonyManager.getServiceState();
        operatorName.setText(serviceState.getOperatorAlphaLong());
        operatorName.setText(serviceState == null ? "" : serviceState.getOperatorAlphaLong());

        final TextView phoneTitle = view.findViewById(R.id.number_label);
        phoneTitle.setVisibility(info.isOpportunistic() ? View.GONE : View.VISIBLE);
+8 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.PersistableBundle;
import android.os.SystemClock;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

@@ -125,7 +126,13 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
        super.updateState(preference);

        preference.setSummary(null);
        if (mTelephonyManager.getServiceState().getRoaming()) {
        final ServiceState serviceState = mTelephonyManager.getServiceState();
        if (serviceState == null) {
            preference.setEnabled(false);
            return;
        }

        if (serviceState.getRoaming()) {
            preference.setEnabled(true);
        } else {
            preference.setEnabled(!mOnlyAutoSelectInHome);