theblixguy / ForceDoze

Enable Doze mode immediately after screen off and turn off motion sensing to get best battery life
https://play.google.com/store/apps/details?id=com.suyashsrijan.forcedoze&hl=en
GNU General Public License v3.0
167 stars 35 forks source link

Shared preferences not readable on restart for Xposed #32

Closed vemacs closed 7 years ago

vemacs commented 8 years ago

After two restarts, Xposed can't read the preferences file and always returns the default values:

ForceDozeXposed: usePermanentDoze: false, useXposedSensorWorkaround: false, serviceEnabled: false

Needless to say, this makes the module not work at all after a set period of restarts. Manually changing sharedpref permissions to 0664 fixes it for the next restart, but not the one after that (I'm assuming ForceDoze resets file permissions on start, as I checked and it's back to 0660).

According to the xposed author, changing a PreferenceManager setting should fix it: https://github.com/rovo89/XposedBridge/issues/56#issuecomment-137236354

Other modules do the same: https://github.com/wasdennnoch/AndroidN-ify/blob/3504b3e461873dc091127b24aa5f85dc22679a76/app/src/main/java/tk/wasdennnoch/androidn_ify/ui/SettingsActivity.java#L127

vemacs commented 8 years ago

Turns out I was toggling a non-Xposed preference (one where chmod 644 isn't run) after toggling the Xposed preference. Maybe run chmod 644 regardless of the preference being chosen if the Xposed preference is on?

theblixguy commented 8 years ago

run chmod

It is run when you toggle the setting on/off: https://github.com/theblixguy/ForceDoze/blob/master/app/src/main/java/com/suyashsrijan/forcedoze/SettingsActivity.java#L294

theblixguy commented 7 years ago

I am closing this issue as it seems like you no longer have this issue.