下面列出了android.app.KeyguardManager#isDeviceLocked ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean isDeviceLocked() {
int callingUserId = UserHandle.getCallingUserId();
final long token = Binder.clearCallingIdentity();
try {
final KeyguardManager keyguardManager = getContext().getSystemService(
KeyguardManager.class);
return keyguardManager != null && keyguardManager.isDeviceLocked(callingUserId);
} finally {
Binder.restoreCallingIdentity(token);
}
}
/**
* Returns whether the given user requires credential entry at this time. This is used to
* intercept activity launches for work apps when the Work Challenge is present.
*/
protected boolean shouldConfirmCredentials(int userId) {
synchronized (mLock) {
if (mStartedUsers.get(userId) == null) {
return false;
}
}
if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
return false;
}
final KeyguardManager km = mInjector.getKeyguardManager();
return km.isDeviceLocked(userId) && km.isDeviceSecure(userId);
}
/**
* Returns whether the device is currently locked and requires a PIN,
* pattern or password to unlock.
*/
@SuppressLint("NewApi")
public static boolean isDeviceLocked(@NonNull KeyguardManager km) {
return Device.hasLollipopMR1Api() ? km.isDeviceLocked() : km.isKeyguardSecure();
}