public KeyguardViewMediator(
      Context context, PhoneWindowManager callback, LocalPowerManager powerManager) {
    mContext = context;

    mRealPowerManager = powerManager;
    mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock =
        mPM.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
    mWakeLock.setReferenceCounted(false);
    mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
    mShowKeyguardWakeLock.setReferenceCounted(false);

    mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff");
    mWakeAndHandOff.setReferenceCounted(false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(DELAYED_KEYGUARD_ACTION);
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    context.registerReceiver(mBroadCastReceiver, filter);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mCallback = callback;

    mUpdateMonitor = new KeyguardUpdateMonitor(context);

    mUpdateMonitor.registerInfoCallback(this);
    mUpdateMonitor.registerSimStateCallback(this);

    mLockPatternUtils = new LockPatternUtils(mContext);
    mKeyguardViewProperties =
        new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor);

    mKeyguardViewManager =
        new KeyguardViewManager(
            context, WindowManagerImpl.getDefault(), this, mKeyguardViewProperties, mUpdateMonitor);

    mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
    mUserPresentIntent.addFlags(
        Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);

    final ContentResolver cr = mContext.getContentResolver();
    mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1);

    mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
    String soundPath = Settings.System.getString(cr, Settings.System.LOCK_SOUND);
    if (soundPath != null) {
      mLockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mLockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
    soundPath = Settings.System.getString(cr, Settings.System.UNLOCK_SOUND);
    if (soundPath != null) {
      mUnlockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mUnlockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
  }
  /**
   * Enable the keyguard if the settings are appropriate. Return true if all work that will happen
   * is done; returns false if the caller can wait for the keyguard to be shown.
   */
  private void doKeyguardLocked() {
    boolean bEnableKeyguard = SystemProperties.getBoolean("keyguard.enable", true);
    if (!bEnableKeyguard) return;

    // if another app is disabling us, don't show
    if (!mExternallyEnabled) {
      if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");

      // note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes
      // for an occasional ugly flicker in this situation:
      // 1) receive a call with the screen on (no keyguard) or make a call
      // 2) screen times out
      // 3) user hits key to turn screen back on
      // instead, we reenable the keyguard when we know the screen is off and the call
      // ends (see the broadcast receiver below)
      // TODO: clean this up when we have better support at the window manager level
      // for apps that wish to be on top of the keyguard
      return;
    }

    // if the keyguard is already showing, don't bother
    if (mKeyguardViewManager.isShowing()) {
      if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
      return;
    }

    // if the setup wizard hasn't run yet, don't show
    final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", false);
    final boolean provisioned = mUpdateMonitor.isDeviceProvisioned();
    final IccCard.State state = mUpdateMonitor.getSimState();
    final boolean lockedOrMissing =
        state.isPinLocked()
            || ((state == IccCard.State.ABSENT || state == IccCard.State.PERM_DISABLED)
                && requireSim);

    if (!lockedOrMissing && !provisioned) {
      if (DEBUG)
        Log.d(
            TAG,
            "doKeyguard: not showing because device isn't provisioned"
                + " and the sim is not locked or missing");
      return;
    }

    if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) {
      if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
      return;
    }

    if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
    showLocked();
  }
  public void keyguardDone(boolean authenticated, boolean wakeup) {
    synchronized (this) {
      EventLog.writeEvent(70000, 2);
      if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")");
      Message msg = mHandler.obtainMessage(KEYGUARD_DONE);
      msg.arg1 = wakeup ? 1 : 0;
      mHandler.sendMessage(msg);

      if (authenticated) {
        mUpdateMonitor.clearFailedAttempts();
      }

      if (mExitSecureCallback != null) {
        mExitSecureCallback.onKeyguardExitResult(authenticated);
        mExitSecureCallback = null;

        if (authenticated) {
          // after succesfully exiting securely, no need to reshow
          // the keyguard when they've released the lock
          mExternallyEnabled = true;
          mNeedToReshowWhenReenabled = false;
        }
      }
    }
  }
  /** Show the keyguard. Will handle creating and attaching to the view manager lazily. */
  public synchronized void show(Bundle options) {
    if (DEBUG) Log.d(TAG, "show(); mKeyguardView=" + mKeyguardView);

    boolean enableScreenRotation = KeyguardUtils.shouldEnableScreenRotation(mContext);
    if (DEBUG) Log.d(TAG, "show() query screen rotation after");

    /// M: Incoming Indicator for Keyguard Rotation @{
    KeyguardUpdateMonitor.getInstance(mContext).setQueryBaseTime();
    /// @}
    maybeCreateKeyguardLocked(enableScreenRotation, false, options);

    if (DEBUG) Log.d(TAG, "show() maybeCreateKeyguardLocked finish");

    maybeEnableScreenRotation(enableScreenRotation);

    // Disable common aspects of the system/status/navigation bars that are not appropriate or
    // useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED
    // activities. Other disabled bits are handled by the KeyguardViewMediator talking
    // directly to the status bar service.
    int visFlags = View.STATUS_BAR_DISABLE_HOME;
    if (shouldEnableTranslucentDecor()) {
      mWindowLayoutParams.flags |=
          WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
              | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
    }
    if (DEBUG) Log.d(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags) + ")");
    mKeyguardHost.setSystemUiVisibility(visFlags);

    mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);
    mKeyguardHost.setVisibility(View.VISIBLE);
    mKeyguardView.show();
    mKeyguardView.requestFocus();
    if (DEBUG) Log.d(TAG, "show() exit; mKeyguardView=" + mKeyguardView);
  }
 @Override
 protected void onDetachedFromWindow() {
   super.onDetachedFromWindow();
   KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mInfoCallback);
   /// M: Unregister the phone listener for dual clock
   mDualClock.resetPhonelistener();
 }
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    mDualClock.createClockView(getContext(), this);

    mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
    mDateView = (TextClock) findViewById(R.id.date_view);
    mClockView = (ClockView) findViewById(R.id.clock_view);
    mLockPatternUtils = new LockPatternUtils(getContext());
    final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
    setEnableMarquee(screenOn);

    /// M: For loading the mediatek resource and avoid changing a lot. @{
    if (mDateView == null) {
      KeyguardUtils.xlogD(TAG, "onFinishInflate mDateView == null");
      mDateView = (TextClock) findViewById(R.id.date_view);
    }
    if (mAlarmStatusView == null) {
      KeyguardUtils.xlogD(TAG, "onFinishInflate mAlarmStatusView == null");
      mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
    }
    if (mClockView == null) {
      KeyguardUtils.xlogD(TAG, "onFinishInflate mClockView == null");
      mClockView = (ClockView) findViewById(R.id.clock_view);
    }
    /// @}

    KeyguardUtils.xlogD(TAG, "onFinishInflate --before-- new LockPatternUtils(getContext())");
    mLockPatternUtils = new LockPatternUtils(getContext());

    KeyguardUtils.xlogD(TAG, "onFinishInflate --before-- refresh()");
    refresh();
  }
  private void showDefaultMessage() {
    KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
    mSubId = monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED);
    if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
      return;
    }
    if (mRemainingAttempts >= 0) {
      mSecurityMessageDisplay.setMessage(
          getPinPasswordErrorMessage(mRemainingAttempts, true), true);
      return;
    }

    int count = TelephonyManager.getDefault().getSimCount();
    Resources rez = getResources();
    final String msg;
    int color = Color.WHITE;
    if (count < 2) {
      msg = rez.getString(R.string.kg_sim_pin_instructions);
    } else {
      SubscriptionInfo info = monitor.getSubscriptionInfoForSubId(mSubId);
      CharSequence displayName = info != null ? info.getDisplayName() : ""; // don't crash
      msg = rez.getString(R.string.kg_sim_pin_instructions_multi, displayName);
      if (info != null) {
        color = info.getIconTint();
      }
    }
    mSecurityMessageDisplay.setMessage(msg, true);
    mSimImageView.setImageTintList(ColorStateList.valueOf(color));

    new CheckSimPin("", mSubId) {
      void onSimCheckResponse(final int result, final int attemptsRemaining) {
        Log.d(
            LOG_TAG,
            "onSimCheckResponse "
                + " dummy One result"
                + result
                + " attemptsRemaining="
                + attemptsRemaining);
        if (attemptsRemaining >= 0) {
          mRemainingAttempts = attemptsRemaining;
          mSecurityMessageDisplay.setMessage(
              getPinPasswordErrorMessage(attemptsRemaining, true), true);
        }
      }
    }.start();
  }
 @Override
 protected void onAttachedToWindow() {
   super.onAttachedToWindow();
   if (mShowDefaultMessage) {
     showDefaultMessage();
   }
   KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
 }
 /** {@inheritDoc} */
 public void cleanUp() {
   if (DEBUG) Log.v(TAG, "Cleanup() called on " + this);
   mUpdateMonitor.removeCallback(this);
   mLockPatternUtils = null;
   mUpdateMonitor = null;
   mCallback = null;
   mLockPatternView.setOnPatternListener(null);
 }
