Env:android M 6.0.1
Import Android.os.UserHandle;
Import Com.android.internal.widget.LockPatternUtils;
Import Android.app.admin.DevicePolicyManager;
Lockpatternutils mlockpatternutils = new Lockpatternutils (mcontext);
int userId = Userhandle.myuserid ();
Boolean lockscreendisabled = mlockpatternutils.islockscreendisabled (userId);
Boolean security = Mlockpatternutils.issecure (userId);
Boolean islockpasswordenabled = mlockpatternutils.islockpasswordenabled (userId);
Boolean islockpatternenabled = mlockpatternutils.islockpatternenabled (userId);
Final int quality = mlockpatternutils.getkeyguardstoredpasswordquality (userId);
LOG.D (TAG, "lockscreendisabled =" + lockscreendisabled);
LOG.D (TAG, "security =" + security);
LOG.D (TAG, "islockpasswordenabled =" + islockpasswordenabled);
LOG.D (TAG, "islockpatternenabled =" + islockpatternenabled);
LOG.D (TAG, "quality =" + quality);
Switch (Quality) {
Case Devicepolicymanager.password_quality_numeric:
Case Devicepolicymanager.password_quality_numeric_complex:
if (mlockpatternutils.islockpasswordenabled (userId)) {
LOG.D (TAG, "PIN code Safe Mode");
}
Break
Case Devicepolicymanager.password_quality_alphabetic:
Case Devicepolicymanager.password_quality_alphanumeric:
Case Devicepolicymanager.password_quality_complex:
if (mlockpatternutils.islockpasswordenabled (userId)) {
LOG.D (TAG, "Password Safe Mode");
}
Break
Case devicepolicymanager.password_quality_something:
Case Devicepolicymanager.password_quality_unspecified:
if (mlockpatternutils.islockpatternenabled (userId)) {
LOG.D (TAG, "pattern Safe mode");
}
Break
}
Print Log
[Email protected]:~$ adb logcat-s lockpatternutilshelp
---------beginning of System
---------beginning of Main
Pattern
11-02 14:36:22.721 4896 4896 D lockpatternutilshelp:lockscreendisabled = False
11-02 14:36:22.721 4896 4896 D lockpatternutilshelp:security = True
11-02 14:36:22.721 4896 4896 D lockpatternutilshelp:islockpasswordenabled = False
11-02 14:36:22.721 4896 4896 D lockpatternutilshelp:islockpatternenabled = True
11-02 14:36:22.722 4896 4896 D lockpatternutilshelp:quality = 65536
11-02 14:36:22.722 4896 4896 D lockpatternutilshelp: Pattern Safe Mode
Pin code
11-02 14:37:34.748 4896 4896 D lockpatternutilshelp:lockscreendisabled = False
11-02 14:37:34.748 4896 4896 D lockpatternutilshelp:security = True
11-02 14:37:34.748 4896 4896 D lockpatternutilshelp:islockpasswordenabled = True
11-02 14:37:34.748 4896 4896 D lockpatternutilshelp:islockpatternenabled = False
11-02 14:37:34.748 4896 4896 D lockpatternutilshelp:quality = 131072
11-02 14:37:34.748 4896 4896 D lockpatternutilshelp:pin Code Safe Mode
Password
11-02 14:38:10.930 4896 4896 D lockpatternutilshelp:lockscreendisabled = False
11-02 14:38:10.930 4896 4896 D lockpatternutilshelp:security = True
11-02 14:38:10.930 4896 4896 D lockpatternutilshelp:islockpasswordenabled = True
11-02 14:38:10.930 4896 4896 D lockpatternutilshelp:islockpatternenabled = False
11-02 14:38:10.930 4896 4896 D lockpatternutilshelp:quality = 327680
11-02 14:38:10.931 4896 4896 D lockpatternutilshelp: Password Safe mode
Sliding
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:lockscreendisabled = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:security = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:islockpasswordenabled = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:islockpatternenabled = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:quality = 0
No
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:lockscreendisabled = True
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:security = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:islockpasswordenabled = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:islockpatternenabled = False
11-02 14:36:58.968 4896 4896 D lockpatternutilshelp:quality = 0
How can I tell if the current lock mode is "None"?
Judging by the islockscreendisabled of lockpatternutils class
How to determine whether the current locking mode is "sliding"?
Through the lockpatternutils class ! Issecure method and ! islockscreendisabled Method judgment
Third , how to determine whether the current locking mode is a "Secure Password" lock screen?
Judging by issecure method and getkeyguardstoredpasswordquality method of Lockpatternutils class
PS: Thelockpatternutils class is the platform inner class, the third-party application layer cannot get the class, consider calling by reflection or other ways to judge
"Android M" get information about screen lock: "None", "swipe", "Pin code", "pattern", "password"