Android电池功耗BatteryHistorian数据分析

  • BatteryHistorian的用法

BatteryHistorian环境搭建配置

官方文档

1.BatteryHistorian图形页面数据分析:

Timeline: 

System stats: 

CPU runing: cpu运行的状态 
Kernel only uptime: 只有kernell运行
Userspace wakelock: 用户空间申请的锁 
Screen: 屏幕是否点亮 
Top app: 当前在内存中的应用,按内存占用率排序 
Activity Manager Proc: 活跃的用户进程 
Crashes(logcat): 某个时间点出现crash的应用 
Doze: 是否进入doze模式 
Device active: 和Doze相反 
JobScheduler: 异步作业调度 
SyncManager: 同步操作 
Temp White List: 电量优化白名单 
Phone call: 是否打电话 
GPS: 是否使用GPS 
Network connectivity: 网络连接状态(wifi、mobile是否连接) 
Mobile signal strength: 移动信号强度(great\good\moderate\poor) 
Wifi scan: 是否在扫描wifi信号 
Wifi supplicant: 是否有wifi请求 
Wifi radio: 是否正在通过wifi传输数据 
Wifi signal strength: wifi信号强度 
Wifi running: wifi组件是否在工作(未传输数据) 
Wifi on: 同上 
Audio: 音频子系统? 
Camera: 相机是否在工作 
Video:是否在播放视频 
Foreground process: 前台进程 
Package install: 是否在进行包安装 
Package active: 包管理在工作 
Battery level: 电池当前电量 
Temperature: 电池温度 
Plugged: 连接usb或者充电 
Charging on: 在充电 
Logcat misc: 是否在导出日志

2.BatteryHistorian日志数据分析:

使用命令 adb shell dumpsys batterystats > batterystats.txt 获取电池状态的日志.

亮屏和灭屏的基本信息:

Statistics since last charge:System starts: 0, currently on battery: false // 手机重启次数: 0,当前是否正在使用电池:falseEstimated battery capacity: 3050 mAh  // 预计电池容量Min learned battery capacity: 3119 mAhMax learned battery capacity: 3119 mAhTime on battery: 21h 22m 29s 526ms (96.7%) realtime, 6h 53m 53s 974ms (32.3%) uptime  // 电池状态下运行时间(realtime)、电池状态下运行时间未待机时间(uptime)Time on battery screen off: 16h 5m 28s 928ms (75.3%) realtime, 1h 36m 53s 326ms (7.6%) uptime    // 电池状态下灭屏时间(realtime)、电池状态下灭屏未待机时间(uptime)Time on battery screen doze: 0ms (0.0%)   // 在Doze模式下,电池的使用时间Total run time: 22h 6m 3s 553ms realtime, 7h 37m 28s 2ms uptime       // 总运行时间(包含充电)Discharge: 2766 mAh   // 放电量(总使用电量)Screen off discharge: 844 mAh // 灭屏状态下的放电量Screen doze discharge: 0 mAh  // 休眠模式下的放电量Screen on discharge: 1923 mAh // 亮屏状态下的放电量Device light doze discharge: 446 mAh  // 浅度休眠模式下耗电量Device deep doze discharge: 219 mAh   // 深度休眠模式下耗电量Start clock time: 2019-05-14-18-13-53Screen on: 5h 17m 0s 598ms (24.7%) 95x, Interactive: 5h 17m 52s 227ms (24.8%)Screen brightnesses:      // 背光状态的占比dark 2h 30m 40s 488ms (47.5%)dim 2h 45m 25s 856ms (52.2%)medium 42s 991ms (0.2%)bright 11s 263ms (0.1%)Device light idling: 7h 1m 17s 487ms (32.8%) 31xIdle mode light time: 6h 58m 40s 432ms (32.6%) 62x -- longest 20m 54s 932ms Device full idling: 5h 59m 49s 245ms (28.1%) 1xIdle mode full time: 5h 58m 49s 89ms (28.0%) 3x -- longest 3h 20m 44s 788ms Connectivity changes: 92Total full wakelock time: 8m 42s 844msTotal partial wakelock time: 29m 57s 633ms
realtime:正常流逝的时间,通常把这个时间叫做“墙上时间(walltime)”,就像挂在墙上的时钟一样,走过了一小时就是小时
uptime:CPU工作的时间。“墙上时间”经过一小时,但CPU可能就工作了一分钟,其他时间CPU都在休眠
这两个时间结合在一起,就能够知道休眠率: (realtime-uptime)/realtime,既手机休眠的时间占整个待机时间的比率。休眠率越高,就表明越省电

耗电排行

