|
7 | 7 | import android.accounts.Account;
|
8 | 8 | import android.app.Activity;
|
9 | 9 | import android.content.Intent;
|
10 |
| -import com.google.android.gms.auth.GoogleAuthException; |
11 | 10 | import com.google.android.gms.auth.GoogleAuthUtil;
|
12 | 11 | import com.google.android.gms.auth.UserRecoverableAuthException;
|
13 | 12 | import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
|
28 | 27 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
29 | 28 | import io.flutter.plugin.common.MethodChannel.Result;
|
30 | 29 | import io.flutter.plugin.common.PluginRegistry;
|
31 |
| -import java.io.IOException; |
32 | 30 | import java.util.HashMap;
|
33 | 31 | import java.util.List;
|
34 | 32 | import java.util.Map;
|
@@ -403,13 +401,31 @@ private static class PendingOperation {
|
403 | 401 |
|
404 | 402 | /** Clears the token kept in the client side cache. */
|
405 | 403 | @Override
|
406 |
| - public void clearAuthCache(Result result, String token) { |
407 |
| - try { |
408 |
| - GoogleAuthUtil.clearToken(registrar.context(), token); |
409 |
| - result.success(null); |
410 |
| - } catch (GoogleAuthException | IOException e) { |
411 |
| - result.error(ERROR_REASON_EXCEPTION, e.getMessage(), e); |
412 |
| - } |
| 404 | + public void clearAuthCache(final Result result, final String token) { |
| 405 | + Callable<Void> clearTokenTask = |
| 406 | + new Callable<Void>() { |
| 407 | + @Override |
| 408 | + public Void call() throws Exception { |
| 409 | + GoogleAuthUtil.clearToken(registrar.context(), token); |
| 410 | + return null; |
| 411 | + } |
| 412 | + }; |
| 413 | + |
| 414 | + backgroundTaskRunner.runInBackground( |
| 415 | + clearTokenTask, |
| 416 | + new BackgroundTaskRunner.Callback<Void>() { |
| 417 | + @Override |
| 418 | + public void run(Future<Void> clearTokenFuture) { |
| 419 | + try { |
| 420 | + result.success(clearTokenFuture.get()); |
| 421 | + } catch (ExecutionException e) { |
| 422 | + result.error(ERROR_REASON_EXCEPTION, e.getCause().getMessage(), null); |
| 423 | + } catch (InterruptedException e) { |
| 424 | + result.error(ERROR_REASON_EXCEPTION, e.getMessage(), null); |
| 425 | + Thread.currentThread().interrupt(); |
| 426 | + } |
| 427 | + } |
| 428 | + }); |
413 | 429 | }
|
414 | 430 |
|
415 | 431 | /**
|
|
0 commit comments