예제 #10
0
 void updateConfiguration() {
   Configuration newConfig = getResources().getConfiguration();
   if (newConfig.orientation != mCreationOrientation) {
     mCallback.recreateMe(newConfig);
   } else if (newConfig.hardKeyboardHidden != mKeyboardHidden) {
     mKeyboardHidden = newConfig.hardKeyboardHidden;
     final boolean isKeyboardOpen = mKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
     if (mUpdateMonitor.isKeyguardBypassEnabled() && isKeyboardOpen) {
       mCallback.goToUnlockScreen();
     }
   }
 }
예제 #11
0
  private void updateTargets() {
    int currentUserHandle = mLockPatternUtils.getCurrentUser();
    DevicePolicyManager dpm = mLockPatternUtils.getDevicePolicyManager();
    int disabledFeatures = dpm.getKeyguardDisabledFeatures(null, currentUserHandle);
    boolean secureCameraDisabled =
        mLockPatternUtils.isSecure()
            && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0;
    boolean cameraDisabledByAdmin =
        dpm.getCameraDisabled(null, currentUserHandle) || secureCameraDisabled;
    final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(getContext());
    boolean disabledBySimState = monitor.isSimLocked();
    boolean cameraTargetPresent =
        isTargetPresent(com.android.internal.R.drawable.ic_lockscreen_camera);
    boolean searchTargetPresent =
        isTargetPresent(com.android.internal.R.drawable.ic_action_assist_generic);

    if (cameraDisabledByAdmin) {
      Log.v(TAG, "Camera disabled by Device Policy");
    } else if (disabledBySimState) {
      Log.v(TAG, "Camera disabled by Sim State");
    }
    boolean currentUserSetup =
        0
            != Settings.Secure.getIntForUser(
                mContext.getContentResolver(),
                Settings.Secure.USER_SETUP_COMPLETE,
                0 /*default */,
                currentUserHandle);
    boolean searchActionAvailable =
        ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
                .getAssistIntent(mContext, UserHandle.USER_CURRENT)
            != null;
    mCameraDisabled =
        cameraDisabledByAdmin || disabledBySimState || !cameraTargetPresent || !currentUserSetup;
    mSearchDisabled =
        disabledBySimState || !searchActionAvailable || !searchTargetPresent || !currentUserSetup;
    updateResources();
  }
  public KeyguardMessageArea(Context context, AttributeSet attrs) {
    super(context, attrs);

    // This is required to ensure marquee works
    setSelected(true);

    // Registering this callback immediately updates the battery state, among other things.
    mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
    mUpdateMonitor.registerCallback(mInfoCallback);
    mHandler = new Handler(Looper.myLooper());

    mSeparator = getResources().getString(R.string.kg_text_message_separator);
    mLockAlwaysBattery =
        Settings.System.getInt(
                getContext().getContentResolver(), Settings.System.LOCKSCREEN_BATTERY, 0)
            == 1;
    setTextColor(
        Settings.System.getInt(
            getContext().getContentResolver(),
            Settings.System.LOCKSCREEN_CUSTOM_TEXT_COLOR,
            0xFFFFFFFF));
    update();
  }
  /**
   * Returns true if the change is resulting in the keyguard beign dismissed, meaning the screen can
   * turn on immediately. Otherwise returns false.
   */
  public boolean doLidChangeTq(boolean isLidOpen) {
    mKeyboardOpen = isLidOpen;

    if (mUpdateMonitor.isKeyguardBypassEnabled()
        && mKeyboardOpen
        && !mKeyguardViewProperties.isSecure()
        && mKeyguardViewManager.isShowing()) {
      if (DEBUG)
        Log.d(TAG, "bypassing keyguard on sliding open of keyboard with non-secure keyguard");
      mHandler.sendEmptyMessage(KEYGUARD_DONE_AUTHENTICATING);
      return true;
    }
    return false;
  }
  public void launchCamera(Handler worker, Runnable onSecureCameraStarted) {
    LockPatternUtils lockPatternUtils = getLockPatternUtils();

    // Workaround to avoid camera release/acquisition race when resuming face unlock
    // after showing lockscreen camera (bug 11063890).
    KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
    updateMonitor.setAlternateUnlockEnabled(false);

    if (mustLaunchSecurely()) {
      // Launch the secure version of the camera
      if (wouldLaunchResolverActivity(SECURE_CAMERA_INTENT)) {
        // TODO: Show disambiguation dialog instead.
        // For now, we'll treat this like launching any other app from secure keyguard.
        // When they do, user sees the system's ResolverActivity which lets them choose
        // which secure camera to use.
        launchActivity(SECURE_CAMERA_INTENT, false, false, null, null);
      } else {
        launchActivity(SECURE_CAMERA_INTENT, true, false, worker, onSecureCameraStarted);
      }
    } else {
      // Launch the normal camera
      launchActivity(INSECURE_CAMERA_INTENT, false, false, null, null);
    }
  }
  public KeyguardViewMediator(
      Context context, PhoneWindowManager callback, LocalPowerManager powerManager) {
    mContext = context;

    mRealPowerManager = powerManager;
    mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock =
        mPM.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
    mWakeLock.setReferenceCounted(false);
    mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
    mShowKeyguardWakeLock.setReferenceCounted(false);

    mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff");
    mWakeAndHandOff.setReferenceCounted(false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(DELAYED_KEYGUARD_ACTION);
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    context.registerReceiver(mBroadCastReceiver, filter);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mCallback = callback;

    mUpdateMonitor = new KeyguardUpdateMonitor(context);

    mUpdateMonitor.registerSimStateCallback(this);

    mKeyguardViewProperties =
        new LockPatternKeyguardViewProperties(new LockPatternUtils(mContext), mUpdateMonitor);

    mKeyguardViewManager =
        new KeyguardViewManager(
            context, WindowManagerImpl.getDefault(), this, mKeyguardViewProperties, mUpdateMonitor);

    mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
    mUserPresentIntent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);

    final ContentResolver cr = mContext.getContentResolver();
    mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1);

    IntentFilter iF = new IntentFilter();
    iF.addAction("com.android.music.metachanged");
    iF.addAction("com.android.music.playstatechanged");
    mContext.registerReceiver(mMusicReceiver, iF);
  }
  private void performAppWidgetSizeCallbacksIfNecessary() {
    View content = getContent();
    if (!(content instanceof AppWidgetHostView)) return;

    if (!KeyguardUpdateMonitor.getInstance(mContext).hasBootCompleted()) {
      mPerformAppWidgetSizeUpdateOnBootComplete = true;
      return;
    }

    // TODO: there's no reason to force the AppWidgetHostView to catch duplicate size calls.
    // We can do that even more cheaply here. It's not an issue right now since we're in the
    // system process and hence no binder calls.
    AppWidgetHostView awhv = (AppWidgetHostView) content;
    float density = getResources().getDisplayMetrics().density;

    int width = (int) (content.getMeasuredWidth() / density);
    int height = (int) (content.getMeasuredHeight() / density);
    awhv.updateAppWidgetSize(null, width, height, width, height, true);
  }
  /** {@inheritDoc} */
  public void onSimStateChanged(IccCard.State simState) {
    if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState);

    switch (simState) {
      case ABSENT:
        // only force lock screen in case of missing sim if user hasn't
        // gone through setup wizard
        if (!mUpdateMonitor.isDeviceProvisioned()) {
          if (!isShowing()) {
            if (DEBUG)
              Log.d(
                  TAG,
                  "INTENT_VALUE_ICC_ABSENT and keygaurd isn't showing, we need "
                      + "to show the keyguard since the device isn't provisioned yet.");
            doKeyguard();
          } else {
            resetStateLocked();
          }
        }
        break;
      case PIN_REQUIRED:
      case PUK_REQUIRED:
        if (!isShowing()) {
          if (DEBUG)
            Log.d(
                TAG,
                "INTENT_VALUE_ICC_LOCKED and keygaurd isn't showing, we need "
                    + "to show the keyguard so the user can enter their sim pin");
          doKeyguard();
        } else {
          resetStateLocked();
        }

        break;
      case READY:
        if (isShowing()) {
          resetStateLocked();
        }
        break;
    }
  }
