Android Power Management System Survey Report-(2)

Source: Internet
Author: User

1
),
Powermanager. Java

This file defines
Powermanager
Class is used by other files.
Nest class
:

Public class wakelock
,
Nest class
There are the following methods:

Public void setreferencecounted (Boolean value)

Public void acquire ()

Public void acquire (long timeout)

Public void release ()

Public void release (INT flags)

Public Boolean isheld ()

Public String tostring ()

@ Override


Protected void finalize () throws throwable

 

The
Nest class
The constructor is as follows:

 
Wakelock (INT flags, string tag)

There is a key parameter.
Flags
It has the following situations:




Partial_wake_lock: screen off, keyboard light off

Screen_dim_wake_lock: screen dim, keyboard light off

Screen_bright_wake_lock: screen bright, keyboard light off

Full_wake_lock: screen bright, keyboard bright

Above 4
Is mutually exclusive, that is, only one of them can be specified, but it can be different from the following two types of flag
Not mutually exclusive:

Acquire_causes_wakeup:
Once a request is locked, it is forcibly opened.
Screen
And
Keyboard light

On_after_release:
When the lock is released
Reset activity timer

 

 

Besides this internal class,
Powermanager
Class is defined as follows:

Public wakelock newwakelock (INT flags, string tag)


//

This method
Return
One
Nest class
. As we can see,
Nest class
Actually completed
Wakelock
Application and release

Public void useractivity (long when, Boolean nochangelights)

Public void Gotosleep (long time)

Public void setbacklightbrightness (INT brightness)

Public int getsupportedwakelockflags ()

Public Boolean isscreenon ()

 

There are two constructor methods for this class:

Private powermanager ()

Public powermanager (ipowermanager service, Handler handler)

2
,
Power. Java

Powermanagerserivive. Java
Some local methods are called.
Java
Layer and
JNI
And declare the local interface.

Public static native void acquirewakelock (INT lock, string ID );


Public static native void releasewakelock (string ID );


Public static native int setscreenstate (Boolean on );


Public static native int setlastuseractivitytimeout (long MS );


@ Deprecated


Public static native void Shutdown ();


 
Public static void reboot (string reason) throws ioexception

 

3
,
Andriod_ow_power.cpp

The local implementation method is written in this file. The local method and
Power. c
Is closely related:

Static jninativemethod method_table [] = {


{"Acquirewakelock", "(iljava/lang/string;) V", (void *) acquirewakelock },


{"Releasewakelock", "(ljava/lang/string;) V", (void *) releasewakelock },


{"Setlastuseractivitytimeout", "(j) I", (void *) setlastuseractivitytimeout },


{"Setscreenstate", "(z) I", (void *) setscreenstate },


{"Shutdown", "() V", (void *) android_ OS _power_shutdown },


{"Rebootnative", "(ljava/lang/string;) V", (void *) android_ OS _power_reboot },

};

 

4
,
Power. c

This file acts
Android
The bottom layer of the system
Linux
Kernel
Power Manager
Interaction.

Static int64_t systemtime ()
;

Static int open_file_descriptors (const char * const paths [])
;

Static inline void initialize_fds (void)
;

Int acquire_wake_lock (INT lock, const char * ID)
;

Int set_last_user_activity_timeout (int64_t delay)
;

Int set_screen_state (INT on)
;

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.