利用power_profile.xml获取Android运行时的能耗

来源:互联网 发布:小王子感悟知乎 编辑:程序博客网 时间:2024/06/05 15:17

     在Android手机中,手机每个组件,如CPU、显示屏、GPS、Audio、WiFi、Bluetooth等,运行时的能耗都保存在power_profile.xml文件中。所以我们可以通过读取power_profile.xml文件获取,获得各组件的能耗值。

    我的手机中power_profile.xml的内容:

<span style="font-size:18px;"><span style="font-size:18px;"><?xml version="1.0" encoding="utf-8" ?> - <device name="Android">  <item name="none">0</item>   <item name="screen.on">100</item>   <item name="bluetooth.active">70</item>   <item name="bluetooth.on">1</item>   <item name="bluetooth.at">1</item>   <item name="screen.full">160</item>   <item name="wifi.on">2</item>   <item name="wifi.active">130</item>   <item name="wifi.scan">45</item>   <item name="dsp.audio">30</item>   <item name="dsp.video">90</item> </span>  <span style="font-size:18px;"><item name="radio.active">125</item>   <item name="gps.on">45</item>   <item name="battery.capacity">2300</item>   <item name="radio.scanning">24</item> </span>
<span style="font-size:18px;"></span><pre class="html" name="code" style="margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 24.05px; background-color: rgb(255, 255, 255);"><!-- Current consumed by the radio at different signal strengths, when paging  -->
- <array name="radio.on"> <value>13.0</value> <value>11.0</value> </array>- <array name="cpu.speeds"> <value>598000</value> <!--5.98MHZ--> <value>747500</value> <!--7.475MHZ--> <value>1040000</value> <!--1.04GHZ--> <value>1196000</value> <!--1.1196GHZ--> <value>1300000</value> <!--1.3GHZ--> </array>
<span style="font-size:18px;"></span><pre class="html" name="code" style="margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 24.05px; background-color: rgb(255, 255, 255);"><!-- Power consumption in suspend -->
<item name="cpu.idle">5</item> 
<span style="font-size:18px;"></span><pre class="html" name="code" style="margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 24.05px; background-color: rgb(255, 255, 255);"><!-- Power consumption due to wake lock held -->
<item name="cpu.awake">70</item> 
<span style="font-size:18px;"></span><pre class="html" name="code" style="margin-top: 0px; margin-bottom: 10px; line-height: 24.05px; background-color: rgb(255, 255, 255);"><span style="font-size:18px;"><!-- Power consumption at different speeds --></span>
- <array name="cpu.active"> <value>100</value> <value>120</value> <value>196</value> <value>223</value> <value>240</value> </array> </device></span>

2、获取的方法: 先从手机上获取framework-res.apk,然后使用apktool工具反编译

该文件位于手机目录: /system/framework/framework-res.apk,在linux下进入终端,执行一下命令:

adb  pull  /system/framework/framework-res.apk ./
这样就可以将framework-res.apk拉到本地的电脑上,然后使用反编译工具ApkToolkit进行反编译。


framework-res.apk拖到反编译输入框中。然后点击反编译.apk按钮。

反编译完成后,power_profile.xml在framework-res.apk的目录:/res/xml/power_profile.xml。



    


0 0
原创粉丝点击