Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ea08203 authored by Chaohui Wang's avatar Chaohui Wang Committed by Android (Google) Code Review
Browse files

Merge "Align PreSelectedTypes with Android U" into main

parents c82282cf 333c3097
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -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<String>) =
        if (ApnSetting.TYPE_ALL_STRING in readOnlyApnTypes) emptyList()
        else APN_TYPES.filter { it !in readOnlyApnTypes + NotPreSelectedTypes }
        else PreSelectedTypes.filterNot { it in readOnlyApnTypes }
}
+45 −0
Original line number Diff line number Diff line
/*
 * 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")
    }
}