deltachat / deltachat-android

Email-based instant messaging for Android.
GNU General Public License v3.0
1.15k stars 148 forks source link

Option to disable permanent notification #82

Closed Hocuri closed 6 years ago

Hocuri commented 7 years ago

I would like an option to disable this permanent notification ("Connected to a@b.c; waiting for messages ...") for the following reasons:

  1. If I am well informed, this will prevent the android system from stopping this app when it runs out of memory. Of course, this may be useful, but personally, I would like it better if all apps were treated equally.
  2. This notification is annoying me.

Nevertheless, this app is a great idea!

kskarthik commented 7 years ago

I also vote for this feature 📊

r10s commented 7 years ago

I also vote for this feature :+1:

However, unfortuately, the permanent notification is technically needed:

As Delta Chat cannot and will not use Goog'e Clould Messaging (newspeach: Firebase Clound Messaging), we have to use Websockets - but recent Android versions kill all processes after some time; as a result, Delta Chat cannot show up reliable notifications for new messages.

The only exception from this are foreground services - and they always come together with a permanent notification.

Goog'e says that all this is to save battery ... IMHO it's more to push dev into using non-free-services; in my experience a mobile phone without Goog'e services nearly doubles the battery lifetime.

So, if you want to get rid of this notification, ask Goog'e for it.

Read on: https://commonsware.com/blog/2015/06/03/random-musing-m-developer-preview-ugly-part-one.html https://developer.android.com/preview/behavior-changes.html#back-all Conversations has the same problem: https://twitter.com/iNPUTmice/status/844257001668513793 [via Heise-Forum (german site)] Signal AFAIK has already a permanent foreground notification (but Signal uses Goog'e for notificatins by default)

kskarthik commented 7 years ago

Yeah, I dont have play services on my phone. I get a great battery life. Will look into these hacks

kskarthik commented 7 years ago

Looks like android is becoming an headache for devs...

Hocuri commented 7 years ago

What about this idea: If the user wants to, they can disable the notification in the settings. To get push messages, they have to install an extra app which replaces the Google Cloud Messaging service or wakes Delta chat up in intervals. It is no problem to allow the second app to use a permanent notification because the user can disable notifications for the extra app in the system settings and will still get notifications from Delta Chat. In the settings of the extra app the user can choose an interval in which to check for new messages. I know this would not be a very nice solution because the user would have to install an extra app.

However, I still think that there should be an option to disable the permanent notification, in case the user uses a custom android.

kskarthik commented 7 years ago

Or should use alarm api ?

r10s commented 7 years ago

Using a second app is far too complicated for such a simple job - eg. the app showing the notification would required to hold the connection then.

But some little older Androids have a workaround: Eg. in "Stock Android M" (if I recall correctly) you can filter notifications away - you can hide the permanent notification but allow all other ones. AFAIK, this option is no longer present in Nougat... but maybe there are apps that allow this behaviour.

alarm api: do you mean this one? this does not help on this issue. In fact, there is no API for this job.

kskarthik commented 7 years ago

I'm on nougat. There's no such option.

kskarthik commented 7 years ago

What api does stock dialer & sms apps use to stay alive in background? I think they are restricted.

I remember Firefox os app devs using alarm api to enable background sync for their IM apps as a workaround due to lack of such feature.

Hocuri commented 7 years ago

As far as I remember, you can filter notifications on Android 7 and above and older android versions do not kill the processes after some time.

If this is right you could just add an option to disable the permanent notification. Android 6 and below users would do that because there is no need for it. And Android 7 and above users can simply hide the notification in the system settings.

r10s commented 7 years ago

