Android Power Management System Survey Report-(1)

Source: Internet
Author: User

The irreconcilable contradiction between handheld devices today is the contradiction between the increasing energy consumption and the bottleneck of battery capacity. Even if this bottleneck is absent, the longer-lasting endurance is also widely applied.
Android
The system is generally used in high-end smart devices, especially for energy consumption.
Android
Power Management System research is necessary.

Android
The system is based on standards
Linux
On the kernel
Linux
Original Kernel
Power Manager
The corresponding file is added to the system
Android
System
Power Manager
Provides underlying service support. Therefore, the research work is carried out at two levels:
Linux
Kernel layer,
Android
System layer.

 

Linux
Kernel layer:


For
Android
Added by the System
Power Manager
There are five files:

Linux-2.6.29/kernel/power/

|-Consoleearlysuspend. c

|-Earlysuspend. c

|-Fbearlysuspend. c

|-Userwakelock. c

|-Wakelock. c

These five files are used together
Linux
Layer
Power Manager
Cabinet and device drivers related to power consumption, directed
Android
Layer provides
Power Manager
. Devices related to power consumption mainly include
LCD
Screen, keyboard, and other devices
LED
Lamp. Because, you should add the corresponding
Power Manager
Function.

In this survey report, only the function functions defined in each file and the interfaces provided up are listed. The specific function calls and the entire
Power Manager
The implementation of cabinets is described in the subsequent research report.

 

1
),
Consoleearlysuspend. c



Function:

Static void console_early_suspend (struct early_suspend * H)
;

Static void console_late_resume (struct early_suspend * H)
;

Static int _ init lele_early_suspend_init (void)
;

Static void
_ Exit
Console_early_suspend_exit (void)
;

 

Data structure:

Static struct early_suspend console_early_suspend_desc = {


. Level =
Early_suspend_level_stop_drawing,


. Suspend =
Lele_early_suspend,


. Resume =
Lele_late_resume,

};

 

2
,
Earlysuspend. c

Function:

Void register_early_suspend (struct early_suspend * Handler)
;

Void unregister_early_suspend (struct early_suspend * Handler );

Static void early_suspend (struct work_struct * work );

Static void late_resume (struct work_struct * work );

Void request_suspend_state (suspend_state_t new_state );

Suspend_state_t get_suspend_state (void );

 

 

Function interfaces for driver:

Export_symbol (register_early_suspend );

Export_symbol (unregister_early_suspend );

 

In
Earlysuspend. h
The file defines the registration interface function:

# Ifdef config_has_earlysuspend

Void register_early_suspend (struct early_suspend * Handler );

Void unregister_early_suspend (struct early_suspend * Handler );

 

3
,
Fbearlysuspend. c



Function:

Static void stop_drawing_early_suspend (struct early_suspend * H );

Static void start_drawing_late_resume (struct early_suspend * H)
;

Static ssize_t wait_for_fb_sleep_show (struct kobject * kobj,



Struct kobj_attribute * ATTR, char * BUF)
;

Static ssize_t wait_for_fb_wake_show (struct kobject * kobj,



Struct kobj_attribute * ATTR, char * BUF)
;

Static int _ init android_power_init (void)
;

Static void
_ Exit
Android_power_exit (void)

 

Main data structure:

Static struct early_suspend stop_drawing_early_suspend_desc = {


. Level =
Early_suspend_level_stop_drawing,


. Suspend =
Stop_drawing_early_suspend,


. Resume =
Start_drawing_late_resume,

};

 

 

All of the above functions call
_ Wake_up
:

In
Sched. c
This function is defined in

/**

 
* _ Wake_up-wake up
Threads blocked on a waitqueue.

 
* @ Q: The waitqueue

 
* @ Mode: Which threads

 
* @ Nr_exclusive: How many
Wake-one or wake-wake threads to wake up

 
* @ Key: is directly passed
To the Wakeup function

 
*/

Void _ wake_up (wait_queue_head_t * q, unsigned int mode,


Int
Nr_exclusive, void * key)

{


Unsigned long flags;


Spin_lock_irqsave (& Q-> lock,
Flags );


_ Wake_up_common (Q,
Mode, nr_exclusive, 0, key );


Spin_unlock_irqrestore (& Q-> lock,
Flags );

}

 

4
,
Userwakelock. c

Static struct
User_wake_lock * lookup_wake_lock_name (const char * Buf, int allocate, long
* Timeoutptr );

Ssize_t wake_lock_show (struct kobject * kobj, struct kobj_attribute
* ATTR, char * BUF );

Ssize_t ssixe_t wake_lock_store (struct kobject * kobj, struct
Kobj_attribute * ATTR,


Const char * Buf,
Size_t N );

Ssize_t wake_unlock_show (struct kobject * kobj, struct
Kobj_attribute * ATTR, char * BUF );

Ssize_t wake_unlock_store (struct kobject * kobj, struct
Kobj_attribute * ATTR,
Const char
* Buf, size_t N );

 

5
,
Wakelock. c

Provided interface functions include:

Export_symbol (wake_lock_init );

Export_symbol (wake_lock_destroy );

Export_symbol (wake_lock );

Export_symbol (wake_lock_timeout );

Export_symbol (wake_unlock );

Export_symbol (wake_lock_active );

 

The above function only provides one
Android Power Manager
The underlying cabinet should be well implemented
Work
Related devices are required.
Driver
And
Android
Layer
Power Manager
The system works well.



Android
System layer

Android
The power management of the layer mainly lies in
Framework
Layer implementation, where
Battery
The management includes the charging and discharging status, power display, and so on, but this part is not within the scope of the survey. The focus of this survey is
LCD
And Related Devices
LED
Status switch.

Related Files include:

/Frameworks/base/services/Java/COM/Android/Server/powermanagerservice. Java

/Platform/frameworks/base/CORE/Java/Android/OS/powermanager. Java

/Platform/frameworks/base/CORE/Java/Android/OS/power. Java

/Frameworks/base/CORE/JNI/android_ OS _power.cpp

/Hardware/libhardware_legacy/power. c

 

Reference a comprehensive
Power Manager
Frame chart, we can see
Power Manager
The core code in
Powermanagerservice. Java
.
Powermanager. Java
Provided class,
Android_ OS _power.cpp
Provides some local methods and
Power. c
The underlying call is completed
Android
System
Power Manager
. For the analysis of this document, see the subsequent research report.

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.