Commit a9fa0793 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android] Make pre-native setup safe in RequestGenerator

This CL makes the pre-native setup and get account number safe inside
RequestGenerator.
This is a revert of the try-catch part of the CL
https://crrev.com/c/2080231.

Bug: 1061951
Change-Id: I6944a7e2acf1d295285b153ee2572d8bde9ad26d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106053
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750937}
parent 65ea79fb
......@@ -16,6 +16,7 @@ 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;
......@@ -202,9 +203,14 @@ public abstract class RequestGenerator {
// RequestGenerator may be invoked from JobService or AlarmManager (through OmahaService),
// so have to make sure AccountManagerFacade instance is initialized.
// TODO(waffles@chromium.org): Ideally, this should be asynchronous.
PostTask.runSynchronously(UiThreadTaskTraits.DEFAULT,
() -> ProcessInitializationHandler.getInstance().initializePreNative());
int numAccounts = AccountManagerFacade.get().tryGetGoogleAccounts().size();
int numAccounts = 0;
try {
PostTask.runSynchronously(UiThreadTaskTraits.DEFAULT,
() -> ProcessInitializationHandler.getInstance().initializePreNative());
numAccounts = AccountManagerFacade.get().tryGetGoogleAccounts().size();
} catch (Exception e) {
Log.e(TAG, "Cannot get number of accounts.", e);
}
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