]> gitweb.stoutner.com Git - PrivacyCell.git/blobdiff - app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt
Bump the target API to 31. https://redmine.stoutner.com/issues/772
[PrivacyCell.git] / app / src / main / java / com / stoutner / privacycell / services / RealtimeMonitoringService.kt
index 23e7278c9bd3a20629fd4ebc005adb1ec12cd564..5aa98f8284d5e201b2ac433f302e65ba294f2a95 100644 (file)
@@ -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)
         }
     }