AI手机网,短视频直播 硬改改机 一键新机 群控软件 刷机定制

 找回密码
 立即注册
搜索
查看: 2705|回复: 1

adb 查看电池状态信息。改变手机电池充电信息电量百分比

[复制链接]
发表于 2020-9-27 08:39:26 | 显示全部楼层 |阅读模式

手机连接上电脑。输入adb命令:adb shell dumpsys battery


Current Battery Service state:   ####当前电池服务状态
  AC powered: false                   ####交流供电
  USB powered: true                  ####USB供电
  Wireless powered: false          ####无线供电
  status: 2                                  ####电池状态:2:充电状态 ,其他数字为非充电状态
  health: 2                                  ####电池健康状态:只有数字2表示good
  present: true                           ####电池是否安装在机身
  level: 82                                  ####电量: 百分比
  scale: 100                                ####规模
  voltage: 4500                          ####电池电压
  temperature: 378                    ####电池温度,单位是0.1摄氏度
  current now: -335232             #-------电流值,负数表示正在充电

  technology: Li-ion                   ####电池种类=

切换手机电池为非充电状态: adb shell dumpsys battery set status 1
让手机电量显示百分百: adb shell dumpsys battery set level 100
让手机电量显示1: adb shell dumpsys battery set level 1
软件角度模拟断开充电(实际上是充进电):adb shell dumpsys battery unplug (注意:必须在andorid 6.0以上的版本)



获取整个设备的电量消耗信息: adb shell dumpsys batterystats  | more

获取某个apk的电量消耗信息:  adb shell dumpsys batterystats  包名 | more


Battery History:            ####电池的历史
    -1d05h55m26s454ms  START
    -1d05h54m26s454ms  START
    -1d05h53m26s454ms  START
    -1d05h53m26s083ms 055 240a0000 status=charging health=good plug=usb temp=301 volt=4332 +plugged +wifi +wifi_running +sensor
    -1d05h53m23s913ms 055 640a0002 +wake_lock brightness=medium    #####设备锁的亮度:中等
    -1d05h53m21s859ms 055 640a0002
    -1d05h53m02s873ms 055 640a0032 signal_strength=good    #####信号强度:好
    -1d05h52m27s845ms 055 640a0030 brightness=dark        #####亮度:暗
    -1d05h05m58s933ms 055 640a0032 brightness=medium        #####亮度:中等
    -1d05h04m44s708ms 055 640a0030 brightness=dark
    -1d04h25m24s489ms 055 640a0032 brightness=medium
    -1d04h24m26s409ms 055 640a0030 brightness=dark
    -1d04h23m26s408ms  START
    -1d04h23m22s033ms 064 640a0002 temp=392 volt=4891 +plugged +wifi +wifi_running +wake_lock +sensor brightness=medium
    -1d04h23m03s613ms 064 640a0032 signal_strength=good
    -1d04h22m24s596ms 064 640a0030 brightness=dark
    -1d04h21m06s862ms 064 640a0032 brightness=medium
    -1d04h20m12s489ms 064 640a0030 brightness=dark
    -1d04h05m03s041ms 064 640a0032 brightness=medium
    -1d04h04m01s905ms 064 640a0030 brightness=dark
    -1d04h02m59s330ms 064 640a0032 brightness=medium
    -1d04h01m16s339ms 064 640a0030 brightness=dark
    -1d03h42m54s214ms 064 640a0032 brightness=medium
    -1d03h41m54s516ms 064 640a0030 brightness=dark
-- More  --

数字的左边的是时间线,在这个文件的记录中,电池消耗是以时间为线索的。
中间的 数字 是剩余电池电量,在正常使用情况下,会随着时间减少。
数字的右边表示在该时间发生了什么事,一般都是与耗电相关的事件的重要节点。比如+wake_lock是某个应用获取了唤醒锁,-wake_lock是释放了唤醒锁。+running则表示CPU被某段程序占用,-running则表示该段程序运行完了等等,意思都是比较字面化的。而u0a78等符号则表示应用id,一个id对应一个应用,应用的id列表可以在这个文件内找到。


 楼主| 发表于 2020-9-27 08:40:00 | 显示全部楼层
1. 电池信息查询
adb shell dumpsys battery

Current Battery Service state:
  AC powered: false
  USB powered: true
  Wireless powered: false
  Max charging current: 0
  Max charging voltage: 0
  Charge counter: 0
  status: 2
  health: 2
  present: true
  level: 100
  scale: 100
  voltage: 4395
  temperature: 320
  technology: Li-ion

2. 模拟电池断开充电(Android 6.0以上)
adb shell dumpsys battery unplug

3. 模拟电池为非充电状态
adb shell dumpsys battery set status 1

4. 模拟电池电量
adb shell dumpsys battery set level 100

我经常使用

adb shell dumpsys battery unplug
adb shell dumpsys battery set status 0
adb shell dumpsys battery set level 100
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

技术交流售后群

QQ|小黑屋|手机版|站点找错-建议|AI手机网 |Sitemap



GMT+8, 2024-5-9 11:25 , Processed in 0.144647 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表