Android Nougat has no longer a filter options (or I haven't found it).

And you're right, Android <= Lollipop would not need the permanent notification.

Hocuri commented 7 years ago

On my Android 6 device if you go to System settings -> Battery -> three vertical dots -> Battery optimisation you can exclude apps from Battery optimisation (which is, as far as I know, just another name for "Doze"). Do you know if this could be an alternative for the ongoing notification?

If the user disables the notification, he could be told that he has to exclude "Delta Chat" from Battery optimisation. If he wants to, he could be redirected directly to the Battery optimisation activity: com.android.settings.Settings$HighPowerApplicationsActivity

licaon-kter commented 7 years ago

Yes, please add an option to toggle this off.

Yes, some ROMs (eg. Huawei or Xiaomi) are too aggresive at killing the apps, but plenty others are not, exclude it in Doze and carry on.

You've mentioned Conversations, I've tested it (without GCM!) with Sony 5.1.1/6.0.1 and Samsung 5.0.2/6.0.1 and it always worked great without the need to force the foreground service (and the obligatory permanent notification).

BTW, speaking about IMAP, K9 works great without a notification too ;)

r10s commented 7 years ago

There is no option to this permanent notification. Sorry.

Signal has it, Riot has it, and others will get it as well.

But, at least, we'll add a little bit of functionality to it: #116

It may be possible under some circumstances to avoid it, however, currently we do not have the resources to check this out - and to test it, over and over, with every new Android version, Samsung may be different from LG etc. I think even if we'd had endless resources, we wont find anyone to handle this.

Please complain at Google about this issue.

licaon-kter commented 7 years ago

Given that the UI is copied from Telegram (or did I understand wrong?) which has no such notification this is sad.

Not sure about GCM as a factor, Telegram/Conversations/Signal work without it anyway.

When did Signal get one? Don't remember seeing it, but it has been a while.

Anyway, Conversations solution is pretty ok since it shifts the burden to the user/ROM, if it works great, if not then blame Google/OEM. (have the notification ON, show a dialogue saying that if toggled off)

r10s commented 7 years ago

Telegram uses GCM and Signal also uses the permanent notification if GCM is not available. Delta Chat never uses GCM - this is a privacy feature! - and, if in doubt, always needs the permanent notification.

Any pull request with smarter approaches are welcome, I would be glad to review them and add them to master. But I fear there is simply no easy solution.

r10s commented 7 years ago

NB: The UI was initially based upon telegram (noy the best choice as we know today, however, there is only few originally code left), but this is no simple UI issue. It's the background service for which Google decides to display the permanent notification. No permanent notification=no repliable background service.

ComptaShop commented 7 years ago

Hello r10s, what do you think of setting DeltaChat as an accessibility service to get rid of this permanent notification ?

licaon-kter commented 7 years ago

No, that the worse solution: https://blog.g3rt.nl/android-lollipop-encryption-user-interface-flaw.html

r10s commented 7 years ago

I don't know. How can we achieve this? What would be the effect?

ComptaShop commented 7 years ago

Wow thank you for the link licaon-kter.

Nevermind r10s, this would be a major security issue.

For details my initial mind, Accessibility service is protect from system kill and restart when stopped, but a "bug" reset encryption password when this type of service is enable (by the user) ...

r10s commented 7 years ago

Okay, one more thing we know not to work. This is also an approach :)

Have a nice day, Björn

vitalyster commented 6 years ago

@r10s

never uses GCM - this is a privacy feature!

1) You didn't trust Google and didn't want to send messages there? No problem, you can just send "You have N messages". 2) You didn't trust Google's "serverless apps"? No problem, you can release plugins for popular opensource mail servers to support GCM/APNS (For example, there is already XAPPLEPUSHSERVICE IMAP extension and some opensource servers are support it) 3) Opensource community may create own GCM self-hosted service alternative, shared between all opensource apps 4) Stop using IMAP IDLE and do polling - it's easy and works in Doze mode

The problem solved with one of or combination of listed methods, but current state of Delta chat is unusable for most people, do you want to have casual users there, not only crazy techno nerds? :)

STPKITT commented 6 years ago

What exactly makes you call it unusable?

nutpantz commented 6 years ago

