Exemplo n.º 1
0
 private Intent getCameraIntent() {
   KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
   boolean currentUserHasTrust = updateMonitor.getUserHasTrust(mLockPatternUtils.getCurrentUser());
   return mLockPatternUtils.isSecure() && !currentUserHasTrust
       ? SECURE_CAMERA_INTENT
       : INSECURE_CAMERA_INTENT;
 }
Exemplo n.º 2
0
 private void updateNotifiOnkeyguard(boolean isShow) {
   if (isShow) {
     KeyguardUpdateMonitor.getInstance(mContext)
         .getNotificationModule()
         .setLastKeyguardShowTime(System.currentTimeMillis());
     KeyguardUpdateMonitor.getInstance(mContext).getNotificationModule().updateNotifications();
   } else {
     KeyguardUpdateMonitor.getInstance(mContext).getNotificationModule().removeAllNotifications();
   }
 }
 @Override
 public void onResume(int reason) {
   log("onResume()");
   synchronized (mIsBouncerVisibleToUserLock) {
     mIsBouncerVisibleToUser = isBouncerVisibleToUser();
   }
   if (!KeyguardUpdateMonitor.getInstance(mContext).isSwitchingUser()) {
     maybeStartBiometricUnlock();
   }
   KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback);
 }
Exemplo n.º 4
0
 private void updateLockIcon() {
   boolean visible = isShown() && KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
   if (visible) {
     mTrustDrawable.start();
   } else {
     mTrustDrawable.stop();
   }
   if (!visible) {
     return;
   }
   // TODO: Real icon for facelock.
   int iconRes =
       mUnlockMethodCache.isFaceUnlockRunning()
           ? com.android.internal.R.drawable.ic_account_circle
           : mUnlockMethodCache.isMethodInsecure()
               ? R.drawable.ic_lock_open_24dp
               : R.drawable.ic_lock_24dp;
   if (mLastUnlockIconRes != iconRes) {
     Drawable icon = mContext.getDrawable(iconRes);
     int iconHeight =
         getResources().getDimensionPixelSize(R.dimen.keyguard_affordance_icon_height);
     int iconWidth = getResources().getDimensionPixelSize(R.dimen.keyguard_affordance_icon_width);
     if (icon.getIntrinsicHeight() != iconHeight || icon.getIntrinsicWidth() != iconWidth) {
       icon = new IntrinsicSizeDrawable(icon, iconWidth, iconHeight);
     }
     mLockIcon.setImageDrawable(icon);
   }
   boolean trustManaged = mUnlockMethodCache.isTrustManaged();
   mTrustDrawable.setTrustManaged(trustManaged);
   updateLockIconClickability();
 }
 @Override
 public void onDetachedFromWindow() {
   log("onDetachedFromWindow()");
   if (mBiometricUnlock != null) {
     mBiometricUnlock.stop();
   }
   KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateCallback);
 }
 @Override
 public void onPause() {
   log("onPause()");
   if (mBiometricUnlock != null) {
     mBiometricUnlock.stop();
   }
   mSecurityMessageDisplay.setMessage(" ", true);
   KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateCallback);
 }
  /**
   * Starts the biometric unlock if it should be started based on a number of factors. If it should
   * not be started, it either goes to the back up, or remains showing to prepare for it being
   * started later.
   */
  private void maybeStartBiometricUnlock() {
    log("maybeStartBiometricUnlock() is called.");
    if (mBiometricUnlock != null) {
      KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
      final boolean backupIsTimedOut =
          (monitor.getFailedUnlockAttempts() >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT);
      final boolean mediaPlaying =
          AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0)
              || AudioSystem.isStreamActive(AudioSystem.STREAM_ALARM, 0);

      boolean isBouncerVisibleToUser;
      synchronized (mIsBouncerVisibleToUserLock) {
        isBouncerVisibleToUser = mIsBouncerVisibleToUser;
      }

      // Don't start it if the bouncer is not showing, but keep this view up because we want
      // it here and ready for when the bouncer does show.
      if (!isBouncerVisibleToUser) {
        if (mediaPlaying) {
          log(
              "maybeStartBiometricUnlock() - isBouncerVisibleToUser is false"
                  + " && mediaPlaying is true, call mBiometricUnlock.stopAndShowBackup()");
          mBiometricUnlock.stopAndShowBackup();
        } else {
          log(
              "maybeStartBiometricUnlock() - isBouncerVisibleToUser is false,"
                  + " call mBiometricUnlock.stop()");
          mBiometricUnlock.stop(); // It shouldn't be running but calling this can't hurt.
        }
        return;
      }

      // Although these same conditions are handled in KeyguardSecurityModel, they are still
      // necessary here.  When a tablet is rotated 90 degrees, a configuration change is
      // triggered and everything is torn down and reconstructed.  That means
      // KeyguardSecurityModel gets a chance to take care of the logic and doesn't even
      // reconstruct KeyguardFaceUnlockView if the biometric unlock should be suppressed.
      // However, for a 180 degree rotation, no configuration change is triggered, so only
      // the logic here is capable of suppressing Face Unlock.
      if (monitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE
          && monitor.isAlternateUnlockEnabled()
          && !monitor.getMaxBiometricUnlockAttemptsReached()
          && !backupIsTimedOut
          && !mediaPlaying) {
        mBiometricUnlock.start();
      } else {
        log("maybeStartBiometricUnlock() - call stopAndShowBackup()");
        mBiometricUnlock.stopAndShowBackup();
      }
    }
  }
Exemplo n.º 8
0
 private void watchForCameraPolicyChanges() {
   final IntentFilter filter = new IntentFilter();
   filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
   getContext().registerReceiverAsUser(mDevicePolicyReceiver, UserHandle.ALL, filter, null, null);
   KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
 }
 // Returns true if the device is currently in a state where the user is seeing the bouncer.
 // This requires isKeyguardBouncer() to be true, but that doesn't imply that the screen is on or
 // the keyguard visibility is set to true, so we must check those conditions as well.
 private boolean isBouncerVisibleToUser() {
   KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
   return updateMonitor.isKeyguardBouncer()
       && updateMonitor.isKeyguardVisible()
       && updateMonitor.isScreenOn();
 }