Utility to compute a single subscription's unique display name.
Bug: 150370656 Bug: 148303118 Test: atest -c SubscriptionUtilTest Change-Id: Id4600dbf038117129c62331f9e00b7035af1c0fd
This commit is contained in:
@@ -306,6 +306,24 @@ public class SubscriptionUtil {
|
||||
info -> info.uniqueName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the display name for a subscription id, which is guaranteed to be unique.
|
||||
* The logic to create this name has the following order of operations:
|
||||
* 1) If the original display name is not unique, the last four digits of the phone number
|
||||
* will be appended.
|
||||
* 2) If the phone number is not visible or the last four digits are shared with another
|
||||
* subscription, the subscription id will be appended to the original display name.
|
||||
* More details can be found at go/unique-sub-display-names.
|
||||
*
|
||||
* @return map of active subscription ids to diaplay names.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static CharSequence getUniqueSubscriptionDisplayName(
|
||||
Integer subscriptionId, Context context) {
|
||||
final Map<Integer, CharSequence> displayNames = getUniqueSubscriptionDisplayNames(context);
|
||||
return displayNames.getOrDefault(subscriptionId, "");
|
||||
}
|
||||
|
||||
public static String getDisplayName(SubscriptionInfo info) {
|
||||
final CharSequence name = info.getDisplayName();
|
||||
if (name != null) {
|
||||
|
Reference in New Issue
Block a user