use of android.app.KeyguardManager in project cordova-plugin-local-notifications by katzer.
the class LocalNotification method isInForeground.
/**
* If the app is running in foreground.
*/
private static boolean isInForeground() {
if (!deviceready || webView == null)
return false;
CordovaWebView view = webView.get();
KeyguardManager km = (KeyguardManager) view.getContext().getSystemService(Context.KEYGUARD_SERVICE);
// noinspection SimplifiableIfStatement
if (km != null && km.isKeyguardLocked())
return false;
return view.getView().getWindowVisibility() == View.VISIBLE;
}
use of android.app.KeyguardManager in project robolectric by robolectric.
the class ShadowKeyguardManagerTest method isKeyguardLocked_retainedAcrossMultipleInstances.
/**
* On Android L and below, calling {@link android.content.Context#getSystemService(String)} for
* {@link android.content.Context#KEYGUARD_SERVICE} will return a new instance each time.
*/
@Test
public void isKeyguardLocked_retainedAcrossMultipleInstances() {
assertThat(manager.isKeyguardLocked()).isFalse();
shadowOf(manager).setKeyguardLocked(true);
KeyguardManager manager2 = (KeyguardManager) ApplicationProvider.getApplicationContext().getSystemService(KEYGUARD_SERVICE);
assertThat(manager2.isKeyguardLocked()).isTrue();
assertThat(shadowOf(manager.newKeyguardLock("tag")).isEnabled()).isTrue();
KeyguardManager.KeyguardLock keyguardLock = manager2.newKeyguardLock("tag");
keyguardLock.disableKeyguard();
assertThat(shadowOf(manager.newKeyguardLock("tag")).isEnabled()).isFalse();
}
use of android.app.KeyguardManager in project robolectric by robolectric.
the class ShadowDevicePolicyManager method resetPassword.
@Implementation
protected boolean resetPassword(String password, int flags) {
if (!passwordMeetsRequirements(password)) {
return false;
}
lastSetPassword = password;
boolean secure = !password.isEmpty();
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
shadowOf(keyguardManager).setIsDeviceSecure(secure);
shadowOf(keyguardManager).setIsKeyguardSecure(secure);
return true;
}
use of android.app.KeyguardManager in project robolectric by robolectric.
the class ShadowDevicePolicyManager method setResetPasswordToken.
@Implementation(minSdk = O)
protected boolean setResetPasswordToken(ComponentName admin, byte[] token) {
if (token.length < 32) {
throw new IllegalArgumentException("token too short: " + token.length);
}
enforceDeviceOwnerOrProfileOwner(admin);
passwordResetTokens.put(admin, token);
componentsWithActivatedTokens.remove(admin);
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if (!keyguardManager.isDeviceSecure()) {
activateResetToken(admin);
}
return true;
}
use of android.app.KeyguardManager in project Xposed-Tinted-Status-Bar by MohammadAG.
the class Utils method isKeyguardLocked.
@SuppressLint("NewApi")
public static boolean isKeyguardLocked(Context context) {
KeyguardManager kgm = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
boolean keyguardLocked;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
keyguardLocked = kgm.isKeyguardLocked();
} else {
keyguardLocked = kgm.inKeyguardRestrictedInputMode();
}
return keyguardLocked;
}
Aggregations