|
1 | 1 | # Disable battery saving in non-stock Android phones
|
2 | 2 |
|
3 |
| -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. |
| 3 | +Certain apps need to do their job in the background (without user interaction). This behaviour is |
| 4 | +usually restricted by battery optimization strategies implemented by Android. In addition, manufacturers |
| 5 | +(OEMs, e.g. Xiaomi, Samsung, Huawei, etc.) add their own battery optimization strategies, which differ from one version |
| 6 | +to another within the same manufacturer. While Android's battery optimization strategy can be disabled programmatically (by asking the user), |
| 7 | +other manufacturer's strategies cannot. |
4 | 8 |
|
5 |
| -Meanwhile, we think the following links to the documentation of specific apps trying to solve this problem could serve for that purpose: |
| 9 | +The most common mechanism that OEMs (e.g. Xiaomi, Huawei/Honor, OnePlus...) implements is the *Auto-launch* setting. These settings, by default, |
| 10 | +avoid an app to be able to be launched and run in the background. Others, like Samsung, are just disabling those apps |
| 11 | +that are not being used for a while. |
6 | 12 |
|
7 |
| -- http://nine-faq.9folders.com/categories/2758-troubleshooting |
8 |
| -- https://drivequant.zendesk.com/hc/en-gb/sections/360002126919-Smartphone-settings |
| 13 | +It is hard to provide a complete guide to disable these settings, but here you can find some resources that may help: |
| 14 | + |
| 15 | +- [**DontKillMyApp**](https://dontkillmyapp.com): website that provides guidance through disabling the battery |
| 16 | +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) |
| 17 | +which analyses how aggressively is your phone closing background apps. |
| 18 | + |
| 19 | +- [**DriveQuant - Support Centre**](https://drivequant.zendesk.com/hc/en-gb/sections/360002126919-Smartphone-settings): |
| 20 | +framework that provides to developers tools to analyze vehicle trips and driving style. As their technology is smartphone |
| 21 | +sensor based, they suffer smartphone's battery optimizations. So, they provide guides to disable battery optimization settings |
| 22 | +for several OEMs. |
| 23 | + |
| 24 | +- [**AutoStarter**](https://github.com/judemanutd/AutoStarter): it's a library developed by [Jude Fernandes](https://github.com/judemanutd) |
| 25 | +that helps bring up the autostart permission manager for different OEMs to the user so they can add an app to autostart. |
| 26 | +Although it does not always works on every OEM version, it's a nice tool that developers can integrate in their apps to |
| 27 | +add a way to disable de *Auto-launch* setting. We are investigating if it can be integrated into this plugin. |
| 28 | + |
| 29 | +> 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). |
| 30 | +
|
| 31 | +## Special considerations |
| 32 | +Samsung limits by default scheduled jobs to a minimum interval of 5 minutes if screen's device is off. For example, |
| 33 | +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. |
| 34 | + |
| 35 | +This behaviour can be avoided with one simple trick: just add the keyword **alarm**/**alert**/**clock** in our app package name |
| 36 | +(e.g. com.example.**alarm**.myapp, com.example.myapp**alert**, etc.). |
| 37 | +Packages containing these keywords are whitelisted by Samsung and are able run (apparently) without restrictions. |
| 38 | + |
| 39 | +It's something yet to be explored if other manufacturers act in the same way Samsung does, or if they have similar tricks. |
0 commit comments