I'm trying to use Battery Historian Python script from GitHub to analyze battery usage, but the html generated each time I use the script shows "cannot find end time".
I'm following the steps form here.
Here is a sample batterystats.txt
file generated:
Battery History: -2m43s770ms 100 44020302 status=not-charging health=good plug=none temp=270 volt=4339 +wifi +wifi_running +wake_lock brightness=medium phone_state=off -2m43s151ms 100 44020302 -2m38s500ms 100 04020302 -wake_lock -2m20s496ms 100 44020302 +wake_lock -2m17s471ms 100 04020302 -wake_lock -2m13s741ms 100 04020302 temp=280 -1m59s447ms 100 44020302 +wake_lock -1m56s423ms 100 04020302 -wake_lock -43s740ms 100 04020302 volt=4317 -21s432ms 100 040a0302 status=full plug=usb volt=4312 +plugged Per-PID Stats: PID 140 wake time: +1s55ms PID 601 wake time: +1s236ms PID 140 wake time: +13s381ms PID 601 wake time: +29ms PID 812 wake time: +555ms PID 939 wake time: +18ms PID 1241 wake time: +51ms PID 601 wake time: +1ms PID 1294 wake time: +3ms PID 601 wake time: +32ms PID 601 wake time: +7ms PID 1689 wake time: +103ms Statistics since last charge: System starts: 0, currently on battery: false Time on battery: 2m 22s 369ms (0.0%) realtime, 2m 22s 369ms (0.0%) uptime Total run time: 21d 4h 47m 25s 154ms realtime, 3d 2h 25m 30s 738ms uptime, Screen on: 0ms (0.0%), Input events: 0, Active phone call: 0ms (0.0%) Screen brightnesses: No activity Mobile total received: 0B, Total sent: 0B Wi-Fi total received: 249.09KB, Total sent: 18.02KB Total full wakelock time: 2m 22s 191ms , Total partial wakelock time: 9s 697ms Signal levels: No activity Signal scanning time: 0ms Radio types: none 2m 22s 369ms (100.0%) 0x Radio data uptime when unplugged: 0 ms Wifi on: 2m 22s 369ms (100.0%), Wifi running: 2m 22s 369ms (100.0%), Bluetooth on: 0ms (0.0%) Device battery use since last full charge Amount discharged (lower bound): 0 Amount discharged (upper bound): 0 Amount discharged while screen on: 0 Amount discharged while screen off: 0 All partial wake locks: Wake lock 1013 AudioMix: 9s 52ms (4 times) realtime Wake lock u0a8 UlrDispSvcFastWL: 166ms (2 times) realtime Wake lock 1000 AlarmManager: 87ms (2 times) realtime Wake lock u0a8 GCoreFlp: 80ms (3 times) realtime Wake lock 1000 NetworkStats: 78ms (1 times) realtime Wake lock 1000 ActivityManager-Launch: 78ms (1 times) realtime Wake lock u0a8 Event Log Service: 75ms (1 times) realtime Wake lock u0a24 AlarmManager: 32ms (1 times) realtime Wake lock u0a8 AlarmManager: 23ms (2 times) realtime Wake lock u0a43 AlarmManager: 7ms (1 times) realtime Wake lock u0a8 Event Log Handoff: 7ms (1 times) realtime Wake lock u0a8 GCM_CONN: 5ms (1 times) realtime Wake lock u0a8 GCM_HB_ALARM: 4ms (1 times) realtime Wake lock u0a23 PUSH_SERVICE_WAKE_LOCK: 3ms (1 times) realtime Wake lock u0a23 AlarmManager: 1ms (1 times) realtime Wake lock u0a8 Wakeful StateMachine: GeofencerStateMachine: 1ms (1 times) realtime 0: Wi-Fi network: 632B received, 1.59KB sent Proc /init: CPU: 20ms usr + 80ms krn ; 0ms fg Proc ksoftirqd/0: CPU: 10ms usr + 0ms krn ; 0ms fg Proc mtk charger_hv_: CPU: 0ms usr + 20ms krn ; 0ms fg Proc vold: CPU: 0ms usr + 10ms krn ; 0ms fg Proc jbd2/mmcblk0p7-: CPU: 0ms usr + 20ms krn ; 0ms fg Proc pmic_thread_kth: CPU: 0ms usr + 450ms krn ; 0ms fg Proc kthreadd: CPU: 0ms usr + 10ms krn ; 0ms fg Proc btif_rxd: CPU: 10ms usr + 0ms krn ; 0ms fg Proc netd: CPU: 10ms usr + 10ms krn ; 0ms fg Proc mmcqd/0: CPU: 0ms usr + 50ms krn ; 0ms fg Proc kworker/u:0: CPU: 0ms usr + 270ms krn ; 0ms fg Proc kworker/u:2: CPU: 0ms usr + 120ms krn ; 0ms fg Proc kworker/0:2: CPU: 0ms usr + 500ms krn ; 0ms fg Proc zygote: CPU: 20ms usr + 30ms krn ; 0ms fg Proc flush-179:0: CPU: 10ms usr + 0ms krn ; 0ms fg Proc tx_thread: CPU: 0ms usr + 100ms krn ; 0ms fg Proc disp_clean_up_k: CPU: 0ms usr + 20ms krn ; 0ms fg Proc healthd: CPU: 0ms usr + 100ms krn ; 0ms fg Proc ueventd: CPU: 0ms usr + 10ms krn ; 0ms fg Proc bat_thread_kthr: CPU: 0ms usr + 520ms krn ; 0ms fg Proc disp_config_upd: CPU: 0ms usr + 440ms krn ; 0ms fg Proc ion_mm_heap: CPU: 0ms usr + 20ms krn ; 0ms fg Proc disp_ovl_kthrea: CPU: 0ms usr + 110ms krn ; 0ms fg 1000: User activity: 6 other, 1 button, 1 touch Wake lock NetworkStats: 78ms partial (1 times) realtime Wake lock ActivityManager-Launch: 78ms partial (1 times) realtime Wake lock AlarmManager: 87ms partial (2 times) realtime TOTAL wake: 243ms partial realtime Sensor 0: 2m 22s 369ms realtime (0 times) Vibrator: 100ms realtime (1 times) Foreground activities: 129ms realtime (1 times) Proc com.mediatek.schpwronoff: CPU: 0ms usr + 10ms krn ; 0ms fg Proc surfaceflinger: CPU: 950ms usr + 1s 30ms krn ; 0ms fg Proc com.android.settings: CPU: 0ms usr + 0ms krn ; 730ms fg Proc system_server: CPU: 2s 680ms usr + 2s 230ms krn ; 0ms fg Proc aal: CPU: 60ms usr + 180ms krn ; 0ms fg Proc servicemanager: CPU: 0ms usr + 10ms krn ; 0ms fg 1001: Proc com.android.phone: CPU: 50ms usr + 20ms krn ; 0ms fg 1010: Proc wpa_supplicant: CPU: 10ms usr + 30ms krn ; 0ms fg 1013: Wake lock AudioMix: 9s 52ms partial (4 times) realtime Proc mediaserver: CPU: 20ms usr + 30ms krn ; 0ms fg 1023: Proc sdcard: CPU: 0ms usr + 20ms krn ; 0ms fg 2000: Proc adbd: CPU: 110ms usr + 380ms krn ; 0ms fg 9997: Proc em_svr: CPU: 0ms usr + 40ms krn ; 0ms fg u0a5: Proc android.process.media: CPU: 60ms usr + 0ms krn ; 0ms fg Apk com.android.providers.media: Service com.android.providers.media.MtpService: Created for: 0ms uptime Starts: 1, launches: 1 u0a8: Wi-Fi network: 5.35KB received, 1.92KB sent Wake lock Wakeful StateMachine: GeofencerStateMachine: 1ms partial (1 times) realtime Wake lock GCoreFlp: 80ms partial (3 times) realtime Wake lock UlrDispSvcFastWL: 166ms partial (2 times) realtime Wake lock GCM_HB_ALARM: 4ms partial (1 times) realtime Wake lock Event Log Service: 75ms partial (1 times) realtime Wake lock GCM_CONN: 5ms partial (1 times) realtime Wake lock Event Log Handoff: 7ms partial (1 times) realtime Wake lock AlarmManager: 23ms partial (2 times) realtime TOTAL wake: 361ms partial realtime Proc com.google.android.gms: CPU: 100ms usr + 40ms krn ; 0ms fg Proc com.google.process.gapps: CPU: 180ms usr + 70ms krn ; 0ms fg Proc com.google.android.gms.persistent: CPU: 1s 130ms usr + 300ms krn ; 0ms fg Apk com.google.android.gms: 2 wakeup alarms Service com.google.android.gms.config.ConfigService: Created for: 0ms uptime Starts: 0, launches: 1 Service com.google.android.gms.checkin.EventLogService: Created for: 85ms uptime Starts: 1, launches: 1 Service com.google.android.gms.gcm.http.GoogleHttpService: Created for: 0ms uptime Starts: 0, launches: 1 Service com.google.android.location.reporting.service.DispatchingService: Created for: 268ms uptime Starts: 1, launches: 1 Service com.google.android.gms.usagereporting.service.UsageReportingService: Created for: 0ms uptime Starts: 0, launches: 1 u0a13: Proc com.android.systemui: CPU: 810ms usr + 300ms krn ; 0ms fg u0a18: Proc com.lenovo.safecenter.hd: CPU: 360ms usr + 120ms krn ; 0ms fg u0a19: Proc com.lenovo.lps.cloud.sync.row: CPU: 0ms usr + 0ms krn ; 0ms fg 1 proc starts u0a20: Proc com.lenovo.lewea: CPU: 40ms usr + 10ms krn ; 0ms fg Apk com.lenovo.lewea: Service com.lenovo.weather.service.UpdateAppWidgetService: Created for: 84ms uptime Starts: 2, launches: 2 u0a23: Wake lock AlarmManager: 1ms partial (1 times) realtime Wake lock PUSH_SERVICE_WAKE_LOCK: 3ms partial (1 times) realtime TOTAL wake: 4ms partial realtime Proc com.lenovo.lsf.device: CPU: 30ms usr + 0ms krn ; 0ms fg u0a24: Wake lock AlarmManager: 32ms partial (1 times) realtime Proc com.lenovo.ue.service: CPU: 40ms usr + 10ms krn ; 0ms fg u0a42: (nothing executed) u0a43: Wake lock AlarmManager: 7ms partial (1 times) realtime u0a58: Proc com.google.android.inputmethod.latin: CPU: 20ms usr + 0ms krn ; 0ms fg u0a65: (nothing executed) u0a74: Proc com.google.android.apps.plus: CPU: 50ms usr + 30ms krn ; 0ms fg Apk com.google.android.apps.plus: (nothing executed) u0a114: Wi-Fi network: 243.13KB received, 14.51KB sent Wake lock WindowManager: 2m 22s 191ms full (1 times) realtime Foreground activities: 2m 22s 208ms realtime (1 times) Proc com.devstring.imageframe: CPU: 6s 300ms usr + 810ms krn ; 0ms fg Statistics since last unplugged: Time on battery: 2m 22s 369ms (86.9%) realtime, 2m 22s 369ms (86.9%) uptime Total run time: 2m 43s 811ms realtime, 2m 43s 811ms uptime, Screen on: 0ms (0.0%), Input events: 0, Active phone call: 0ms (0.0%) Screen brightnesses: No activity Mobile total received: 0B, Total sent: 0B Wi-Fi total received: 249.09KB, Total sent: 18.02KB Total full wakelock time: 2m 22s 191ms , Total partial wakelock time: 9s 697ms Signal levels: No activity Signal scanning time: 0ms Radio types: none 2m 22s 369ms (100.0%) 0x Radio data uptime when unplugged: 0 ms Wifi on: 2m 22s 369ms (100.0%), Wifi running: 2m 22s 369ms (100.0%), Bluetooth on: 0ms (0.0%) Device is currently plugged into power Last discharge cycle start level: 100 Last discharge cycle end level: 100 Amount discharged while screen on: 0 Amount discharged while screen off: 0 All partial wake locks: Wake lock 1013 AudioMix: 9s 52ms (4 times) realtime Wake lock u0a8 UlrDispSvcFastWL: 166ms (2 times) realtime Wake lock 1000 AlarmManager: 87ms (2 times) realtime Wake lock u0a8 GCoreFlp: 80ms (3 times) realtime Wake lock 1000 NetworkStats: 78ms (1 times) realtime Wake lock 1000 ActivityManager-Launch: 78ms (1 times) realtime Wake lock u0a8 Event Log Service: 75ms (1 times) realtime Wake lock u0a24 AlarmManager: 32ms (1 times) realtime Wake lock u0a8 AlarmManager: 23ms (2 times) realtime Wake lock u0a43 AlarmManager: 7ms (1 times) realtime Wake lock u0a8 Event Log Handoff: 7ms (1 times) realtime Wake lock u0a8 GCM_CONN: 5ms (1 times) realtime Wake lock u0a8 GCM_HB_ALARM: 4ms (1 times) realtime Wake lock u0a23 PUSH_SERVICE_WAKE_LOCK: 3ms (1 times) realtime Wake lock u0a23 AlarmManager: 1ms (1 times) realtime Wake lock u0a8 Wakeful StateMachine: GeofencerStateMachine: 1ms (1 times) realtime 0: Wi-Fi network: 632B received, 1.59KB sent Proc /init: CPU: 20ms usr + 80ms krn ; 0ms fg Proc ksoftirqd/0: CPU: 10ms usr + 0ms krn ; 0ms fg Proc mtk charger_hv_: CPU: 0ms usr + 20ms krn ; 0ms fg Proc vold: CPU: 0ms usr + 10ms krn ; 0ms fg Proc jbd2/mmcblk0p7-: CPU: 0ms usr + 20ms krn ; 0ms fg Proc pmic_thread_kth: CPU: 0ms usr + 450ms krn ; 0ms fg Proc kthreadd: CPU: 0ms usr + 10ms krn ; 0ms fg Proc btif_rxd: CPU: 10ms usr + 0ms krn ; 0ms fg Proc netd: CPU: 10ms usr + 10ms krn ; 0ms fg Proc mmcqd/0: CPU: 0ms usr + 50ms krn ; 0ms fg Proc kworker/u:0: CPU: 0ms usr + 270ms krn ; 0ms fg Proc kworker/u:2: CPU: 0ms usr + 120ms krn ; 0ms fg Proc kworker/0:2: CPU: 0ms usr + 500ms krn ; 0ms fg Proc zygote: CPU: 20ms usr + 30ms krn ; 0ms fg Proc flush-179:0: CPU: 10ms usr + 0ms krn ; 0ms fg Proc tx_thread: CPU: 0ms usr + 100ms krn ; 0ms fg Proc disp_clean_up_k: CPU: 0ms usr + 20ms krn ; 0ms fg Proc healthd: CPU: 0ms usr + 100ms krn ; 0ms fg Proc ueventd: CPU: 0ms usr + 10ms krn ; 0ms fg Proc bat_thread_kthr: CPU: 0ms usr + 520ms krn ; 0ms fg Proc disp_config_upd: CPU: 0ms usr + 440ms krn ; 0ms fg Proc ion_mm_heap: CPU: 0ms usr + 20ms krn ; 0ms fg Proc disp_ovl_kthrea: CPU: 0ms usr + 110ms krn ; 0ms fg 1000: User activity: 6 other, 1 button, 1 touch Wake lock NetworkStats: 78ms partial (1 times) realtime Wake lock ActivityManager-Launch: 78ms partial (1 times) realtime Wake lock AlarmManager: 87ms partial (2 times) realtime TOTAL wake: 243ms partial realtime Sensor 0: 2m 22s 369ms realtime (0 times) Vibrator: 100ms realtime (1 times) Foreground activities: 129ms realtime (1 times) Proc com.mediatek.schpwronoff: CPU: 0ms usr + 10ms krn ; 0ms fg Proc surfaceflinger: CPU: 950ms usr + 1s 30ms krn ; 0ms fg Proc com.android.settings: CPU: 0ms usr + 0ms krn ; 730ms fg Proc system_server: CPU: 2s 680ms usr + 2s 230ms krn ; 0ms fg Proc aal: CPU: 60ms usr + 180ms krn ; 0ms fg Proc servicemanager: CPU: 0ms usr + 10ms krn ; 0ms fg 1001: Proc com.android.phone: CPU: 50ms usr + 20ms krn ; 0ms fg 1010: Proc wpa_supplicant: CPU: 10ms usr + 30ms krn ; 0ms fg 1013: Wake lock AudioMix: 9s 52ms partial (4 times) realtime Proc mediaserver: CPU: 20ms usr + 30ms krn ; 0ms fg 1023: Proc sdcard: CPU: 0ms usr + 20ms krn ; 0ms fg 2000: Proc adbd: CPU: 110ms usr + 380ms krn ; 0ms fg 9997: Proc em_svr: CPU: 0ms usr + 40ms krn ; 0ms fg u0a5: Proc android.process.media: CPU: 60ms usr + 0ms krn ; 0ms fg Apk com.android.providers.media: Service com.android.providers.media.MtpService: Created for: 0ms uptime Starts: 1, launches: 1 u0a8: Wi-Fi network: 5.35KB received, 1.92KB sent Wake lock Wakeful StateMachine: GeofencerStateMachine: 1ms partial (1 times) realtime Wake lock GCoreFlp: 80ms partial (3 times) realtime Wake lock UlrDispSvcFastWL: 166ms partial (2 times) realtime Wake lock GCM_HB_ALARM: 4ms partial (1 times) realtime Wake lock Event Log Service: 75ms partial (1 times) realtime Wake lock GCM_CONN: 5ms partial (1 times) realtime Wake lock Event Log Handoff: 7ms partial (1 times) realtime Wake lock AlarmManager: 23ms partial (2 times) realtime TOTAL wake: 361ms partial realtime Proc com.google.android.gms: CPU: 100ms usr + 40ms krn ; 0ms fg Proc com.google.process.gapps: CPU: 180ms usr + 70ms krn ; 0ms fg Proc com.google.android.gms.persistent: CPU: 1s 130ms usr + 300ms krn ; 0ms fg Apk com.google.android.gms: 2 wakeup alarms Service com.google.android.gms.config.ConfigService: Created for: 0ms uptime Starts: 0, launches: 1 Service com.google.android.gms.checkin.EventLogService: Created for: 85ms uptime Starts: 1, launches: 1 Service com.google.android.gms.gcm.http.GoogleHttpService: Created for: 0ms uptime Starts: 0, launches: 1 Service com.google.android.location.reporting.service.DispatchingService: Created for: 268ms uptime Starts: 1, launches: 1 Service com.google.android.gms.usagereporting.service.UsageReportingService: Created for: 0ms uptime Starts: 0, launches: 1 u0a13: Proc com.android.systemui: CPU: 810ms usr + 300ms krn ; 0ms fg u0a18: Proc com.lenovo.safecenter.hd: CPU: 360ms usr + 120ms krn ; 0ms fg u0a19: Proc com.lenovo.lps.cloud.sync.row: CPU: 0ms usr + 0ms krn ; 0ms fg 1 proc starts u0a20: Proc com.lenovo.lewea: CPU: 40ms usr + 10ms krn ; 0ms fg Apk com.lenovo.lewea: Service com.lenovo.weather.service.UpdateAppWidgetService: Created for: 84ms uptime Starts: 2, launches: 2 u0a23: Wake lock AlarmManager: 1ms partial (1 times) realtime Wake lock PUSH_SERVICE_WAKE_LOCK: 3ms partial (1 times) realtime TOTAL wake: 4ms partial realtime Proc com.lenovo.lsf.device: CPU: 30ms usr + 0ms krn ; 0ms fg u0a24: Wake lock AlarmManager: 32ms partial (1 times) realtime Proc com.lenovo.ue.service: CPU: 40ms usr + 10ms krn ; 0ms fg u0a42: (nothing executed) u0a43: Wake lock AlarmManager: 7ms partial (1 times) realtime u0a58: Proc com.google.android.inputmethod.latin: CPU: 20ms usr + 0ms krn ; 0ms fg u0a65: (nothing executed) u0a74: Proc com.google.android.apps.plus: CPU: 50ms usr + 30ms krn ; 0ms fg Apk com.google.android.apps.plus: (nothing executed) u0a114: Wi-Fi network: 243.13KB received, 14.51KB sent Wake lock WindowManager: 2m 22s 191ms full (1 times) realtime Foreground activities: 2m 22s 208ms realtime (1 times) Proc com.devstring.imageframe: CPU: 6s 300ms usr + 810ms krn ; 0ms fg
Command:
adb shell dumpsys batterystats > batterystats.txt python historian.py batterystats.txt > batterystats.html
batterystats.html shows cannot find end time
I have referred to Displaying "Cannot find endtime" on Using hisorian.py
EDIT1
When I'm testing with a different device . no such error is generated. But every time this devices battery stats is giving no end time error
EDIT 2 Different versions of android have different dumpsys formats and the battery historian seems to be compatible with the newer version. To generate the chart I commentent line 646 to 649 i.e
#if not self._end_time: #print "cannot find end time" #sys.exit(1)
Although its a hack, my device is Android 4.4 and its battery dumpsys does not give app wise battery usage but android 5.2 devices do so.