如何开发/修改屏幕锁

系统屏幕锁的源码在
在framework里面的phone/com/android/internal/policy/impl下面
http://gitorious.org/0xdroid/fra ... nternal/policy/impl这里可以看到源码
LockPatternKeyguardView它负责用来创建LockScreen和UnLockScreen和锁屏的模式(图案、Sim锁之类的)
KeyguardViewMediator就是负责控制锁屏和键盘保护功能

---------------------------------------------------------------------

下面的代码可以用来点亮屏幕
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.SCREEN_DIM_WAKE_LOCK, "SimpleTimer");
mWakelock.acquire();
.......
mWakelock.release();
下面的代码用来屏幕解锁
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock(""); 
keyguardLock.disableKeyguard(); 
使用这两段代码,需要在AndroidManifest文件中加入
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>

---------------------------------------------------------------------

修改framework/base/policy下面的代码,phonewindow.java和lockscreen.java。

---------------------------------------------------------------------

 

你可能感兴趣的:(android)