我需要检查锁屏是否有 Pin 码或更安全的东西(密码、指纹等)。我能够检查是否有 PIN、密码或图案。
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager.isKeyguardSecure();
我的问题是我无法检测锁屏是否是图案或更低的东西。我试过这个:
int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
但它已被弃用并引发错误。我也尝试过这个:
long mode2 = Settings.Secure.getLong(contentResolver, "lockscreen.password_type");
但这也以 SecurityException 结束。
有什么方法可以检测锁屏是否有 PIN(或更高级别)或者是否有锁定图案或更低级别的内容? KeyguardManager 在这方面对我来说没有用:/
任何帮助表示赞赏!
谢谢!
/edit
第一个的错误是:
Caused by: java.lang.SecurityException: Settings.Secure.lock_pattern_autolock is deprecated and no longer accessible. See API documentation for potential replacements.
第二个例外是: W/System.err: android.provider.Settings$SettingNotFoundException: lockscreen.password_type
当您使用带有 Marshmallow 或更高版本的设备时,才会出现该错误(https://developer.android.com/reference/android/provider/Settings.Secure.html)