-
Notifications
You must be signed in to change notification settings - Fork 138
Description
Describe the bug
Mozilla VPN on android will disable itself without a warning after a couple of hours
VPN version:
latest
Affected Platforms:
Android
Prerequisites:
Android probably after API 28 ?
Steps to reproduce:
Expected result:
VPN works
Actual result:
Mozilla VPN on android will disable itself without a warning after a couple of hours
Additional notes:
I had this issue for years. I had problems with Threema recently, which gave me the idea of how to resolve this issue. I did research and found that other people had this problem and were disappointed 3 years back: https://www.reddit.com/r/firefox/comments/10tk7b9/why_so_many_issues_with_mozilla_vpn/ (I attached a screenshot).
So Threema messenger does not use the Google Notification system. Instead, they always need to keep a background polling process. What happened is that the new version of Android could put this process to sleep for battery optimization. Threema is aware of it, so they actively warn users when this setting is active.
So I checked the battery settings for Mozilla VPN, and it was set to "Optimized". So Android put the app to sleep after some time (?). I changed it to "Unrestricted", and I finally had the VPN running for 33 hours without disconnection.
AI told me this Android API can give a tip about which regime is set for the app
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean isIgnoringOptimizations = pm.isIgnoringBatteryOptimizations(context.getPackageName());