Originally Posted by osm0sis
Only thing that came to mind for me was the `uptime` command. Doesn't tell you anything about when it was powered off though.
Yes that could be used to catch the last time it powered up, but I would be missing when it was powered down or how log it was powered down for, or as can be sen in the image below, if it was powered down multiple times.
Originally Posted by Keule-T
Maybe something like a service catching a shutdown command? Or a script like "alias shutdown=X; if $0=shutdown; do <write timestamp to file> && X -h now; done". (This wouldn't work as it is, obviously)
Just brainstorming, no clear ideas in mind.
I dont want to add anything.
It is obviously stored somewhere within android, as most custom ROMs I run, have a battery history that displays the info. So, at the very least it is available from Java. see below image. I also did a very brief look for the source, but it was getting very convoluted quickly, for me .
I am basically trying to duplicate the graph below, but using data sourced directly from shell commands which would be commonly available across multiple phones without requiring installing or running anything extra. Or even from BusyBox as a worse case.
For example, LOS ROMs do not have this visual history graph built into the ROM; the below is from Havoc-OS. I do a similar thing for a doze history graph, sourcing data from a "dumpsys deviceidle" and then using HTML to create a visual representation see: https://forum.xda-developers.com/sho...9&postcount=74
It would be great to add the battery drain graph to it as well. Although since the idle history is only since the last boot, its actually already there
. But combining the two graphs is more of a long term plan, right now it would be to simply duplicate the following.