android锁屏创建流程
本文简单分析,android启动之后,锁屏界面启动过程。android系统开机后会运行PhoneWindowManage管理系统相关按键和事件,
看下PhoneWindowManager锁屏相关
1.Pwm初始化KeyguardViewMediator类,用来接受PhoneWindowManager传递相关事件
[java]
<PRE class=java name="code"> /** {@inheritDoc} */
public void init(Context context, IWindowManager windowManager,
WindowManagerFuncs windowManagerFuncs,
LocalPowerManager powerManager) {
mContext = context;
mWindowManager = windowManager;
mWindowManagerFuncs = windowManagerFuncs;
mPowerManager = powerManager;
<SPAN style="COLOR: #ff0000"> mKeyguardMediator = new KeyguardViewMediator(context, this, powerManager);
</SPAN> ........}</PRE><BR>
<PRE></PRE>
<P>2.系统启动完成会调用SystemReady函数,进入锁屏流程</P>
<PRE class=java name="code"> /** {@inheritDoc} */
public void systemReady() {
// tell the keyguard
<SPAN style="COLOR: #ff0000"> mKeyguardMediator.onSystemReady();
</SPAN> android.os.SystemProperties.set("dev.bootcomplete", "1");
synchronized (mLock) {
updateOrientationListenerLp();
mSystemReady = true;
mHandler.post(new Runnable() {
public void run() {
updateSettings();
}
});
}
}</PRE>
<P>3.KeyguradMediator中onSystemReady函数</P>
<PRE class=java name="code"> /**
* Let us know that the system is ready after startup.
*/
public void onSystemReady() {
synchronized (this) {
if (DBG_WAKE) Log.d(TAG, "onSystemReady");
mSystemReady = true;
doKeyguardLocked();
}
}</PRE>
<P><BR>
4.doKeyguardLocked进入锁屏判断,是否有第三方锁屏应用文件。</P>
<PRE class=java name="code"> /**
* Enable the keyguard if the settings are appropriate. Return true if all
* work that will happen is done; returns false if the caller can wait for
* the keyguard to be shown.
*/
private void doKeyguardLocked() {
// if another app is disabling us, don't show
if (!mExternallyEnabled && !mUpdateMonitor.DM_IsLocked()) {
if (DEBUG) Xlog.d(TAG, "doKeyguard: not showing because externally disabled");
// note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes
// for an occasional ugly flicker in this situation:
// 1) receive a call with the screen on (no keyguard) or make a call
// 2) screen times out
// 3) user hits key to turn screen back on
// instead, we reenable the keyguard when we know the screen is off and the call
// ends (see the broadcast receiver below)
// TODO: clean this up when we have better support at the window manager level
// for apps that wish to be on top of the keyguard
return;
}
// if the keyguard is already showing, don't bother
if (mKeyguardViewManager.isShowing()) {
if (DEBUG) Xlog.d(TAG, "doKeyguard: not showing because it is already showing");
return;
}
// if the setup wizard hasn't run yet, don't show
final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim",
false);
final boolean provisioned = mUpdateMonitor.isDeviceProvisioned();
final IccCard.State state = mUpdateMonitor.getSimState(Phone.GEMINI_SIM_1);
final IccCard.State stateGemini = mUpdateMonitor.getSimState(Phone.GEMINI_SIM_2);
boolean lockedOrMissing = state.isPinLocked()
|| state == IccCard.State.PERM_DISABLED
&& requireSim;
boolean lockedOrMissingGemini = stateGemini.isPinLocked()
|| stateGemini == IccCard.State.PERM_DISABLED
&& requireSim;
if (FeatureOption.MTK_GEMINI_SUPPORT){
lockedOrMissing = lockedOrMissing || lockedOrMissingGemini;
}
boolean keyguardisable = mLockPatternUtils.isLockScreenDisabled();
 
补充:移动开发 , Android ,