您现在的位置是:首页 > 文章详情

【Android电量】Battery Historian高级用法

日期:2019-07-05点击:718
  • Wakelock analysis
  • Kernel trace analysis
  • Other command line tools

Wakelock analysis

默认情况下,Android不会记录指定应用的用户空间下wakelock transitions的时间戳。如果想要让 Historian 在timeline展示每个 individual wakelock 的详细信息,就需要在开始操作试验之前通过下面的命令开启 full wakelock reporting。

adb shell dumpsys batterystats --enable full-wake-history

需要注意的是,一旦开启 full wakelock reporting,电池历史日志记录将在几小时后溢出。使用此选项可进行短期测试(3-4小时)。

Kernel trace analysis

要生成记录内核唤醒源和内核唤醒锁活动的跟踪文件,

首先开启 kernel trace logging:

$ adb root $ adb shell

Set the events to trace.

$ echo "power:wakeup_source_activate" >> /d/tracing/set_event $ echo "power:wakeup_source_deactivate" >> /d/tracing/set_event

The default trace size for most devices is 1MB, which is relatively low and might cause the logs to overflow.
8MB to 10MB should be a decent size for 5-6 hours of logging.

$ echo 8192 > /d/tracing/buffer_size_kb $ echo 1 > /d/tracing/tracing_on

使用设备跑测试场景
完成后导出日志

$ echo 0 > /d/tracing/tracing_on $ adb pull /d/tracing/trace <some path> ##### Take a bug report at this time. $ adb bugreport > bugreport.txt

Other command line tools

System stats
$ go run cmd/checkin-parse/local_checkin_parse.go --input=bugreport.txt
Timeline analysis
$ go run cmd/history-parse/local_history_parse.go --summary=totalTime --input=bugreport.txt
Diff two bug reports
$ go run cmd/checkin-delta/local_checkin_delta.go --input=bugreport_1.txt,bugreport_2.txt
原文链接:https://yq.aliyun.com/articles/707904
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章