See original posting here.
Hey I realized yesterday that Flush O Matic doens't work properly on newer kernels.
Well it works, but it doesn't wait for the screen to go off before flushing.
A little googlie told me that the newer kernels no longer have the /sys/power/wait_for_fb_sleep file.
Normally, FOM will try and read it's contents (but it's unreadable) and it just hangs until the device goes to sleep.
When it goes to sleep, that file can be read and the script gets "unhung" and flushes.
And when the file is missing, well FOM will just spit out errors (check the log) and dump cache without uh... waiting for the fan to be turned on...
BUTT (yeah, thats a big butt!) I fingered out another way for newer kernels... heh.
Check it via PC... with the screen on do this
adb shell su while [ "`cat /sys/class/graphics/fb0/dynamic_fps`" ]; do sleep 1; done; echo " OK Flush Time!"
While the screen is on it should hang there until you turn off the screen.
When the screen goes off, it will pronounce what "time" it is...
I'll probably do sleep 10 instead of sleep 1 tho to minimize battery suckage.
Currently effected hardware, that I'm aware so far: some Sony, Moto and Nexus devices using kernel version 3.3 or above.
These scripts change things or do things depending on whether the screen turns off or turns on.
Examples are cpu governor scripts or other screen state scaling scripts.
As mentioned above, it had effected my FOM script which dumps caches at a user defined interval.
However, when the time is up, it will actually wait until the screen is off if the screen happens to be on at the time.
So if you have a misbehaving script due to the missing /sys/power/wait_for_fb_sleep/wake files, you should have 2 other files that you can use.
File contents with screen off:
shell@C6906:/ $ cat /sys/class/graphics/fb0/dynamic_fps shell@C6906:/ $ cat /sys/class/graphics/fb0/show_blank_event panel_power_on = 0 shell@C6906:/ $
shell@C6906:/ $ cat /sys/class/graphics/fb0/dynamic_fps 60 shell@C6906:/ $ cat /sys/class/graphics/fb0/show_blank_event panel_power_on = 1 shell@C6906:/ $
I preferred to take advantage of that file.
However some may like to use the contents of show_blank_event and check whether panel_power_on = 0 (off) or panel_power_on = 1 (on).
Of course, a script will have to check and decide whether to use the wait_for_fb_sleep file or use the new way.
So a fixed script will look something like:
if [ -f "/sys/power/wait_for_fb_sleep" ]; then echo "Android is now `cat /sys/power/wait_for_fb_sleep`!" else while [ "`cat /sys/class/graphics/fb0/dynamic_fps`" ]; do sleep 10; done echo "Android is now sleeping!" fi
Alternately, to do something when the screen turns on...
if [ -f "/sys/power/wait_for_fb_wake" ]; then echo "Android is now `cat /sys/power/wait_for_fb_wake`!" else while [ ! "`cat /sys/class/graphics/fb0/dynamic_fps`" ]; do sleep 10; done echo "Android is now awake!" fi
I used sleep 10 so that it doesn't do any needless work.
Of course sleep 1 would give an instant reaction but isn't very battery or cpu friendly.
You can decide for yourself how long is a good sleep interval between checks.
Anyhow, hope that helped