Mobile Phone Management application Research "6"--Power saving management

Source: Internet
Author: User

Welcome reprint, Reprint please specify:Http://blog.csdn.net/zhgxhuaa

Description

This article will introduce the energy saving management, mainly about the power consumption of Android and the current market "battery helper" class application involves some of the technical points. This article will do a summary and analysis of these points of knowledge. Mainly include:

A. Battery information (power consumption ranking)

B. Power-saving management

C. Remaining available time estimates, etc.


Power consumption analysis
Mobile Phone power consumption analysis

Take my phone (Xiaomi 2S) For example, first look at the battery usage of my phone, such as (view in Settings, Power):




The power consumption of applications in mobile phones can be measured from two levels of hardware and software.

The main hardware level is:

A. Screen (Generally speaking, the larger the screen size, the higher the resolution, the more power consumption per unit of time)

B. CPU (Generally speaking, the more cores the CPU runs , the higher the main frequency, the more power consumption per unit time)

C. Baseband (generally speaking, WiFi power consumption is less than wireless, the network good situation consumes less power than the network poor situation)

At the software level are mainly:

A. Application run (normal application run is considered behavior, is reasonable, but too much push, notification, etc. in the application will cause additional power consumption)

B. Background resident Service (consumes system resources and may be awakened from time to time)

C. Long connection (occupies the baseband, in order to maintain the connection will be timed wake system)

So, the next look at the power-saving assistants are targeted to do what work, the following is the Golden Hill battery Doctor:




Battery Charging method

Next, we'll define a few nouns with the first image above:

N Fast charge: (0% ~ 80%) At this stage, the battery can be quickly charged to the total power of 80%, but still need to carry out a continuous charge to complete full. (strong current, faster)

n Continuous Charging: (80%~100%) when the battery is about to fill, the charging current will gradually decrease, ensuring that the battery is fully charged. (current weakening, slow charging)

N Trickle charge: (100%~100%) The battery is filled with a tiny pulse current charge that keeps the electrons flowing and prolongs battery life, but does not overcharge. (active electrons, longer life)

Here is a cell phone battery charging process:




Here you can see:

Http://www.apple.com/cn/batteries/iphone.html

http://www.apple.com/cn/batteries/

Http://www.apple.com/cn/iphone/battery.html


A comparison of these three modes of charging (c for battery capacity):




About trickle charge


"Fast charging" and "continuous charging" are easier to understand, so here's a simple "trickle charge". So why do trickle charge? In fact, it is mainly based on the following two considerations:

A. Some of the efficiency losses that occur during battery charging are used to compensate for the loss of capacity due to self-discharge when the battery is fully charged.

B. The battery is filled with a small current charge that keeps the electrons flowing and prolongs battery life.

Trickle charging process generally accounted for about 20% of the charging process time, Baidu Encyclopedia said this phase usually takes 30-40 minutes.

There is a lot of debate online about whether trickle charging is really necessary. According to the official Apple and Jinshan Battery doctor test, there is a certain use. This article is introduced here, interested students can consult the relevant information, here no longer introduce too much.

Some references in this section:

Http://wenku.baidu.com/view/44709e1da76e58fafab0038e.html

Http://wenku.baidu.com/view/c0882e15a2161479171128b8.html

Http://baike.baidu.com/view/206627.htm

Http://baike.baidu.com/view/10022.htm


Power Saving Management
You can do it from those points.

Combined with the first section of the squadron power consumption analysis, we have in the energy management of those jobs can be done?

n from the hardware level:

A. Screen: Screen brightness, screen timeout

B. CPU:CPU frequency, sleep mode

C. Baseband: WiFi, Bluetooth, 3G network, Sync, GPS

n from the software level:

A. Background process restrictions (see System settings, developer options, background process restrictions)

B. Set non-reserved activities (the user destroys each activity after leaving, see "Settings, developer options, set not to retain activity")

C. Kill the background resident process and clean up memory by banning boot-up, background self-booting.

D. Killing background processes through process cleanup and cleaning up memory (lock screen cleanup, scheduled cleanup)

E. Snap-to-wake policy for long connections (green Guardian and Xiaomi V5)

F. Limit wake-up locks.

N Other:

A. Turn off vibration

B. Turn off the touch (vibrate on touch, touch beep)

C. Adjust the system volume appropriately

D. System animations

The following features are implemented in the battery helper:




It can be seen that the current popular battery helper applications, but also in accordance with our previous ideas.


Technology implementation
Screen control

Screen-related can be directly called System Settingsprovider to set, the specific settings are:

N Screen timeout: Settings.System.SCREEN_OFF_TIMEOUT

n Automatically adjusts screen brightness: Settings.System.SCREEN_BRIGHTNESS_MODE;

The values are: screen_brightness_mode_manual = 0 and screen_brightness_mode_automatic= 1

n Screen Brightness: Settings.System.SCREEN_BRIGHTNESS


CPU Frequency Control


The frequency control of the CPU mainly involves three aspects:

N CPU Working Core number

by/sys/devices/system/cpu[id]/cpu1/online

N CPU Mode

by/sys/devices/system/cpu/cpu[id]/cpufreq/scaling_governor

N CPU Frequency

Supported Frequencies:/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

Current Core frequency:/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Maximum Operating frequency:/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

Minimum operating frequency:/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

Here are a few things to note:

A. Not all CPUs can control the number of cores, depending on the type of CPU, in general, the use of asymmetric multi-processor CPU is controllable, whereas the use of symmetric multi-processing technology (SMP) of the CPU is not controllable.

B. The above CPU control requires root privileges.

C. CPU limit frequency, etc. is required by the root authority to achieve.


CPU Tuning Mode

CPU and IO tuning modes. Different adjustment modes corresponding to the performance improvement, power saving effect is not the same


CPU Tuning Mode


? OnDemand (on-demand mode)

As the name implies, adjust the CPU frequency on demand, when not operating the mobile phone control at the lowest frequency, sliding screen or enter the application will quickly increase to the highest frequency, when idle quickly reduce the frequency, performance is stable, but because of the frequency change amplitude is too large, power-saving only the general level.

? powersave (Power saving mode)

According to set the lowest frequency operation, the most power-saving also the most turtle speed, daily no use value, unless combined with SETCPU scenario mode, off sleep when using this adjustment mode.

? Performance (high performance mode)

and power saving mode, in contrast, always set the highest recipe frequency run, the most power consumption is also the most just fierce! This mode also does not have any daily use value, decisive pass.

? Userspace (user isolation mode)

Strictly speaking it is not a pattern, is to allow non-kernel process control CPU frequency setting, now no longer need it, setcpu the official recommendation is, "Do not use this option."

? Conservative (conservative mode)

and OnDemand mode of the FM set similar, but there is the operation of the speed of the CPU to increase the frequency of slow, idle fast down, so the name is conservative mode, low performance, less than the power of OnDemand, with the CPU load increases, frequency gradually rise, in the CPU idle frequency gradually decline, Therefore, this setting is compared to the OnDemand mode power saving, but the frequency conversion is not smooth enough, so there will be a lag phenomenon. Overall not recommended

Interactive (interactive mode)

In contrast to conservative mode, this model is a high-performance version of the OnDemand, the beginning of the operation of the mobile phone, the frequency of the highest, can provide better response speed, idle slow down to set the minimum frequency. The power of the natural is also a little more cost.

The settings for the CPU tuning mode can be found in the following:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor



I/O tuning mode


(What is the I/O tuning mode?) I/O is the abbreviation of input/output, the data read and write operation, the order of the different process request data priority and so on. Io scheduling mode is more complex, here are only a few common patterns, some reference xda, Androidforums, Wik1pedia, linuxarchive data)

? NoOp

This scheduling mode merges all data requests directly into a simple queue. Not suitable for memory with mechanical structure, because there is no optimization order, it will increase the additional seek time. is one of the simplest scheduling modes, ignoring the priority and complexity of IO operations, executing one after another, and if there is a large variety of read and write operations, it will result in less efficiency.

? Anticipatory

In fact, this is somewhat similar to the NCQ function of the PC hard disk, the execution of a predictable scheduling, it seems to be able to improve efficiency, but because its prediction mechanism in the process will end a read and write operation to start preparing the next preprocessing, it will disrupt the normal continuous IO scheduling, reduce the random access efficiency. The use of people is very small, not recommended.

? deadline

As the name implies, the sequence of IO operations is sorted by the expiration time to ensure that the first IO request has the shortest delay time, relative to the write operation, to the level of priority for the read operation. is a better scheduling mode.

? CFQ

The complete fair queue, which is an alternative to the anticipatory model, does not have too much predictive scheduling, but rather assigns the sequence of operations directly to the given process IO priority. This mode performs well on Linux, but may not be the most suitable IO scheduling mode for Android, which emphasizes equalization and reduces the performance of continuous read and write data.

? VR

With deadline similar to the operation sequencing mechanism, with the highest peak read and write speed, but the performance is not stable, that is, may run the highest score, but also the lowest value.

? Sio

Although based on deadline, it does not sort IO operations like noop, so it has the same fast access speed as NOOP, but does not optimize IO operations much. You can also choose this if you do not like the NoOp to participate completely in scheduling.

The settings for I/O scheduler can be found in:

/sys/block/{device-name}/queue/scheduler




Speaking of I/O Scheduler, I have to mention all kinds of "running points" software at the same time.

At present, the popular running software is Quadrant Quadrant and Super Bunny evaluation. The former test results are very inaccurate, but most people still use the software test scores as a measure of Android device performance standards.

In view of the current Android phones, its CPU performance is basically not too big fluctuations (except overclocking, set an inappropriate CPU governor, except), so affect the final results of the software, mainly I/O testing and graphics testing.

Just said, Android has a read-write caching mechanism. And some rom/kernel modifier, in order to let their own modified ROM or kernel performance looks very NB, to attract more people to use, deliberately for the quadrant Test, set the Android disk cache larger, so that the score higher. In theory, using larger memory as a disk read-write cache can actually improve I/O performance, but this also increases the risk of data loss, if the I/O Scheduler with NoOp, Sio, and no read-write priority adjustments, It is likely that the data will never be actually written to the NAND flash.

Therefore, on behalf of the vast majority of Android users, strongly despise this part of the rom/kernel modifier (most of them are domestic, especially the "X" Big, "X" God, etc.) that are often heard or referred to. Technology is not as scary as people, and the use of beggar means to achieve the goal is rather shameless.

The accuracy of the Super rabbit evaluation is relatively high, especially for the I/O part of the test, the test results and the PC on the CrystalDiskMark and other software gap is small.

This paragraph is for reference from: http://bbs.gfan.com/android-3588731-1-1.html


Network control

In the Battery Assistant network control mainly refers to the control of 3G data, WIFI, Bluetooth and other switches, these systems are provided by the interface, direct use can be.

Some of the control measures for the software are already in the mobile phone acceleration, and so on, here is only a thought, not to do a detailed introduction.


Software Layer Control

The previous sections focus on power-saving controls from the hardware level of the screen, CPU, and network, and this section provides a brief look at what you can do from a system and software level.

A. Control the Standby function (switch off unnecessary peripherals in standby mode, the standby power of the general platform can be controlled in 3-5ma).

B. When the phone lock screen, clean up unnecessary applications.

C. Control the use of partial-type Wakelock locks in the frame layer.

D. Control the frequency of the system-level RTC Alarm Wakeup System.

E. Timing mode Switching, etc.


Battery information
Get Battery basic information

Get the basic information of the battery, can listen to broadcast Android.intent.action.BATTERY_CHANGED implementation, specific implementation code can refer to:

@/package/app/settings/src/com/android/settings/batteryinfo.java




Get Power Rating Information


In the Android system setup has the application and subsystem power consumption ranking statistics, can be used as our reference when implementing the Battery Assistant software, the relevant code can refer to the directory: @/package/app/settings/src/com/android/settings/ fuelguage/.

Battery-related statistics are implemented by the class Batterystatsimpl service, and the way to get Batterystatsimpl is as follows:




Is it possible for us to use Batterystatsimpl to get the power rating information? In fact, this is not possible for the following reasons:

1) Use the Batterystatsimpl required permissions: "Android.permission.BATTERY_STATS", and the system is limited to it, non-system applications are unable to use Batterystatsimpl.

2) When developing an application through eclipse, it is not possible to drink the class in the com.android.internal package because ADT excludes it. See http://mogoweb.net/archives/87 If you want to use it .


Estimating Battery Charging time


Battery charging and discharging, the manufacturers of batteries will generally have a charge and discharge calculation model. That is, different manufacturers of battery products charge and discharge curve will have a difference. Different battery technology before the charge and discharge curve may be large differences (such as Ni-CD batteries and lithium batteries), the same technology of the battery different manufacturers will not be too large.

Here is a calculation model that I found on the internet to estimate the time spent on battery charging, and I am not sure whether it is completely reliable, as a reference, because the battery-related technology is not particularly familiar.

1, charging current is less than equal to 5% of the battery capacity: Charging time (hours) = battery capacity (MAH) x1.6÷ charge current (MA)

2, charging current is greater than 5% of the battery capacity, less than or equal to 10%: Charging time (hours) = battery capacity (MAH) x1.5÷ charge current (MA)

3, charging current is greater than 10% of the battery capacity, less than or equal to 15%: Charging time (hours) = battery capacity (MAH) x1.3÷ charge current (MA

4, charging current greater than 15% of the battery capacity, less than or equal to 20% when charging time (hours) = battery capacity (MAH) x1.2÷ charge current (MA)

5, charging current greater than 20% of the battery capacity: Charging time (hours) = battery capacity (MAH) x1.1÷ charge current (MA)

Reference: http://wenku.baidu.com/view/c0882e15a2161479171128b8.html

Here's a quick introduction to why the battery capacity (MAH) is behind a factor greater than 1 in the above model: in fact, here more than 1 of the part is the battery charging process loss.


Estimating Battery life


Simple battery life Calculation model: battery life = battery capacity/battery discharge current. In fact, the battery life will also be affected by temperature and battery use time, discharge and other factors. The higher the current in the discharge, the higher the temperature, the higher the heat consumption, and the constant attenuation of the battery capacity as the number of charge and discharge increases. Therefore, in practice, the battery discharge is not a simple linear relationship, but a more complex curve. Here are typical discharge graphs for lithium batteries:




In the Battery Management Software Squadron battery Life estimates are often divided into two types:

A. Overall endurance (battery life during normal use)

B. Specific situations (such as how long you can watch video, how long 3G calls, how long to surf the internet)

Either way, the data we need to estimate the battery life is the same: battery power and current consumption. The consumption of current in Android is defined in the file @/frameworks/base/core/res/res/xml/power_profile.xml, and here is a fragment:

@/frameworks/base/core/res/res/xml/power_profile.xml




This information can be obtained through @/frameworks/base/core/java/com/android/internel/os/powerprofile.java.


Well, the relevant information about the power saving first introduced these, welcome to exchange discussions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.