Wire-android: Set the persistent notification priority to Low when foreground service is enabled

Created on 11 Oct 2018  路  5Comments  路  Source: wireapp/wire-android

The problem

A recent update (3.17.645) added a persistent notification (foreground service) for GApps-free phones to ensure that the application is not killed by the OS due to background inactivity.

In my case, everything worked just fine on older versions with no GApps and no foreground service because I disabled battery optimisation for Wire. Since version 3.17.645, Wire is no longer able to work in background without a persistent notification (this means, I am not notified about incoming messages and calls unless I enable "Maintain connection to server" in Settings -> Advanced).

The presence of a Wire icon in the notification bar annoys me and makes me think that this is a notification for an incoming message / call / invitation / etc.

Could you please change the persistent notification's behaviour so that it is displayed with low (or even minimum) priority?

Environment

  • Wire version that exhibits the issue: 3.17.645 and higher (currently tested on 3.19.654)
  • Last Wire version that did not exhibit the issue: 3.16.638 and lower
  • Android OS version used to run Wire: 6.0.1
  • Is this a custom firmware or a stock one: Custom, LineageOS 13.0, no Google Play Services, no microG

Details

API level 16 (deprecated in API level 26):
https://developer.android.com/reference/android/app/Notification.html#PRIORITY_LOW
https://developer.android.com/reference/android/app/Notification.html#PRIORITY_MIN

API level 24:
https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_LOW
https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_MIN

I think this is the particular piece of code responsible for this behaviour:
https://github.com/wireapp/wire-android/blob/677fb28e1faecf7b8752dabfa2bfdb0aad2091d0/app/src/main/scala/com/waz/services/websocket/WebSocketService.scala#L151
But as I can see, PRIORITY_LOW doesn't seem to help. According to IMPORTANCE_MIN documentation in API level 24, it "only shows in the shade, below the fold".

Somehow other apps like Clip Stack and Conversations show their persistent notifications properly (in the shade, below the fold). Here is a link to code in Conversations for reference: https://github.com/siacs/Conversations/blob/58c6dbbbbed2817e6f86c14e83d2df1d866e678e/src/main/java/eu/siacs/conversations/services/NotificationService.java#L872

enhancement

All 5 comments

Here is an example screenshot of what I am asking for.

persistent_notifications_example

The applications are:
Conversations
Gadgetbridge
Clip Stack
Easer

By the way, Conversations has a setting to enable or disable the foreground service / persistent notification just like in Wire (the setting is visible below the notifications list on my screenshot). Unlike Wire, Conversations works perfectly in background, i.e., maintains connections to servers, delivers incoming messages and notifies about them. This works even without foreground service and without GApps or microG, just because I disabled battery optimisation, and, as I said before, this used to work with Wire as well.

I am aware that I am just lucky to use a decent firmware and that this doesn't work well on lots of other phones/ROMs, and people that use them may really need this foreground service. I just don't agree with everybody being forced to use it if GApps are not available.

Is it possible to separate the current setting, "Maintain connection to server", to something similar to the following two?

  1. "Maintain connection to server while running in background / Enable this if Google Play Services are not installed on your phone", which would simply keep the websocket connection alive as long as the application is not killed by the OS, no matter if foreground service is enabled or not. (Again, this is how Wire operated before 3.17.645.)
  2. "Keep Wire always running in background / Enable this to let Wire always be online, you may miss incoming messages and calls if you disable this", plus make this setting greyed out if the first one is not enabled.

IMHO, it may be worth to completely hide the the first setting by enabling it by default (at least if GApps are not installed), just like it was in older versions, and only leave the second one to user's choice. That is how this is implemented in Conversations.

hi @selurvedu

I plan to revisit these options in the near future as we introduce more functionality for workarounds due to notification (or more precisely, FCM push) issues. What I've done for now is 1) change the icon to something different and 2) on < 8.0 devices, I'll set the priority of the notification to PRIORITY_MIN, so that the notification is then only in the pull-down tray.

Unfortunately on Android >= 8.0, if we need a service while there are no activities active, it has to be a ForegroundService and the notification priority has to be at least PRIORITY_LOW (it can't be PRIORITY_MIN), meaning the icon will be in the system bar.

You can find the changes here - they should be in a release coming soon.
https://github.com/wireapp/wire-android/pull/1838

@deanrobertcook

Unfortunately on Android >= 8.0, if we need a service while there are no activities active, it has to be a ForegroundService and the notification priority has to be at least PRIORITY_LOW (it can't be PRIORITY_MIN), meaning the icon will be in the system bar.

That explains a lot.

What I've done for now is 1) change the icon to something different and 2) on < 8.0 devices, I'll set the priority of the notification to PRIORITY_MIN, so that the notification is then only in the pull-down tray.

Awesome, thank you!

@selurvedu no problem,

This is in yesterday's release, closing this now then.

Was this page helpful?
0 / 5 - 0 ratings