Using the phone number without formate for the unique DisplayName
If the phone number has formate, the getUniqueSubscriptionDisplayNames may have the white space.
Bug: 318022908
Change-Id: I459fb244ec690eff03d565b494b007849ef44c8b
Test: atest SubscriptionUtilTest
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index ca49823..1065e37 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -335,8 +335,16 @@
if (duplicateOriginalNames.contains(info.originalName)) {
// This may return null, if the user cannot view the phone number itself.
- final String phoneNumber = getBidiFormattedPhoneNumber(context,
- info.subscriptionInfo);
+ String phoneNumber = "";
+ try {
+ final SubscriptionManager subscriptionManager = context.getSystemService(
+ SubscriptionManager.class);
+ phoneNumber = subscriptionManager.getPhoneNumber(infoSubId);
+ } catch (IllegalStateException
+ | SecurityException
+ | UnsupportedOperationException e) {
+ Log.w(TAG, "get number error." + e);
+ }
String lastFourDigits = "";
if (phoneNumber != null) {
lastFourDigits = (phoneNumber.length() > 4)