DO NOT MERGE - qt-qpr1-dev-plus-aosp-without-vendor@5915889 into stage-aosp-master
Bug: 142003500 Change-Id: Ibae6b218a616a93cfda05dd77a5ea6f3a2dc4cea
This commit is contained in:
@@ -135,7 +135,10 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
private int mBearerInitialVal = 0;
|
||||
private String mMvnoTypeStr;
|
||||
private String mMvnoMatchDataStr;
|
||||
private String[] mReadOnlyApnTypes;
|
||||
@VisibleForTesting
|
||||
String[] mReadOnlyApnTypes;
|
||||
@VisibleForTesting
|
||||
String[] mDefaultApnTypes;
|
||||
private String[] mReadOnlyApnFields;
|
||||
private boolean mReadOnlyApn;
|
||||
private Uri mCarrierUri;
|
||||
@@ -189,7 +192,8 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
private static final int MMSPROXY_INDEX = 12;
|
||||
private static final int MMSPORT_INDEX = 13;
|
||||
private static final int AUTH_TYPE_INDEX = 14;
|
||||
private static final int TYPE_INDEX = 15;
|
||||
@VisibleForTesting
|
||||
static final int TYPE_INDEX = 15;
|
||||
private static final int PROTOCOL_INDEX = 16;
|
||||
@VisibleForTesting
|
||||
static final int CARRIER_ENABLED_INDEX = 17;
|
||||
@@ -250,12 +254,17 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
mReadOnlyApnTypes = b.getStringArray(
|
||||
CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY);
|
||||
if (!ArrayUtils.isEmpty(mReadOnlyApnTypes)) {
|
||||
for (String apnType : mReadOnlyApnTypes) {
|
||||
Log.d(TAG, "onCreate: read only APN type: " + apnType);
|
||||
}
|
||||
Log.d(TAG,
|
||||
"onCreate: read only APN type: " + Arrays.toString(mReadOnlyApnTypes));
|
||||
}
|
||||
mReadOnlyApnFields = b.getStringArray(
|
||||
CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY);
|
||||
|
||||
mDefaultApnTypes = b.getStringArray(
|
||||
CarrierConfigManager.KEY_APN_SETTINGS_DEFAULT_APN_TYPES_STRING_ARRAY);
|
||||
if (!ArrayUtils.isEmpty(mDefaultApnTypes)) {
|
||||
Log.d(TAG, "onCreate: default apn types: " + Arrays.toString(mDefaultApnTypes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1150,17 +1159,24 @@ public class ApnEditor extends SettingsPreferenceFragment
|
||||
return sNotSet.equals(value) ? null : value;
|
||||
}
|
||||
|
||||
private String getUserEnteredApnType() {
|
||||
@VisibleForTesting
|
||||
String getUserEnteredApnType() {
|
||||
// if user has not specified a type, map it to "ALL APN TYPES THAT ARE NOT READ-ONLY"
|
||||
// but if user enter empty type, map it just for default
|
||||
String userEnteredApnType = mApnType.getText();
|
||||
if (userEnteredApnType != null) userEnteredApnType = userEnteredApnType.trim();
|
||||
if ((TextUtils.isEmpty(userEnteredApnType)
|
||||
|| PhoneConstants.APN_TYPE_ALL.equals(userEnteredApnType))
|
||||
&& !ArrayUtils.isEmpty(mReadOnlyApnTypes)) {
|
||||
String[] apnTypeList = PhoneConstants.APN_TYPES;
|
||||
if (TextUtils.isEmpty(userEnteredApnType) && !ArrayUtils.isEmpty(mDefaultApnTypes)) {
|
||||
apnTypeList = mDefaultApnTypes;
|
||||
}
|
||||
|
||||
StringBuilder editableApnTypes = new StringBuilder();
|
||||
List<String> readOnlyApnTypes = Arrays.asList(mReadOnlyApnTypes);
|
||||
boolean first = true;
|
||||
for (String apnType : PhoneConstants.APN_TYPES) {
|
||||
for (String apnType : apnTypeList) {
|
||||
// add APN type if it is not read-only and is not wild-cardable
|
||||
if (!readOnlyApnTypes.contains(apnType)
|
||||
&& !apnType.equals(PhoneConstants.APN_TYPE_IA)
|
||||
|
@@ -37,6 +37,7 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.network.telephony.MobileNetworkActivity;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.Utils;
|
||||
@@ -162,6 +163,6 @@ public class MobileNetworkPreferenceController extends AbstractPreferenceControl
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mTelephonyManager.getNetworkOperatorName();
|
||||
return MobileNetworkUtils.getCurrentCarrierNameForDisplay(mContext);
|
||||
}
|
||||
}
|
||||
|
@@ -536,4 +536,60 @@ public class MobileNetworkUtils {
|
||||
icons.setTintList(Utils.getColorAttr(context, android.R.attr.colorControlNormal));
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@@ -310,9 +310,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
* 1. use {@code ServiceState#getNetworkRegistrationInfoList()} to get the currently
|
||||
* registered cellIdentity, wrap it into a CellInfo;
|
||||
* 2. set the signal strength level as strong;
|
||||
* 3. use {@link TelephonyManager#getNetworkOperatorName()} to get the title of the
|
||||
* previously connected network operator, since the CellIdentity got from step 1 only has
|
||||
* PLMN.
|
||||
* 3. get the title of the previously connected network operator, since the CellIdentity
|
||||
* got from step 1 only has PLMN.
|
||||
* - If the device has no data, we will remove the connected network operators list from the
|
||||
* screen.
|
||||
*/
|
||||
@@ -333,7 +332,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
if (cellInfo != null) {
|
||||
NetworkOperatorPreference pref = new NetworkOperatorPreference(
|
||||
cellInfo, getPrefContext(), mForbiddenPlmns, mShow4GForLTE);
|
||||
pref.setTitle(mTelephonyManager.getNetworkOperatorName());
|
||||
pref.setTitle(MobileNetworkUtils.getCurrentCarrierNameForDisplay(
|
||||
getPrefContext(), mSubId));
|
||||
pref.setSummary(R.string.network_connected);
|
||||
// Update the signal strength icon, since the default signalStrength value would be
|
||||
// zero (it would be quite confusing why the connected network has no signal)
|
||||
|
@@ -75,7 +75,7 @@ public class OpenNetworkSelectPagePreferenceController extends
|
||||
public CharSequence getSummary() {
|
||||
final ServiceState ss = mTelephonyManager.getServiceState();
|
||||
if (ss != null && ss.getState() == ServiceState.STATE_IN_SERVICE) {
|
||||
return mTelephonyManager.getNetworkOperatorName();
|
||||
return MobileNetworkUtils.getCurrentCarrierNameForDisplay(mContext, mSubId);
|
||||
} else {
|
||||
return mContext.getString(R.string.network_disconnected);
|
||||
}
|
||||
@@ -108,4 +108,4 @@ public class OpenNetworkSelectPagePreferenceController extends
|
||||
public void onNetworkSelectModeChanged() {
|
||||
updateState(mPreference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user