-
開機啓動
在開機過程中無線模塊初始化時獲取SIM卡,狀態。在初始化完成後調用vm.systemReady()函數通知進入相應的LockScreen進行解鎖。
-
在hardware/ril/reference-ril/reference-ril.c中:
通過 setRadioState(RADIO_STATE_SIM_NOT_READY) 來觸發對無線模塊的初始化。
通過 staticvoid onRadioPowerOn() 對無線模塊初始化。
首先通過pollSIMState(Null):輪詢sim卡狀態。
由getSIMStatus()函數獲取sim卡狀態。
2.當系統初始化完成後 會調用wm.systemReady()函數,觸發解鎖界面。
VM:WindowManagerServicewm = null;
由於WM爲空,調用WindowManagerService中函數:
publicvoid systemReady () {
mPolicy.systemReady();
}
mPolicy:final WindowManagerPolicy mPolicy =PolicyManager.makeNewWindowManager();
(以下文件在frameworks/policies/base/phone/com/android/internal/policy/impl中)
3.PolicyManager.makeNewWindowManager(),調用文件PolicyManagerer.java中函數:
publicstatic WindowManagerPolicy makeNewWindowManager() {
returnsPolicy.makeNewWindowManager();
}
4.sPolicy.makeNewWindowManager 調用的是文件Policy.java中函數:
publicPhoneWindowManager makeNewWindowManager() {
returnnew PhoneWindowManagerwv
}
5.PhoneWindowManager 繼承自 WindowManagerPolicy
mPolicy.systemReady()最終調用的是文件 PhoneWindowManager.java中的函數:
publicvoid systemReady();
mKeyguardMediator.onSystemReady();
doKeyguard();
showLocked();
Messagemsg = mHandler.obtainMessage(Show);
mHandler.sendMessage(msg);
發送SHOW消息。
6.public void handleMessage(Message msg) 對 SHOW消息進行了處理。
如果 msg.what等於 SHOW 那麼執行:
handleShow();
privatevoid handleShow()
...
mCallback.onKeyguardShow();
mKeyguardViewManag.show()
7.mKeyguardViewManager.show() 調用的是文件KeyguardViewManager.java 中的函數:
publicsynchronized void show()
...
mKeyguardView =mKeyguardViewProperties.createKeyguardView( mContext, mUpdateMonitor,this);
...
8.mKeyguardViewProperties.createKeyguardView
調用的是文件LockPatternKeyguardViewProperties.java中的函數:
publicKeyguardViewBase createKeyguardView(Context context,
KeyguardUpdateMonitorupdateMonitor,
KeyguardWindowControllercontroller) {
returnnew LockPatternKeyguardView(context, updateMonitor,
mLockPatternUtils,controller);
}
9. new LockPatternKeyguardView 調用了類LockPatternKeyguardView 的構造函數:
publicLockPatternKeyguardView(
Contextcontext,
KeyguardUpdateMonitorupdateMonitor,
LockPatternUtilslockPatternUtils,
KeyguardWindowControllercontroller)
...
mLockScreen= createLockScreen();
addView(mLockScreen);
finalUnlockMode unlockMode = getUnlockMode();
mUnlockScreen= createUnlockScreenFor(unlockMode);
mUnlockScreenMode=unlockMode;
addView(mUnlockScreen);
updateScreen(mMode);
其中getUnlockMode獲得鎖類型,通常有三種:
enumUnlockMode {
Pattern,
SinPIN,
Account
}
createUnlockScreenFor(unlockMode)根據相應的unlockMode而調用對應的解鎖屏。
-
按紅鍵啓動
點擊結束通話鍵(紅鍵),根據action:
TelephonyManager.ACTION_PHONE_STATE_CHANGE和TelephonyManager.EXTRA_STATE_IDLE
調用frameworks/policies/base/phone/com/android/internal/policy/impl/
KeyguardViewMediator.java中函數:
doKeyguard();
privatevoid showLocked() {
if(DEBUG) Log.d(TAG, "showLocked");
//ensure we stay awake until we are finished displaying the keyguard
mShowKeyguardWakeLock.acquire();
Messagemsg = mHandler.obtainMessage(SHOW);
mHandler.sendMessage(msg);
}
發送SHOW消息。
之後轉到“開機啓動”的第六步。
-
其它方式
-
SIM卡狀態改變,當sim卡狀態爲ABSENT
//only force lock screen in case of missing sim if user hasn't gonethrough setup wizard
當sim卡狀態爲PUK_REQUIRED :即輸入PIN失敗。(調用PUK解鎖屏)
-
設置的自動鎖屏時間out
都是通過KeyguardViewMediator.java啓動。