Settings: fix npe in ImeiInfoPreferenceController
This commit is contained in:
@@ -54,6 +54,7 @@ public class ImeiInfoPreferenceController extends BasePreferenceController {
|
|||||||
|
|
||||||
public ImeiInfoPreferenceController(Context context, String key) {
|
public ImeiInfoPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
|
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Fragment fragment, SlotSimStatus slotSimStatus) {
|
public void init(Fragment fragment, SlotSimStatus slotSimStatus) {
|
||||||
@@ -187,8 +188,13 @@ public class ImeiInfoPreferenceController extends BasePreferenceController {
|
|||||||
private CharSequence getTitle(int simSlot) {
|
private CharSequence getTitle(int simSlot) {
|
||||||
boolean isPrimaryImei = isMultiSim() && isPrimaryImei(simSlot);
|
boolean isPrimaryImei = isMultiSim() && isPrimaryImei(simSlot);
|
||||||
final int phoneType = getPhoneType(simSlot);
|
final int phoneType = getPhoneType(simSlot);
|
||||||
|
if (mTelephonyManager != null) {
|
||||||
return phoneType == PHONE_TYPE_CDMA ? getTitleForCdmaPhone(simSlot, isPrimaryImei)
|
return phoneType == PHONE_TYPE_CDMA ? getTitleForCdmaPhone(simSlot, isPrimaryImei)
|
||||||
: getTitleForGsmPhone(simSlot, isPrimaryImei);
|
: getTitleForGsmPhone(simSlot, isPrimaryImei);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "TelephonyManager is null. Unable to get phone type.");
|
||||||
|
return mContext.getString(R.string.status_imei);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPhoneType(int slotIndex) {
|
public int getPhoneType(int slotIndex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user