use of android.app.KeyguardManager in project kickmaterial by byoutline.
the class U2020TestRunner method onStart.
// Permissions added in debug only manifest.
@Override
@SuppressLint("MissingPermission")
public void onStart() {
Context app = getTargetContext().getApplicationContext();
String name = U2020TestRunner.class.getSimpleName();
// Unlock the device so that the tests can input keystrokes.
KeyguardManager keyguard = (KeyguardManager) app.getSystemService(KEYGUARD_SERVICE);
// noinspection ResourceType
keyguard.newKeyguardLock(name).disableKeyguard();
// Wake up the screen.
PowerManager power = (PowerManager) app.getSystemService(POWER_SERVICE);
wakeLock = power.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, name);
wakeLock.acquire();
SystemAnimations.disableAll(InstrumentationRegistry.getTargetContext());
super.onStart();
}
use of android.app.KeyguardManager in project RxBinding by JakeWharton.
the class RxBindingTestRunner method onStart.
@Override
public void onStart() {
Context app = getTargetContext().getApplicationContext();
String name = RxBindingTestRunner.class.getSimpleName();
// Unlock the device so that the tests can input keystrokes.
KeyguardManager keyguard = (KeyguardManager) app.getSystemService(KEYGUARD_SERVICE);
keyguard.newKeyguardLock(name).disableKeyguard();
// Wake up the screen.
PowerManager power = (PowerManager) app.getSystemService(POWER_SERVICE);
wakeLock = power.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, name);
wakeLock.acquire();
super.onStart();
}
use of android.app.KeyguardManager in project Signal-Android by WhisperSystems.
the class PassphrasePromptActivity method resumeScreenLock.
private void resumeScreenLock(boolean force) {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
assert keyguardManager != null;
if (!keyguardManager.isKeyguardSecure()) {
Log.w(TAG, "Keyguard not secure...");
handleAuthenticated();
return;
}
if (Build.VERSION.SDK_INT != 29 && biometricManager.canAuthenticate(ALLOWED_AUTHENTICATORS) == BiometricManager.BIOMETRIC_SUCCESS) {
if (force) {
Log.i(TAG, "Listening for biometric authentication...");
biometricPrompt.authenticate(biometricPromptInfo);
} else {
Log.i(TAG, "Skipping show system biometric dialog unless forced");
}
} else if (Build.VERSION.SDK_INT >= 21) {
if (force) {
Log.i(TAG, "firing intent...");
Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.PassphrasePromptActivity_unlock_signal), "");
startActivityForResult(intent, AUTHENTICATE_REQUEST_CODE);
} else {
Log.i(TAG, "Skipping firing intent unless forced");
}
} else {
Log.w(TAG, "Not compatible...");
handleAuthenticated();
}
}
use of android.app.KeyguardManager in project Conversations by siacs.
the class XmppConnectionService method isScreenLocked.
public boolean isScreenLocked() {
final KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
final boolean locked = keyguardManager != null && keyguardManager.isKeyguardLocked();
final boolean interactive = powerManager != null && powerManager.isInteractive();
return locked || !interactive;
}
Aggregations