Commit 55016d4e authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Signin][Android] Clean AccountManagerFacade.getGoogleAccounts usage

This CL cleans the AccountManagerFacade.getGoogleAccounts usage in
RequestGenerator. We should use this method when the error
thrown is meaningful.

Bug: 1057040
Change-Id: Ib6dbd625d20c6da4a231a25055333100e93bc844
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080231Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747145}
parent 638640a4
......@@ -16,7 +16,6 @@ import androidx.annotation.VisibleForTesting;
import org.xmlpull.v1.XmlSerializer;
import org.chromium.base.BuildInfo;
import org.chromium.base.Log;
import org.chromium.base.task.PostTask;
import org.chromium.chrome.browser.identity.SettingsSecureBasedIdentificationGenerator;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
......@@ -199,23 +198,11 @@ public abstract class RequestGenerator {
public int getNumGoogleAccountsOnDevice() {
// RequestGenerator may be invoked from JobService or AlarmManager (through OmahaService),
// so have to make sure AccountManagerFacade instance is initialized.
int numAccounts = 0;
try {
// TODO(waffles@chromium.org): Ideally, this should be asynchronous.
PostTask.runSynchronously(UiThreadTaskTraits.DEFAULT,
() -> ProcessInitializationHandler.getInstance().initializePreNative());
numAccounts = AccountManagerFacade.get().getGoogleAccounts().size();
} catch (Exception e) {
Log.e(TAG, "Can't get number of accounts.", e);
}
switch (numAccounts) {
case 0:
return 0;
case 1:
return 1;
default:
return 2;
}
// TODO(waffles@chromium.org): Ideally, this should be asynchronous.
PostTask.runSynchronously(UiThreadTaskTraits.DEFAULT,
() -> ProcessInitializationHandler.getInstance().initializePreNative());
int numAccounts = AccountManagerFacade.get().tryGetGoogleAccounts().size();
return numAccounts < 2 ? numAccounts : 2;
}
/**
......
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