From 5d8e96c54cad4115e962eac556c10f871807f02f Mon Sep 17 00:00:00 2001 From: soren Date: Thu, 28 Oct 2021 14:56:21 -0700 Subject: [PATCH] Bump the target API to 31. https://redmine.stoutner.com/issues/772 --- app/build.gradle | 8 ++--- .../override_network_nr_advanced.html | 36 +++++++++++++++++++ .../activities/PrivacyCellActivity.kt | 18 +++++----- .../privacycell/dialogs/WebViewDialog.kt | 13 ++++++- .../services/RealtimeMonitoringService.kt | 10 +++--- app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 app/src/main/assets/en/explanations/override_network_nr_advanced.html diff --git a/app/build.gradle b/app/build.gradle index 1f5f1c6..751bd07 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,12 +23,12 @@ plugins { } android { - compileSdk 30 + compileSdk 31 defaultConfig { applicationId "com.stoutner.privacycell" minSdk 30 - targetSdk 30 + targetSdk 31 versionCode 5 versionName "1.4" } @@ -50,11 +50,11 @@ android { dependencies { // Include the following AndroidX libraries. implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.preference:preference-ktx:1.1.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.webkit:webkit:1.4.0' - implementation 'androidx.work:work-runtime-ktx:2.6.0' + implementation 'androidx.work:work-runtime-ktx:2.7.0' // Include the Kotlin standard libraries. This should be the same version number listed in project build.gradle. implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31' diff --git a/app/src/main/assets/en/explanations/override_network_nr_advanced.html b/app/src/main/assets/en/explanations/override_network_nr_advanced.html new file mode 100644 index 0000000..3faf268 --- /dev/null +++ b/app/src/main/assets/en/explanations/override_network_nr_advanced.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + +

New Radio Advanced + is a marketing term that indicates that the carrier has done something beyond the bare minimum to qualify for the 5G logo. + It likely indicates that speeds beyond those typically associated with standard 5G are available. + For example, the carrier might be using the mmWave spectrum (24.25–52.6 GHz), which goes really fast but doesn't penetrate walls. + Or, they might be using carrier aggregation to increase bandwidth.