예제 #18
0
  /** Determine the current status of the lock screen given the SIM state and other stuff. */
  private StatusMode getStatusForIccState(IccCardConstants.State simState) {
    // Since reading the SIM may take a while, we assume it is present until told otherwise.
    if (simState == null) {
      return StatusMode.Normal;
    }

    final boolean missingAndNotProvisioned =
        !KeyguardUpdateMonitor.getInstance(mContext).isDeviceProvisioned()
            && (simState == IccCardConstants.State.ABSENT
                || simState == IccCardConstants.State.PERM_DISABLED);

    // M: Directly maps missing and not Provisioned to SimMissingLocked Status.
    if (missingAndNotProvisioned) {
      return StatusMode.SimMissingLocked;
    }
    // simState = missingAndNotProvisioned ? IccCardConstants.State.NETWORK_LOCKED : simState;
    // @}

    switch (simState) {
      case ABSENT:
        return StatusMode.SimMissing;
      case NETWORK_LOCKED:
        // M: correct IccCard state NETWORK_LOCKED maps to NetowrkLocked.
        return StatusMode.NetworkLocked;
      case NOT_READY:
        return StatusMode.SimNotReady;
      case PIN_REQUIRED:
        return StatusMode.SimLocked;
      case PUK_REQUIRED:
        return StatusMode.SimPukLocked;
      case READY:
        return StatusMode.Normal;
      case PERM_DISABLED:
        return StatusMode.SimPermDisabled;
      case UNKNOWN:
        return StatusMode.SimMissing;
    }
    return StatusMode.SimMissing;
  }
 /** @see android.app.KeyguardManager#exitKeyguardSecurely */
 public void verifyUnlock(WindowManagerPolicy.OnKeyguardExitResult callback) {
   synchronized (this) {
     if (DEBUG) Log.d(TAG, "verifyUnlock");
     if (!mUpdateMonitor.isDeviceProvisioned()) {
       // don't allow this api when the device isn't provisioned
       if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned");
       callback.onKeyguardExitResult(false);
     } else if (mExternallyEnabled) {
       // this only applies when the user has externally disabled the
       // keyguard.  this is unexpected and means the user is not
       // using the api properly.
       Log.w(TAG, "verifyUnlock called when not externally disabled");
       callback.onKeyguardExitResult(false);
     } else if (mExitSecureCallback != null) {
       // already in progress with someone else
       callback.onKeyguardExitResult(false);
     } else {
       mExitSecureCallback = callback;
       verifyUnlockLocked();
     }
   }
 }
 private void verifyPasswordAndUnlock() {
   String entry = mPasswordEntry.getText().toString();
   if (mLockPatternUtils.checkPassword(entry)) {
     mCallback.keyguardDone(true);
     mCallback.reportSuccessfulUnlockAttempt();
     mStatusViewManager.setInstructionText(null);
     KeyStore.getInstance().password(entry);
   } else if (entry.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT) {
     // to avoid accidental lockout, only count attempts that are long enough to be a
     // real password. This may require some tweaking.
     mCallback.reportFailedUnlockAttempt();
     if (0
         == (mUpdateMonitor.getFailedAttempts()
             % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
       long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
       handleAttemptLockout(deadline);
     }
     mStatusViewManager.setInstructionText(mContext.getString(R.string.lockscreen_password_wrong));
   } else if (entry.length() > 0) {
     mStatusViewManager.setInstructionText(mContext.getString(R.string.lockscreen_password_wrong));
   }
   mPasswordEntry.setText("");
 }
 /** {@inheritDoc} */
 public void cleanUp() {
   mUpdateMonitor.removeCallback(this);
 }
예제 #22
0
 @Override
 public void onResume(int reason) {
   KeyguardUpdateMonitor.getInstance(getContext()).registerCallback(mInfoCallback);
 }
예제 #23
0
 @Override
 public void onPause() {
   KeyguardUpdateMonitor.getInstance(getContext()).removeCallback(mInfoCallback);
 }
  /** {@inheritDoc} */
  public void onSimStateChanged(IccCard.State simState) {
    if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState);

    switch (simState) {
      case ABSENT:
        // only force lock screen in case of missing sim if user hasn't
        // gone through setup wizard
        synchronized (this) {
          if (!mUpdateMonitor.isDeviceProvisioned()) {
            if (!isShowing()) {
              if (DEBUG)
                Log.d(
                    TAG,
                    "ICC_ABSENT isn't showing,"
                        + " we need to show the keyguard since the "
                        + "device isn't provisioned yet.");
              doKeyguardLocked();
            } else {
              resetStateLocked();
            }
          }
        }
        break;
      case PIN_REQUIRED:
      case PUK_REQUIRED:
        synchronized (this) {
          if (!isShowing()) {
            if (DEBUG)
              Log.d(
                  TAG,
                  "INTENT_VALUE_ICC_LOCKED and keygaurd isn't showing, we need "
                      + "to show the keyguard so the user can enter their sim pin");
            doKeyguardLocked();
          } else {
            resetStateLocked();
          }
        }
        break;
      case PERM_DISABLED:
        synchronized (this) {
          if (!isShowing()) {
            if (DEBUG) Log.d(TAG, "PERM_DISABLED and " + "keygaurd isn't showing.");
            doKeyguardLocked();
          } else {
            if (DEBUG)
              Log.d(
                  TAG,
                  "PERM_DISABLED, resetStateLocked to"
                      + "show permanently disabled message in lockscreen.");
            resetStateLocked();
          }
        }
        break;
      case READY:
        synchronized (this) {
          if (isShowing()) {
            resetStateLocked();
          }
        }
        break;
    }
  }
