If the user add APN with empty APN type, map it for default type

Original behavior will map all APN type if enter empty APN type. But it
sometimes cause problem that MMS or IMS not working when select to this
custom APN. So if the user doesn't enter any APN type, just map to
valure of carrier config 'apn_settings_default_apn_types_string_array'
to avoid all the functions broken.

Bug: 129704611
Test: 1.Enter empty APN type and check if only default is added into
APN. 2.atest ApnEditorTest pass.
Change-Id: Icec274e5b402af06822479bcc60294b347f5254f
This commit is contained in:
andychou
2019-08-07 14:41:49 +08:00
committed by SongFerngWang
parent 5188a0560f
commit 34fc2495d2
2 changed files with 60 additions and 7 deletions

View File

@@ -463,6 +463,43 @@ public class ApnEditorTest {
verify(mApnEditorUT).finish();
}
@Test
public void getUserEnteredApnType_emptyApnType_shouldReturnDefault() {
// case 1
// GIVEN read only APN types with DUN
String[] readOnlyApnTypes = {"dun"};
mApnEditorUT.mReadOnlyApnTypes = readOnlyApnTypes;
// GIVEN read specificApnTypeForEmptyInput with DEFAULT,DUN
String[] defaultApnTypes = {"default", "dun"};
mApnEditorUT.mDefaultApnTypes = defaultApnTypes;
// Input empty in TYPE
final FakeApnData apnData = new FakeApnData(APN_DATA);
apnData.mData[ApnEditor.TYPE_INDEX] = "";
mApnEditorUT.mApnData = apnData;
mApnEditorUT.fillUI(true /* firstTime */);
// THEN APN type should be default
assertThat(mApnEditorUT.getUserEnteredApnType()).isEqualTo("default");
// case 2
// GIVEN read only APN types with DUN
String[] readOnlyApnTypesCase2 = {"dun"};
mApnEditorUT.mReadOnlyApnTypes = readOnlyApnTypesCase2;
// GIVEN read specificApnTypeForEmptyInput with DEFAULT
String[] defaultApnTypesCase2 = {"default"};
mApnEditorUT.mDefaultApnTypes = defaultApnTypesCase2;
// Input empty in TYPE
final FakeApnData apnDataCase2 = new FakeApnData(APN_DATA);
apnDataCase2.mData[ApnEditor.TYPE_INDEX] = "";
mApnEditorUT.mApnData = apnDataCase2;
mApnEditorUT.fillUI(true /* firstTime */);
// THEN APN type should be default
assertThat(mApnEditorUT.getUserEnteredApnType()).isEqualTo("default");
}
private void initCursor() {
doReturn(2).when(mCursor).getColumnCount();
doReturn(2).when(mCursor).getInt(CURSOR_INTEGER_INDEX);