I want to get battery usage data from my OnePlus 5 over a longer period (months), to keep track of how much I use my phone.
I've been playing around with adb and the batterystats dump, like so:
adb shell dumpsys batterystats > batterystats.txt
,but this data only seems to cover the data since the last charge.
Is battery usage data even stored for a longer period on your phone? Or is it reset every time you charge it? If it is stored somewhere, how would I access it?
$ adb version
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
From the android documentation dumpsys service. As indicated I executed the following command adb shell dumpsys batterystats -h
to get the available arguments
From my experimentations, battery logs records do not last more than few days (in my case 10 days on my motorola Moto x 2nd gen). You may have to plug and log the phone more often than each month
As printed by the -h argument you can use enable no-auto-reset
by doing adb shell dumpsys batterystats enable no-auto-reset
no-auto-reset: don't automatically reset stats when unplugged
but you have to do it after each boot as indicated by the command
Option state is not saved across boots.