+1 for user defined time for polling. Even just as a back up for push mail. It's an option I would love regardless if it would kill the notification always present. (Which I'm glad k9 mail has not yet implemented) Google's ideas are not always the best ideas.

r10s commented 6 years ago

yes, polling might be an alternative, maybe we got for iOS into this direction, if so, it might also come for Android. But this is another issue :)

X-Ryl669 commented 6 years ago

@Hocceruser : That's a good idea, if you invert it. Instead of having an app that's a foreground service that's querying the server and that's triggering deltachat, you can have deltachat triggering an intent when it has detected a new message (instead of the notification). So basically, you can hide deltachat notification forever (so the foreground notification is masked), but when a new message is received, a dumb app is run showing "You have N message in deltachat" and it then, it callback deltachat when clicked and quits. That's not a lot of work to do, it's a basic app with almost no functionality.

X-Ryl669 commented 6 years ago

@vitalyster: 1) No you don't. Some user don't want Google to know they have messages whatever the content. Google already knows most of the links between you and the other people and it's easy to link a mail going out of gmail and a notification being triggered on your phone because of the close timing. 2) PUSH imap does not work either with Doze without GCM. K9 relies on doze exceptions but this does not work well on many phones that still kill applications anyway. The extension you've listed gives Google all details about the pushed email metadata. 3) It's called MicroG, but it's not a solution because GCM use cryptography to authentify the GCM service on your phone, and you must be root to install MicroG's private keys in place of Google's GCM. (Most users aren't and even if they are, they might not want to break GApps with a limited service) 4) Polling is a very bad idea and does not solve anything. It's consuming a lot of battery if you want "instant" notification (I'm speaking of "not every hour" polling here, but every 5mn or so!) and with Doze, it's limited to minimum 15mn or so, IIRC if using the Alarm API. Not good for a messaging app, don't you think ?

As you said for non nerds, Google locked us all to its GCM feature.

vitalyster commented 6 years ago

@X-Ryl669 1.2. These are solutions for use with GCM and keeping privacy as much as possible, for non nerds.

  1. MicroG is only client for GCM, I mean it is also possible to run self-hosted GCM server alternative. Of course it is for nerds.
  2. This is the solution both for casuals and nerds: a) 5-15 mins may be ok for many users, especially if b) when application is in foreground (and user is actively chatting) it can enable IMAP IDLE and receive replies instantly, and switch to polling only when application is switched to background.
vitalyster commented 6 years ago

Google locked us all to its GCM feature.

I didn't understand the whole point of hiding from Google on the Google phone. If me (and most of users) buy some device from Google or Apple then we are trust device vendor and want to use their services. Why deltachat force us to do these crazy things of hiding from Google? It can be configurable and me and only me should decide how I want to keep my "privacy", not the some nerdy app.

r10s commented 6 years ago

Why deltachat force us to do these crazy things of hiding from Google?

Thank you for your post. I do not think, Delta Chat forces users to do crazy things to hide from Google. It's just that plain IMAP does not work well with GCM, see https://github.com/deltachat/deltachat-android/issues/82#issuecomment-298614536 , and Google does no longer really offer a proper solution for this issue. To fix this, this may required crazy things.

Moreover, Delta Chat just does not want to rely and use Google Services to be compatible with phones not using Google (yes, they exist, maybe not many, but maybe a growing number if more apps stop relying completely on Google :).

vitalyster commented 6 years ago

plain IMAP does not work well with GCM

No, plain IMAP does not work well on mobile devices with limited battery/connectivity, it was designed to work on always-connected and always-on-power machines. GCM is the solution for keeping one background network connection for many applications on the device.

Delta Chat just does not want

You are blaming top 5 companies in the world for not allowing user to have options, and doing it the same way ;) If user will be happy Delta Chat user on "Google-locked" device - then it can recommend it to friend, then it can see Delta Chat is not require Google services, and then and only then users can be free from "proprietary services". Now your policy is too strict(!) for users and Delta Chat is only limited to "crazy nerds".

