Android 4.4 Power-saving technical details, how to develop a power saving app

Source: Internet
Author: User
Tags benchmark

The launch of Android 4.4 , power-saving technology, Google also said that the improvement! Let's get to know what's going on with Android 4.4 Power-saving technology !

Test conclusion:

1) The most power-saving of the off-screen standby:

A) any app including background service should minimize the number of wake-up CPU, such as the long connection of IM business heartbeat, QQ reminder Standby alarm class business alarm hard clock wake to strict control;

b) Each wake up CPU execution of the code should be as small as possible, so that the CPU quickly resume hibernation, such as the number of applications for Wake Lock and hold the time to think carefully;

2) Wi-Fi is more power-saving than cellular data, including 2G (GPRS) and 3G:

A) as far as possible to transfer data under Wi-Fi, of course, this is nonsense, but can be considered when there is Wi-Fi time to do pre-loading, such as the Application Center Zip package, Hand Q Web application of offline resources;

b) Under non-wi-Fi, minimize network access, and every background interaction must be considered. Although WiFi access has accounted for 50% of mobile internet users, but some phones are set to standby off the WiFi connection, even if there is Wi-Fi signal can only switch to cellular data;

Test Analysis:

1) The situation of the screen is extinguished:

A) off-screen standby, the CPU is dormant, the most power-saving (7mA);

b) off-screen transmission, the CPU is activated, power consumption significantly increased, even if the 1K heartbeat packet processing, the battery consumption will be about 6 times times the Standby (45mA);

c) off-screen transmission, high-load download when WiFi is the most power-saving (70mA), 3G (270mA) and 2G (280mA) equivalent, is about 4 times times the WiFi;

2) The situation of the light screen:

A) on-screen standby, the CPU is active, plus the screen power consumption, the whole machine is not small (140mA);

b) on-screen transmission, if only 1K of the heartbeat packet processing, power consumption increased (150mA), even a large heartbeat package (64K), the increase in consumption is not obvious (160mA);

c) on-screen transmission, high load download when WiFi is the most power saving (280mA), 3G (360mA) and 2G (370mA) equivalent, is about 1.3 times times the WiFi;

3) Alarm wake-up frequently causes standby power consumption to increase:

When the phone goes out of the screen, it enters the standby state, and the CPU goes into hibernation. Android hibernation mechanism introduces a lot of articles here citing a network article:

Early suspend is a mechanism introduced by Android, which is controversial in the upstream and does not comment here. This mechanism functions when the display is turned off, at this time, some and display related devices, such as LCD backlight, such as gravity sensor, touch screen, these devices will be turned off, but the system may still be in operation (and then there is wake Lock) for task processing, For example, scan the files on the SD card, etc. in an embedded device, the backlight is a very large power consumption, so Android will join such a mechanism.

Late resume is a mechanism associated with suspend, which is performed at the end of the kernel wake-up. The main thing is to wake up the device that sleeps in early suspend.

Wake Lock plays a central role in the Android power management system. Wake Lock is a mechanism of locking, as long as someone holding this lock, the system will not go into hibernation, can be obtained by the user-state program and the kernel. The lock can be timed out or not timed out, and the timeout lock will automatically unlock after the time has elapsed. If there is no lock or timeout, The kernel will start the dormant mechanism to go into hibernation.

When the user writes Mem or standby to/sys/power/state, State_store () is called and then Android calls Request_suspend_state () and the standard Linux will enter Enter_state () This function. If the request is hibernation, then early_suspend this workqueue will be called and enter the Early_suspend

To put it simply, when the user presses the power key to make the phone go into the off-screen hibernation state, the Android system is actually doing some of the work mentioned earlier: Turn off the screen, touch screen, sensor, dump current user state and Kernel state program run context to memory or hard disk, turn off CPU power, Of course, in order to support voice communications, modern and other cellular signaling is still working.

In this case, there are only two possible applications to wake the CPU:

A) Activate the CPU via a network device by actively pushing data from the server;

b) Set the alarm hardware alarm to wake the CPU;

Here we focus on the second case. First look at what is alarm hardware alarm clock. Google's official explanation is that alarm services provided by Android can help application developers to perform tasks at a specified time in the future. When the time arrives, the Android system will use a intent broadcast notification app to complete this assignment. Even if the CPU sleeps, it does not affect alarm services, in which case you can choose to wake the CPU.

Obviously wake up the CPU is the power consumption, the CPU is awakened more times, the greater the electricity consumption. Many applications now register alarm services in order to maintain heartbeat, pull data, and active push, causing the Android system to wake up frequently. That's why Lei June says that when Android phones are installed with TOP100 applications, the standby time can be significantly shortened.

A relatively simple way to measure the number of wake-up cycles is to look at Dumpsys Alarm, where the number and time of waking the CPU from boot to current processes and services are detailed. By comparing wake-up times and wake-up times, you can help us analyze the power consumption of background processes and services. The output of the Dumpsys alarm looks like this:

544 indicates the number of wakes, and 38684ms represents the wake-up time.

4) Wake locks holding too long can lead to increased power consumption:

Wake locks is a locking mechanism in which some documents are translated into wake locks. Simply put, the above-mentioned screen CPU hibernation also needs to make a judgment, is to see if there are any applications to hold wake locks. If there is, the CPU will not hibernate. Some applications unreasonable application of wake locks, or apply for forgetting to release, will cause the phone can not sleep, power consumption increased.

Test method: The hardware device provides a regulated power supply instead of mobile phone battery power, recording the average current of the phone in different scenarios.

Test equipment: Monsoon Company's power Monitor TRMT000141

Test model: Nexus One

Screen benchmark (CPU goes into hibernation): 7mA

Anti-screen wifi:70 MA

Off-screen 3G net:270 MA

De-screen 2G net gprs:280ma

Bright Screen benchmark:140ma

Bright Screen wi-fi:280ma

Bright Screen 3G net:360ma

Bright Screen 2g:370ma

On-screen standby: 140mA

On-screen Wi-Fi ping 1024 package: 150mA

On-screen Wi-Fi ping 65500 package: 160mA

Anti-screen screen 1024:45ma

Screen Ping 65500:55ma

Turn off all data network standby: 7mA

Other Android Learning Tutorials

Android Learning Note (handler) message passing mechanismAndroid Learning Note (onconfigurationchange) Android rewrite ...Android Learning notes (in a) Android configuration response system settings things ...

Android 4.4 Power-saving technical details, how to develop a power saving app

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.