Estimated power use (mAh):Capacity: 3200, Computed drain: 2927, actual drain: 2848-2912   // 电池容量 3200,计算耗电 2927,实际耗电 2848-2912Screen: 782 Excluded from smearing  // 屏幕耗电Uid u0a173: 351 ( cpu=46.8 wake=0.813 radio=267 wifi=33.7 sensor=0.000569 camera=2.37 ) Including smearing: 700 ( screen=187 proportional=162 ) //一个Uid的耗电量,可以理解为一个应用的耗电量,括号里面为具体的模块Uid 1000: 248 ( cpu=213 wake=0.411 radio=30.9 wifi=3.01 gps=0.441 sensor=0.409 camera=0.0327 ) Excluded from smearingCell standby: 207 ( radio=207 ) Excluded from smearing  // 射频待机的耗电量Uid u0a153: 139 ( cpu=18.6 wake=0.309 radio=113 wifi=6.85 gps=0.0293 sensor=0.288 ) Including smearing: 303 ( screen=93.4 proportional=70.3 )Uid 0: 133 ( cpu=83.1 wake=5.43 radio=42.5 wifi=2.33 ) Excluded from smearingUid u0a71: 133 ( cpu=0.373 wake=0.00817 radio=130 wifi=3.13 ) Including smearing: 174 ( proportional=40.3 )Uid u999a173: 108 ( cpu=3.38 wake=0.381 radio=103 wifi=2.04 ) Including smearing: 141 ( proportional=32.8 )Uid u0a214: 96.1 ( cpu=12.6 wake=0.000575 radio=67.0 wifi=16.5 ) Including smearing: 612 ( screen=374 proportional=142 )Uid u0a192: 84.6 ( cpu=0.381 radio=84.3 ) Including smearing: 110 ( proportional=25.6 )Phone calls: 82.6 Including smearing: 108 ( proportional=25.0 )Uid 1051: 67.0 ( radio=63.6 wifi=3.35 ) Excluded from smearingUid u0a194: 48.7 ( cpu=19.8 wake=0.00325 radio=26.6 wifi=0.793 gps=1.49 sensor=0.000107 ) Including smearing: 73.2 ( screen=7.52 proportional=17.0 )Uid u0a122: 41.5 ( cpu=1.89 wake=0.00122 radio=38.9 wifi=0.153 gps=0.547 sensor=0.00720 ) Including smearing: 56.5 ( screen=1.89 proportional=13.1 )Uid u0a135: 38.4 ( cpu=6.32 wake=0.00000135 radio=32.1 gps=0.00303 sensor=0.000966 ) Including smearing: 56.0 ( screen=4.59 proportional=13.0 )Idle: 33.6 Excluded from smearingUid u0a62: 33.1 ( cpu=2.42 wake=0.000138 radio=25.9 wifi=4.79 ) Including smearing: 43.1 ( proportional=10.0 )Bluetooth: 28.5 ( cpu=0.789 wake=0.0176 radio=0.857 bt=26.9 ) Including smearing: 37.2 ( proportional=8.63 )Uid u0a250: 25.6 ( cpu=4.81 wake=0.0000744 radio=16.9 wifi=3.83 gps=0.132 sensor=0.000870 ) Including smearing: 41.6 ( screen=6.29 proportional=9.65 )Uid u0a45: 22.7 ( cpu=1.87 radio=12.5 wifi=8.28 sensor=0.00936 ) Including smearing: 46.9 ( screen=13.3 proportional=10.9 )Uid u0a182: 21.2 ( cpu=4.41 wake=0.0000541 radio=9.30 wifi=7.51 sensor=0.0162 ) Including smearing: 56.8 ( screen=22.4 proportional=13.2 )Uid u0a187: 20.9 ( cpu=0.361 wake=0.000852 radio=20.3 gps=0.247 sensor=0.00335 ) Including smearing: 47.1 ( screen=15.3 proportional=10.9 )Uid u0a74: 16.3 ( cpu=0.211 wake=0.0000162 radio=15.2 wifi=0.873 ) Including smearing: 21.2 ( proportional=4.92 )Uid u0a147: 15.9 ( cpu=1.33 wake=0.00706 radio=7.81 wifi=2.94 sensor=3.86 ) Including smearing: 20.8 ( proportional=4.82 )Uid u0a155: 13.7 ( cpu=0.444 wake=0.000436 radio=12.4 wifi=0.873 gps=0.0121 ) Including smearing: 17.8 ( proportional=4.14 )Uid u0a101: 13.2 ( cpu=0.142 radio=13.0 wifi=0.0579 ) Including smearing: 17.2 ( proportional=4.00 )Uid u0a79: 11.9 ( cpu=0.430 wake=0.000465 radio=9.49 wifi=1.97 ) Including smearing: 15.5 ( proportional=3.59 )Uid u0a108: 10.0 ( cpu=0.153 wake=0.000212 radio=9.44 wifi=0.452 ) Including smearing: 13.1 ( proportional=3.04 )Uid u0a60: 9.83 ( cpu=0.105 radio=9.25 wifi=0.474 ) Including smearing: 12.8 ( proportional=2.97 )Uid 1001: 9.63 ( cpu=9.08 wake=0.343 sensor=0.206 ) Excluded from smearingWifi: 6.76 ( cpu=0.931 wifi=5.83 ) Including smearing: 8.80 ( proportional=2.04 )Uid u0a172: 6.16 ( cpu=1.46 wake=0.0000135 wifi=4.70 sensor=0.000958 ) Including smearing: 13.9 ( screen=4.51 proportional=3.23 )Uid u0a129: 5.93 ( cpu=0.460 radio=3.89 gps=1.57 sensor=0.0147 ) Including smearing: 11.8 ( screen=3.10 proportional=2.73 )Uid u0a203: 5.23 ( cpu=0.506 radio=4.72 sensor=0.00165 ) Including smearing: 10.2 ( screen=2.63 proportional=2.38 )Uid u0a249: 5.11 ( cpu=0.757 wifi=4.34 gps=0.0105 sensor=0.00000024 ) Including smearing: 15.8 ( screen=7.06 proportional=3.68 )Uid u0a76: 4.36 ( cpu=0.764 wake=0.00235 radio=1.10 wifi=2.49 ) Including smearing: 9.87 ( screen=3.22 proportional=2.29 )Uid u0a31: 4.02 ( cpu=0.226 wake=0.000110 radio=3.73 wifi=0.0644 ) Including smearing: 5.46 ( screen=0.179 proportional=1.27 )Uid u0a82: 3.90 ( cpu=0.281 wake=0.00000271 radio=2.61 wifi=1.01 ) Including smearing: 5.07 ( proportional=1.18 )Uid u0a34: 3.64 ( cpu=0.0733 radio=3.55 wifi=0.0103 ) Including smearing: 4.76 ( screen=0.0168 proportional=1.10 )