phones not using Google

That is what I described about self-hosted server alternative. Growing number of apps will require that alternative to share single network connection or this attempt to "fight Google" will fail.

X-Ryl669 commented 6 years ago

You can use signal or telegram then. Signal and Telegram both decided to use GCM when it's available. However, if you think it's a good idea that Google knows everything you're saying, it's not my case. Currently, I do recognize the amount (herculean) effort spent by Google to build a viable mobile internet device, but I still dislike the strings attached to that. I don't want Google to monitor my life and my connections. So, yes, I would like to have a solution that not using Google as MITM.

Please forgive the bad analogy, but if I buy a car from Toyota, I don't expect Toyota to know everywhere I go with it, or what I store in the trunk. Why would I accept this from my phone manufacturer ? What would you say if, everytime you had to go somewhere with your car, you had to call Toyota to get permission to do it (even if Toyota always grants you the permission) ? Because that's exactly what google is doing with GCM.

To answer your last comment, think of a message like "Got accident. I'm locked in my car and it's burning". Do you really think 15mn latency is good enough in that case ?

The issue is not about the merging idea for "waking up a device". It's a good move. The bad move is to lock everything in a proprietary and closed system. Honestly, how hard would it be to let user set up the server to query for merged notifications ? A URL in a setting page that's all that's required, since the notification protocol is already documented. The fact that this URL is buried in GApps and it's protected by cryptography is the evidence that Google wanted to lock this out.

By the way, IMAP's IDLE is proved to be optimal for mobile's device battery saving compared to GCM.

vitalyster commented 6 years ago

@X-Ryl669

yes, I would like to have a solution that not using Google as MITM.

You can disable GCM in settings when there will be such setting :) Moreover, you can use the phone without Google Apps and smart app (as signal or telegram, you mentioned) can detect and enable its own keep-alive service (and Delta Chat already have it, using IMAP). Why these proprietary apps should be smarter than free Delta Chat app? ;)

15mn latency is good enough in that case ?

How many users require minimal latency? 1 or 0.5%? Why they move app to background then? Google does not close foreground network connections.

X-Ryl669 commented 6 years ago

Bah, no I disagree. Delta Chat's solution is not that nice compared to GCM. The initial excellent idea of GCM is to avoid repetitive wake up that drains battery. If all app on my phone starts using a foreground service, and they all wake up at random interval, the battery drain will be huge (on my phone, K9 drains 30% of the battery on average and I'm not using any polling). GCM / Doze idea is to batch the different wake-up to avoid such cases. With a foreground service, one has to be very careful about resource consumption (go sleeping as much as possible) and there is no communication between process to synchronize their actions, so it can only fail the more application start using this scheme.

I think the issue with latency is not about how many users, but how often you need low latency. You don't care to receive a "Ok, thanks" message 5mn later (or even one hour later), but in case some message is urgent, you want it now, not one hour later. If the system can not do that, then it fails (at least for me, I will not use it as my main messaging app). If you write this out "Beware this messaging app can have up to 15mn before you are notified about a new message", no one will use it. If you don't, you lie to your users (that's worse, IMHO).

vitalyster commented 6 years ago

If you write this out "Beware this messaging app can have up to 15mn before you are notified about a new message"

The same for now, Delta chat should have warning "We are draining your battery with our home-made GCM alternative service" and users will not use it.

It can be more user-friendly and provide options and description of advatanges and disadvantages of each, but the main problem for now is absence of any option.

X-Ryl669 commented 6 years ago

That's true. If it was possible to use GCM then having the choice in user's hand would be good. (And I'm sure a lot of people will use GCM here unfortunately, since it's a good technical solution with a bad political issue). Yet depending on GCM prevent Deltachat from being included in F-Droid's repository and also is against the dev philosophy, as I understand it (I'm not a dev for this project, just a user like you...)

