[Settings] Fix conflict of AOSP merge
Merge for fixing conflict of Ib4b0e1191c83e23377ccf8ed013252728ef9dd95 Bug: 144960427 Test: build pass Change-Id: I0e8c9b060f23547cec541819e657fc5560d6312c Merged-In: I7a86395c86d31fe2ba54c04ac16b1a0ebfc843f3
This commit is contained in:
@@ -536,4 +536,60 @@ public class MobileNetworkUtils {
|
|||||||
icons.setTintList(Utils.getColorAttr(context, android.R.attr.colorControlNormal));
|
icons.setTintList(Utils.getColorAttr(context, android.R.attr.colorControlNormal));
|
||||||
return icons;
|
return icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is migrated from
|
||||||
|
* {@link android.telephony.TelephonyManager.getNetworkOperatorName}. Which provides
|
||||||
|
*
|
||||||
|
* 1. Better support under multi-SIM environment.
|
||||||
|
* 2. Similar design which aligned with operator name displayed in status bar
|
||||||
|
*/
|
||||||
|
public static CharSequence getCurrentCarrierNameForDisplay(Context context, int subId) {
|
||||||
|
SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
|
||||||
|
if (sm != null) {
|
||||||
|
SubscriptionInfo subInfo = getSubscriptionInfo(sm, subId);
|
||||||
|
if (subInfo != null) {
|
||||||
|
return subInfo.getCarrierName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getOperatorNameFromTelephonyManager(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence getCurrentCarrierNameForDisplay(Context context) {
|
||||||
|
SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
|
||||||
|
if (sm != null) {
|
||||||
|
int subId = sm.getDefaultSubscriptionId();
|
||||||
|
SubscriptionInfo subInfo = getSubscriptionInfo(sm, subId);
|
||||||
|
if (subInfo != null) {
|
||||||
|
return subInfo.getCarrierName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getOperatorNameFromTelephonyManager(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SubscriptionInfo getSubscriptionInfo(SubscriptionManager subManager,
|
||||||
|
int subId) {
|
||||||
|
List<SubscriptionInfo> subInfos = subManager.getAccessibleSubscriptionInfoList();
|
||||||
|
if (subInfos == null) {
|
||||||
|
subInfos = subManager.getActiveSubscriptionInfoList();
|
||||||
|
}
|
||||||
|
if (subInfos == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (SubscriptionInfo subInfo : subInfos) {
|
||||||
|
if (subInfo.getSubscriptionId() == subId) {
|
||||||
|
return subInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getOperatorNameFromTelephonyManager(Context context) {
|
||||||
|
TelephonyManager tm =
|
||||||
|
(TelephonyManager) context.getSystemService(TelephonyManager.class);
|
||||||
|
if (tm == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return tm.getNetworkOperatorName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user