Skip to content

Commit

Permalink
[Signin][Android] Only reload accounts if account fetching succeeded
Browse files Browse the repository at this point in the history
Bug: b/40284908
Change-Id: Ia839e3daf5bfc2f805417cafcee716a8c7652e9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5377867
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Samar Chehade-Lepleux <samarchehade@google.com>
Cr-Commit-Position: refs/heads/main@{#1276802}
  • Loading branch information
Samar authored and Chromium LUCI CQ committed Mar 22, 2024
1 parent ba627ce commit bcdd7db
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 44 deletions.
Expand Up @@ -168,7 +168,9 @@ private SigninManagerImpl(
mAccountManagerFacade.addObserver(this);
Promise<List<CoreAccountInfo>> coreAccountInfosPromise =
mAccountManagerFacade.getCoreAccountInfos();
if (coreAccountInfosPromise.isFulfilled()) {
if (coreAccountInfosPromise.isFulfilled()
&& (mAccountManagerFacade.didAccountFetchSucceed()
|| !coreAccountInfosPromise.getResult().isEmpty())) {
seedThenReloadAllAccountsFromSystem(
CoreAccountInfo.getIdFrom(
identityManager.getPrimaryAccountInfo(ConsentLevel.SIGNIN)));
Expand All @@ -177,8 +179,8 @@ private SigninManagerImpl(
}

/**
* Triggered during SigninManagerAndroidWrapper's KeyedService::Shutdown.
* Drop references with external services and native.
* Triggered during SigninManagerAndroidWrapper's KeyedService::Shutdown. Drop references with
* external services and native.
*/
@VisibleForTesting
@CalledByNative
Expand All @@ -203,6 +205,12 @@ public void onCoreAccountInfosChanged() {
mAccountManagerFacade.getCoreAccountInfos();
assert coreAccountInfosPromise.isFulfilled();
List<CoreAccountInfo> coreAccountInfos = coreAccountInfosPromise.getResult();
if (!mAccountManagerFacade.didAccountFetchSucceed() && coreAccountInfos.isEmpty()) {
// If the account fetch did not succeed, the AccountManagerFacade falls back to an empty
// list. Do nothing when this is the case.
return;
}

@Nullable
CoreAccountInfo primaryAccountInfo =
mIdentityManager.getPrimaryAccountInfo(ConsentLevel.SIGNIN);
Expand Down

0 comments on commit bcdd7db

Please sign in to comment.