Application of mobile phone management "6"--Power management Chapter

Source: Internet
Author: User


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

Description


This article will introduce the Power saving management chapter. This article mainly introduces the power consumption of Android and some technical points that are involved in the "Battery assistant" category in the market right now.



This article will do a summary and analysis of these points of knowledge. Mainly includes:



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 (2S) For example, first take a look at the battery usage of my phone, for example (view in set-up battery):




watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvemhnegh1ywe=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">



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 executes . The higher the frequency. 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 execution (general application execution is normal feel 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. Next, look at what the provincial power assistants have done specifically. Here are the Golden Hill battery doctor's:





Battery Charging method


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



N High-speed charging: (0% ~ 80%) At this stage, the battery can be high-speed charge to the total power of 80%, but still need to carry out a continuous charging talent complete full. (current is strong.) Faster)



n Continuous Charging: (80%~100%) in the state of the battery is about to fill. The charging current will gradually decrease. Make sure the battery is full. (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 not too charged.



(Active electrons.) Longer life)



The following 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 the three charging methods (c for battery capacity):









About trickle charge








"High-speed charging" and "continuous charging" are easier to understand, here is 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. 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 time of the charging process, Baidu Encyclopedia said that this phase usually requires 30-40 minutes.



About "trickle charge" is really necessary, there is a lot of controversy on the Internet. According to Apple's official and Jinshan battery Doctor test. There is still a certain usefulness. This article is introduced here, the interested students can consult the relevant documents on their own. There is no longer much to introduce.









Some of the 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
To be able to do it from those points


Combined with the first section of the squadron power consumption analysis, we have in the energy management of the work to do?



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 (background process restrictions, developer options, system settings, optional)



B. Set non-retention activities (the user destroys each activity after leaving, see "Settings, developer options, setting does not preserve 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 strategy for long connections (green Guardian and 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 in the current popular battery helper applications, but also in accordance with our previous ideas to achieve.



Technology implementation
Screen control


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



N Screen timeout: Settings.System.SCREEN_OFF_TIMEOUT



n Self-adjusting the 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 working cores, depending on the type of CPU. In general, the use of asymmetric multi-processing CPU is able to control, conversely, the use of symmetric multi-processing technology (SMP) of the CPU can not be controlled.



B. The above CPU control requires root authority.



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






CPU Tuning Mode


CPU and IO tuning modes.



Different adjustment modes corresponding performance improvement, power saving effect is not the same





CPU Tuning Mode








? OnDemand (on-demand mode)






Name implies. Adjust CPU frequency on demand, control at the lowest frequency when not operating the phone. Sliding screen or entering the application will quickly increase to the highest frequency, when the spare quickly reduce the frequency. The performance is more stable, but because the frequency change amplitude is too big, the electricity-saving aspect only has the general level.









? powersave (Power saving mode)






According to the minimum frequency set, the most power-saving is also the most turtle speed. There is no use value in everyday life, unless you are in the SETCPU scenario mode, off sleep with this adjustment mode.






? Performance (high performance mode)






And the power-saving mode is reversed. Always run at the maximum recipe frequency set. The most power consumption is also the most just fierce! This mode is also no matter what the daily use value, decisive pass.









? Userspace (user isolation mode)






Strictly speaking, it is not a pattern, it is the setting that agrees with non-kernel processes to control CPU frequency, it is not needed now. SETCPU The official recommendation is, "Do not use this option."






? Conservative (conservative mode)






and OnDemand mode of the FM setting is similar, just have the operation to increase the speed of the CPU frequency is slow, spare quickly reduced frequency, so the name is called Conservative mode, performance is low, the power level is slightly better than OnDemand, with the CPU load increased, frequency gradually rise, in the CPU idle frequency gradually decline, So this setting saves power relative to the OnDemand mode, but the frequency conversion is not smooth enough. So there will be a lag phenomenon.



Overall not recommended



Interactive (interactive mode)






This model is a high-performance version of OnDemand relative to conservative mode. After you start operating the phone. The frequency rises to the highest, resulting in better response times. Spare 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:






/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. The IO scheduling mode is more complex. Here are just a few patterns that are used frequently, part of XDA, Androidforums, Wik1pedia, linuxarchive data)






