File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
app/src/main/java/com/firebase/uidemo/auth
auth/src/main/java/com/firebase/ui/auth Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 2727import android .support .v7 .app .AlertDialog ;
2828import android .support .v7 .app .AppCompatActivity ;
2929import android .text .TextUtils ;
30+ import android .util .Log ;
3031import android .view .View ;
3132import android .widget .ImageView ;
3233import android .widget .TextView ;
5657
5758public class SignedInActivity extends AppCompatActivity {
5859
60+ private static final String TAG = "SignedInActivity" ;
61+
5962 private static final String EXTRA_IDP_RESPONSE = "extra_idp_response" ;
6063 private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config" ;
6164
@@ -126,6 +129,7 @@ public void onComplete(@NonNull Task<Void> task) {
126129 startActivity (AuthUiActivity .createIntent (SignedInActivity .this ));
127130 finish ();
128131 } else {
132+ Log .w (TAG , "signOut:failure" , task .getException ());
129133 showSnackbar (R .string .sign_out_failed );
130134 }
131135 }
Original file line number Diff line number Diff line change 8181 * for examples on how to get started with FirebaseUI Auth.
8282 */
8383public class AuthUI {
84+
85+ private static final String TAG = "AuthUI" ;
86+
8487 @ StringDef ({
8588 EmailAuthProvider .PROVIDER_ID ,
8689 PhoneAuthProvider .PROVIDER_ID ,
@@ -268,9 +271,31 @@ public static int getDefaultTheme() {
268271 @ NonNull
269272 public Task <Void > signOut (@ NonNull Context context ) {
270273 mAuth .signOut ();
274+
275+ Task <Void > maybeDisableAutoSignIn = GoogleApiUtils .getCredentialsClient (context )
276+ .disableAutoSignIn ()
277+ .continueWithTask (new Continuation <Void , Task <Void >>() {
278+ @ Override
279+ public Task <Void > then (@ NonNull Task <Void > task ) throws Exception {
280+ // We want to ignore a specific exception, since it's not a good reason
281+ // to fail (see Issue 1156).
282+ if (!task .isSuccessful () && (task .getException () instanceof ApiException )) {
283+ ApiException ae = (ApiException ) task .getException ();
284+ if (ae .getStatusCode () == CommonStatusCodes .CANCELED ) {
285+ Log .w (TAG , "Could not disable auto-sign in, maybe there are no " +
286+ "SmartLock accounts available?" , ae );
287+
288+ return Tasks .forResult (null );
289+ }
290+ }
291+
292+ return task ;
293+ }
294+ });
295+
271296 return Tasks .whenAll (
272297 signOutIdps (context ),
273- GoogleApiUtils . getCredentialsClient ( context ). disableAutoSignIn () );
298+ maybeDisableAutoSignIn );
274299 }
275300
276301 /**
You can’t perform that action at this time.
0 commit comments