Now, taking the above into account and accepting that GCM is not (will not be?) in this project, how to have:

  1. Push notification
  2. Non painful UI (unlike currently)
  3. Low latency
  4. Low battery drain
  5. Privacy / Secrecy

is the current goal of this discussion/issue.

And for now, there is no better solution than GCM (except for point 5). If point 5 is not that important to you, there are other solution to this (look at Signal/Telegram/Conversation/Whatsapp). In this project, I think point 5 is one of the main selling pitch. The question of this issue, as I understand it, is about having point 2 done right even if point 4 is not optimal.

vitalyster commented 6 years ago

depending on GCM prevent Deltachat from being included in F-Droid's repository

Android build system provide so called "product flavors" which allowing to build single app with different dependencies. For example, https://conversations.im/ - have "playstore" and "free" flavors, and free flavor living in F-Droid, so it is not an issue.

r10s commented 6 years ago

It can be more user-friendly and provide options and description of advatanges and disadvantages of each, but the main problem for now is absence of any option.

I agree. Who can implement this? :) However, #269 suggests an option to decide between poll or push.

kevincox commented 6 years ago

With newer versions of android these notifications can now be hidden, unfortunately this hides all deltachat notifications. I think that putting these in a separate notification channel would allow blocking that category of notifications while still receiving chat notifications. Has anyone looked into this?

r10s commented 6 years ago

@kevincox i also saw some older ones, where you could disable this type explicitly, was in cyanogen, i do not remember which version.

apart from that: afaik no one has played with "notification channels" yet. i reopen this issue so that it gets more visible; though its #269 will also offer a partly solution.

testbird commented 6 years ago

See https://github.com/nextcloud/talk-android/issues/58#issuecomment-365561399, hiding seems only to work in newest android version, or by separating the permanent notification into a push client package:

https://gitlab.com/foss-push/planning/ https://github.com/deltachat/deltachat-core/issues/113.

testbird commented 6 years ago

"We are draining your battery with our home-made GCM alternative service" and users will not use it."

Sorry, looks like there are postings trying to inject FUD.

I see DC on devices running in idle for days without noticeable battery drain.

If battery drain is observed, the problem is much more likely to be due to some remaining timing, reconnect, network change, or imap scanning issue.

An "instant messenger" with background notification delays of 15 minutes (anything beyond a minute actually) would seem more like a joke. (As if you could talk yourself out of the competition.)

vitalyster commented 6 years ago

devices running in idle

Did you try to leave your home wifi station?

out of the competition.

You are competing with Google, right?

testbird commented 6 years ago

Did you try to leave your home wifi station?

So you observed something, but posted about something else? What could be the cause for increased battery usage according to your problem analysis?

vitalyster commented 6 years ago

@testbird constant network changes causes increased battery usage. To minimize battery impact I have Google services which provides single network connection for all background activities, thousands of well-paid engineers are working on its optimization. Thousands of "instant messengers" are working great over Google services. Now you say "Google services are evil, we will keep another background connection". Yes, you can do it on the device without Google services, what about casual users?

stefan-niedermann commented 6 years ago

@vitalyster

And what about users who care about privacy and therefore do not use proprietairy google services?

Let's be honest: "casual users" use whatsapp.

Sorry, this should not sound offensive, but this is an important topic for a decentralized messenger with privacy focus, since google services are the exact opposite and depending on it woupd at leaste for me be a no-go.

testbird commented 6 years ago

Yep, it's just that working for Apple Push Notifications and Google Cloud Messaging modules in open source apps may produce some monopoly aversion, and lead to detect the wrong causality and to working on alternatives. https://github.com/vitalyster/mod_smacks_notifications

vitalyster commented 6 years ago

Let's be honest: "casual users" use whatsapp.

That is what I want at first: be honest and have big red warning in the app "this app in for nerds who doesn't want to use proprietary services". Or provide options for casual users as discussed earlier.

testbird commented 6 years ago

Some difference lies between agitating, distorted reflexing ... vs. looking for solutions to some (claimed but not confirmed) higher battery usage.