内核唤醒锁排名

  All kernel wake locks:Kernel Wake lock PowerManagerService.WakeLocks   : 29m 18s 215ms (3810 times) realtimeKernel Wake lock wlan                            : 8m 22s 906ms (591 times) realtimeKernel Wake lock IPA_RM12                        : 7m 32s 860ms (2288 times) realtimeKernel Wake lock IPA_WS                          : 5m 48s 166ms (6539 times) realtimeKernel Wake lock [timerfd]-system_server         : 5m 28s 437ms (10013 times) realtimeKernel Wake lock radio-interface                 : 4m 32s 349ms (1336 times) realtimeKernel Wake lock NETLINK-hvdcp_opti              : 4m 30s 9ms (346090 times) realtimeKernel Wake lock 898000.qcom,qup_uart            : 4m 23s 210ms (228 times) realtimeKernel Wake lock hal_bluetooth_lock              : 4m 23s 159ms (221 times) realtimeKernel Wake lock NETLINK-healthd                 : 4m 4s 226ms (360071 times) realtimeKernel Wake lock alarmtimer                      : 3m 47s 713ms (112 times) realtimeKernel Wake lock 1-0028                          : 2m 54s 820ms (82 times) realtimeKernel Wake lock qcom-step-chg                   : 2m 44s 124ms (164 times) realtimeKernel Wake lock fpc_ttw_wl                      : 2m 41s 180ms (78 times) realtimeKernel Wake lock GPSD                            : 2m 16s 566ms (103 times) realtimeKernel Wake lock qcom_rx_wakelock                : 1m 56s 94ms (1721 times) realtimeKernel Wake lock PowerManagerService.Display     : 1m 39s 996ms (45 times) realtimeKernel Wake lock ipc00000079_1318_NasModemEndPoi : 56s 780ms (5098 times) realtimeKernel Wake lock PowerManagerService.Broadcasts  : 39s 787ms (170 times) realtimeKernel Wake lock netmgr_wl                       : 35s 468ms (2272 times) realtimeKernel Wake lock ipc000000e7_1258_netmgrd        : 34s 110ms (1235 times) realtimeKernel Wake lock ipc000000e6_1258_netmgrd        : 32s 469ms (1238 times) realtimeKernel Wake lock ipc000000b1_1449_DataModule-Loo : 30s 843ms (1300 times) realtimeKernel Wake lock prim_panel_wakelock             : 19s 552ms (77 times) realtimeKernel Wake lock wlan_pno_wl                     : 16s 921ms (23 times) realtimeKernel Wake lock batteryd                        : 16s 120ms (205469 times) realtimeKernel Wake lock ipc000000d7_1258_netmgrd        : 15s 831ms (1043 times) realtimeKernel Wake lock SensorService_wakelock          : 15s 22ms (5205 times) realtimeKernel Wake lock vdev_start                      : 14s 499ms (17 times) realtimeKernel Wake lock CHG_PLCY_MAIN_WL                : 7s 424ms (205496 times) realtimeKernel Wake lock cne_voice_ind_handler_wl_       : 6s 726ms (4 times) realtimeKernel Wake lock bluetooth_timer                 : 6s 348ms (1101 times) realtime

batterystats会从/proc/wakelocks和/d/wakeup_sources这两个文件中读取内核的持锁情况.

如果有内核持锁,CPU就无法休眠.如果持锁频率高会严重影响耗电量

一般打游戏、看视频、灭屏听音乐、后台下载等场景需要向框架层的PowerManagerService申请和释放Wake Lock,再由框架层决策是否向内核申请锁,而应用是不能直接使用内核锁的.应用可以持有多个不同的锁,但反应到内核的锁也就三种:

PowerManagerService.WakeLocks:控制CPU状态的锁
PowerManagerService.Display: 控制屏幕状态的锁
PowerManagerService.Broadcasts:控制电源状态改变的通知锁

应用持锁排行

  All partial wake locks:Wake lock u0a173 PlatformComm: 5m 10s 160ms (844 times) max=19868 actual=556488 realtimeWake lock u0a153 *job*/com.taobao.taobao/androidx.work.impl.background.systemjob.SystemJobService: 3m 48s 384ms (0 times) max=123890 actual=238396 realtimeWake lock 1001 RILJ_ACK_WL: 3m 47s 232ms (1309 times) max=700 actual=274575 realtimeWake lock 1000 deviceidle_maint: 3m 24s 597ms (33 times) max=30077 actual=217225 realtimeWake lock u999a173 PlatformComm: 3m 20s 891ms (566 times) max=15024 actual=348648 realtimeWake lock u0a173 MicroMsg.MMAutoAuth: 2m 37s 438ms (448 times) max=1119 actual=367878 realtimeWake lock u0a173 StnCallBack: 1m 24s 174ms (228 times) max=1083 actual=219430 realtimeWake lock u0a8 ProximitySensor: 58s 872ms (0 times) max=66135 actual=79030 realtimeWake lock u999a173 MicroMsg.MMAutoAuth: 44s 519ms (164 times) max=1090 actual=128941 realtimeWake lock 1000 GnssLocationProviderXtraDownload: 27s 734ms (1 times) max=27349 actual=28155 realtimeWake lock u0a173 MicroMsg.SyncService: 20s 333ms (241 times) max=1445 actual=55921 realtimeWake lock 1000 *alarm*: 16s 213ms (448 times) max=149 actual=20803 realtimeWake lock 1000 IpReachabilityMonitor.wlan0: 15s 439ms (5 times) max=3510 actual=20437 realtimeWake lock 1001 *telephony-radio*: 15s 427ms (2326 times) max=357 actual=33662 realtimeWake lock u0a173 MicroMsg.Alarm: 14s 614ms (127 times) max=294 actual=29647 realtimeWake lock 1002 StartingObexPbapTransaction: 13s 27ms (2 times) max=10097 actual=16590 realtimeWake lock u999a173 MicroMsg.Alarm: 12s 726ms (121 times) max=256 actual=27864 realtimeWake lock 1000 show keyguard: 12s 31ms (75 times) max=408 actual=20887 realtimeWake lock 1041 AudioMix: 11s 712ms (5 times) max=3027 actual=21331 realtimeWake lock 1000 ActivityManager-Sleep: 9s 399ms (75 times) max=582 actual=14011 realtimeWake lock u999a173 MicroMsg.CoreService: 9s 63ms (11 times) max=5596 actual=46177 realtimeWake lock u0a173 MicroMsg.CoreService: 9s 32ms (11 times) max=5624 actual=45980 realtimeWake lock 1000 AnyMotionDetector: 6s 483ms (1 times) max=9939 actual=9939 realtimeWake lock u999a173 MicroMsg.SyncService: 6s 200ms (31 times) max=10192 actual=19885 realtimeWake lock 1001 GsmInboundSmsHandler: 4s 704ms (1 times) max=5015 actual=5015 realtimeWake lock 1001 QcrilOemhookMsgTunnel: 4s 613ms (1453 times) max=42 actual=5475 realtimeWake lock u0a173 *alarm*: 3s 829ms (233 times) max=793 actual=5019 realtime
RIJ:通信上层需要向Modem发送数据时,会获取名为RIJ的锁
RILJ_ACK_WL:通信上层收到Modem上报的数据后,需要向Modem回复一个ACK,此时会获取名为RILJ_ACK_WL的锁
NetworkStats:进行流量统计时所持有的锁
*walarm*或者*alarm*: 通过AlarmManager唤醒所持有的锁
*job*/xxx:通过JobScheduler调度的任务所持有的锁
*vibrator*:在震动状态下所持有的锁
deviceidle_maint:进入Doze Maintainace状态所持有的锁,此时,手机从深度睡眠中唤醒,用很短的时间执行之前被搁置的CPU任务

所有的唤醒原因

