Merge "Change empty apn type in user entered APN to non-read-only types." into oc-dr1-dev am: 4fffc20ada
am: fb2b63df05
Change-Id: I04784337fe7a2ed0d3752383d781a9a446c55d1e
This commit is contained in:
@@ -52,6 +52,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
|||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -117,6 +118,7 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
private String[] mReadOnlyApnTypes;
|
private String[] mReadOnlyApnTypes;
|
||||||
private String[] mReadOnlyApnFields;
|
private String[] mReadOnlyApnFields;
|
||||||
private boolean mReadOnlyApn;
|
private boolean mReadOnlyApn;
|
||||||
|
private String mUserEnteredApnType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard projection for the interesting columns of a normal note.
|
* Standard projection for the interesting columns of a normal note.
|
||||||
@@ -212,6 +214,7 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
mReadOnlyApn = false;
|
mReadOnlyApn = false;
|
||||||
mReadOnlyApnTypes = null;
|
mReadOnlyApnTypes = null;
|
||||||
mReadOnlyApnFields = null;
|
mReadOnlyApnFields = null;
|
||||||
|
mUserEnteredApnType = null;
|
||||||
|
|
||||||
CarrierConfigManager configManager = (CarrierConfigManager)
|
CarrierConfigManager configManager = (CarrierConfigManager)
|
||||||
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||||
@@ -220,6 +223,11 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
if (b != null) {
|
if (b != null) {
|
||||||
mReadOnlyApnTypes = b.getStringArray(
|
mReadOnlyApnTypes = b.getStringArray(
|
||||||
CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
mReadOnlyApnFields = b.getStringArray(
|
mReadOnlyApnFields = b.getStringArray(
|
||||||
CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY);
|
CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY);
|
||||||
}
|
}
|
||||||
@@ -951,7 +959,7 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
callUpdate = setStringValueAndCheckIfDiff(values,
|
callUpdate = setStringValueAndCheckIfDiff(values,
|
||||||
Telephony.Carriers.TYPE,
|
Telephony.Carriers.TYPE,
|
||||||
checkNotSet(mApnType.getText()),
|
checkNotSet(getUserEnteredApnType()),
|
||||||
callUpdate,
|
callUpdate,
|
||||||
TYPE_INDEX);
|
TYPE_INDEX);
|
||||||
|
|
||||||
@@ -1057,10 +1065,11 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
// if carrier does not allow editing certain apn types, make sure type does not include
|
// if carrier does not allow editing certain apn types, make sure type does not include
|
||||||
// those
|
// those
|
||||||
if (!ArrayUtils.isEmpty(mReadOnlyApnTypes)
|
if (!ArrayUtils.isEmpty(mReadOnlyApnTypes)
|
||||||
&& apnTypesMatch(mReadOnlyApnTypes, mApnType.getText())) {
|
&& apnTypesMatch(mReadOnlyApnTypes, getUserEnteredApnType())) {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (String type : mReadOnlyApnTypes) {
|
for (String type : mReadOnlyApnTypes) {
|
||||||
stringBuilder.append(type).append(", ");
|
stringBuilder.append(type).append(", ");
|
||||||
|
Log.d(TAG, "getErrorMsg: appending type: " + type);
|
||||||
}
|
}
|
||||||
// remove last ", "
|
// remove last ", "
|
||||||
if (stringBuilder.length() >= 2) {
|
if (stringBuilder.length() >= 2) {
|
||||||
@@ -1107,6 +1116,41 @@ public class ApnEditor extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getUserEnteredApnType() {
|
||||||
|
if (mUserEnteredApnType != null) {
|
||||||
|
return mUserEnteredApnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if user has not specified a type, map it to "ALL APN TYPES THAT ARE NOT READ-ONLY"
|
||||||
|
mUserEnteredApnType = mApnType.getText();
|
||||||
|
if (mUserEnteredApnType != null) mUserEnteredApnType = mUserEnteredApnType.trim();
|
||||||
|
if ((TextUtils.isEmpty(mUserEnteredApnType)
|
||||||
|
|| PhoneConstants.APN_TYPE_ALL.equals(mUserEnteredApnType))
|
||||||
|
&& !ArrayUtils.isEmpty(mReadOnlyApnTypes)) {
|
||||||
|
StringBuilder editableApnTypes = new StringBuilder();
|
||||||
|
List<String> readOnlyApnTypes = Arrays.asList(mReadOnlyApnTypes);
|
||||||
|
boolean first = true;
|
||||||
|
for (String apnType : PhoneConstants.APN_TYPES) {
|
||||||
|
// add APN type if it is not read-only and is not wild-cardable
|
||||||
|
if (!readOnlyApnTypes.contains(apnType)
|
||||||
|
&& !apnType.equals(PhoneConstants.APN_TYPE_IA)
|
||||||
|
&& !apnType.equals(PhoneConstants.APN_TYPE_EMERGENCY)) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
editableApnTypes.append(",");
|
||||||
|
}
|
||||||
|
editableApnTypes.append(apnType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mUserEnteredApnType = editableApnTypes.toString();
|
||||||
|
Log.d(TAG, "getUserEnteredApnType: changed apn type to editable apn types: "
|
||||||
|
+ mUserEnteredApnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mUserEnteredApnType;
|
||||||
|
}
|
||||||
|
|
||||||
public static class ErrorDialog extends InstrumentedDialogFragment {
|
public static class ErrorDialog extends InstrumentedDialogFragment {
|
||||||
|
|
||||||
public static void showError(ApnEditor editor) {
|
public static void showError(ApnEditor editor) {
|
||||||
|
Reference in New Issue
Block a user