@SuppressWarnings("deprecation") // TODO: refactor to use DialogFrament
  private void interpretScanResult(Uri scanResult, boolean confirmBeforeSave) {
    // The scan result is expected to be a URL that adds an account.

    // If confirmBeforeSave is true, the user has to confirm/reject the action.
    // We need to ensure that new results are accepted only if the previous ones have been
    // confirmed/rejected by the user. This is to prevent the attacker from sending multiple results
    // in sequence to confuse/DoS the user.
    if (confirmBeforeSave) {
      if (saveKeyIntentConfirmationInProgress) {
        Log.w(LOCAL_TAG, "Ignoring save key Intent: previous Intent not yet confirmed by user");
        return;
      }
      // No matter what happens below, we'll show a prompt which, once dismissed, will reset the
      // flag below.
      saveKeyIntentConfirmationInProgress = true;
    }

    // Sanity check
    if (scanResult == null) {
      showDialog(DIALOG_ID_INVALID_QR_CODE);
      return;
    }

    // See if the URL is an account setup URL containing a shared secret
    if (OTP_SCHEME.equals(scanResult.getScheme()) && scanResult.getAuthority() != null) {
      parseSecret(scanResult, confirmBeforeSave);
    } else {
      showDialog(DIALOG_ID_INVALID_QR_CODE);
    }
  }
Interprets the QR code that was scanned by the user. Decides whether to launch the key
provisioning sequence or the OTP seed setting sequence.

@param scanResult a URI holding the contents of the QR scan result
@param confirmBeforeSave a boolean to indicate if the user should be prompted for confirmation
    before updating the otp account information.
java/com/google/android/apps/authenticator/AuthenticatorActivity.java