Exemplo n.º 1
0
  protected final void finishWithResultOk(char[] pattern) {
    if (LockPatternType.CREATE_PATTERN == lockPatternType) {
      if (autoSave) {
        AlpSettings.Security.setPattern(this, pattern);
      }
      intentResult.putExtra(EXTRA_PATTERN, pattern);
    } else {
      intentResult.putExtra(EXTRA_RETRY_COUNT, retryCount);
    }

    setResult(Activity.RESULT_OK, intentResult);

    /** ResultReceiver */
    ResultReceiver receiver = getIntent().getParcelableExtra(EXTRA_RESULT_RECEIVER);
    if (receiver != null) {
      Bundle bundle = new Bundle();
      if (LockPatternType.CREATE_PATTERN == lockPatternType)
        bundle.putCharArray(EXTRA_PATTERN, pattern);
      else {
        /** If the user was "logging in", minimum try count can not be zero. */
        bundle.putInt(EXTRA_RETRY_COUNT, retryCount);
      }
      bundle.putSerializable(EXTRA_LOCK_PATTERN_TYPE, lockPatternType);
      bundle.putBoolean(EXTRA_IS_MODIFY, isModify());
      receiver.send(Activity.RESULT_OK, bundle);
    }

    /** PendingIntent */
    PendingIntent pi = getIntent().getParcelableExtra(EXTRA_PENDING_INTENT_OK);
    if (pi != null) {
      try {
        pi.send(this, Activity.RESULT_OK, intentResult);
      } catch (Throwable t) {
        Log.e(CLASSNAME, "Error sending PendingIntent: " + pi, t);
      }
    }

    finish();
  }