学习笔记,自己记录,如有错望指出,谢谢。
1:开机锁屏流程 main()--->init1---->init2---->ServerThread---->WindowManagerService.systemReady()
(1) main()
判断时间,设置时间,开启性能统计,创建计时器,整理内存,优化内存清理效率,加载library,启动init1
(2) init1()
native方法,启动系统完成后回调init2,进行android service。
(3) init2()
创建一个ServerThread,然后start
(4) ServerThread
一系列service都是在这里被创建和启动.servicemanager在这里add.WindowManagerService在这里被创建,然后被加入到servicemanager中.然后会调用WindowManagerSerivce的systemReady()方法判断是否启动完成.其他service步骤一样.
(5)WindowManagerService
当调用WindowManagerService的systemReady方法时会直接调用PolicyManager类的systemReady方法.实际是调用makeNewWindowManager方法
(6)PolicyManagerer
在这里会调用IPolicy接口的makeNewWindowManager().实际是调用它的实现类Policy.java里面的new PhoneWindowManager()方法.
(7)PhoneWindowManager
找到了systemReady的方法体,最终调用的是这里的systemReady()方法-----> mKeyguardMediator.onSystemReady()
(8)KeyguardViewMediator
doKeyguardLocked()-----> showLocked() -----> handleShow() ----> mKeyguardViewManager.show();
(9)KeyguardViewManager
mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this)
(10)LockPatternKeyguardViewProperties
实际上是调用的这个类new LockPatternKeyguardView.
2.灭屏锁屏流程
(1)PhoneWindowManager.java KeyguardViewMediator.java
screenTurnedOff------>onScreenTurnedoff---->doKeyguardLocked
3.设置的自动锁屏时间out
(1)KeyguardViewMediator.java
Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT);
mHandler.sendMessage(msg);------>doKeyguardLocked
4.SIM卡状态改变,如sim卡状态为ABSENT
(1)KeyguardViewMediator.java
onSimStateChangedGemini(IccCard.State simState, int simId) ---->doKeyguardLocked
5.个性化解锁
(1)禁用自带锁屏
方法:用KeyguardLock类来禁用和启用屏保。
void disableKeyguard ()
Disable the keyguard from showing.
void reenableKeyguard ()
Reenable the keyguard.
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
mKeyguardLock = mKeyguardManager.newKeyguardLock(LOG_TAG);
mKeyguardLock.disableKeyguard()
(2)开机启动初始化
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name=".service.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
(3)启动自定义锁屏
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
registerReceiver(mReceiver, filter);
不要忘记unregister,否则内存泄露
(4)屏蔽HOME键
<category android:name="android.intent.category.HOME" />
默认改为自定义的
(5)解锁
1:开机锁屏流程 main()--->init1---->init2---->ServerThread---->WindowManagerService.systemReady()
(1) main()
判断时间,设置时间,开启性能统计,创建计时器,整理内存,优化内存清理效率,加载library,启动init1
(2) init1()
native方法,启动系统完成后回调init2,进行android service。
(3) init2()
创建一个ServerThread,然后start
(4) ServerThread
一系列service都是在这里被创建和启动.servicemanager在这里add.WindowManagerService在这里被创建,然后被加入到servicemanager中.然后会调用WindowManagerSerivce的systemReady()方法判断是否启动完成.其他service步骤一样.
(5)WindowManagerService
当调用WindowManagerService的systemReady方法时会直接调用PolicyManager类的systemReady方法.实际是调用makeNewWindowManager方法
(6)PolicyManagerer
在这里会调用IPolicy接口的makeNewWindowManager().实际是调用它的实现类Policy.java里面的new PhoneWindowManager()方法.
(7)PhoneWindowManager
找到了systemReady的方法体,最终调用的是这里的systemReady()方法-----> mKeyguardMediator.onSystemReady()
(8)KeyguardViewMediator
doKeyguardLocked()-----> showLocked() -----> handleShow() ----> mKeyguardViewManager.show();
(9)KeyguardViewManager
mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this)
(10)LockPatternKeyguardViewProperties
实际上是调用的这个类new LockPatternKeyguardView.
2.灭屏锁屏流程
(1)PhoneWindowManager.java KeyguardViewMediator.java
screenTurnedOff------>onScreenTurnedoff---->doKeyguardLocked
3.设置的自动锁屏时间out
(1)KeyguardViewMediator.java
Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT);
mHandler.sendMessage(msg);------>doKeyguardLocked
4.SIM卡状态改变,如sim卡状态为ABSENT
(1)KeyguardViewMediator.java
onSimStateChangedGemini(IccCard.State simState, int simId) ---->doKeyguardLocked
5.个性化解锁
(1)禁用自带锁屏
方法:用KeyguardLock类来禁用和启用屏保。
void disableKeyguard ()
Disable the keyguard from showing.
void reenableKeyguard ()
Reenable the keyguard.
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
mKeyguardLock = mKeyguardManager.newKeyguardLock(LOG_TAG);
mKeyguardLock.disableKeyguard()
(2)开机启动初始化
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name=".service.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
(3)启动自定义锁屏
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
registerReceiver(mReceiver, filter);
不要忘记unregister,否则内存泄露
(4)屏蔽HOME键
<category android:name="android.intent.category.HOME" />
默认改为自定义的
(5)解锁