From: Soren Stoutner Date: Thu, 26 Oct 2023 22:27:44 +0000 (-0700) Subject: Repopulate the realtime monitoring notification every 15 minutes. https://redmine... X-Git-Tag: v1.10~1 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=5893c1309ba952e5230c4c4ab0de131e4ea6b53e;p=PrivacyCell.git Repopulate the realtime monitoring notification every 15 minutes. https://redmine.stoutner.com/issues/1105 --- diff --git a/app/src/main/assets/de/permissions.html b/app/src/main/assets/de/permissions.html index ae2b5b0..b689501 100644 --- a/app/src/main/assets/de/permissions.html +++ b/app/src/main/assets/de/permissions.html @@ -35,17 +35,18 @@

android.permission.READ_PHONE_STATE

Benötigt, um die vom Mobilfunk-Netzwerk genutzten Protokolle zu ermitteln.

-

Show Notifications

+

Zeige Benachrichtigungen

android.permission.POST_NOTIFICATIONS

Erlaubt Privacy Cell, ein Benachrichtigungs-Icon für die Echtzeit-Überwachung in der Status-Zeile anzuzeigen.

Vordergrund-Service ausführen

android.permission.FOREGROUND_SERVICE

-

Allows Privacy Cell to update the realtime monitoring notification icon when the app is not in the foreground.

+

Erlaubt Privacy Cell, das Benachrichtigungs-Icon für die Echtzeit-Überwachung in der Status-Zeile zu aktualisieren, auch wenn die App im Hintergrund läuft.

+

Spezieller Vordergrund-Service

android.permission.FOREGROUND_SERVICE_SPECIAL_USE

-

Specifies the type of foreground service. - Special Use is for services that don't fit into any of the standard categories.

+

Legt den Typ des verwendeten Vordergrund-Services fest. "Special Use" wird für Services verwendet, die nicht in die + Standard-Kategorien für Vordergrund-Services (z.B. Medienwiedergabe, Positionsbestimmung, etc.) fallen.

Ausführung bei Systemstart

android.permission.RECEIVE_BOOT_COMPLETED

diff --git a/app/src/main/assets/it/permissions.html b/app/src/main/assets/it/permissions.html index 226b5dc..bd71ddb 100644 --- a/app/src/main/assets/it/permissions.html +++ b/app/src/main/assets/it/permissions.html @@ -35,21 +35,21 @@

android.permission.READ_PHONE_STATE

Richiesta per determinare i protocolli utilizzati dalla rete.

-

Show Notifications

+

Mostra notifiche

android.permission.POST_NOTIFICATIONS

-

Allows Privacy Cell to display a realtime monitoring notification icon in the status bar.

+

Permette a Privacy Cell di mostrare una icona di notifica di monitoraggio in tempo reale nella barra di stato.

-

Run foreground service

+

Esegui il servizio in primo piano

android.permission.FOREGROUND_SERVICE

-

Allows Privacy Cell to update the realtime monitoring notification icon when the app is not in the foreground.

+

Permette a Privacy Cell di aggiornare licona di notifica di monitoraggio in tempo reale anche quando la app non è in primo piano.

android.permission.FOREGROUND_SERVICE_SPECIAL_USE

-

Specifies the type of foreground service. - Special Use is for services that don't fit into any of the standard categories.

+

Specifica il tipo di servizio in primo piano. + L'utilizzo speciale è per i servizi che non ricadono in nessuna delle categorie standard.

-

Run at startup

+

Esegui all'avvio

android.permission.RECEIVE_BOOT_COMPLETED

-

Allows Privacy Cell to enable the realtime monitoring service when the phone boots.

+

Permette a Privacy Cell di abilitare il servizio di monitoraggio in tempo reale durante l'avvio del dispositivo.

com.stoutner.privacycell.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION

Aggiunta automaticamente a tutte le App che hanno come target API >= 33 (Android 13) per impedire ad altre App di connettersi ai ricevitori dinamici senza una autorizzazione esplicita.

diff --git a/app/src/main/assets/ru/permissions.html b/app/src/main/assets/ru/permissions.html index 8e3b4ea..9f8b489 100644 --- a/app/src/main/assets/ru/permissions.html +++ b/app/src/main/assets/ru/permissions.html @@ -33,17 +33,18 @@

android.permission.READ_PHONE_STATE

Необходим для определения используемых протоколов в сети сотовой связи.

-

Show Notifications

+

Отображение уведомлений

android.permission.POST_NOTIFICATIONS

Разрешает Privacy Cell отображать значок уведомления о мониторинге в реальном времени в строке состояния.

Запуск фоновой службы

android.permission.FOREGROUND_SERVICE