+ + \ No newline at end of file diff --git a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt index 13cfe7b..55d7c92 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/PrivacyCellActivity.kt @@ -26,7 +26,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle -import android.telephony.PhoneStateListener +import android.telephony.PhoneStateListener // This can be replaced by `TelephonyCallback` once the minimum API >= 31. import android.telephony.ServiceState import android.telephony.TelephonyDisplayInfo import android.telephony.TelephonyManager @@ -56,7 +56,7 @@ import com.stoutner.privacycell.services.RealtimeMonitoringService class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener, PhonePermissionDialog.StoragePermissionDialogListener { // Declare the class variables. private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle - private lateinit var phoneStateListener: PhoneStateListener + private lateinit var phoneStateListener: PhoneStateListener // The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. // Declare the class views. private lateinit var drawerLayout: DrawerLayout @@ -135,7 +135,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem } }) - // Define the phone state listener. + // Define the phone state listener. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. phoneStateListener = object : PhoneStateListener() { override fun onDisplayInfoChanged(telephonyDisplayInfo: TelephonyDisplayInfo) { // Populate the stingray security information. @@ -217,8 +217,9 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_LTE_CA) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_LTE_ADVANCED_PRO) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA) - TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA_MMWAVE) - else -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA_MMWAVE) + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_NSA_MMWAVE) // Can be removed once the minimum API >= 31. + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NR_ADVANCED) + else -> WebViewDialog().type(WebViewDialog.OVERRIDE_NETWORK_NONE) } // Show the alert dialog. @@ -326,7 +327,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem // Get a handle for the telephony manager. val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - // Unregister the telephony manager listener. + // Unregister the telephony manager listener. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE) } @@ -478,7 +479,7 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem // Get a handle for the telephony manager. val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - // Listen to changes in the cell network state. + // Listen to changes in the cell network state. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED or PhoneStateListener.LISTEN_SERVICE_STATE) } @@ -516,7 +517,8 @@ class PrivacyCellActivity : AppCompatActivity(), NavigationView.OnNavigationItem TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA -> arrayOf(getString(R.string.lte_ca), getString(R.string.lte_ca_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO -> arrayOf(getString(R.string.lte_advanced_pro), getString(R.string.lte_advanced_pro_detail)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA -> arrayOf(getString(R.string.nr_nsa), getString(R.string.nr_nsa_detail)) - TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(getString(R.string.nr_nsa_mmwave), getString(R.string.nr_nsa_mmwave_detail)) + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE -> arrayOf(getString(R.string.nr_nsa_mmwave), getString(R.string.nr_nsa_mmwave_detail)) // Can be removed once the minimum API >= 31. + TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED -> arrayOf(getString(R.string.nr_advanced), getString(R.string.nr_advanced_detail)) else -> arrayOf(getString(R.string.error), "") } } diff --git a/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt b/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt index 3b448bd..0103424 100644 --- a/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt +++ b/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt @@ -73,7 +73,8 @@ class WebViewDialog : DialogFragment() { const val OVERRIDE_NETWORK_LTE_CA = 27 const val OVERRIDE_NETWORK_LTE_ADVANCED_PRO = 28 const val OVERRIDE_NETWORK_NR_NSA = 29 - const val OVERRIDE_NETWORK_NR_NSA_MMWAVE = 30 + const val OVERRIDE_NETWORK_NR_NSA_MMWAVE = 30 // Can be removed once the minimum API >= 31. + const val OVERRIDE_NETWORK_NR_ADVANCED = 31 } // Define the class views. @@ -353,6 +354,14 @@ class WebViewDialog : DialogFragment() { // Set the title. dialogBuilder.setTitle(R.string.nr_nsa_mmwave) } + + OVERRIDE_NETWORK_NR_ADVANCED -> { + // Set the icon. + dialogBuilder.setIcon(R.drawable.privacy_policy) + + // Set the title. + dialogBuilder.setTitle(R.string.nr_advanced) + } } // Set the view. @@ -439,7 +448,9 @@ class WebViewDialog : DialogFragment() { OVERRIDE_NETWORK_LTE_ADVANCED_PRO -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_lte_advanced_pro.html") OVERRIDE_NETWORK_NR_NSA -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_nr_nsa.html") + // The item below can be removed once the minimum API >= 31. OVERRIDE_NETWORK_NR_NSA_MMWAVE -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_nr_nsa_mmwave.html") + OVERRIDE_NETWORK_NR_ADVANCED -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_nr_advanced.html") } // Scroll the WebView if the saved instance state is not null. diff --git a/app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt b/app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt index 23e7278..5aa98f8 100644 --- a/app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt +++ b/app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt @@ -31,7 +31,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.os.Binder import android.os.IBinder -import android.telephony.PhoneStateListener +import android.telephony.PhoneStateListener // This can be replaced by `TelephonyCallback` once the minimum API >= 31. import android.telephony.TelephonyDisplayInfo import android.telephony.TelephonyManager @@ -60,7 +60,7 @@ class RealtimeMonitoringService : Service() { // Define the class variables. private var currentStatus = "" - private lateinit var phoneStateListener: PhoneStateListener + private lateinit var phoneStateListener: PhoneStateListener // The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. inner class ServiceBinder : Binder() { // Get a copy of this service as a binder. @@ -127,7 +127,7 @@ class RealtimeMonitoringService : Service() { // Start the foreground notification. startForeground(NOTIFICATION_ID, notificationBuilder.build()) - // Define the phone state listener. + // Define the phone state listener. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. phoneStateListener = object : PhoneStateListener() { override fun onDisplayInfoChanged(telephonyDisplayInfo: TelephonyDisplayInfo) { // Populate the notification according to the network type. @@ -203,10 +203,10 @@ class RealtimeMonitoringService : Service() { // Get a handle for the telephony manager. val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager - // Cancel the current listener if it exists. + // Cancel the current listener if it exists. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE) - // Listen for changes to the phone state. + // Listen for changes to the phone state. The `PhoneStateListener` can be replaced by `TelephonyCallback` once the minimum API >= 31. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c637402..3c2a2a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -104,6 +104,8 @@ New Radio Non-Standalone NR NSA mmWave – 4G/5G New Radio Non-Standalone millimeter Wave + NR Advanced - 5G + New Radio Advanced Phone Permission -- 2.43.0