Android 4.4 power-saving technology details: How to Develop a power-saving app, android4.4

Source: Internet
Author: User
Tags benchmark

Android 4.4 power-saving technology details: How to Develop a power-saving app, android4.4

With the launch of Android 4.4, Google said it had improved its power-saving technology! Let's take a look at the changes in the power-saving technology of Android 4.4!

Test conclusion:

1) screen-off standby power-saving:

A) Any App, including the background Service, should minimize the number of CPU wake-up times, such as the persistent connection heartbeat of IM-type businesses and the alarm hard clock wake-up of QQ reminder standby alarm-type businesses should be strictly controlled;

B) every time the CPU is awakened, the code should be as few as possible, so that the CPU can quickly recover to sleep, such as the number and holding time of applying for a wake lock;

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

A) Try to transmit data in Wi-Fi. Of course this is nonsense, but you can consider pre-loading when Wi-Fi is available, for example, the Application Center zip package and offline resources of mobile Q web applications;

B) network access should be minimized in non-Wi-Fi scenarios, and every background interaction should be considered as required. Although the Wi-Fi access method accounts for 50% of mobile Internet users, some mobile phones are set to disable Wi-Fi connections by standby mode, and even Wi-Fi signals can only be switched to cellular data;

Test Analysis:

1) screen removal:

A) the screen is off for standby, the CPU is in sleep state, and the maximum power consumption (7mA );

B) screen-out transmission. The CPU is activated and the power consumption increases significantly. Even if the 1 K heartbeat packet is processed, the power consumption is about 6 times that of the standby system (45mA );

C) screen-out transmission. During high load download, WiFi is the most energy-efficient (70mA), 3G (270mA) and 2G (280mA), which is about 4 times that of WiFi;

2) on-screen display:

A) bright screen standby, CPU activation, and screen power consumption, the power consumption of the entire machine is not small (140mA );

B) bright screen transmission. If you only process 1 K heartbeat packets, the power consumption will not increase much (150mA), even if it is a large heartbeat packet (64 K ), the consumption increase is not obvious (160mA );

C) for on-screen transmission, Wi-Fi is the most energy-efficient (280mA), 3G (360mA) and 2G (370mA) at high load download, which is about 1.3 times that of WiFi;

3) Frequent Alarm wake-up will increase the standby power consumption:

The phone enters the STANDBY state after the screen is disabled, and the CPU enters the sleep state. There are many articles about the Android sleep mechanism. Here is a network article:

Early suspend is a mechanism introduced by android, which is highly controversial in the upstream and will not be commented here. This mechanism is used to turn off the display. At this time, some display-related devices, such as LCD backlights, such as Gravity Sensors and touch screens, are switched off, however, the system may still be running (at this time, there is also a wake lock) to process tasks, such as scanning files on the SD card. in embedded devices, backlight is a huge power consumption, so android will add such a mechanism.

Late Resume is a mechanism supporting suspend. It is used to wake up the device that is sleeping during Early Suspend.

Wake Lock plays a core role in the Android power management system. wake Lock is a Lock mechanism. As long as someone holds this Lock, the system will not be able to sleep and can be obtained by user State programs and kernels. the lock may be time-out or not time-out, and the lock will be automatically unlocked after the time passes. if there is no lock or timeout, the kernel will start the sleep mechanism to enter sleep.

When the user writes mem or standby to/sys/power/state, state_store () will be called, and Android will call request_suspend_state () here () standard Linux will enter the enter_state () function here. if the request is for sleep, the workqueue early_suspend will be called and enters early_suspend

Simply put, when the user presses the power key to bring the mobile phone to the sleep state of the screen off, the Android system actually did the following work: shut down the screen, touch screen, sensor, dump the current user State and kernel state program running context to memory or hard disk, shut down the CPU power supply, of course, in order to support voice communication, modern and other Cellular Signaling work.

In this case, there are only two possibilities for the application to wake up the CPU:

A) Actively PUSH data through the server and activate the CPU through the network device;

B) set the alarm hardware alarm to wake up the CPU;

Here we will focus on the second situation. First, let's take a look at what is the alarm hardware alarm clock. The official explanation provided by Google is that the alarm services provided by Android can help application developers to execute tasks at a specified time in the future. When the time arrives, the Android system sends an Intent broadcast notification to the application to complete this specified task. Even if the CPU sleep, alarm services are not affected. In this case, you can wake up the CPU.

Obviously, there is a consumption of power to wake up the CPU. The more times the CPU is awakened, the larger the power consumption. Nowadays, many applications register alarm services to different degrees to maintain heartbeat, pull data, and actively PUSH, which causes frequent wake-up of the Android system. This is why Lei Jun said that the standby time is greatly shortened after the Android mobile phone has installed the TOP100 application.

The method for evaluating the number of CPU wake-up operations is to check dumpsys alarm. Here, the number and time of the processes and services that wake up the CPU are recorded in detail. By comparing the number of wake-up times and wake-up time, we can analyze the power consumption of background processes and services. The output of Dumpsys alarm looks like this:

544 indicates the number of wakeups, and Ms indicates the wake-up time.

4) Wake locks will increase power consumption if it takes too long:

Wake locks is a lock mechanism. Some documents translate it into a Wake-up lock. To put it simply, we also need to determine whether any application holds the wake locks when the off-screen CPU sleep. If yes, the CPU will not sleep. Some applications unreasonably apply for wake locks, or apply for forgot to release, will cause the phone to sleep and increase power consumption.

 

Test method: the hardware device provides a regulated power supply to replace the cell phone battery power supply, and records the average current of the mobile phone in different scenarios.

Test Device: Monsoon's Power Monitor TRMT000141

Test Model: Nexus One

Disable benchmark (CPU enters sleep state): 7mA

Screen-off WiFi: 70 mA

Screen removal 3G net: 270 mA

Screen removal 2G net GPRS: 280mA

Bright screen benchmark: 140mA

Bright screen Wi-Fi: 280mA

Bright screen 3G net: 360mA

Bright screen 2G: 370mA

Bright screen Standby: 140mA

Bright screen Wi-Fi ping 1024 packets: 150mA

Bright screen Wi-Fi ping 65500 packets: 160mA

Screen removal 1024: 45mA

Ping 65500: 55mA

Disable all data network Standby: 7mA

Other android tutorials

Android learning notes (57) Handler message passing mechanism android learning notes (56) android rewriting onConfigurationChange... android learning notes (55) android Configuration responding to system settings...

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.