MarkAdamson / home-assistant-plugin-for-tasker

Home Assistant plugin for Tasker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request no battery optimisation

MarkAdamson opened this issue · comments

Some users have found that although the plugin works when testing in the config screens, and in the Task editing screen immediately afterwards, it will stop working at some point later. After some troubleshooting, it has been found that disabling battery optimization for the plugin rectifies this.

Android has an API for checking whether an app is being optimised, and requesting for it to be disabled (for the specific app). The plugin should make use of this, checking and requesting if necessary whenever a user enters any of the config screens.

Ref:

  1. https://developer.android.com/reference/android/os/PowerManager.html#isIgnoringBatteryOptimizations()
  2. https://developer.android.com/reference/android/provider/Settings.html#ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS

Just a note for myself here:

Apparently, Google are know to remove apps from the Play Store for using ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS. However there is a list of acceptable use cases here, and I would say this plugin definitely falls under "Task Automation App", which is deemed acceptable. Just worth noting.

For now, to stay on the safe side, rather than directly requesting to ignore battery optimisation, I've added a check and warning, then send the user to settings to disable optimisation themselves.

Implemented in 956f329

Hey, I'm getting the prompt to go in and disable battery optimisation, but I can't do so because it simply doesn't appear on the list of apps, even the full list of everything installed. Could there be another setting that needs changing in order for it to appear?