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();
  }
Exemplo n.º 2
0
  private void initSettings() {
    Bundle metaData = null;
    try {
      metaData =
          getPackageManager()
              .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA)
              .metaData;
    } catch (PackageManager.NameNotFoundException e) {
      e.printStackTrace();
    }

    if (metaData != null && metaData.containsKey(METADATA_MIN_WIRED_DOTS)) {
      minWiredDots =
          AlpSettings.Display.validateMinWiredDots(this, metaData.getInt(METADATA_MIN_WIRED_DOTS));
    } else {
      minWiredDots = AlpSettings.Display.getMinWiredDots(this);
    }

    if (metaData != null && metaData.containsKey(METADATA_MAX_RETRIES)) {
      maxRetries =
          AlpSettings.Display.validateMaxRetries(this, metaData.getInt(METADATA_MAX_RETRIES));
    } else {
      maxRetries = AlpSettings.Display.getMaxRetries(this);
    }

    if (metaData != null && metaData.containsKey(METADATA_AUTO_SAVE_PATTERN)) {
      autoSave = metaData.getBoolean(METADATA_AUTO_SAVE_PATTERN);
    } else {
      autoSave = AlpSettings.Security.isAutoSavePattern(this);
    }

    if (metaData != null && metaData.containsKey(METADATA_CAPTCHA_WIRED_DOTS)) {
      captchaWiredDots =
          AlpSettings.Display.validateCaptchaWiredDots(
              this, metaData.getInt(METADATA_CAPTCHA_WIRED_DOTS));
    } else {
      captchaWiredDots = AlpSettings.Display.getCaptchaWiredDots(this);
    }

    if (metaData != null && metaData.containsKey(METADATA_STEALTH_MODE)) {
      stealthMode = metaData.getBoolean(METADATA_STEALTH_MODE);
    } else {
      stealthMode = AlpSettings.Display.isStealthMode(this);
    }

    char[] encrypterClass;
    if (metaData != null && metaData.containsKey(METADATA_ENCRYPTER_CLASS)) {
      encrypterClass = metaData.getString(METADATA_ENCRYPTER_CLASS).toCharArray();
    } else {
      encrypterClass = AlpSettings.Security.getEncrypterClass(this);
    }

    if (encrypterClass != null) {
      try {
        encrypter =
            (IEncrypter)
                Class.forName(new String(encrypterClass), false, getClassLoader()).newInstance();
      } catch (Throwable t) {
        throw new InvalidEncrypterException();
      }
    }
  }