Settings app - read phone number from TelephonyManager.
The phone number needs to be always read from the TelephonyManager
since it can be overridden.
Bug: 18487514
Change-Id: If72094eb230c41b4f70146b0ccb012c9f9860626
diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java
index 2afdb84..b3e43af 100644
--- a/src/com/android/settings/deviceinfo/SimStatus.java
+++ b/src/com/android/settings/deviceinfo/SimStatus.java
@@ -343,7 +343,7 @@
}
}
- String rawNumber = mPhone.getLine1Number(); // may be null or empty
+ String rawNumber = mTelephonyManager.getLine1Number(); // may be null or empty
String formattedNumber = null;
if (!TextUtils.isEmpty(rawNumber)) {
formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
@@ -353,9 +353,7 @@
final String imei = mPhone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA
? mPhone.getImei() : mPhone.getDeviceId();
setSummaryText(KEY_IMEI, imei);
- setSummaryText(KEY_IMEI_SV,
- ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
- .getDeviceSoftwareVersion(/*slotId*/));
+ setSummaryText(KEY_IMEI_SV, mTelephonyManager.getDeviceSoftwareVersion(/*slotId*/));
if (!mShowLatestAreaInfo) {
removePreferenceFromScreen(KEY_LATEST_AREA_INFO);
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 6c3ddb5..ecca10c 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -418,7 +418,7 @@
} else {
sir = mSelectableSubInfos.get(position);
holder.title.setText(sir.getDisplayName());
- holder.summary.setText(sir.getNumber());
+ holder.summary.setText(getPhoneNumber(sir));
holder.icon.setImageBitmap(sir.createIconBitmap(mContext));
}
return rowView;
@@ -458,11 +458,11 @@
setTitle(String.format(getResources()
.getString(R.string.sim_editor_title), (mSlotId + 1)));
if (mSubInfoRecord != null) {
- if (TextUtils.isEmpty(mSubInfoRecord.getNumber())) {
+ if (TextUtils.isEmpty(getPhoneNumber(mSubInfoRecord))) {
setSummary(mSubInfoRecord.getDisplayName());
} else {
setSummary(mSubInfoRecord.getDisplayName() + " - " +
- mSubInfoRecord.getNumber());
+ getPhoneNumber(mSubInfoRecord));
setEnabled(true);
}
setIcon(new BitmapDrawable(res, (mSubInfoRecord.createIconBitmap(mContext))));
@@ -517,7 +517,7 @@
});
TextView numberView = (TextView)dialogLayout.findViewById(R.id.number);
- final String rawNumber = mSubInfoRecord.getNumber();
+ final String rawNumber = getPhoneNumber(mSubInfoRecord);
if (TextUtils.isEmpty(rawNumber)) {
numberView.setText(res.getString(com.android.internal.R.string.unknownName));
} else {
@@ -635,6 +635,14 @@
}
+ // Returns the line1Number. Line1number should always be read from TelephonyManager since it can
+ // be overridden for display purposes.
+ private String getPhoneNumber(SubscriptionInfo info) {
+ final TelephonyManager tm =
+ (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
+ return tm.getLine1NumberForSubscriber(info.getSubscriptionId());
+ }
+
private void log(String s) {
Log.d(TAG, s);
}