List of usage examples for android.content Context KEYGUARD_SERVICE
String KEYGUARD_SERVICE
To view the source code for android.content Context KEYGUARD_SERVICE.
Click Source Link
From source file:io.flutter.plugins.localauth.AuthenticationHelper.java
AuthenticationHelper(Activity activity, MethodCall call, AuthCompletionHandler completionHandler) { this.activity = activity; this.completionHandler = completionHandler; this.call = call; this.keyguardManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE); this.fingerprintManager = FingerprintManagerCompat.from(activity); }
From source file:library.artaris.cn.library.utils.SystemUtils.java
/** * ???//from w ww . j a v a 2 s .c o m * @param context * @return */ public static boolean isSleeping(Context context) { KeyguardManager kgMgr = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); return kgMgr.inKeyguardRestrictedInputMode(); }
From source file:com.example.isaac.nileswestlitcenter.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras();// w ww . j a v a2 s .co m GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. } if (extras.getString("subject") != null) { if (intent.getExtras().getString("delete") != null) { if (((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode()) { //delete from arraylist for (int i = 0; i < storeWhileScreenOff.size(); i++) { if (storeWhileScreenOff.get(i)[1] == extras.getString("subject") && storeWhileScreenOff.get(i)[2] == extras.getString("name")) { storeWhileScreenOff.remove(i); return; } } //not in stored list, but on screen storeWhileScreenOff.add( new String[] { "true", extras.getString("subject"), extras.getString("name") }); } else { sendMessage(true, extras.getString("subject"), extras.getString("name")); // MainActivity.deleteStudentFromList(extras.getString("subject"),extras.getString("name")); // or MainActivity.delete(extras.getInt("id")); } } else { if (((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode()) { storeWhileScreenOff.add( new String[] { "false", extras.getString("subject"), extras.getString("name") }); } else { sendMessage(false, extras.getString("subject"), extras.getString("name")); } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification(extras.getString("subject"), extras.getString("name")); Vibrator v = (Vibrator) this.getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.vibrate(1000); ((PowerManager) getSystemService(POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG") .acquire(); Log.i(TAG, "Received: " + extras.toString()); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.cloverstudio.spika.GCMIntentService.java
/** * Method called on Receiving a new message * *///from www . j av a 2 s. c om @Override protected void onMessage(Context context, Intent intent) { Bundle pushExtras = intent.getExtras(); String pushMessage = intent.getStringExtra(Const.PUSH_MESSAGE); String pushFromName = intent.getStringExtra(Const.PUSH_FROM_NAME); try { boolean appIsInForeground = new SpikaApp.ForegroundCheckAsync().execute(getApplicationContext()).get(); boolean screenLocked = ((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode(); if (appIsInForeground && !screenLocked) { mPushBroadcast.replaceExtras(pushExtras); LocalBroadcastManager.getInstance(this).sendBroadcast(mPushBroadcast); } else { triggerNotification(this, pushMessage, pushFromName, pushExtras); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } }
From source file:net.micode.soundrecorder.RecorderService.java
@Override public void onCreate() { super.onCreate(); mRecorder = null;//from w w w .j ava 2s.c o m mLowStorageNotification = null; mRemainingTimeCalculator = new RemainingTimeCalculator(); mNeedUpdateRemainingTime = false; mNotifiManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SoundRecorder"); mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mAudioSampleRate = Integer .parseInt(settings.getString("p_audio_samplerate", Constants.DEFAULT_AUDIO_SAMPLE_RATE)); }
From source file:com.better.alarm.presenter.alert.AlarmAlertReceiver.java
private void onAlert(Alarm alarm) { int id = alarm.getId(); /* Close dialogs and window shade */ Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); mContext.sendBroadcast(closeDialogs); // Decide which activity to start based on the state of the // keyguard - is the screen locked or not. Class<? extends AlarmAlertFullScreen> c = AlarmAlert.class; KeyguardManager km = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); if (km.inKeyguardRestrictedInputMode()) { // Use the full screen activity to unlock the screen. c = AlarmAlertFullScreen.class; }//from w w w . j a va 2 s . c o m // Trigger a notification that, when clicked, will show the alarm // alert dialog. No need to check for fullscreen since this will always // be launched from a user action. Intent notify = new Intent(mContext, c); notify.putExtra(Intents.EXTRA_ID, id); PendingIntent pendingNotify = PendingIntent.getActivity(mContext, id, notify, 0); PendingIntent pendingSnooze = PresentationToModelIntents.createPendingIntent(mContext, PresentationToModelIntents.ACTION_REQUEST_SNOOZE, id); PendingIntent pendingDismiss = PresentationToModelIntents.createPendingIntent(mContext, PresentationToModelIntents.ACTION_REQUEST_DISMISS, id); //@formatter:off Notification status = new NotificationCompat.Builder(mContext) .setContentTitle(alarm.getLabelOrDefault(mContext)) .setContentText(mContext.getString(R.string.alarm_notify_text)) .setSmallIcon(R.drawable.stat_notify_alarm) // setFullScreenIntent to show the user AlarmAlert dialog at the same time // when the Notification Bar was created. .setFullScreenIntent(pendingNotify, true) // setContentIntent to show the user AlarmAlert dialog // when he will click on the Notification Bar. .setContentIntent(pendingNotify).setOngoing(true) .addAction(R.drawable.ic_action_snooze, mContext.getString(R.string.alarm_alert_snooze_text), pendingSnooze) .addAction(R.drawable.ic_action_dismiss, mContext.getString(R.string.alarm_alert_dismiss_text), pendingDismiss) .setDefaults(Notification.DEFAULT_LIGHTS).build(); //@formatter:on // Send the notification using the alarm id to easily identify the // correct notification. nm.notify(id, status); }
From source file:com.outsystemscloud.andrevieira.secureDevice.java
/** * @param context/*from w ww.j ava2 s.com*/ * @return true if pass or pin set */ @SuppressLint("NewApi") private static boolean isPassOrPinSet(Context context) { KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); //api 16+ return keyguardManager.isKeyguardSecure(); }
From source file:com.keepassdroid.fingerprint.FingerPrintHelper.java
public FingerPrintHelper(final Context context, final FingerPrintCallback fingerPrintCallback) { if (!isFingerprintSupported()) { // really not much to do when no fingerprint support found setInitOk(false);/*from www . j av a 2 s. c o m*/ return; } this.fingerprintManager = FingerprintManagerCompat.from(context); this.keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); this.fingerPrintCallback = fingerPrintCallback; if (hasEnrolledFingerprints()) { try { this.keyStore = KeyStore.getInstance("AndroidKeyStore"); this.keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore"); this.cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); this.cryptoObject = new FingerprintManagerCompat.CryptoObject(cipher); setInitOk(true); } catch (final Exception e) { setInitOk(false); fingerPrintCallback.onException(); } } }
From source file:com.android.browser.BrowserActivity.java
private boolean shouldIgnoreIntents() { // Only process intents if the screen is on and the device is unlocked // aka, if we will be user-visible if (mKeyguardManager == null) { mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); }// w w w.j a va 2 s . c om if (mPowerManager == null) { mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); } boolean ignore = !mPowerManager.isScreenOn(); ignore |= mKeyguardManager.inKeyguardRestrictedInputMode(); if (LOGV_ENABLED) { Log.v(LOGTAG, "ignore intents: " + ignore); } return ignore; }
From source file:com.snappy.GCMIntentService.java
/** * Method called on Receiving a new message * *///from w ww . j av a 2 s . c o m @Override protected void onMessage(Context context, Intent intent) { db = new LocalDB(context); Bundle pushExtras = intent.getExtras(); String pushMessage = intent.getStringExtra(Const.PUSH_MESSAGE); String pushFromName = intent.getStringExtra(Const.PUSH_FROM_NAME); String pushMessageBody = intent.getStringExtra(Const.PUSH_FROM_MESSAGE_BODY); String pushMessaBodyStyled = pushFromName + ": " + pushMessageBody; db.writeMessage(pushMessaBodyStyled); try { boolean appIsInForeground = new SpikaApp.ForegroundCheckAsync().execute(getApplicationContext()).get(); boolean screenLocked = ((KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE)) .inKeyguardRestrictedInputMode(); if (appIsInForeground && !screenLocked) { mPushBroadcast.replaceExtras(pushExtras); LocalBroadcastManager.getInstance(this).sendBroadcast(mPushBroadcast); generateNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); } else { //triggerNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); generateNotification(this, pushMessage, pushFromName, pushExtras, pushMessaBodyStyled); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } }