@@ -96,9 +96,7 @@ public void onCancel(DialogInterface dialogInterface) {
96
96
return ;
97
97
}
98
98
99
- if (!mFlowParams .smartLockEnabled ) {
100
- startAuthMethodChoice ();
101
- } else {
99
+ if (mFlowParams .smartLockEnabled ) {
102
100
showProgress ();
103
101
initGoogleApiClient (null );
104
102
Auth .CredentialsApi
@@ -108,6 +106,8 @@ public void onCancel(DialogInterface dialogInterface) {
108
106
.setAccountTypes (IdentityProviders .GOOGLE )
109
107
.build ())
110
108
.setResultCallback (this );
109
+ } else {
110
+ startAuthMethodChoice ();
111
111
}
112
112
}
113
113
@@ -119,31 +119,29 @@ public void onResult(@NonNull CredentialRequestResult result) {
119
119
if (status .isSuccess ()) {
120
120
// Auto sign-in success
121
121
handleCredential (result .getCredential ());
122
- delegateSignIn (true , false );
122
+ delegateSignIn (true );
123
123
} else if (status .getStatusCode () == CommonStatusCodes .RESOLUTION_REQUIRED ) {
124
- delegateSignIn (false , true );
124
+ delegateSignIn (false );
125
125
}
126
126
}
127
127
128
- private void delegateSignIn (boolean isAutoSignInAvailable , boolean isSignInResolutionNeeded ) {
128
+ private void delegateSignIn (boolean isAutoSignInAvailable ) {
129
129
String email = getEmailFromCredential ();
130
130
String password = getPasswordFromCredential ();
131
131
132
132
// Attempt auto-sign in using SmartLock
133
133
if (isAutoSignInAvailable ) {
134
134
googleSilentSignIn ();
135
- if (!TextUtils .isEmpty (password )) {
136
- // Sign in with the email/password retrieved from SmartLock
137
- signInWithEmailAndPassword (email , password );
138
- } else {
135
+ if (TextUtils .isEmpty (password )) {
139
136
// log in with id/provider
140
137
redirectToIdpSignIn (email , getAccountTypeFromCredential ());
138
+ } else {
139
+ // Sign in with the email/password retrieved from SmartLock
140
+ signInWithEmailAndPassword (email , password );
141
141
}
142
- } else if ( isSignInResolutionNeeded ) {
142
+ } else {
143
143
// resolve credential
144
144
resolveSavedEmails ();
145
- } else {
146
- startAuthMethodChoice ();
147
145
}
148
146
hideProgress ();
149
147
}
@@ -169,12 +167,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
169
167
String email = getEmailFromCredential ();
170
168
String password = getPasswordFromCredential ();
171
169
if (email != null ) {
172
- if (password != null && !password .isEmpty ()) {
173
- // email/password combination
174
- signInWithEmailAndPassword (email , password );
175
- } else {
170
+ if (password == null || password .isEmpty ()) {
176
171
// identifier/provider combination
177
172
redirectToIdpSignIn (email , getAccountTypeFromCredential ());
173
+ } else {
174
+ // email/password combination
175
+ signInWithEmailAndPassword (email , password );
178
176
}
179
177
}
180
178
} else if (resultCode == RESULT_CANCELED
0 commit comments