Merge "Fix account deletion not updating account display"
This commit is contained in:
committed by
Android (Google) Code Review
commit
9f553bc863
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user