Java Code Examples for android.app.KeyguardManager#isDeviceLocked()
The following examples show how to use
android.app.KeyguardManager#isDeviceLocked() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClipboardService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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); } }
Example 2
Source File: UserController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * 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); }
Example 3
Source File: KeyguardUtils.java From AcDisplay with GNU General Public License v2.0 | 4 votes |
/** * 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(); }