コード例 #1
0
  /**
   * 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();
  }
コード例 #2
0
  /**
   * 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;
  }