Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who and when should call method confirmCredentials of AbstractAccountAuthenticator-based class?

I don't understand how method confirmCredentials works. I've never seen any options in the Android UI like “Confirm Credentials” or something like, there are only “Create account” and “Remove account”.

like image 653
Sergey Stolyarov Avatar asked Feb 18 '12 12:02

Sergey Stolyarov


1 Answers

Its used if you want to use the Gmail account on the device as a verification method. NFCSecure uses it when you open the app, forcing you to login with your gmail.

public void verifyAuth(Bundle b) throws IllegalArgumentException {
    accountManager.confirmCredentials(getImportantAccount(importantEmail), b, (Activity) c, new OnConfirmed(), null);
}


public void attemptLogin() {
    mEmailView.setError(null);
    mPasswordView.setError(null);

    mEmail = mEmailView.getText().toString();
    mPassword = mPasswordView.getText().toString();

    boolean cancel = false;
    View focusView = null;

    if (TextUtils.isEmpty(mPassword)) {
        mPasswordView.setError(getString(R.string.error_field_required));
        focusView = mPasswordView;
        cancel = true;
    } else if (mPassword.length() < 4) {
        mPasswordView.setError(getString(R.string.error_invalid_password));
        focusView = mPasswordView;
        cancel = true;
    }

    if (TextUtils.isEmpty(mEmail)) {
        mEmailView.setError(getString(R.string.error_field_required));
        focusView = mEmailView;
        cancel = true;
    } else if (!mEmail.contains("@")) {
        mEmailView.setError(getString(R.string.error_invalid_email));
        focusView = mEmailView;
        cancel = true;
    }

    if (cancel) {
        focusView.requestFocus();
    } else {
        mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
        showProgress(true);
        gAuth = new GoogleAuthentication(ctx, mEmailView.getText().toString());
        gAuth.setUserConfirmedListener(SettingsUnlockActivity.this);

        Bundle b = new Bundle();
        b.putString(AccountManager.KEY_PASSWORD, mPasswordView.getText().toString());
        try {
            gAuth.verifyAuth(b);
        } catch (IllegalArgumentException e) {
            doUnSuccessfulLogin();
        }
    }
}
like image 196
r2DoesInc Avatar answered Oct 07 '22 19:10

r2DoesInc