All wakeup reasons:Wakeup reason Abort:Wakeup IRQ detected during suspend: 101 qcom,glink-smem-native-xprt-modem: 20m 20s 773ms (2385 times) realtimeWakeup reason Abort:Wakeup IRQ detected during suspend: 663 qpnp_rtc_alarm: 4m 27s 362ms (645 times) realtimeWakeup reason Abort:Wakeup IRQ detected during suspend: 106 ipa: 1m 41s 245ms (362 times) realtimeWakeup reason Abort:Wakeup IRQ detected during suspend: 111 WLAN_CE_2: 2m 27s 527ms (305 times) realtimeWakeup reason Abort:Last active Wakeup Source: IPA_WS, handle process swapper/0: 2m 2s 869ms (160 times) realtimeWakeup reason Abort:Some devices failed to suspend, or early wake event detected: 2m 48s 320ms (124 times) realtimeWakeup reason Abort:Wakeup IRQ detected during suspend: 1011 dma-grant: 1m 20s 20ms (67 times) realtimeWakeup reason 469:: 3s 426ms (59 times) realtimeWakeup reason Abort:Pending Wakeup Sources: qcom_rx_wakelock, handle process cds_ol_rx_threa: 39s 743ms (46 times) realtimeWakeup reason Abort:Last active Wakeup Source: IPA_WS, handle process PowerManagerSer: 27s 42ms (38 times) realtimeWakeup reason Abort:Pending Wakeup Sources: wlan, handle process wpa_supplicant: 1m 11s 130ms (36 times) realtimeWakeup reason Abort:Wakeup IRQ detected during suspend: 999 msoc-delta: 17s 414ms (21 times) realtimeWakeup reason Abort:Last active Wakeup Source: qcom_rx_wakelock, handle process cds_ol_rx_threa: 21s 723ms (20 times) realtimeWakeup reason Abort:Pending Wakeup Sources: [timerfd]-system_server, handle process swapper/0: 13s 173ms (16 times) realtimeWakeup reason Abort:Pending Wakeup Sources: wlan, handle process cds_mc_thread: 18s 408ms (13 times) realtimeWakeup reason Abort:Pending Wakeup Sources: ipc00000079_1318_NasModemEndPoi, handle process mpss_IPCRTR: 13s 764ms (13 times) realtimeWakeup reason Abort:Pending Wakeup Sources: NETLINK-hvdcp_opti, handle process kworker/0:2NETLINK-healthd, handle process kworker/0:2: 8s 277ms (12 times) realtimeWakeup reason Abort:Last active Wakeup Source: IPA_WS, handle process kworker/u16:18: 8s 669ms (12 times) realtimeWakeup reason Abort:Last active Wakeup Source: IPA_WS, handle process kworker/u16:19: 6s 682ms (11 times) realtimeWakeup reason Abort:Last active Wakeup Source: IPA_WS, handle process kworker/u16:13: 7s 121ms (10 times) realtimeWakeup reason Abort:Last active Wakeup Source: IPA_WS, handle process kworker/u16:12: 8s 948ms (10 times) realtimeWakeup reason Abort:Pending Wakeup Sources: IPA_RM12, handle process kworker/u16:13: 7s 575ms (10 times) realtimeWakeup reason Abort:Pending Wakeup Sources: PowerManagerService.WakeLocks, handle process Binder:1231_15: 8s 902ms (10 times) realtime

应用耗电情况

  u999a173:     // 微信的apk的 UIDMobile network: 1.10MB received, 348.54KB sent (packets 2222 received, 2940 sent)Mobile radio active: 33m 18s 765ms (7.9%) 302x @ 387 msppMobile radio AP wakeups: 161Cellular Sleep time:  0ms (0.0%)Cellular Idle time:   0ms (0.0%)Cellular Rx time:     24m 8s 58ms (1.9%)Cellular Tx time:     less than 0dBm:  1m 22s 271ms (0.1%)0dBm to 8dBm:  12ms (0.0%)8dBm to 15dBm:  63ms (0.0%)15dBm to 20dBm:  67ms (0.0%)above 20dBm:  28ms (0.0%)Wi-Fi network: 337.52KB received, 111.72KB sent (packets 670 received, 916 sent)WiFi AP wakeups: 17WiFi Scan time:  0ms (0.0%)WiFi Sleep time:  21h 22m 27s 551ms (100.0%)WiFi Idle time:   0ms (0.0%)WiFi Rx time:     523ms (0.0%)WiFi Tx time:     1s 452ms (0.0%)Wake lock MicroMsg.MMAutoAuth: 44s 519ms partial (164 times) max=1090 actual=128941, 2m 8s 941ms background partial (164 times) max=1090 realtimeWake lock MicroMsg.CoreService: 9s 63ms partial (11 times) max=5596 actual=46177, 46s 177ms background partial (11 times) max=5596 realtimeWake lock *alarm*: 3s 575ms partial (215 times) max=237 actual=4178, 4s 178ms background partial (215 times) max=237 realtimeWake lock MicroMsg.NetSceneSynCheck: 1s 803ms partial (13 times) max=3037 actual=7173, 7s 173ms background partial (13 times) max=3037 realtimeWake lock PlatformComm: 3m 20s 891ms partial (566 times) max=15024 actual=348648, 5m 48s 648ms background partial (566 times) max=15024 realtimeWake lock MicroMsg.SyncService: 6s 200ms partial (31 times) max=10192 actual=19885, 19s 885ms background partial (31 times) max=10192 realtimeWake lock fiid-sync realtimeWake lock MicroMsg.Alarm: 12s 726ms partial (121 times) max=256 actual=27864, 27s 864ms background partial (121 times) max=256 realtimeWake lock StnCallBack: 2s 981ms partial (18 times) max=1078 actual=18802, 18s 802ms background partial (18 times) max=1078 realtimeTOTAL wake: 4m 41s 758ms blamed partial, 6m 4s 179ms actual partial, 6m 4s 179ms actual background partial realtimeBackground for: 21h 22m 29s 526ms Total running: 21h 22m 29s 526ms Total cpu time: u=2m 15s 813ms s=50s 91ms Proc com.tencent.mm:tools:CPU: 9s 90ms usr + 2s 290ms krn ; 0ms fg1 startsProc *wakelock*:CPU: 8s 533ms usr + 9s 251ms krn ; 0ms fgProc com.tencent.mm:CPU: 1m 12s 820ms usr + 21s 300ms krn ; 0ms fgProc com.tencent.mm:push:CPU: 35s 620ms usr + 15s 320ms krn ; 0ms fgProc com.tencent.mm:sandbox:CPU: 3s 300ms usr + 960ms krn ; 0ms fg4 startsApk com.tencent.mm:Wakeup alarm *walarm*:ALARM_ACTION(11119): 121 timesWakeup alarm *walarm*:com.tencent.mm/.booter.MMReceivers$AlarmReceiver: 65 timesService com.tencent.mm.service.ProcessService$SandBoxProcessService:Created for: 0ms uptimeStarts: 0, launches: 4Service com.tencent.mm.remoteservice.RemoteService:Created for: 0ms uptimeStarts: 0, launches: 1Service com.tencent.mm.ipcinvoker.wx_extension.service.MainProcessIPCService:Created for: 0ms uptimeStarts: 0, launches: 1Service com.tencent.mm.ipcinvoker.wx_extension.service.ToolsProcessIPCService:Created for: 0ms uptimeStarts: 0, launches: 1Service com.tencent.mm.plugin.wepkg.ipc.WepkgMainProcessService:Created for: 0ms uptimeStarts: 0, launches: 1

