Android standby Process Analysis

Source: Internet
Author: User

 

The following is an analysis of Google source code based on android2.2.

When starting the system, run phonewindowmanager. systemready () (the previous process is not analyzed ). Call keyguardviewmediator. onsystemready () to lock the screen by standby mode and unlock the logic.

Keyguardviewmediator is the Scheduler for the entire unlock/lock screen service. It schedules the actions on the screen lock page and queries the status of the unlock screen., Including the following:

Query the screen lock status and whether the screen is locked or unlocked. phonewindowmanager holds a reference of keyguardviewmediator. When you touch the screen or press a key, phonewindowmanager queries the screen lock status (Lock/unlock) through keyguardviewmediator for different response processing. If the system is locked, system input events are limited.

Responds to power events (black/bright screen ). Determine the status (display or reset) of the screen lock interface ). After the black screen of the mobile phone is displayed, the screen lock page will be displayed immediately, so that the screen can be displayed immediately after the next screen is highlighted without blinking or delay.

Other applications or services can also request to disable lock screen (by calling the setkeyguardenabled (Boolean) method of keyguardviewmediator ). For example, the incoming call interface.

The keyguardviewmediator class is created during windowmanagerpolicy initialization (which is a phonewindowmanager instance in the mobile phone system) and runs on its thread. The screen lock UI is also created and displayed on this thread. The status query API provided by the keyguardviewmediator class can be called by Android. view. windowmanager, Com. android. server. inputmanager is called by other threads. Therefore, these API methods in the keyguardviewmediator class are all synchronized ).

The scheduling operations that keyguardviewmediator can perform include:
1) Light up the screen pokewakelock ();
2) report whether the lock screen permission verification is successful keyguarddone (Boolean );
3) Respond to SIM card status changes and make corresponding adjustments to the screen lock interface onsimstatechanged ().
4) Manage the UI of the scheduling standby lock screen, including displaying handleshow (), hiding handlehide (), resetting handlereset (), and illuminating the screen handlewakewhenready, keyguardviewmediator implements this part of scheduling by holding a keyguardviewmanager.

Keyguardupdatemonitor is a monitor for all events that affect the entire unlock/lock process.(In addition to serving as a monitor, it also plays a role similar to the context. Maybe we should name this class as (keyguardcontext ). It monitors events such as time changes, battery status changes, time zone changes, SIM card status changes, phone status changes, and phone signal changes. It is an observed object in the Observer mode. The observer registers by calling the registerinfocallback (infocallback) and registersimstatecallback (simstatecallback) Methods of keyguardupdatemonitor to observe the changes he is interested in. Keyguardupdatemonitor's observers include keyguardviewmediator, lockscreen, patternunlockscreen, accountunlockscreen, passwordunlockscreen, and simunlockscreen. The observer cancels the observation by calling the removecallback (object) of keyguardupdatemonitor.

Keyguardviewmanager is responsible for managing the creation, display, hide, and reset of the UI interface of the standby screen, and scheduling through a callback keyguardviewcallback notification dispatcher keyguardviewmediator..

Lockpatternkeyguardview (keyguardviewbase) is the host for all screen lock and UI unlocking.. It has two modes: mode. lockscreen and mode. unlockscreen. It is responsible for switching the standby screen that should be displayed according to the current context. It provides a callback to the currently displayed standby screen and processes its callback. If the callback action cannot be handled by itself, it will continue to report it to keyguardviewmediator for processing.
The screen lock interface is lockscreen. The unlock interface includes Sim card unlocking simunlockscreen, patternunlockscreen unlocking patternunlockscreen, password unlocking passwordunlockscreen, and account unlocking accountunlockscreen.

After the unlock is successful, the screen lock process is transferred to keyguardviewmediator's keyguarddone (Boolean, Boolean) for subsequent processes (such as switching to the launcher desktop ).

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.