Check accounts in all profiles on account detail dashboard

In cl/5074783 I fixed a problem with account deletion where the account
didn't appear to be deleted even when it was. Part of that fix broke the
ability to make changes to work profile accounts - this CL fixes that by
making sure not to early exit the account detail dashboard unless we've
checked the accounts owned by all profiles for the user.

Bug: 117965642
Test: make -j40 RunSettingsRoboTests
Change-Id: Id034418beb4aec8bd4d10191b4924509d27e55d4
This commit is contained in:
Antony Sargent
2018-11-05 14:56:28 -08:00
parent 92792ee806
commit 95f34b43f4
4 changed files with 80 additions and 19 deletions

View File

@@ -92,18 +92,18 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
@VisibleForTesting
void finishIfAccountMissing() {
AccountManager accountManager = (AccountManager) getContext().getSystemService(
Context.ACCOUNT_SERVICE);
boolean accountExists = false;
for (Account account : accountManager.getAccountsByType(mAccount.type)) {
if (account.equals(mAccount)) {
accountExists = true;
break;
final Context context = getContext();
final UserManager um = context.getSystemService(UserManager.class);
final AccountManager accountManager = (AccountManager) context.getSystemService(
AccountManager.class);
for (UserHandle userHandle : um.getUserProfiles()) {
for (Account account : accountManager.getAccountsAsUser(userHandle.getIdentifier())) {
if (account.equals(mAccount)) {
return;
}
}
}
if (!accountExists) {
finish();
}
finish();
}
@Override
@@ -177,4 +177,4 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
accountTypePreferenceLoader.updatePreferenceIntents(prefs, mAccountType, mAccount);
}
}
}
}