-

Allows Privacy Cell to update the realtime monitoring notification icon when the app is not in the foreground.

+

Разрешает Privacy Cell обновлять значок уведомления о мониторинге в реальном времени при работе приложения в фоновом режиме.

android.permission.FOREGROUND_SERVICE_SPECIAL_USE

-

Specifies the type of foreground service. - Special Use is for services that don't fit into any of the standard categories.

+

Определяет тип сервиса фонового режима. + Специальное использование предназначено для сервисов, которые не соответствуют ни одной из + стандартных категорий.

Запуск при загрузке

android.permission.RECEIVE_BOOT_COMPLETED

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 9c1b052..72ace81 100644 --- a/app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt +++ b/app/src/main/java/com/stoutner/privacycell/services/RealtimeMonitoringService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 Soren Stoutner . + * Copyright 2021-2023 Soren Stoutner . * * This file is part of Privacy Cell . * @@ -204,9 +204,9 @@ class RealtimeMonitoringService : Service() { // Check to see if the read phone state permission has been granted. if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { - // Create a register realtime listener work request that fires every hour. - // This periodic request will fire shortly after being created (it fires about every hour near the beginning of the hour) and will reregister the listener if it gets garbage collected. - val registerRealtimeListenerWorkRequest = PeriodicWorkRequestBuilder(1, TimeUnit.HOURS).build() + // Create a register realtime listener work request that fires every fifteen minutes. + // This periodic request will fire shortly after being created and will reregister the listener if it gets garbage collected. + val registerRealtimeListenerWorkRequest = PeriodicWorkRequestBuilder(15, TimeUnit.MINUTES).build() // Register the realtime listener work request. WorkManager.getInstance(this).enqueueUniquePeriodicWork(getString(R.string.register_listener_work_request), ExistingPeriodicWorkPolicy.REPLACE, registerRealtimeListenerWorkRequest) @@ -235,10 +235,16 @@ class RealtimeMonitoringService : Service() { } fun populateNotification() { + // Get the list of current notifications. + val activeNotificationsArray = notificationManager.activeNotifications + + // Check to see if there is a current notification. + val noCurrentNotification = activeNotificationsArray.isEmpty() + // Populate the notification according to the security status. if ((voiceNetworkSecurityStatus == ProtocolHelper.ANTIQUATED) || (dataNetworkSecurityStatus == ProtocolHelper.ANTIQUATED)) { // This is an antiquated network. // Only update the notification if the network status has changed. - if (currentStatus != ANTIQUATED_NETWORK) { + if ((currentStatus != ANTIQUATED_NETWORK) || noCurrentNotification) { // Create an antiquated network notification builder. val antiquatedNetworkNotificationBuilder = Notification.Builder(applicationContext, ANTIQUATED_NETWORK) @@ -265,7 +271,7 @@ class RealtimeMonitoringService : Service() { } } else if ((voiceNetworkSecurityStatus == ProtocolHelper.INSECURE) || (dataNetworkSecurityStatus == ProtocolHelper.INSECURE)) { // This is an insecure network. // Only update the notification if the network status has changed. - if (currentStatus != INSECURE_NETWORK) { + if ((currentStatus != INSECURE_NETWORK) || noCurrentNotification) { // Create an insecure network notification builder. val insecureNetworkNotificationBuilder = Notification.Builder(applicationContext, INSECURE_NETWORK) @@ -292,7 +298,7 @@ class RealtimeMonitoringService : Service() { } } else { // This is a secure network. // Only update the notification if the network status has changed. - if (currentStatus != SECURE_NETWORK) { + if ((currentStatus != SECURE_NETWORK) || noCurrentNotification) { // Create a secure network notification builder. val secureNetworkNotificationBuilder = Notification.Builder(applicationContext, SECURE_NETWORK) diff --git a/app/src/main/java/com/stoutner/privacycell/workers/RegisterRealtimeListenerWorker.kt b/app/src/main/java/com/stoutner/privacycell/workers/RegisterRealtimeListenerWorker.kt index d899bf7..7eeea89 100644 --- a/app/src/main/java/com/stoutner/privacycell/workers/RegisterRealtimeListenerWorker.kt +++ b/app/src/main/java/com/stoutner/privacycell/workers/RegisterRealtimeListenerWorker.kt @@ -77,6 +77,9 @@ class RegisterRealtimeListenerWorker(appContext: Context, workerParameters: Work // Register the telephony manager listener. realtimeMonitoringService.registerTelephonyManagerListener() + // Populate the notification, which might have been accidentally dismissed by the user beginning in Android 14. + realtimeMonitoringService.populateNotification() + // Unbind the service. applicationContext.unbindService(this) }