X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fhelpers%2FProtocolHelper.kt;h=11407f7517d0e9e87941876f5597c0c20b8ec50d;hb=HEAD;hp=dcbc9adc71b1972cabfc3c6747e715287fe5c973;hpb=e917bd2fc33983d1a3194a032b1f2a1cc3879502;p=PrivacyCell.git diff --git a/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt b/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt index dcbc9ad..cb6ca1d 100644 --- a/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt +++ b/app/src/main/java/com/stoutner/privacycell/helpers/ProtocolHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2022 Soren Stoutner . + * Copyright 2022-2023 Soren Stoutner . * * This file is part of Privacy Cell . * @@ -69,22 +69,23 @@ class ProtocolHelper { } fun checkAdditionalNetworkInfo(additionalNetworkInfoType: Int): Int { - if ((additionalNetworkInfoType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE) || - (additionalNetworkInfoType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED)) { + return if ((additionalNetworkInfoType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE) || + (additionalNetworkInfoType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED)) { // The additional network info is secure. - return SECURE + SECURE } else { // The additional network info is insecure. // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA // TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -- Can be removed once the minimum API >= 31. - return INSECURE + INSECURE } } fun getNetworkTypeStringArray(networkType: Int, context: Context) : Array { - // Return the string array that corresponds to the network type. + // Return the string array that corresponds to the network type. The deprecated `NETWORK_TYPE_IDEN` can be removed once the minimum API >= 34. + @Suppress("DEPRECATION") return when(networkType) { TelephonyManager.NETWORK_TYPE_UNKNOWN -> arrayOf(context.getString(R.string.unknown), "") TelephonyManager.NETWORK_TYPE_GPRS -> arrayOf(context.getString(R.string.gprs), context.getString(R.string.gprs_detail)) @@ -112,14 +113,16 @@ class ProtocolHelper { fun getAdditionalNetworkInfoStringArray(overrideNetworkType: Int, context: Context) : Array { // Return the string array that corresponds to the override network type. + @Suppress("DEPRECATION") // OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE can be removed once the minimum API >= 31. return when(overrideNetworkType) { TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE -> arrayOf(context.getString(R.string.none), "") TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA -> arrayOf(context.getString(R.string.lte_ca), context.getString(R.string.lte_ca_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO -> arrayOf(context.getString(R.string.lte_advanced_pro), context.getString(R.string.lte_advanced_pro_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA -> arrayOf(context.getString(R.string.nr_nsa), context.getString(R.string.nr_nsa_detail)) - TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(context.getString(R.string.nr_nsa_mmwave), context.getString(R.string.nr_nsa_mmwave_detail)) // Can be removed once the minimum API >= 31. + // OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE can be removed once the minimum API >= 31. + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(context.getString(R.string.nr_nsa_mmwave), context.getString(R.string.nr_nsa_mmwave_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED -> arrayOf(context.getString(R.string.nr_advanced), context.getString(R.string.nr_advanced_detail)) else -> arrayOf(context.getString(R.string.error), "") } } -} \ No newline at end of file +}