开机启动
在开机过程中无线模块初始化时获取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启动。