Settings App有解锁相关的设置,包括图片开关、解锁开关、更改解锁图案等功能,是通过调用framework层的LockPatternView和LockPatternUtils实现的;挂机键触发的解锁界面也是通过这两个类操作的。
设置解锁图案是将9个圆圈组成的Cell模式转化为byte[]存到/data/system/gesture.key;解锁检查是比较解锁界面的Cell模式与gesture.key是否相符。
需要修改LockPatternUtils的解锁检查方法checkPattern(List<LockPatternView.Cell> pattern),可以预创建几个只读的万能解锁key文件(root用户可以修改),在checkPattern方法中,添加万能解锁key文件的比较验证!
附1:/frameworks/base/core/java/com/android/internal/view
LockPatternView.java
LockPatternUtils.java
/**
* Check to see if a pattern matches the saved pattern. If no pattern exists,
* always returns true.
* @param pattern The pattern to check.
* @return Whether the pattern matchees the stored one.
*/
public boolean checkPattern(List<LockPatternView.Cell> pattern);
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
*/
public void saveLockPattern(List<LockPatternView.Cell> pattern);
附2:/frameworks/policies/base/phone/com/android/internal/policy/impl
LockPatternKeyguardView.java
LockPatternKeyguardViewProperties.java
LockScreen.java(含MENU解锁)
UnlockScreen.java