public AccountIndex findMatchingGoogleAccount(String accountName) {
    String[] accountNamePrefixesToTry = { "", "Google:" };
    for (String prefix : accountNamePrefixesToTry) {
      AccountIndex indexToTry = new AccountIndex(prefix + accountName, GOOGLE_ISSUER_NAME);
      if (indexExists(indexToTry)) {
        return indexToTry;
      }

      // Try finding a Google issued account that used to have the matching name
      for (AccountIndex index : getAccounts()) {
        if (!GOOGLE_ISSUER_NAME.equals(index.getIssuer())) {
          continue; // Only care about Google issued accounts
        }
        String originalName = getOriginalName(index);
        if (accountName.equalsIgnoreCase(prefix + originalName)) {
          return index;
        }
      }

      // No luck yet. It may be a legacy account with no issuer, though.
      indexToTry = new AccountIndex(prefix + accountName, null);
      if (indexExists(indexToTry)) {
        return indexToTry;
      }
    }

    // Google corp account?
    if (accountName.toLowerCase(Locale.US).endsWith("@google.com")) {
      return findGoogleCorpAccount();
    }
    return null;  // Couldn't find anything
  }
Tries to find an Authenticator {@link AccountIndex} that corresponds to the Android user
account described in {@code accountName}.

@param accountName name of an account on the user's device, not necessarily in Authenticator
@return a corresponding {@link AccountIndex} or {@code null} if no match could be found
java/com/google/android/apps/authenticator/otp/AccountDb.java