Example usage for android.content Context KEYGUARD_SERVICE

List of usage examples for android.content Context KEYGUARD_SERVICE

Introduction

In this page you can find the example usage for android.content Context KEYGUARD_SERVICE.

Prototype

String KEYGUARD_SERVICE

To view the source code for android.content Context KEYGUARD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.app.KeyguardManager for controlling keyguard.

Usage

From source file:Main.java

/**
 * telephone is sleeping/*  ww w . j av  a  2 s  .  c o  m*/
 *
 * @param context
 * @return
 */
public static boolean isSleeping(Context context) {
    KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return keyguardManager.inKeyguardRestrictedInputMode();
}

From source file:Main.java

/**
 * Release the devices screen lock.//w w w .  j  a v a  2 s  . co  m
 * @param context
 */
public static void releaseScreenLock(Context context) {
    KeyguardManager keyguardManager = (KeyguardManager) context.getApplicationContext()
            .getSystemService(Context.KEYGUARD_SERVICE);
    KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG");
    keyguardLock.disableKeyguard();
}

From source file:Main.java

public static boolean isScreenLocked(Context context) {
    KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return keyguardManager.inKeyguardRestrictedInputMode();
}

From source file:Main.java

/**
 * Return whether the keyguard requires a password to unlock and may
 * have any privacy restrictions./* w w w  .  j av  a  2 s.c o m*/
 */
public static boolean isSecure(@NonNull Context context) {
    KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return km.isKeyguardSecure() && km.isKeyguardLocked();
}

From source file:net.nordist.lloydproof.LloydProofTest.java

@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException") // it's super's fault
public void setUp() throws Exception {
    super.setUp();
    activity = getActivity();/*from w w w .j  a  va2  s.com*/
    store = new CorrectionStorage(activity);
    store.deleteAll();
    KeyguardManager keyGuardManager = (KeyguardManager) activity.getApplicationContext()
            .getSystemService(Context.KEYGUARD_SERVICE);
    keyguardLock = keyGuardManager.newKeyguardLock("LloydProof");
    keyguardLock.disableKeyguard();
}

From source file:org.ebayopensource.fidouafclient.ExampleFidoUafActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    Bundle extras = this.getIntent().getExtras();
    setContentView(R.layout.activity_fido_uaf);
    operation = (TextView) findViewById(R.id.textViewOperation);
    uafMsg = (TextView) findViewById(R.id.textViewOpMsg);
    operation.setText(extras.getString("UAFIntentType"));
    uafMsg.setText(extras.getString("message"));
}

From source file:alexander.martinz.fingerprintfuzzer.FingerPrinter.java

public FingerPrinter(@NonNull Context context, FingerprinterCallback authenticationCallback,
        @Nullable String keyName) {
    this.context = context;
    this.cryptoHelper = new CryptoHelper(context, keyName);

    this.keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    this.fingerprintManager = FingerprintManagerCompat.from(context);

    this.authenticationCallback = authenticationCallback;
}

From source file:com.elkriefy.android.apps.authenticationexample.credentialsgrace.CredGraceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.credentials_grace_activity_main);
    mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    Button purchaseButton = (Button) findViewById(R.id.purchase_button);
    if (!mKeyguardManager.isKeyguardSecure()) {
        // Show a message that the user hasn't set up a lock screen.
        Toast.makeText(this,
                "Secure lock screen hasn't set up.\n"
                        + "Go to 'Settings -> Security -> Screenlock' to set up a lock screen",
                Toast.LENGTH_LONG).show();
        purchaseButton.setEnabled(false);
        return;//from  w w  w .  j  a  va  2s  .c  o m
    }
    createKey();
    findViewById(R.id.purchase_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Test to encrypt something. It might fail if the timeout expired (30s).
            tryEncrypt();
        }
    });
}

From source file:at.amartinz.hardware.security.Fingerprinter.java

public Fingerprinter(@NonNull Context context, FingerprinterCallback authenticationCallback,
        @Nullable String keyName) {
    this.context = context;
    this.cryptoHelper = new CryptoHelper(context, keyName);

    this.keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    this.fingerprintManager = FingerprintManagerCompat.from(context);

    this.authenticationCallback = authenticationCallback;
}

From source file:com.github.sryze.wirebug.DebugStatusService.java

@Override
public void onCreate() {
    super.onCreate();

    Log.d(TAG, "Service is created");

    preferences = PreferenceManager.getDefaultSharedPreferences(this);

    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG);

    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
}