射频模块(Radio Modem)的耗电统计,在使用数据网络时,就需要用到这个模块

  Cellular Statistics:Cellular kernel active time: 4h 21m 2s 319ms (28.0%)   // 射频模块的kernel层活跃时间Cellular data received: 157.34MB   // 数据收发的大小和数据包的个数Cellular data sent: 15.43MBCellular packets received: 114831Cellular packets sent: 102118      // 数据收发的大小和数据包的个数Cellular Radio Access Technology:  // 接入的网络类型(none未插卡、umts、hspa、lte、hspap等)none 1m 33s 860ms (0.2%) lte 14m 23s 982ms (1.5%) lte_ca 15h 16m 7s 722ms (98.3%) Cellular Rx signal strength (RSRP):    // 信号强度.如果长时间信号不好,射频模块会提高功率,从而引起更大的耗电great (greater than -98dBm):  6m 42s 442ms (0.7%) Cellular Sleep time:  10h 5m 55s 865ms (65.0%) // 射频模块处于休眠、空闲、接收数据、发送数据这几种不同状态下的时间Cellular Idle time:   1d 19h 45m 15s 59ms (281.7%)Cellular Rx time:     5h 20m 21s 445ms (34.4%)Cellular Tx time:     less than 0dBm:  2s 202ms (0.0%)0dBm to 8dBm:  683ms (0.0%)8dBm to 15dBm:  559ms (0.0%)15dBm to 20dBm:  716ms (0.0%)above 20dBm:  747ms (0.0%)
  • android电量统计概述

android的电池功耗统计都是通过代码估算,没有集成电路参与汇报.是通过power_profile.xml配置中各器件的状态与之对应的电流消耗来统计得出.

    路径: frameworks\base\core\res\res\xml\power_profile.xml<item name="ambient.on">100</item>  <!-- ~100mA --><item name="screen.on">150</item>  <!-- ~100mA --><item name="screen.full">250</item>  <!-- ~100mA --><item name="bluetooth.active">25</item> <!-- Bluetooth data transfer, ~10mA --><item name="bluetooth.on">5</item>  <!-- Bluetooth on & connectable, but not connected, ~0.1mA --><item name="wifi.on">3</item>  <!-- ~3mA --><item name="wifi.active">200</item>  <!-- WIFI data transfer, ~200mA --><item name="wifi.scan">100</item>  <!-- WIFI network scanning, ~100mA --><item name="audio">100</item> <!-- ~10mA --><item name="video">50</item> <!-- ~50mA --><item name="camera.flashlight">160</item> <!-- Avg. power for camera flash, ~160mA --><item name="camera.avg">550</item> <!-- Avg. power use of camera in standard usecases, ~550mA --><item name="gps.on">50</item> <!-- ~50mA --><item name="radio.active">200</item> <!-- ~200mA --><item name="radio.scanning">10</item> <!-- cellular radio scanning for signal, ~10mA --><!-- Current consumed by the radio at different signal strengths, when paging --><array name="radio.on"> <!-- Strength 0 to BINS-1 --><value>13.8</value> <!-- ~2mA --><value>12.2</value> <!-- ~1mA --><value>11.6</value> <!-- ~1mA --><value>10.2</value> <!-- ~1mA --><value>9.6</value> <!-- ~1mA --></array>

