Search in sources :

Example 91 with KeyguardManager

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();
}
Also used : Context(android.content.Context) PowerManager(android.os.PowerManager) KeyguardManager(android.app.KeyguardManager) SuppressLint(android.annotation.SuppressLint)

Example 92 with KeyguardManager

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();
}
Also used : Context(android.content.Context) PowerManager(android.os.PowerManager) KeyguardManager(android.app.KeyguardManager)

Example 93 with KeyguardManager

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();
    }
}
Also used : Intent(android.content.Intent) KeyguardManager(android.app.KeyguardManager)

Example 94 with KeyguardManager

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;
}
Also used : PowerManager(android.os.PowerManager) KeyguardManager(android.app.KeyguardManager)

Aggregations

KeyguardManager (android.app.KeyguardManager)94 Intent (android.content.Intent)44 PendingIntent (android.app.PendingIntent)18 PowerManager (android.os.PowerManager)17 Context (android.content.Context)12 SuppressLint (android.annotation.SuppressLint)10 IIntentSender (android.content.IIntentSender)10 IntentSender (android.content.IntentSender)10 FingerprintManager (android.hardware.fingerprint.FingerprintManager)7 Resources (android.content.res.Resources)5 TelephonyManager (android.telephony.TelephonyManager)5 TargetApi (android.annotation.TargetApi)4 ConnectivityManager (android.net.ConnectivityManager)4 RemoteException (android.os.RemoteException)4 Activity (android.app.Activity)3 NotificationManager (android.app.NotificationManager)3 Bitmap (android.graphics.Bitmap)3 NetworkInfo (android.net.NetworkInfo)3 DialogFragment (android.app.DialogFragment)2 Notification (android.app.Notification)2