예제 #25
0
 @Override
 protected void onDetachedFromWindow() {
   super.onDetachedFromWindow();
   KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mCallback);
 }
예제 #26
0
 @Override
 protected void onAttachedToWindow() {
   super.onAttachedToWindow();
   KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mCallback);
 }
 private boolean mustLaunchSecurely() {
   LockPatternUtils lockPatternUtils = getLockPatternUtils();
   KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
   int currentUser = lockPatternUtils.getCurrentUser();
   return lockPatternUtils.isSecure() && !updateMonitor.getUserHasTrust(currentUser);
 }
예제 #28
0
 /** {@inheritDoc} */
 public void cleanUp() {
   mUpdateMonitor.removeCallback(this); // this must be first
   mLockPatternUtils = null;
   mUpdateMonitor = null;
   mCallback = null;
 }
예제 #29
0
 /** Increments the number of failed Face Unlock attempts. */
 void handleReportFailedAttempt() {
   if (DEBUG) Log.d(TAG, "handleReportFailedAttempt()");
   mUpdateMonitor.reportFailedBiometricUnlockAttempt();
 }
 /**
  * Given the state of the keyguard, is the input restricted? Input is restricted when the keyguard
  * is showing, or when the keyguard was suppressed by an app that disabled the keyguard or we
  * haven't been provisioned yet.
  */
 public boolean isInputRestricted() {
   return mShowing || mNeedToReshowWhenReenabled || !mUpdateMonitor.isDeviceProvisioned();
 }