1. Signal Process:
Brightnesspreference ----> onbinddialogview (getbrightness) ----> showdialog ----> onpreferencetreeclick ----> onprogresschanged (coming in if there is a change) (setbrightness) -----> ondialogclosed ----> contentobserver-mbrightnessobserver -----> onbrightnesschanged (getbrightness ).
2. Related Knowledge points:
Contentobserver-content observer, which is used to observe (capture) database changes caused by a specific URI, and then perform corresponding processing
* Follow these steps to observe a specific URI:
* 1. Create a specific contentobserver derived class. The contentobserver constructor must be reloaded and the onchange () method must be reloaded to process the callback function.
* 2. Use context. getcontentresolover () to obtain the contentresolove object, and then call registercontentobserver () to register the content observer.
* 3. Because the life cycle of contentobserver is not synchronized with activity and service, you need to manually call it if you do not need it.
Unregistercontentobserver () to cancel registration.
*
* Conclusion: contentobserver is mainly used in the following situations:
1. Whether or not the database or data that needs to be frequently checked has changed. It is very economic and time-consuming to operate using threads;
2. perform database events when users do not know, such as sending messages quietly or rejecting text message blacklists;
* Public final void registercontentobserver (URI Uri, Boolean policyfordescendents, contentobserver observer)
* Function: registers a contentobserver derived class instance for the specified URI. When the specified URI changes, the instance object is called back for processing.
* Parameter: URI to be observed (you need to register it in urimatcher; otherwise, this URI does not make sense)
* If policyfordescendents is set to false, exact match is performed.
True indicates that the URI derived from the URI can be matched at the same time.
* Instance of the observer contentobserver derived class
*
*
* Public final void unregistercontentobserver (contentobserver observer)
* Function: Disable the observation of a given Uri.
Parameter: Observer contentobserver's derived class instance
3. Public void onprogresschanged (seekbar, int progress, Boolean fromtouch) -------------------- set the brightness using the progress bar control in manual mode;
Public void oncheckedchanged (compoundbutton buttonview, Boolean ischecked) ----------------- select to adjust the brightness automatically or manually;
Private void setbrightness (INT brightness) ------------- this is set brightness! It calls powermanager (Framework \ base \ core \ Java \ Android \ OS \ powermanager. java) and powermanagerservice (Framework \ base \ service \ Java \ com \ Android \ Server \ powermanagerservice. java) interface to adjust the height. mbuttonlight and mkeyboardlight defined in powermanagerservice are both keyboard lights.
Public void setbacklightbrightness (INT brightness );
(Framework \ base \ service \ Java \ com \ Android \ Server \ lightsservice. Java)
(Framework \ base \ Services \ JNI \ com_android_server_lightsservice.cpp)