Wake-up Lock Wakelock

Source: Internet
Author: User

The essence of the application power consumption is that the enabled hardware is consuming electricity.
Power consumption unit of mobile phone
CPU: Application Processor (AP) and baseband processor (BB or BP)

GPU (graphics processing unit)

Peripherals: WIFI,BT, GPS,LCD, etc.

The AP is an arm-architected processor for running Android systems;

BP is used to run a real-time operating system (RTOS), and the communication stack runs on the BP RTOs.

Power Consumption comparison:

bp non-talk time energy consumption is basically around 5mA; And the AP as long as the non-dormant state, energy consumption at least 50mA, the implementation of graphics operations will be higher, and LCD, WiFi, etc. higher.

When the phone is in standby, the AP, LCD, WiFi all go to sleep, then the Android application code will stop execution, only the baseband processor (base Band) power consumption.

Why is it so much worse than texting? The answer is that the use of short messages using BP, and using the AP power consumption.


Wakelock mechanism:

In order to ensure the proper execution of critical code in the application, Android provides the API for Wake Lock, which allows the application to have permission to prevent the AP from entering hibernation through code.
Wakelock Blocks the application processor (application Processor) from suspending, ensuring critical code runs, and by interrupting the application processor (application Processor), you can prevent the screen from darkening. After all the Wakelock are released, the system hangs.
PowerManager pm = (powermanager) context.getsystemservice (Context.power_service); WakeLock Scpuwakelock = Pm.newwakelock (
Powermanager.full_wake_lock |
Powermanager.acquire_causes_wakeup, "Oktag");

if (scpuwakelock!= null) {

Scpuwakelock.release ();

Scpuwakelock = null;

}


Partial_wake_lock: Keep the CPU running, and the screen and keyboard lights may be off.
Screen_dim_wake_lock: Keep the CPU running, allow the screen to be displayed but may be gray, allow to turn off the keyboard light
Screen_bright_wake_lock: Keep the CPU running, keep the screen highlighted, allow the keyboard light to turn off
Full_wake_lock: Keep the CPU running, keep the screen highlighted, and the keyboard lights remain bright
Acquire_causes_wakeup: Does not wake the device, force the screen to be highlighted immediately, the keyboard light is turned on. With one exception, if a notification pops up, the device will wake up.
On_after_release:wakelock is released, maintain the brightness of the screen for a short period of time, reduce the flicker when the WakeLock cycle
If you apply for partial wakelock, the system does not enter sleep even when you press the power key, such as when music is playing; If you apply for a different wakelocks, press the Power key and the system will still be in sleep. (See API documentation)

However, if you do not understand the intentions of the Android designer to misuse the wake Lock API, in order to its own program in the background of the normal operation and long time to prevent the AP into hibernation, will become a standby battery killer.

Alarm Manager
Alarmmanage has a alarmmanagerservice, the service program is mainly to maintain the app registered alarm, and always monitor the alarm device, once there is a alarm trigger, or alarm event occurred, Alarmmanagerservice will traverse the alarm list, find the appropriate registration alarm, and issue a broadcast.

The Alarm Manager maintains a CPU wake lock, which guarantees that the phone will be able to handle Alarm broadcasts when it sleeps. Once alarm receiver's onreceive () method is executed, Wake Lock is released quickly. If a service is turned on in receiver, it is possible that the service has not been started and Wake Lock has been released. So this is the time to implement a separate wake lock policy.

There are 4 types of alarm:
1) rtc_wakeup
At the specified moment (when setting the alarm), wake the device to trigger the intent.

2) RTC
Triggers the intent at an explicit time, but does not wake the device.
3) Elapsed_realtime
After booting from the device, if the elapsed time reaches the total time, the intent is triggered, but the device is not awakened. The elapsed time includes any time the device sleeps. Note that the calculation point for the time lapse is since it was last started.
4) Elapsed_realtime_wakeup
When the total elapsed time is reached after the device is booted, the device is awakened and intent is triggered if necessary.

Wake-up Lock Wakelock

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.