FORUMS
Remove All Ads from XDA

[TOOLS][ZIPS][SCRIPTS] osm0sis' Odds and Ends [Multiple Devices/Platforms]

13,672 posts
Thanks Meter: 30,198
 
By osm0sis, Recognized Developer / Recognized Contributor on 18th April 2013, 12:37 AM
Post Reply Email Thread
30th July 2019, 02:19 AM |#2451  
Senior Member
Flag Sydney
Thanks Meter: 1,824
 
More
Question
Sorry if the following question is OT, but it appears to be thread which can stray...

I am trying to find a shell command or system file that reports/saves the times the device is switched on and off? I can get the battery drain from multiple places (eg dumpsys batterystats, but all the ones I have found thus far, show a time line in respect to only while the phone is on. For example, if I charge the phone to 100%, leave it on for 1hr then turn the phone off for 8hrs, then turn it on for 1hr, the details imply that the phone was on constantly for 2hrs. No reference that I can see logs that it was off for an 8hr window. Have I missed something or is there somewhere else where it is stored?
 
 
30th July 2019, 07:07 AM |#2452  
amg314's Avatar
Senior Member
Flag Kharkov
Thanks Meter: 136
 
More
Quote:
Originally Posted by DiamondJohn

Sorry if the following question is OT, but it appears to be thread which can stray...

I am trying to find a shell command or system file that reports/saves the times the device is switched on and off? I can get the battery drain from multiple places (eg dumpsys batterystats, but all the ones I have found thus far, show a time line in respect to only while the phone is on. For example, if I charge the phone to 100%, leave it on for 1hr then turn the phone off for 8hrs, then turn it on for 1hr, the details imply that the phone was on constantly for 2hrs. No reference that I can see logs that it was off for an 8hr window. Have I missed something or is there somewhere else where it is stored?

Try 3C ToolBox Battery Manager. It include History Monitor. https://www.3c71.com/android/?q=node/585
30th July 2019, 07:27 AM |#2453  
Quote:
Originally Posted by amg314

Try 3C ToolBox Battery Manager. It include History Monitor. https://www.3c71.com/android/?q=node/585

Highly recommend the full pro version of this app. With that said, the battery stats will only function properly if the power profile is configured right, inside the framework, if it even is at all.

Sent from my Amazon KFSUWI using XDA Labs
30th July 2019, 08:11 AM |#2454  
Senior Member
Flag Sydney
Thanks Meter: 1,824
 
More
Quote:
Originally Posted by amg314

Try 3C ToolBox Battery Manager. It include History Monitor. https://www.3c71.com/android/?q=node/585

Quote:
Originally Posted by DiamondJohn

...I am trying to find a shell command or system file that reports/saves...

My rom itself has the actual detail as part of the battery details. I was specifically looking for the shell command / or a cat of a system file to retrieve the values for when the device is off or on.
30th July 2019, 09:48 AM |#2455  
Quote:
Originally Posted by DiamondJohn

My rom itself has the actual detail as part of the battery details. I was specifically looking for the shell command / or a cat of a system file to retrieve the values for when the device is off or on.

Might look over the recovery and system logs at boot. Amazon tablets display similar if not the exact info in those logs. Problem is that's OEM specific details.
30th July 2019, 11:37 AM |#2456  
amg314's Avatar
Senior Member
Flag Kharkov
Thanks Meter: 136
 
More
Quote:
Originally Posted by DiamondJohn

My rom itself has the actual detail as part of the battery details. I was specifically looking for the shell command / or a cat of a system file to retrieve the values for when the device is off or on.

Make search *battery* starting at / directory.
Look at files like batterystats-daily.xml and so on.
https://forum.xda-developers.com/cro...-data-t3264715
30th July 2019, 12:01 PM |#2457  
Senior Member
Flag Sydney
Thanks Meter: 1,824
 
More
Quote:
Originally Posted by amg314

Make search *battery* starting at / directory.
Look at files like batterystats-daily.xml and so on.

I'll take another look.

Quote:
Originally Posted by amg314

https://forum.xda-developers.com/cro...-data-t3264715

On a side note, to reset your battery statistics you can use
Code:
dumpsys batterystats --reset;
I have seen that thread, and the way they propose is really dodgy.
30th July 2019, 02:39 PM |#2458  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,198
 
Donate to Me
More
Only thing that came to mind for me was the `uptime` command. Doesn't tell you anything about when it was powered off though.
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
30th July 2019, 04:00 PM |#2459  
Member
Thanks Meter: 23
 
More
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.
31st July 2019, 12:39 AM |#2460  
Senior Member
Flag Sydney
Thanks Meter: 1,824
 
More
Quote:
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.

Quote:
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.

Click image for larger version

Name:	Screenshot_Settings_20190731-092522.png
Views:	290
Size:	194.7 KB
ID:	4799611
31st July 2019, 02:26 PM |#2461  
Member
Thanks Meter: 23
 
More
Interesting idea.

But
Quote:
Originally Posted by DiamondJohn

For example, LOS ROMs do not have this visual history graph built into the ROM [snap].

is not correct. I'm running LOS 14.1, and I get that chart when I e.g. touch the battery QS tile (and in settings).
Post Reply Subscribe to Thread

Tags
automation, batch, flashable zip, script, tool

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes