summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Marado <mindboosternoori@gmail.com>2016-11-29 18:24:21 +0000
committerMarcos Marado <mindboosternoori@gmail.com>2016-12-31 01:48:02 +0000
commit383b5d8e7076a801b60421bdd929d44de074a801 (patch)
tree3280688b5672d2f7f8e9883cba900f4870c72b42
parentcd93a79b8c0f61c9d3be2587f903ec5861bd9e51 (diff)
downloadpackages_apps_Settings-383b5d8e7076a801b60421bdd929d44de074a801.zip
packages_apps_Settings-383b5d8e7076a801b60421bdd929d44de074a801.tar.gz
packages_apps_Settings-383b5d8e7076a801b60421bdd929d44de074a801.tar.bz2
SimSettings: avoid NPE
Don't assume getPhoneAccount doesn't return null just because you're passing a non-null argument. Avoids: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.telecom.PhoneAccount.getLabel()' on a null object reference at com.android.settings.sim.SimSettings.updateCallValues(SimSettings.java:299) at com.android.settings.sim.SimSettings.updateActivitesCategory(SimSettings.java:237) at com.android.settings.sim.SimSettings.updateAllOptions(SimSettings.java:222) at com.android.settings.sim.SimSettings.updateSubscriptions(SimSettings.java:217) at com.android.settings.sim.SimSettings.-wrap4(SimSettings.java) at com.android.settings.sim.SimSettings$1.onSubscriptionsChanged(SimSettings.java:175) at android.telephony.SubscriptionManager$OnSubscriptionsChangedListener$1.handleMessage(SubscriptionManager.java:397) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5461) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Change-Id: Ibdb5a978744a8f3e5dd916d08297a07d98aca5be
-rw-r--r--src/com/android/settings/sim/SimSettings.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index b97ee03..c5d3822 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -45,6 +45,7 @@ import android.telephony.SmsManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.text.TextUtils;
@@ -288,15 +289,19 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
private void updateCallValues() {
final Preference simPref = findPreference(KEY_CALLS);
final TelecomManager telecomManager = TelecomManager.from(mContext);
- final PhoneAccountHandle phoneAccount =
+ final PhoneAccountHandle phoneAccountHandle =
telecomManager.getUserSelectedOutgoingPhoneAccount();
final List<PhoneAccountHandle> allPhoneAccounts =
telecomManager.getCallCapablePhoneAccounts();
simPref.setTitle(R.string.calls_title);
+ PhoneAccount phoneAccount = null;
+ if (phoneAccountHandle != null) {
+ phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
+ }
simPref.setSummary(phoneAccount == null
? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title)
- : (String)telecomManager.getPhoneAccount(phoneAccount).getLabel());
+ : (String)phoneAccount.getLabel());
simPref.setEnabled(allPhoneAccounts.size() > 1);
}