Search in sources :

Example 86 with KeyguardManager

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;
}
Also used : CordovaWebView(org.apache.cordova.CordovaWebView) KeyguardManager(android.app.KeyguardManager)

Example 87 with KeyguardManager

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();
}
Also used : KeyguardManager(android.app.KeyguardManager) Test(org.junit.Test)

Example 88 with KeyguardManager

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;
}
Also used : KeyguardManager(android.app.KeyguardManager) Implementation(org.robolectric.annotation.Implementation)

Example 89 with KeyguardManager

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;
}
Also used : KeyguardManager(android.app.KeyguardManager) Implementation(org.robolectric.annotation.Implementation)

Example 90 with KeyguardManager

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

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