在代码方面,硬件和软件的电量统计都是通过BatteryStatsHelper来统计

    路径:frameworks\base\core\java\com\android\internal\os\BatteryStatsHelper.javaprivate void processAppUsage(SparseArray<UserHandle> asUsers) {final boolean forAllUsers = (asUsers.get(UserHandle.USER_ALL) != null);mStatsPeriod = mTypeBatteryRealtimeUs;BatterySipper osSipper = null;final SparseArray<? extends Uid> uidStats = mStats.getUidStats();final int NU = uidStats.size();for (int iu = 0; iu < NU; iu++) {final Uid u = uidStats.valueAt(iu);final BatterySipper app = new BatterySipper(BatterySipper.DrainType.APP, u, 0);mCpuPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);mWakelockPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);mMobileRadioPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs,mStatsType);mWifiPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);mBluetoothPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs,mStatsType);mSensorPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);mCameraPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);mFlashlightPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs,mStatsType);mMediaPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);final double totalPower = app.sumPower();if (DEBUG && totalPower != 0) {Log.d(TAG, String.format("UID %d: total power=%s", u.getUid(),makemAh(totalPower)));}// Add the app to the list if it is consuming power.// ... ...}if (osSipper != null) {// The device has probably been awake for longer than the screen on// time and application wake lock time would account for.  Assign// this remainder to the OS, if possible.mWakelockPowerCalculator.calculateRemaining(osSipper, mStats, mRawRealtimeUs,mRawUptimeUs, mStatsType);osSipper.sumPower();}}

上述方式通过计算cpu、Wakelock(保持唤醒锁)、无线电(2G/3G/4G)、WIFI、蓝牙、传感器、相机、闪光灯、多媒体来统计APP的总功耗

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/24226.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

时间序列预测:用电量预测 07 灰色预测算法

&#x1f32e;开发平台&#xff1a;jupyter lab &#x1f356;运行环境&#xff1a;python3、TensorFlow2.x ----------------------------------------------- 2022.9.16 测验成功 ---------------------------------------------------------------- 1. 时间序列预测&#x…

时间序列预测15:Multi-input / Multi-head CNN 实现用电量/发电量预测

【时间序列预测/分类】 全系列60篇由浅入深的博文汇总&#xff1a;传送门 接上文&#xff0c;本文介绍如何为多变量数据开发多输入通道多步时间序列预测的CNN模型和多子模型异构多步时间序列预测的CNN模型。 文章目录 2. 多输入通道 CNN 模型2.1 建模2.2 完整代码 3. 多头&…

人工智能迅猛发展,如何应对避免失业?

“人工智能从感知智能向认知智能演进”&#xff0c;人工智能的发展带给我们哪些思考&#xff1f;它究竟会给我们的工作生活带来哪些变化?我们要如何去应对&#xff1f; 阿里达摩院票选出2020年十大科技趋势&#xff1a; 量子计算进入攻坚期工业互联网的超融合保护数据隐私的A…

【杂谈】人脸图像书看完了感觉不过瘾?这些拓展人脸资料值得你关注一下

相信许多朋友都看过我这本人脸图像处理的书籍了&#xff0c;内容涵盖了人脸检测&#xff0c;人脸关键点检测&#xff0c;人脸识别&#xff0c;人脸属性分析&#xff0c;人脸美颜&#xff0c;人脸编辑与风格化&#xff0c;三维人脸重建内容&#xff0c;基本上包括了人脸的所有领…

Guava、Spring 如何抽象观察者模式?

什么是观察者模式 观察者模式 是一种行为设计模式&#xff0c;允许定义一种订阅通知机制&#xff0c;可以在对象&#xff08;被观察者&#xff09;事件发生时通知多个 “观察” 该对象的观察者对象&#xff0c;所以也被称为 发布订阅模式 其实我个人而言&#xff0c;不太喜欢使…

苹果「Find My iPhone」立功,帮警察追踪偷车嫌犯

By 超神经 内容提要&#xff1a;在澳大利亚墨尔本的一起入室盗窃案中&#xff0c;警方在 iPad 上「Find My」的协助下追踪到嫌犯位置&#xff0c;但追踪过程中嫌犯却因车祸丧生。 关键词&#xff1a;Find My 协警 盗窃 苹果的「Fing My」最近在一起入室抢劫案中立功了。 2 月 …

Hive 知识体系保姆级教程

Hive涉及的知识点如下图所示&#xff0c;本文将逐一讲解&#xff1a; 正文开始&#xff1a; 一. Hive概览 1.1 hive的简介 Hive是基于Hadoop的一个数据仓库工具&#xff0c;可以将结构化的数据文件映射为一张数据库表&#xff0c;并提供类SQL查询功能。 其本质是将SQL转换为Map…

跟着 Guava、Spring 学习如何设计观察者模式

