Merge "Fix account deletion not updating account display"

This commit is contained in:
TreeHugger Robot
2018-09-24 17:16:42 +00:00
committed by Android (Google) Code Review
4 changed files with 68 additions and 7 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.accounts;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
@@ -89,6 +90,28 @@ public class AccountDetailDashboardFragment extends DashboardFragment {
updateUi();
}
@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;
}
}
if (!accountExists) {
finish();
}
}
@Override
public void onResume() {
super.onResume();
finishIfAccountMissing();
}
@Override
public int getMetricsCategory() {
return MetricsEvent.ACCOUNT;

View File

@@ -157,10 +157,6 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl
new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
// If already out of this screen, don't proceed.
if (!getTargetFragment().isResumed()) {
return;
}
boolean failed = true;
try {
if (future.getResult()