Home | History | Annotate | Download | only in tech
      1 page.title=Power Profiles for Android
      2 @jd:body
      3 
      4 <!--
      5     Copyright 2014 The Android Open Source Project
      6 
      7     Licensed under the Apache License, Version 2.0 (the "License");
      8     you may not use this file except in compliance with the License.
      9     You may obtain a copy of the License at
     10 
     11         http://www.apache.org/licenses/LICENSE-2.0
     12 
     13     Unless required by applicable law or agreed to in writing, software
     14     distributed under the License is distributed on an "AS IS" BASIS,
     15     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16     See the License for the specific language governing permissions and
     17     limitations under the License.
     18 -->
     19 <div id="qv-wrapper">
     20   <div id="qv">
     21     <h2>In this document</h2>
     22     <ol id="auto-toc"></ol>
     23   </div>
     24 </div>
     25 
     26 <p>Battery usage information is derived from battery usage statistics and power profile values.</p>
     27 
     28 <h2 id="usage-statistics">Battery Usage Statistics</h2>
     29 
     30 <p>The framework automatically determines battery usage statistics by tracking how long device
     31 components spend in different states. As components (WiFi chipset, Cellular Radio, Bluetooth, GPS,
     32 Display, CPU) change states (OFF/ON, idle/full power, low/high brightness, etc.), the controlling
     33 service reports to the framework BatteryStats service, which collects information over time and
     34 stores it for use across reboots. The service doesnt track battery current draw directly,
     35 but instead collects timing information that can be used to approximate battery
     36 consumption by different components.</p>
     37 
     38 <p>The framework gathers statistics using the following methods:</p>
     39 
     40 <ul>
     41 <li><strong>Push</strong>. Services aware of component changes push state changes to the
     42 BatteryStats service.</li>
     43 <li><strong>Pull</strong>. For components such as the CPU usage by apps, the framework automatically
     44 pulls the data at transition points (such as starting or stopping an activity) to take a
     45 snapshot.</li>
     46 </ul>
     47 
     48 <p>Resource consumption is associated with the application using the resource. When multiple
     49 applications simultaneously use a resource (such as wakelocks that prevent the system from
     50 suspending), the framework spreads consumption across those applications, although not necessarily
     51 equally.</p>
     52 
     53 <p>To avoid losing usage statistics for a shutdown event, which may indicate battery power
     54 consumption problems (i.e. shutdown occurs because the battery reached zero remaining capacity), the
     55 framework flashes statistics approximately every 30 minutes.</p>
     56 
     57 <p>Battery usage statistics are handled entirely by the framework and do not require OEM
     58 modifications.</p>
     59 
     60 <h2 id="profile-values">Power Profile Values</h2>
     61 
     62 <p>Device manufacturers must provide a component power profile that defines the current
     63 consumption value for the component and the approximate the actual battery drain caused by the
     64 component over time. Within a power profile, power consumption is specified in milliamps (mA) of
     65 current draw at a nominal voltage and can be a fractional value specified in microamps (uA). The
     66 value should be the mA consumed at the battery and not a value applicable to a power rail that does
     67 not correspond to current consumed from the battery.</p>
     68 
     69 <p>For example, a display power profile specifies the mA of current required to keep the display on
     70 at minimum brightness and at maximum brightness. To determine the power cost (i.e the battery
     71 drained by the display component) of keeping the display on, the framework tracks the time spent at
     72 each brightness level, then multiplies those time intervals by an interpolated display brightness
     73 cost.</p>
     74 
     75 <p>The framework also multiplies the CPU time for each application by the mA required to run the CPU
     76 at a specific speed. This calculation establishes a comparative ranking of how much battery an
     77 application consumes by executing CPU code (time as the foreground app and total time including
     78 background activity are reported separately).</p>
     79 
     80 <h2 id="component-power">Measuring Component Power</h2>
     81 
     82 <p>You can determine individual component power consumption by comparing the current drawn by the
     83 device when the component is in the desired state (on, active, scanning, etc.) and when the
     84 component is off. Measure the average instantaneous current drawn on the device at a
     85 nominal voltage using an external power monitor, such as a bench power supply or specialized
     86 battery-monitoring tools (such as Monsoon Solution Inc. Power Monitor and Power Tool software).</p>
     87 
     88 <p class="note">
     89 <strong>Note:</strong> Manufacturers often supply information about the current consumed by an
     90 individual component. Use this information if it accurately represents the current drawn from the
     91 device battery in practice. However, validate manufacturer-provided values before
     92 using those values in your device power profile.</p>
     93 
     94 <p>When measuring, ensure the device does not have a connection to an external charge source, such
     95 as a USB connection to a development host used when running Android Debug Bridge (adb). The device
     96 under test might draw current from the host, thus lowering measurements at the battery. Avoid USB
     97 On-The-Go (OTG) connections, as the OTG device might draw current from the device under test.</p>
     98 
     99 <p>Excluding the component being measured, the system should run at a constant level of power
    100 consumption to avoid inaccurate measurements caused by changes in other components. System
    101 activities that can introduce unwanted changes to power measurements include:</p>
    102 
    103 <ul>
    104 <li><strong>Cellular, Wi-Fi, and Bluetooth receive, transmit, or scanning activity</strong>. When
    105 not measuring cell radio power, set the device to airplane mode and enable Wi-Fi or Bluetooth as
    106 appropriate.</li>
    107 <li><strong>Screen on/off</strong>. Colors displayed while the screen is on can affect power draw on
    108 some screen technologies. Turn the screen off when measuring values for non-screen components.</li>
    109 <li><strong>System suspend/resume</strong>. A screen off state can trigger a system suspension,
    110 placing parts of the device in a low-power or off state. This can affect power consumption of the
    111 component being measured and introduce large variances in power readings as the system periodically
    112 resumes to send alarms, etc. For details, see <a href="#control-suspend">Controlling System
    113 Suspend</a>.</li>
    114 <li><strong>CPUs changing speed and entering/exiting low-power scheduler idle state</strong>. During
    115 normal operation, the system makes frequent adjustments to CPU speeds, the number of online CPU
    116 cores, and other system core states such as memory bus speed and voltages of power rails associated
    117 with CPUs and memory. During testing, these adjustments affect power measurements:
    118 
    119 <ul>
    120 <li>CPU speed scaling operations can reduce the amount of clock and voltage scaling of memory buses
    121 and other system core components.</li>
    122 <li>Scheduling activity can affect the percentage of the time CPUs spend in low-power idle states.
    123 For details on preventing these adjustments from occurring during testing, see
    124 <a href="#control-cpu">Controlling CPU Speeds</a>.</li>
    125 </ul>
    126 
    127 </li>
    128 </ul>
    129 
    130 <p>For example, Joe Droid wants to compute the <code>screen.on</code> value for a device. He enables
    131 airplane mode on the device, runs the device at a stable current state, holds the CPU speed constant
    132 , and uses a partial wakelock to prevent system suspend. Joe then turns the device screen off and
    133 takes a measurement (200mA). Next, Joe turns the device screen on at minimum brightness and takes
    134 another measurement (300mA). The <code>screen.on</code> value is 100mA (300 - 200).</p>
    135 
    136 <p>For components that dont have a flat waveform of current consumption when active (such as
    137 cellular radio or Wi-Fi), measure the average current over time using a power monitoring tool.</p>
    138 
    139 <p>When using an external power source in place of the device battery, the system might experience
    140 problems due to an unconnected battery thermistor or integrated fuel gauge pins (i.e. an invalid
    141 reading for battery temperature or remaining battery capacity could shut down the kernel or Android
    142 system). Fake batteries can provide signals on thermistor or fuel gauge pins that mimic temperature
    143 and state of charge readings for a normal system, and may also provide convenient leads for
    144 connecting to external power supplies. Alternatively, you can modify the system to ignore the
    145 invalid data from the missing battery.</p>
    146 
    147 <a name="control-suspend"><h3 id="control-suspend">Controlling System Suspend</h3></a>
    148 
    149 <p>This section describes how to avoid system suspend state when you dont want it to interfere with
    150 other measurements, and how to measure the power draw of system suspend state when you do want to
    151 measure it.</p>
    152 
    153 <h4>Preventing System Suspend</h4>
    154 
    155 <p>System suspend can introduce unwanted variance in power measurements and place system components
    156 in low-power states inappropriate for measuring active power use. To prevent the system from
    157 suspending while the screen is off, use a temporary partial wakelock. Using a USB cable, connect the
    158 device to a development host, then issue the following command:</p>
    159 
    160 <pre>
    161 $ adb shell "echo temporary &gt; /sys/power/wake_lock"
    162 </pre>
    163 
    164 <p>While in wake_lock, the screen off state does not trigger a system suspend. (Remember to
    165 disconnect the USB cable from the device before measuring power consumption.)</p>
    166 
    167 <p>To remove the wakelock:</p>
    168 
    169 <pre>
    170 $ adb shell "echo temporary &gt; /sys/power/wake_unlock"
    171 </pre>
    172 
    173 <h4>Measuring System Suspend</h4>
    174 
    175 <p>To measure the power draw during the system suspend state, measure the value of cpu.idle in the
    176 power profile. Before measuring:
    177 
    178 <ul>
    179 <li>Remove existing wakelocks (as described above).</li>
    180 <li>Place the device in airplane mode to avoid concurrent activity by the cellular radio, which
    181 might run on a processor separate from the SoC portions controlled by the system suspend.</li>
    182 <li>Ensure the system is in suspend state by:
    183 <ul>
    184 <li>Confirming current readings settle to a steady value. Readings should be within the expected
    185 range for the power consumption of the SoC suspend state plus the power consumption of system
    186 components that remain powered (such as the USB PHY).</li>
    187 <li>Checking the system console output.</li>
    188 <li>Watching for external indications of system status (such as an LED turning off when not in
    189 suspend).</li>
    190 </ul>
    191 </li>
    192 </ul>
    193 
    194 <a name="control-cpu"><h3 id="control-cpu">Controlling CPU Speeds</h3></a>
    195 
    196 <p>Active CPUs can be brought online or put offline, have their clock speeds and associated voltages
    197 changed (possibly also affecting memory bus speeds and other system core power states), and
    198 can enter lower power idle states while in the kernel idle loop. When measuring different CPU power
    199 states for the power profile, avoid the power draw variance when measuring other parameters. The
    200 power profile assumes all CPUs have the same available speeds and power characteristics.</p>
    201 
    202 <p>While measuring CPU power, or while holding CPU power constant to make other measurements, keep
    203 the number of CPUs brought online constant (such as having one CPU online and the rest
    204 offline/hotplugged out). Keeping all CPUs except one in scheduling idle may product acceptable
    205 results. Stopping the Android framework with <code>adb shell stop</code> can reduce system
    206 scheduling activity.</p>
    207 
    208 <p>You must specify the available CPU speeds for your device in the power profile cpu.speeds
    209 entry. To get a list of available CPU speeds, run:</p>
    210 
    211 <pre>
    212 adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
    213 </pre>
    214 
    215 <p>These speeds match the corresponding power measurements in value <code>cpu.active</code>.</p>
    216 
    217 <p>For platforms where number of cores brought online significantly affects power consumption, you
    218 might need to modify the cpufreq driver or governor for the platform. Most platforms support
    219 controlling CPU speed using the userspace cpufreq governor and using sysfs interfaces to
    220 set the speed. For example, to set speed for 200MHz on a system with only 1 CPU or all CPUs sharing
    221 a common cpufreq policy, use the system console or adb shell to run the following commands:</p>
    222 
    223 <pre>
    224 echo userspace &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    225 echo 200000 &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
    226 echo 200000 &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    227 echo 200000 &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
    228 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
    229 </pre>
    230 
    231 <p class="note">
    232 <strong>Note</strong>: The exact commands differ depending on the platform cpufreq implementation.
    233 </p>
    234 
    235 <p>These commands ensure the new speed is not outside the allowed bounds, set the new speed, then
    236 print the speed at which the CPU is actually running (for verification). If the current
    237 minimum speed prior to execution is higher than 200000, you might need to reverse the order
    238 of the first two lines, or execute the first line again to drop the minimum speed prior to
    239 setting the maximum speed.</p>
    240 
    241 <p>To measure current consumed by a CPU running at various speeds, use the system console place the
    242 CPU in a CPU-bound loop using the command:</p>
    243 <pre>
    244 # while true; do true; done
    245 </pre>
    246 
    247 <p>Take the measurement while the loop executes.</p>
    248 
    249 <p>Some devices can limit maximum CPU speed while performing thermal throttling due to a high
    250 temperature measurement (i.e. after running CPUs at high speeds for sustained periods). Watch for
    251 such limiting, either using the system console output when taking measurements or by checking the
    252 kernel log after measuring.</p>
    253 
    254 <p>For the <code>cpu.active</code> value, measure the power consumed when the system is not in
    255 suspend and not executing tasks. The CPU should be in a low-power scheduler <em>idle loop
    256 </em>, possibly executing an ARM Wait For Event instruction or in an SoC-specific low power state
    257 with a fast exit latency suitable for idle use. Your platform might have more than one idle state in
    258 use with differing levels of power consumption; choose a representative idle state for
    259 longer periods of scheduler idle (several milliseconds). Examine the power graph on your measurement
    260 equipment and choose samples where the CPU is at its lowest consumption, discarding higher samples
    261 where the CPU exited idle.</p>
    262 
    263 <h3 id="screen-power">Measuring Screen Power</h3>
    264 
    265 <p>When measuring screen on power, ensure that other devices normally turned on when the screen is
    266 enabled are also on. For example, if the touchscreen and display backlight would normally be on when
    267 the screen is on, ensure these devices are on when you measure to get a realistic example of screen
    268 on power usage.</p>
    269 
    270 <p>Some display technologies vary in power consumption according to the colors displayed, causing
    271 power measurements to vary considerably depending on what is displayed on the screen at the time of
    272 measurement. When measuring, ensure the screen is displaying something that has power
    273 characteristics of a realistic screen. Aim between the extremes of an all-black screen (which
    274 consumes the lowest power for some technologies) and an all-white screen. A common choice is a view
    275 of a schedule in the calendar app, which has a mix of white background and non-white elements.</p>
    276 
    277 <p>Measure screen on power at <em>minimum</em> and <em>maximum</em> display/backlight brightness.
    278 To set minimum brightness:</p>
    279 
    280 <ul>
    281 <li><strong>Use the Android UI</strong> (not recommended). Set the Settings > Display Brightness
    282 slider to the minimum display brightness. However, the Android UI allows setting brightness only to
    283 a minimum of 10-20% of the possible panel/backlight brightness, and does not allow setting
    284 brightness so low that the screen might not be visible without great effort.</li>
    285 <li><strong>Use a sysfs file</strong> (recommended). If available, use a sysfs file to control panel
    286 brightness all the way down to the minimum brightness supported by the hardware.</li>
    287 </ul>
    288 
    289 <p>Additionally, if the platform sysfs file enables turning the LCD panel, backlight, and
    290 touchscreen on and off, use the file to take measurements with the screen on and off. Otherwise,
    291 set a partial wakelock so the system does not suspend, then turn on and off the
    292 screen with the power button.</p>
    293 
    294 <h3 id="wifi-power">Measuring Wi-Fi Power</h3>
    295 
    296 <p>Perform Wi-Fi measurements on a relatively quiet network. Avoid introducing additional work
    297 processing high volumes of broadcast traffic that is unrelated to the activity being measured.</p>
    298 
    299 <p>The <code>wifi.on</code> value measures the power consumed when Wi-Fi is enabled but not actively
    300 transmitting or receiving. This is often measured as the delta between the current draw in
    301 system suspend (sleep) state with Wi-Fi enabled vs. disabled.</p>
    302 
    303 <p>The <code>wifi.scan</code> value measures the power consumed during a Wi-Fi scan for access
    304 points. Applications can trigger Wi-Fi scans using the WifiManager class
    305 <a href = "http://developer.android.com/reference/android/net/wifi/WifiManager.html">
    306 <code>startScan()</code>API</a>. You can also open Settings &gt; Wi-Fi, which performs access point
    307 scans every few seconds with an apparent jump in power consumption, but you must subtract screen
    308 power from these measurements.</p>
    309 
    310 <p class="note">
    311 <strong>Note</strong>: Use a controlled setup (such as
    312 <a href="http://en.wikipedia.org/wiki/Iperf">iperf</a>) to generate network receive and transmit
    313 traffic.</p>
    314 
    315 <h2 id="device-power">Measuring Device Power</h2>
    316 
    317 <p>You can determine device power consumption for Android devices that include a battery fuel gauge
    318 such as a Summit SMB347 or Maxim MAX17050 (available on many Nexus devices). Use the in-system
    319 battery fuel gauge when external measurement equipment is not available or is inconvenient to
    320 connect to a device (such as in mobile usage).</p>
    321 
    322 <p>Measurements can include instantaneous current, remaining charge, battery capacity at test start
    323 and end, and more depending on the supported properties of the device (see below). For best results,
    324 perform device power measurements during long-running A/B tests that use the same device type with
    325 the same fuel gauge and same current sense resistor. Ensure the starting battery charge is the same
    326 for each device to avoid differing fuel gauge behavior at different points in the battery discharge
    327 curve.</p>
    328 
    329 <p>Even with identical test environments, measurements are not guaranteed to be of high absolute
    330 accuracy. However, most inaccuracies specific to the fuel gauge and sense resistor are consistent
    331 between test runs, making comparisons between identical devices useful. We recommend running
    332 multiple tests in different configurations to identify significant differences and relative power
    333 consumption between configurations.</p>
    334 
    335 <h3 id="power-consumption">Reading Power Consumption</h3>
    336 
    337 <p>To read power consumption data, insert calls to the API in your testing code.</p>
    338 
    339 <pre>
    340 import android.os.BatteryManager;
    341 import android.os.ServiceManager;
    342 import android.content.Context;
    343 BatteryManager mBatteryManager =
    344 (BatteryManager)Context.getSystemService(Context.BATTERY_SERVICE);
    345 Long energy =
    346 mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER);
    347 Slog.i(TAG, "Remaining energy = " + energy + "nWh");
    348 </pre>
    349 
    350 <h3 id="avail-props">Available Properties</h3>
    351 
    352 <p>Android supports the following battery fuel gauge properties:</p>
    353 
    354 <pre>
    355 BATTERY_PROPERTY_CHARGE_COUNTER   Remaining battery capacity in microampere-hours
    356 BATTERY_PROPERTY_CURRENT_NOW      Instantaneous battery current in microamperes
    357 BATTERY_PROPERTY_CURRENT_AVERAGE  Average battery current in microamperes
    358 BATTERY_PROPERTY_CAPACITY         Remaining battery capacity as an integer percentage
    359 BATTERY_PROPERTY_ENERGY_COUNTER   Remaining energy in nanowatt-hours
    360 </pre>
    361 
    362 <p>Most properties are read from kernel power_supply subsystem attributes of similar names.
    363 However, the exact properties, resolution of property values, and update frequency
    364 available for a specific device depend on:</p>
    365 
    366 <ul>
    367 <li>Fuel gauge hardware, such as a Summit SMB347 or Maxim MAX17050.</li>
    368 <li>Fuel gauge-to-system connection, such as the value of external current sense resistors.</li>
    369 <li>Fuel gauge chip software configuration, such as values chosen for average current computation
    370 intervals in the kernel driver.</li>
    371 </ul>
    372 
    373 <p>For details, see the properties available for <a href="#nexus-devices">Nexus devices</a>.</p>
    374 
    375 <h3 id="maxim-fuel">Maxim Fuel Gauge</h3>
    376 
    377 <p>When determining battery state-of-charge over a long period of time, the Maxim fuel gauge
    378 (MAX17050, BC15) corrects for coulomb-counter offset measurements. For measurements made over a
    379 short period of time (such as power consumption metering tests), the fuel gauge does not make
    380 corrections, making the offset the primary source of error when current measurements are too small
    381 (although no amount of time can eliminate the offset error completely).</p>
    382 
    383 <p>For a typical 10mOhm sense resistor design, the offset current should be better than 1.5mA,
    384 meaning any measurement is +/-1.5mA (PCBoard layout can also affect this variation). For example,
    385 when measuring a large current (200mA) you can expect the following:</p>
    386 
    387 <ul>
    388 <li>2mA (1% gain error of 200mA due to fuel gauge gain error)</li>
    389 <li>+2mA (1% gain error of 200mA due to sense resistor error)</li>
    390 <li>+1.5mA  (current sense offset error from fuel gauge)</li>
    391 </ul>
    392 
    393 <p>The total error is 5.5mA (2.75%). Compare this to a medium current (50mA) where the same error
    394 percentages give a total error of 7% or to a small current (15mA) where +/-1.5mA gives a total error
    395 of 10%.</p>
    396 
    397 <p>For best results, we recommend measuring greater than 20mA. Gain measurement errors are
    398 systematic and repeatable, enabling you to test a device in multiple modes and get clean relative
    399 measurements (with exceptions for the 1.5mA offset).</p>
    400 
    401 <p>For +/-100uA relative measurements, required measurement time depends on:</p>
    402 
    403 <ul>
    404 <li><b>ADC sampling noise</b>. The MAX17050 with its normal factory configuration produces +/-1.5mA
    405 sample-to-sample variation due to noise, with each sample delivered at 175.8ms. You can expect a
    406 rough +/-100uA for a 1 minute test window and a clean  3-sigma noise less than 100uA (or 1-sigma
    407 noise at 33uA) for a 6 minute test window.</li>
    408 <li><b>Sample Aliasing because of load variation</b>. Variation exaggerates errors, so for samples
    409 with variation inherent in the loading, consider using a longer test window.</li>
    410 </ul>
    411 
    412 <a name="nexus-devices"><h3>Supported Nexus Devices</h3></a>
    413 
    414 <h5><a name="nexus-5">Nexus 5</a></h5>
    415 
    416 <table>
    417 <tbody>
    418 <tr>
    419 <th>Model</th>
    420 <td>Nexus 5</td>
    421 </tr>
    422 <tr>
    423 <th>Fuel Gauge</th>
    424 <td>Maxim MAX17048 fuel gauge (ModelGauge, no coulomb counter)</td>
    425 </tr>
    426 <tr>
    427 <th>Properties</th>
    428 <td>BATTERY_PROPERTY_CAPACITY</td>
    429 </tr>
    430 <tr>
    431 <th>Measurements</th>
    432 <td>The fuel gauge does not support any measurements other than battery State Of Charge to a
    433 resolution of %/256 (1/256th of a percent of full battery capacity).</td>
    434 </tr>
    435 </tbody>
    436 </table>
    437 
    438 
    439 <h5><a name="nexus-6">Nexus 6</a></h5>
    440 
    441 <table>
    442 <tbody>
    443 <tr>
    444 <th>Model</th>
    445 <td>Nexus 6</td>
    446 </tr>
    447 <tr>
    448 <th>Fuel Gauge</th>
    449 <td>Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10mohm
    450 current sense resistor.</td>
    451 </tr>
    452 <tr>
    453 <th>Properties</th>
    454 <td>BATTERY_PROPERTY_CAPACITY<br>
    455 BATTERY_PROPERTY_CURRENT_NOW<br>
    456 BATTERY_PROPERTY_CURRENT_AVERAGE<br>
    457 BATTERY_PROPERTY_CHARGE_COUNTER<br>
    458 BATTERY_PROPERTY_ENERGY_COUNTER</td>
    459 </tr>
    460 <tr>
    461 <th>Measurements</th>
    462 <td>CURRENT_NOW resolution 156.25uA, update period is 175.8ms.<br>
    463 CURRENT_AVERAGE resolution 156.25uA, update period configurable 0.7s - 6.4h, default 11.25 secs.<br>
    464 CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500uAh (raw coulomb
    465 counter read, not adjusted by fuel gauge for coulomb counter offset, plus inputs from the ModelGauge
    466 m3 algorithm including empty compensation).<br>
    467 CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8nAh.<br>
    468 ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.</td>
    469 </tr>
    470 </tbody>
    471 </table>
    472 
    473 
    474 <h5><a name="nexus-9">Nexus 9</a></h5>
    475 
    476 <table>
    477 <tbody>
    478 <tr>
    479 <th>Model</th>
    480 <td>Nexus 9</td>
    481 </tr>
    482 <tr>
    483 <th>Fuel Gauge</th>
    484 <td>Maxim MAX17050 fuel gauge (a coulomb counter with Maxim ModelGauge adjustments), and a 10mohm
    485 current sense resistor.</td>
    486 </tr>
    487 <tr>
    488 <th>Properties</th>
    489 <td>BATTERY_PROPERTY_CAPACITY<br>
    490 BATTERY_PROPERTY_CURRENT_NOW<br>
    491 BATTERY_PROPERTY_CURRENT_AVERAGE<br>
    492 BATTERY_PROPERTY_CHARGE_COUNTER<br>
    493 BATTERY_PROPERTY_ENERGY_COUNTER</td>
    494 </tr>
    495 <tr>
    496 <th>Measurements</th>
    497 <td>CURRENT_NOW resolution 156.25uA, update period is 175.8ms.<br>
    498 CURRENT_AVERAGE resolution 156.25uA, update period configurable 0.7s - 6.4h, default 11.25 secs.<br>
    499 CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 500uAh.<br>
    500 CHARGE_COUNTER_EXT (extended precision in kernel) resolution 8nAh.<br>
    501 ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.<br>
    502 Accumulated current update period 175.8ms.<br>
    503 ADC sampled at 175ms quantization with a 4ms sample period. Can adjust duty cycle.</td>
    504 </tr>
    505 </tbody>
    506 </table>
    507 
    508 
    509 <h5><a name="nexus-10">Nexus 10</a></h5>
    510 
    511 <table>
    512 <tbody>
    513 <tr>
    514 <th>Model</th>
    515 <td>Nexus 10</td>
    516 </tr>
    517 <tr>
    518 <th>Fuel Gauge</th>
    519 <td>Dallas Semiconductor DS2784 fuel gauge (a coulomb counter), with a 10mohm current sense
    520 resistor.</td>
    521 </tr>
    522 <tr>
    523 <th>Properties</th>
    524 <td>BATTERY_PROPERTY_CAPACITY<br>
    525 BATTERY_PROPERTY_CURRENT_NOW<br>
    526 BATTERY_PROPERTY_CURRENT_AVERAGE<br>
    527 BATTERY_PROPERTY_CHARGE_COUNTER<br>
    528 BATTERY_PROPERTY_ENERGY_COUNTER</td>
    529 </tr>
    530 <tr>
    531 <th>Measurements</th>
    532 <td>Current measurement (instantaneous and average) resolution is 156.3uA.<br>
    533 CURRENT_NOW instantaneous current update period is 3.5 seconds.<br>
    534 CURRENT_AVERAGE update period is 28 seconds (not configurable).<br>
    535 CHARGE_COUNTER (accumulated current, non-extended precision) resolution is 625uAh.<br>
    536 CHARGE_COUNTER_EXT (extended precision in kernel) resolution is 144nAh.<br>
    537 ENERGY_COUNTER is CHARGE_COUNTER_EXT at nominal voltage of 3.7V.<br>
    538 Update period for all is 3.5 seconds.</td>
    539 </tr>
    540 </tbody>
    541 </table>
    542 
    543 
    544 <h2 id="viewing-usage">Viewing Battery Usage Data</h2>
    545 
    546 <p>The <code>dumpsys</code> <code>batterystats</code> command generates interesting statistical data
    547 about battery usage on a device, organized by unique application ID. You can view a history of
    548 battery-related events such as mobile radio state, Wi-Fi and Bluetooth power states, and wakelock
    549 reasons.</p>
    550 
    551 <p>Statistics include:</p>
    552 
    553 <ul>
    554 <li>History of battery-related events</li>
    555 <li>Global statistics for the device</li>
    556 <li>Approximate power use per UID and system component</li>
    557 <li>System UID aggregated statistics</li>
    558 </ul>
    559 
    560 <p>Use the output of the dumpsys command with the
    561 <a href="https://github.com/google/battery-historian">Battery Historian</a> tool to generate HTML
    562 visualizations of power-related events from logs.</p>
    563 
    564 
    565 <h2 id="power-values">Power Values</h2>
    566 <table>
    567 <tr>
    568   <th>Name</th>
    569   <th>Description</th>
    570   <th>Example Value</th>
    571   <th>Notes</th>
    572 </tr>
    573 <tr>
    574   <td>none</td>
    575   <td>Nothing</td>
    576   <td>0</td>
    577   <td></td>
    578 </tr>
    579 
    580 <tr>
    581   <td>screen.on</td>
    582   <td>Additional power used when screen is turned on at minimum brightness.</td>
    583   <td>200mA</td>
    584   <td>Includes touch controller and display backlight. At 0 brightness, not the Android minimum which tends to be 10 or 20%.</td>
    585 </tr>
    586 
    587 <tr>
    588   <td>screen.full</td>
    589   <td>Additional power used when screen is at maximum brightness, compared to screen at minimum brightness.</td>
    590   <td>100mA-300mA</td>
    591   <td>A fraction of this value (based on screen brightness) is added to the screen.on value to compute the power usage of the screen.</td>
    592 </tr>
    593 
    594 <tr>
    595   <td>bluetooth.active</td>
    596   <td>Additional power used when playing audio through bluetooth A2DP.</td>
    597   <td>14mA</td>
    598   <td></td>
    599 </tr>
    600 
    601 <tr>
    602   <td>bluetooth.on</td>
    603   <td>Additional power used when bluetooth is turned on but idle.</td>
    604   <td>1.4mA</td>
    605   <td></td>
    606 </tr>
    607 
    608 <tr>
    609   <td>wifi.on</td>
    610   <td>Additional power used when Wi-Fi is turned on but not receiving, transmitting, or scanning.</td>
    611   <td>2mA</td>
    612   <td></td>
    613 </tr>
    614 
    615 <tr>
    616   <td>wifi.active</td>
    617   <td>Additional power used when transmitting or receiving over Wi-Fi.</td>
    618   <td>31mA</td>
    619   <td></td>
    620 </tr>
    621 
    622 <tr>
    623   <td>wifi.scan</td>
    624   <td>Additional power used when Wi-Fi is scanning for access points.</td>
    625   <td>100mA</td>
    626   <td></td>
    627 </tr>
    628 
    629 <tr>
    630   <td>dsp.audio</td>
    631   <td>Additional power used when audio decoding/encoding via DSP.</td>
    632   <td>14.1mA</td>
    633   <td>Reserved for future use.</td>
    634 </tr>
    635 
    636 
    637 <tr>
    638   <td>dsp.video</td>
    639   <td>Additional power used when video decoding via DSP.</td>
    640   <td>54mA</td>
    641   <td>Reserved for future use.</td>
    642 </tr>
    643 
    644 <tr>
    645   <td>gps.on</td>
    646   <td>Additional power used when GPS is acquiring a signal.</td>
    647   <td>50mA</td>
    648   <td></td>
    649 </tr>
    650 
    651 <tr>
    652   <td>radio.active</td>
    653   <td>Additional power used when cellular radio is transmitting/receiving.</td>
    654   <td>100mA-300mA</td>
    655   <td></td>
    656 </tr>
    657 
    658 <tr>
    659   <td>radio.scanning</td>
    660   <td>Additional power used when cellular radio is paging the tower.</td>
    661   <td>1.2mA</td>
    662   <td></td>
    663 </tr>
    664 
    665 <tr>
    666   <td>radio.on</td>
    667   <td>Additional power used when the cellular radio is on. Multi-value entry, one per signal strength (no signal, weak, moderate, strong).</td>
    668   <td>1.2mA</td>
    669   <td>Some radios boost power when they search for a cell tower and do not detect a signal. These
    670   numbers could all be the same or decreasing with increasing signal strength. If you provide only
    671   one value, the same value will be used for all strengths. If you provide 2 values, the first will
    672   be for no-signal and the second for all other strengths, and so on.</td>
    673 </tr>
    674 
    675 <tr>
    676   <td>cpu.speeds</td>
    677   <td>Multi-value entry that lists each possible CPU speed in KHz.</td>
    678   <td>125000, 250000, 500000, 1000000, 1500000</td>
    679   <td>The number and order of entries must correspond to the mA entries in cpu.active.</td>
    680 </tr>
    681 
    682 <tr>
    683   <td>cpu.idle</td>
    684   <td>Total power drawn by the system when CPUs (and the SoC) are in system suspend state.</td>
    685   <td>3mA</td>
    686   <td></td>
    687 </tr>
    688 
    689 <tr>
    690   <td>cpu.awake</td>
    691   <td>Additional power used when CPUs are in scheduling idle state (kernel idle loop); system is not
    692   in system suspend state.</td>
    693   <td>50mA</td>
    694   <td></td>
    695 </tr>
    696 
    697 <tr>
    698   <td>cpu.active</td>
    699   <td>Additional power used by CPUs when running at different speeds.</td>
    700   <td>100, 120, 140, 160, 200</td>
    701   <td>Set the max speed in the kernel to each of the allowed speeds and peg the CPU at that
    702 speed. The number of entries here correspond to the number of entries in cpu.speeds, in the
    703 same order.</td>
    704 </tr>
    705 
    706 <tr>
    707   <td>battery.capacity</td>
    708   <td>The total battery capacity in mAh.</td>
    709   <td>3000mAh</td>
    710   <td></td>
    711 </tr>
    712 
    713 </table>
    714  
    715 <p>The power_profile.xml file is placed in an overlay in
    716 device///frameworks/base/core/res/res/xml/power_profile.xml</p>
    717 
    718 <h3 id="sample">Sample file</h3>
    719 
    720 <pre>
    721 &lt;!-- Most values are the incremental current used by a feature, in mA (measured at
    722 nominal voltage). OEMs must measure and provide actual values before shipping a device.
    723 Example real-world values are given, but are dependent on the platform
    724 and can vary significantly, so should be measured on the shipping platform with a power meter.
    725 --&gt;
    726 0
    727 200
    728 160
    729 10
    730 &lt;!-- Bluetooth stereo audio playback 10.0 mA --&gt;
    731 1.3
    732 0.5
    733 30
    734 100
    735 12
    736 50
    737 50
    738 75
    739 1.1
    740 &lt;!-- Strength 0 to BINS-1 (4) --&gt;
    741 1.1
    742 
    743 &lt;!-- Different CPU speeds as reported in
    744 /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state --&gt;
    745 
    746 250000  <!-- 250 MHz -->
    747 500000  <!-- 500 MHz -->
    748 750000  <!-- 750 MHz -->
    749 1000000 <!-- 1   GHz -->
    750 1200000 <!-- 1.2 GHz -->
    751 
    752 &lt;!-- Power consumption when CPU is idle --&gt;
    753 3.0
    754 50.1
    755 &lt;!-- Power consumption at different speeds --&gt;
    756 
    757 100 &lt;!-- 250 MHz --&gt;
    758 120 &lt;!-- 500 MHz --&gt;
    759 140 &lt;!-- 750 MHz --&gt;
    760 155 &lt;!-- 1   GHz --&gt;
    761 175 &lt;!-- 1.2 GHz --&gt;
    762 
    763 &lt;!-- This is the battery capacity in mAh --&gt;
    764 3000
    765 &lt;!-- Battery capacity is 3000 mAH (at 3.6 Volts) --&gt;
    766 
    767 </pre>