tobykurien / BatteryFu

BatteryFu (pronounced Battery-Foo, like in Kung-Fu) is an Android app that extends battery life (and lowers data usage) by changing always-on mobile/wifi data to periodic sync (meaning it disables your mobile data and/or Wifi, then checks your accounts every X minutes).
GNU General Public License v2.0
68 stars 17 forks source link

Fix data sometimes not disconnected on Android >= Kit Kat #21

Closed andyboeh closed 9 years ago

andyboeh commented 9 years ago

On Kit Kat and Lollipop, mobile data is sometimes not disconnected after connection. This seems to happen more often on Lollipop and is quite annoying. The reason seems to be the behaviour of the PreferenceManager when working with Shared Preferences with multiple processes. A workaround is the re-reading of the preferences file on each preference update / read (which is a bit costly, though).

The acutal data toggling logic was also moved to its own (short-living) service, eliminating the need for a Thread object.

The code works fine on my CM12 (Lollipop) Android build and is currently being tested on a CM11 (Kit Kat) build.