? NoOp






This scheduling mode merges all the data requests directly into a simple queue.



Not suitable for storage with mechanical structure. Because there is no optimization order. Additional seek time is added. is one of the simplest scheduling modes, ignoring the priority and complexity of IO operations, running one after the other. Assuming a wide range of read and write operations, it will result in reduced efficiency.






? Anticipatory






In fact, this is somewhat similar to the NCQ function of a PC hard drive. Run a pre-measured dispatch. It seems to be able to improve efficiency. Just because its pre-test mechanism will start to prepare the next preprocessing when the process is about to end a read-write operation, it will disrupt the system's normal continuous IO scheduling and reduce the random access efficiency. Very few people to use, not recommended.






? deadline






Name implies. Use the expiration time to sort the order of IO operations. Ensure that the first IO request has the shortest delay time, relative to the write operation. A higher-priority level for read operations. is a better scheduling mode.






? CFQ



The complete fair queue, is a substitute for the anticipatory model, does not have too much to do pre-measurement scheduling, but according to the given process IO priority, directly to assign the sequence of operations. This mode works well on Linux, but may not be the most suitable IO scheduling mode for Android. Too much emphasis on balance. It 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 relatively unstable, that is, may run the highest score. However, the lowest value is also present.









? Sio





Although based on deadline, it does not sort IO operations like noop. So the speed of access is as high as noop. However, there is no excessive optimization of IO operations. Let's say you don't like noop completely out of schedule. can also choose this.






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.









Now the more popular running software is the Quadrant Quadrant and the Super Bunny. 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 phone, its CPU performance is basically not too big fluctuations (except overclocking, set an inappropriate CPU governor, except), so the impact of the software finally results, mainly I/O test and graphics test.






Just said. Android has a read-write caching mechanism.



And some rom/kernel churn. In order to make the ROM or kernel of your own changes in the performance looks very NB, attracting many other people to use, useful for quadrant test, set the Android disk cache larger, so that the score higher. In theory, using larger memory as a disk read-write cache does improve I/O performance, but it also adds to the risk of data loss. Assuming that you have an I/O Scheduler with NoOp, Sio, and no read-write priority adjustments, the data is very likely to never be actually written to the NAND flash.






Therefore, this represents the vast majority of Android users. Strongly discriminated against this part of the rom/kernel churn (mostly domestic, especially the "X" Big, "X" God, etc.) that everyone often hears or mentions. 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 Bunny test is relatively high, especially for the I/O part. The test results have little difference with the CrystalDiskMark on the PC.






This section is 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 available with interfaces. You can use it directly.



Some of the controls on the software have been introduced in mobile acceleration and so on, providing only one idea. Do not make a specific 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 outlines 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 mobile phone lock screen. Clean up unnecessary apps.



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 basic information about the battery. Can be implemented by listening to broadcast Android.intent.action.BATTERY_CHANGED, detailed 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 as we in the implementation of the Battery Assistant software, the relevant code can refer to folder: @/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 that we can use Batterystatsimpl to get the power rating information? In fact, this is not possible for the following reasons:



1) The use of Batterystatsimpl required permission: "Android.permission.BATTERY_STATS", and the system has limited 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. To use can be seen http://mogoweb.net/archives/87.



Estimating Battery Charging time








About battery charge and discharge. Battery manufacturers generally have a calculation model of charge and discharge. 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 big difference.






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






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 more 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 more 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)






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






Here's a brief 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 parts here are the losses in the battery charging process.



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 larger the current at discharge, the higher the temperature. The higher the heat consumption, the more the capacity of the battery will be attenuated with the addition of the battery charge and discharge times. Therefore, in practice the discharge of the battery is not a simple linear relationship. But rather a more complex curve.



The following are typical discharge graphs for lithium batteries:






In battery management software, the battery life of the squadron is estimated. are often divided into two types:



A. Overall endurance (battery life during normal use)



B. Specific situations (for example, how long to 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 the following 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.






All right. The relevant content of power saving is introduced first, welcome the exchange discussion.


Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.



Application of mobile phone management "6"--Power management Chapter


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.