歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android開機鎖屏流程分析

Android開機鎖屏流程分析

日期:2017/3/1 9:57:38   编辑:Linux編程

Android開機鎖屏流程:

首先:手機開機時,在SystemServer類的init2()方法中會啟動線程類ServerThread的run方法如下:

WindowManagerService wm = null; ...

try {

wm.systemReady(); //調用WindowManagerService的systemReady()方法。

2.WindowManagerService.java

mPolicy.systemReady(); //調用PhoneWindowManager .java中的systemReady方法。

phoneWindowManager.java中:

mKeyguardMediator.onSystemReady(); //進行待機鎖屏及解鎖邏輯


3. KeyguardViewMediator.java

中的onSystemReady()方法中:

doKeyguardLocked();

中的showLocked()方法:

mShowKeyguardWakeLock.acquire(); //確保屏幕處於喚醒狀態

Message msg = mHandler.obtainMessage(SHOW);

mHandler.sendMessage(msg);

發送異步消息:

執行handleShow(); 方法。

handleShow方法中調用:

mKeyguardViewManager.show();

在這個show方法中:

mKeyguardView = mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this);

這個createKeyguardView方法是調用的LockPatternKeyguardViewProperties.java中createKeyguardView方法:

c reateKeyguardView方法構建一個LockPatternKeyguardView();

4.LockPatternKeyguardView();

在這個構造方法中調用了keyguardScreenCallback()方法,

調用updateScreen(getInitialMode(), false); //getInitialMode獲取是鎖屏還是解鎖界面

假如是解鎖的話調用recreateUnlockScreen()方法,

這個方法中 addView(mUnlockScreen);//將UnlockScreen添進LockPatternKeyguardView

然後調用createUnlockScreenFor()方法,

在這個方法中裡判斷解鎖方式。

其中的這個方法initializeBiometricUnlockView(unlockView);

用來初始化人臉解鎖,

以上,LockScreen或者UnlockScreen就創建出來了,當然,只是創建了相應對象,還得再顯示。

5.再次回到KeyguardViewManager類的show方法,在執行完該方法中的 的mKeyguardView = mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this)代碼流程後,接著執行mKeyguardView.show(),即調 用KeyguardViewBase的實現類LockPatternKeyguardView的show方法,如下:

@Override

public void show() {

// Emulate activity life-cycle for both lock and unlock screen.

if (mLockScreen != null) {

((KeyguardScreen) mLockScreen).onResume();

}

if (mUnlockScreen != null) {

((KeyguardScreen) mUnlockScreen).onResume();

}

if (mBiometricUnlock != null && mSuppressBiometricUnlock) {

mBiometricUnlock.hide();

}

}

開機鎖屏的大致流程就是這樣了。

更多Oracle相關信息見Oracle 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=12

Copyright © Linux教程網 All Rights Reserved