Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java

Issue 1630673002: In case of an AuthException, start the recovery intent if it exists. This is a temporary fix to unb… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java
diff --git a/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java b/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java
index 7e8e205ecb555294f940c048ea93faaa90338730..aaea7aaaf041c818079e092e98758751fd812416 100644
--- a/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java
+++ b/sync/android/java/src/org/chromium/sync/signin/AccountManagerHelper.java
@@ -9,6 +9,7 @@ import android.Manifest;
import android.accounts.Account;
import android.accounts.AuthenticatorDescription;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Process;
@@ -298,13 +299,16 @@ public class AccountManagerHelper {
*/
public void getAuthToken(final Account account, final String authTokenType,
final GetAuthTokenCallback callback) {
- ConnectionRetry.runAuthTask(new AuthTask<String>() {
+ ConnectionRetry.runAuthTask(mApplicationContext, new AuthTask<String>() {
+ @Override
public String run() throws AuthException {
return mAccountManager.getAuthToken(account, authTokenType);
}
+ @Override
public void onSuccess(String token) {
callback.tokenAvailable(token);
}
+ @Override
public void onFailure(boolean isTransientError) {
callback.tokenUnavailable(isTransientError);
}
@@ -334,12 +338,15 @@ public class AccountManagerHelper {
if (authToken == null || authToken.isEmpty()) {
return;
}
- ConnectionRetry.runAuthTask(new AuthTask<Boolean>() {
+ ConnectionRetry.runAuthTask(mApplicationContext, new AuthTask<Boolean>() {
+ @Override
public Boolean run() throws AuthException {
mAccountManager.invalidateAuthToken(authToken);
return true;
}
+ @Override
public void onSuccess(Boolean result) {}
+ @Override
public void onFailure(boolean isTransientError) {
Log.e(TAG, "Failed to invalidate auth token: " + authToken);
}
@@ -367,15 +374,17 @@ public class AccountManagerHelper {
implements NetworkChangeNotifier.ConnectionTypeObserver {
private static final int MAX_TRIES = 3;
+ private final Context mContext;
private final AuthTask<T> mAuthTask;
private final AtomicInteger mNumTries;
private final AtomicBoolean mIsTransientError;
- public static <T> void runAuthTask(AuthTask<T> authTask) {
- new ConnectionRetry<T>(authTask).attempt();
+ public static <T> void runAuthTask(Context context, AuthTask<T> authTask) {
+ new ConnectionRetry<T>(context, authTask).attempt();
}
- private ConnectionRetry(AuthTask<T> authTask) {
+ private ConnectionRetry(Context context, AuthTask<T> authTask) {
+ mContext = context;
mAuthTask = authTask;
mNumTries = new AtomicInteger(0);
mIsTransientError = new AtomicBoolean(false);
@@ -394,9 +403,17 @@ public class AccountManagerHelper {
try {
return mAuthTask.run();
} catch (AuthException ex) {
- // TODO(547048): Handle the recovery intent if it is present.
- Log.e(TAG, "Failed to perform auth task", ex);
+ Log.w(TAG, "Failed to perform auth task", ex);
mIsTransientError.set(ex.isTransientError());
+
+ // TODO(547048): This will fire the intent indiscriminately. We should fix
+ // this in the future to fire only once per user actionable intent to avoid
+ // spamming the user.
+ if (ex.getRecoveryIntent() != null) {
+ Intent i = ex.getRecoveryIntent();
+ i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(i);
+ }
}
return null;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698