利用power_profile.xml獲取Android運行時的能耗

     在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。



    


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章