Skip to content

Commit

Permalink
Merge pull request #16 from GeoTecINIT/battery-savings-docs
Browse files Browse the repository at this point in the history
Battery savings docs
  • Loading branch information
agonper authored Feb 1, 2021
2 parents 02b5e18 + 2a21290 commit 407dd46
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions docs/disable-android-battery-saving.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
# Disable battery saving in non-stock Android phones

We are working on creating a curated documentation about how to disable Android battery saving capabilities for a certain app when de device is not using Android stock, categorized by manufacturer and Android version.
Certain apps need to do their job in the background (without user interaction). This behaviour is
usually restricted by battery optimization strategies implemented by Android. In addition, manufacturers
(OEMs, e.g. Xiaomi, Samsung, Huawei, etc.) add their own battery optimization strategies, which differ from one version
to another within the same manufacturer. While Android's battery optimization strategy can be disabled programmatically (by asking the user),
other manufacturer's strategies cannot.

Meanwhile, we think the following links to the documentation of specific apps trying to solve this problem could serve for that purpose:
The most common mechanism that OEMs (e.g. Xiaomi, Huawei/Honor, OnePlus...) implements is the *Auto-launch* setting. These settings, by default,
avoid an app to be able to be launched and run in the background. Others, like Samsung, are just disabling those apps
that are not being used for a while.

- http://nine-faq.9folders.com/categories/2758-troubleshooting
- https://drivequant.zendesk.com/hc/en-gb/sections/360002126919-Smartphone-settings
It is hard to provide a complete guide to disable these settings, but here you can find some resources that may help:

- [**DontKillMyApp**](https://dontkillmyapp.com): website that provides guidance through disabling the battery
optimization settings for several manufacturers and versions. They also have an [app](https://play.google.com/store/apps/details?id=com.urbandroid.dontkillmyapp&pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1)
which analyses how aggressively is your phone closing background apps.

- [**DriveQuant - Support Centre**](https://drivequant.zendesk.com/hc/en-gb/sections/360002126919-Smartphone-settings):
framework that provides to developers tools to analyze vehicle trips and driving style. As their technology is smartphone
sensor based, they suffer smartphone's battery optimizations. So, they provide guides to disable battery optimization settings
for several OEMs.

- [**AutoStarter**](https://github.com/judemanutd/AutoStarter): it's a library developed by [Jude Fernandes](https://github.com/judemanutd)
that helps bring up the autostart permission manager for different OEMs to the user so they can add an app to autostart.
Although it does not always works on every OEM version, it's a nice tool that developers can integrate in their apps to
add a way to disable de *Auto-launch* setting. We are investigating if it can be integrated into this plugin.

> In summary, if your app needs to run in background or trigger alarms, make sure to tell your users to add your app to the battery optimizer white list and to allow it to start in background (*auto-launch* setting).
## Special considerations
Samsung limits by default scheduled jobs to a minimum interval of 5 minutes if screen's device is off. For example,
if you set up a task to be executed in 2 minutes, it will be scheduled to run in 5 minutes if the device screen is off.

This behaviour can be avoided with one simple trick: just add the keyword **alarm**/**alert**/**clock** in our app package name
(e.g. com.example.**alarm**.myapp, com.example.myapp**alert**, etc.).
Packages containing these keywords are whitelisted by Samsung and are able run (apparently) without restrictions.

It's something yet to be explored if other manufacturers act in the same way Samsung does, or if they have similar tricks.

0 comments on commit 407dd46

Please sign in to comment.