diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java index b5be9a1a9bca380c3f0000ffb6505f904524af0a..a56dc94c2a35555b36ff858c9baee5ee5b3c5190 100644 --- a/src/com/android/settings/accounts/AccountSyncSettings.java +++ b/src/com/android/settings/accounts/AccountSyncSettings.java @@ -386,16 +386,6 @@ public class AccountSyncSettings extends AccountPreferenceBase { extras); } else { ContentResolver.cancelSyncAsUser(account, authority, mUserHandle.getIdentifier()); - cancelMailSync(account, authority); - } - } - - private void cancelMailSync(Account account, String authority) { - if (MailAccountSyncHelper.MAIL_SYNC_AUTHORITY.equals(authority)) { - final Context context = getPrefContext().getApplicationContext(); - final AccountManager accountManager = AccountManager.get(context); - final String email = accountManager.getUserData(account, "email_address"); - MailAccountSyncHelper.getInstance().disableSync(context, email); } } diff --git a/src/com/android/settings/accounts/MailAccountSyncHelper.java b/src/com/android/settings/accounts/MailAccountSyncHelper.java deleted file mode 100644 index 1af8faa0043048280d641ebc30109b41cd7829b9..0000000000000000000000000000000000000000 --- a/src/com/android/settings/accounts/MailAccountSyncHelper.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright ECORP SAS 2022 - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.android.settings.accounts; - -import android.annotation.TargetApi; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.os.Build; - -public class MailAccountSyncHelper { - - public static final String MAIL_SYNC_AUTHORITY = "foundation.e.mail.provider.AppContentProvider"; - - private static final String MAIL_PACKAGE = "foundation.e.mail"; - private static final String MAIL_RECEIVER_CLASS = "com.fsck.k9.account.AccountSyncReceiver"; - private static final String ACTION_PREFIX = "foundation.e.accountmanager.account."; - private static final String ACCOUNT = "account"; - - private static MailAccountSyncHelper instance = null; - - public void accountLoggedIn(Context applicationContext) { - if (applicationContext == null) { - return; - } - Intent intent = getIntent(); - intent.setAction(ACTION_PREFIX + "create"); - applicationContext.sendBroadcast(intent); - } - - public void accountLoggedOut(Context applicationContext, String email) { - sendBroadCast(applicationContext, email, "remove"); - } - - public void disableSync(Context applicationContext, String email) { - sendBroadCast(applicationContext, email, "disablesync"); - } - - private void sendBroadCast(Context applicationContext, String email, String action) { - if (applicationContext == null || email == null || !email.contains("@") || action == null || action.isEmpty()) { - return; - } - final Intent intent = getIntent(); - intent.setAction(ACTION_PREFIX + action); - intent.putExtra(ACCOUNT, email); - applicationContext.sendBroadcast(intent); - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) - private Intent getIntent() { - Intent intent = new Intent(); - intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - intent.setComponent(new ComponentName(MAIL_PACKAGE, MAIL_RECEIVER_CLASS)); - return intent; - } - - - public static MailAccountSyncHelper getInstance() { - if (instance == null) { - synchronized (MailAccountSyncHelper.class) { - if (instance == null) { - instance = new MailAccountSyncHelper(); - } - } - } - return instance; - } - - private MailAccountSyncHelper() { - } -} diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java index 5858f9e1c5ec7af13c2823fed2c772ea8a5847fe..037f5846a886681c9a5d1abc2448f9f6e342c2d1 100644 --- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java +++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java @@ -158,10 +158,7 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl @Override public void onClick(DialogInterface dialog, int which) { Activity activity = getTargetFragment().getActivity(); - AccountManager accountManager = AccountManager.get(activity); - String email = accountManager.getUserData(mAccount, "email_address"); - - accountManager.removeAccountAsUser(mAccount, activity, + AccountManager.get(activity).removeAccountAsUser(mAccount, activity, future -> { final Activity targetActivity = getTargetFragment().getActivity(); if (targetActivity == null || targetActivity.isFinishing()) { @@ -182,7 +179,6 @@ public class RemoveAccountPreferenceController extends AbstractPreferenceControl if (failed) { RemoveAccountFailureDialog.show(getTargetFragment()); } else { - MailAccountSyncHelper.getInstance().accountLoggedOut(targetActivity.getApplicationContext(), email); targetActivity.finish(); } }, null, mUserHandle);