Commit c6f65f76 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Android] Fix thread assert in InvalidationClientService

This CL adds ThreadUtils.runOnUiThread around call to
AccountManagerFacade.getNewAuthToken as this method should be invoked
on UI thread only.

Bug: 759023
Change-Id: I67c05084dca091ab1909549556211f84b8dec9c6
Reviewed-on: https://chromium-review.googlesource.com/702303Reviewed-by: default avatarPavel Yatsuk <pavely@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506769}
parent 7dbdfb95
......@@ -26,6 +26,7 @@ import org.chromium.base.BuildInfo;
import org.chromium.base.CollectionUtil;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.components.signin.AccountManagerFacade;
import org.chromium.components.signin.ChromeSigninController;
......@@ -251,19 +252,21 @@ public class InvalidationClientService extends AndroidListener {
return;
}
// Attempt to retrieve a token for the user. This method will also invalidate
// invalidAuthToken if it is non-null.
AccountManagerFacade.get().getNewAuthToken(account, invalidAuthToken,
getOAuth2ScopeWithType(), new AccountManagerFacade.GetAuthTokenCallback() {
@Override
public void tokenAvailable(String token) {
setAuthToken(InvalidationClientService.this.getApplicationContext(),
pendingIntent, token, getOAuth2ScopeWithType());
}
@Override
public void tokenUnavailable(boolean isTransientError) {}
});
ThreadUtils.runOnUiThread(() -> {
// Attempt to retrieve a token for the user. This method will also invalidate
// invalidAuthToken if it is non-null.
AccountManagerFacade.get().getNewAuthToken(account, invalidAuthToken,
getOAuth2ScopeWithType(), new AccountManagerFacade.GetAuthTokenCallback() {
@Override
public void tokenAvailable(String token) {
setAuthToken(InvalidationClientService.this.getApplicationContext(),
pendingIntent, token, getOAuth2ScopeWithType());
}
@Override
public void tokenUnavailable(boolean isTransientError) {}
});
});
}
@Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment