diff --git a/src/com/android/settings/network/apn/ApnTypes.kt b/src/com/android/settings/network/apn/ApnTypes.kt index 2c8fa2a51a0..d384625a149 100644 --- a/src/com/android/settings/network/apn/ApnTypes.kt +++ b/src/com/android/settings/network/apn/ApnTypes.kt @@ -109,11 +109,15 @@ object ApnTypes { return regularOptions.filter { it.selected.value }.joinToString(",") { it.text } } - private val NotPreSelectedTypes = setOf( - ApnSetting.TYPE_IMS_STRING, - ApnSetting.TYPE_IA_STRING, - ApnSetting.TYPE_EMERGENCY_STRING, - ApnSetting.TYPE_MCX_STRING, + private val PreSelectedTypes = setOf( + ApnSetting.TYPE_DEFAULT_STRING, + ApnSetting.TYPE_MMS_STRING, + ApnSetting.TYPE_SUPL_STRING, + ApnSetting.TYPE_DUN_STRING, + ApnSetting.TYPE_HIPRI_STRING, + ApnSetting.TYPE_FOTA_STRING, + ApnSetting.TYPE_CBS_STRING, + ApnSetting.TYPE_XCAP_STRING, ) fun getPreSelectedApnType(customizedConfig: CustomizedConfig): String = @@ -123,5 +127,5 @@ object ApnTypes { private fun defaultPreSelectedApnTypes(readOnlyApnTypes: List) = if (ApnSetting.TYPE_ALL_STRING in readOnlyApnTypes) emptyList() - else APN_TYPES.filter { it !in readOnlyApnTypes + NotPreSelectedTypes } + else PreSelectedTypes.filterNot { it in readOnlyApnTypes } } diff --git a/tests/spa_unit/src/com/android/settings/network/apn/ApnTypesTest.kt b/tests/spa_unit/src/com/android/settings/network/apn/ApnTypesTest.kt new file mode 100644 index 00000000000..95471b0d4cc --- /dev/null +++ b/tests/spa_unit/src/com/android/settings/network/apn/ApnTypesTest.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.network.apn + +import android.telephony.data.ApnSetting +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class ApnTypesTest { + + @Test + fun getPreSelectedApnType_regular() { + val apnType = ApnTypes.getPreSelectedApnType(CustomizedConfig()) + + assertThat(apnType).isEqualTo("default,mms,supl,dun,hipri,fota,cbs,xcap") + } + + @Test + fun getPreSelectedApnType_readOnlyApnTypes() { + val customizedConfig = CustomizedConfig( + readOnlyApnTypes = listOf(ApnSetting.TYPE_DUN_STRING), + ) + + val apnType = ApnTypes.getPreSelectedApnType(customizedConfig) + + assertThat(apnType).isEqualTo("default,mms,supl,hipri,fota,cbs,xcap") + } +}