private boolean isSecured() {
//int uid= UserHandle.myUserId();
int uid = -101010;
try {
Class<?> threadClazz = Class.forName("android.os.UserHandle");
Method method = threadClazz.getMethod("myUserId");
uid = (int) method.invoke(null);
Log.i("yuyong_lock", "uid:" + uid);
} catch (Exception e) {
Log.i("yuyong_lock", "uid:" + e.getMessage());
return false;
}
String classPath = "com.android.internal.widget.LockPatternUtils";
try {
Class<?> lockPatternClass = Class.forName(classPath);
Object lockPatternObject = lockPatternClass.getConstructor(Context.class).newInstance(getApplicationContext());
Method method = lockPatternClass.getMethod("isSecure", int.class);
boolean isLock = (boolean) method.invoke(lockPatternObject, uid);
Log.i("yuyong_lock", "isLock:" + isLock);
return isLock;
} catch (Exception e) {
Log.i("yuyong_lock", "isLock:" + e.getMessage());
return false;
}
}
Android 6 多用户操作系统 检测当前系统是否设置了锁屏密码
最新推荐文章于 2023-04-28 17:09:58 发布