Null check added when updating the roaming status.
If the serviceState is null, calling getRoaming will cause a crash.
Instead of calling this method, set the string to not-roaming if the
value is null.
Test: atest -c SettingsUnitTest
Bug: 184334050
Change-Id: Ifa8a006838ea17f7d098c1b83bb6ab0349e7d569
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 1e25179..95f74fa 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -38,7 +38,6 @@
import android.telephony.CellBroadcastService;
import android.telephony.CellSignalStrength;
import android.telephony.ICellBroadcastService;
-import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -245,6 +244,8 @@
private void updateSubscriptionStatus() {
updateNetworkProvider();
+ // getServiceState() may return null when the subscription is inactive
+ // or when there was an error communicating with the phone process.
final ServiceState serviceState = mTelephonyManager.getServiceState();
final SignalStrength signalStrength = mTelephonyManager.getSignalStrength();
@@ -577,7 +578,10 @@
}
private void updateRoamingStatus(ServiceState serviceState) {
- if (serviceState.getRoaming()) {
+ // If the serviceState is null, we assume that roaming is disabled.
+ if (serviceState == null) {
+ mDialog.setText(ROAMING_INFO_VALUE_ID, mRes.getString(R.string.radioInfo_unknown));
+ } else if (serviceState.getRoaming()) {
mDialog.setText(ROAMING_INFO_VALUE_ID, mRes.getString(R.string.radioInfo_roaming_in));
} else {
mDialog.setText(ROAMING_INFO_VALUE_ID, mRes.getString(R.string.radioInfo_roaming_not));