文章首发在公众号&#xff08;龙台的技术笔记&#xff09;&#xff0c;之后同步到掘金和个人网站&#xff1a;xiaomage.info 今天讲解一篇行为型设计模式&#xff0c;什么是行为型&#xff1f;行为型主要负责设计 类或对象之间的交互。工作中常用的观察者模式就是一种行为型设…

【总结】有三AI重要原创人脸相关的技术文章汇总(2022年8月)

人脸图像的应用领域想必所有做视觉算法的都不会陌生&#xff0c;所有的安防监控、几乎现在所有的在线身份认证、支付、考勤都需要用到人脸检测与人脸识别&#xff0c;人脸识别甚至被用于追逃疑犯&#xff0c;找寻失踪人口。 所有的在线直播平台&#xff0c;手机拍照软件&#x…

【总结】有三AI所有原创人脸相关的学习资料汇总(2022年12月)

人脸图像的应用领域想必所有做视觉算法的都不会陌生&#xff0c;所有的安防监控、几乎现在所有的在线身份认证、支付、考勤都需要用到人脸检测与人脸识别&#xff0c;人脸识别甚至被用于追逃疑犯&#xff0c;找寻失踪人口。 所有的在线直播平台&#xff0c;手机拍照软件&#x…

CV:计算机视觉技最强学习路线之CV简介(传统视觉技术/相关概念)、早期/中期/近期应用领域(偏具体应用)、经典CNN架构(偏具体算法)概述、常用工具/库/框架/产品、环境安装、常用数据集、编程技巧

CV&#xff1a;计算机视觉技最强学习路线之CV简介(传统视觉技术/相关概念)、早期/中期/近期应用领域(偏具体应用)、经典CNN架构(偏具体算法)概述、常用工具/库/框架/产品、环境安装、常用数据集、编程技巧 导读&#xff1a;计算机视觉技最强学习路线&#xff0c;2022年10月18日…

Hive——函数-Explode(含案例演示建议收藏)

创建文件 vim movie.txt数据准备&#xff1a; 《疑犯追踪》 悬疑,动作,科幻,剧情 《Lie to me》 悬疑,警匪,动作,心理,剧情 《战狼 2》 战争,动作,灾难创建新表&#xff1a; create table movie_info(movie string,category string) row format delimited fields …

看美剧《疑犯追踪》,学地道美语 Learn idiomatic American English by watching Tv series Person of Interest

看美剧《疑犯追踪》&#xff0c;学地道美语 Learn idiomatic American English by watching Tv series Person of Interest cemike126.com 题记&#xff1a;暑期看了美剧《疑犯追踪》&#xff08;Person of Interest&#xff09;。开始只是记下第一级中一些引发我思考的片段台词…

疑犯追踪第五季/全集Person of Interest迅雷下载

英文全名Person of Interest&#xff0c;第5季(2015)CBS. 本季看点&#xff1a;《疑犯追踪》本季剧组暗示Finch可能重建机器&#xff0c;这次他会给机器更多自由&#xff08;如Root一直要求的那样&#xff09;。或许新机器更像个战士&#xff0c;比旧机器更强大。目前&#xff…

现实版的“疑犯追踪”是如何开展的?

为什么80%的码农都做不了架构师&#xff1f;>>> 童鞋们&#xff0c; 还记得在美剧《疑犯追踪》中&#xff0c; Finch发明的人工智能“The Machine”吗&#xff1f; 它通过获得和关联大量数据&#xff0c; 可分析出即将发生的犯罪事件并发出预警。 可以说是灰常滴了…

南澳行

上周随部门到南澳&#xff0c;其实这是我第二次去南澳了&#xff0c;不过上次去了大鹏古城&#xff0c;这次主要是在海边玩沙滩足球&#xff0c;好过隐呀&#xff01; 以前觉得南澳不错&#xff0c;因为可以在海边玩耍&#xff0c;至少比红树林感觉要好吧。但去年去了海南之后&…

大三期末网页设计作业 以旅游景点风景主题介绍网站设计与实现 (广东名胜古迹)

&#x1f329;️ 精彩专栏推荐&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; &#x1f482; 作者主页: 【进入主页—&#x1f680;获取更多源码】 &#x1f393; web前端期末大作业&#xff1a; 【&#x1f4da;HTML5网页期末作业 (1000套…

JS根据城市名称获取所在省份

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 实现代码&#xff1a; var provinces require(../../../utils/provinces);var city 昆明市;provinces.forEach((item,index) > {item.city.forEach((itt, idx) > {if (itt.name city) {console.…

JS搜索省份匹配出省份的所有城市

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 效果图&#xff1a; 模糊搜索和精确搜索省份的所有城市名称&#xff0c; 模糊搜索和精确搜索城市名称&#xff0c; js // pages/test/test.js var val; var provinces require(../../utils/provinces…

微信小程序选择市,区县

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 微信小程序选择市&#xff0c;区县的实现 demo的需求是 做一个两列选择器&#xff0c;选择江西省范围内的所有市以及区县&#xff0c;滑动到每个城市 自动匹配出它的区县并赋值到第二列&#xff0c;用户…