Remove mAmAccount from the email provider account object
b/11070468 Change-Id: I51bad4be41800e4cd6dae42744005ade784cdf82
This commit is contained in:
parent
91508db973
commit
840408c41c
@ -31,9 +31,11 @@ import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.emailcommon.provider.EmailContent.AccountColumns;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -145,8 +147,6 @@ public final class Account extends EmailContent implements AccountColumns, Parce
|
||||
public transient HostAuth mHostAuthRecv;
|
||||
public transient HostAuth mHostAuthSend;
|
||||
public transient Policy mPolicy;
|
||||
// Might hold the corresponding AccountManager account structure
|
||||
public transient android.accounts.Account mAmAccount;
|
||||
|
||||
public static final int CONTENT_ID_COLUMN = 0;
|
||||
public static final int CONTENT_DISPLAY_NAME_COLUMN = 1;
|
||||
@ -602,6 +602,16 @@ public final class Account extends EmailContent implements AccountColumns, Parce
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a corresponding account manager object using the passed in type
|
||||
*
|
||||
* @param type We can't look up the account type from here, so pass it in
|
||||
* @return system account object
|
||||
*/
|
||||
public android.accounts.Account getAccountManagerAccount(String type) {
|
||||
return new android.accounts.Account(mEmailAddress, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the account ID for a message with a given id
|
||||
*
|
||||
|
@ -75,6 +75,7 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
@ -292,15 +293,21 @@ public abstract class SyncManager extends Service implements Runnable {
|
||||
public class AccountList extends ArrayList<Account> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final WeakHashMap<Account, android.accounts.Account> mAmMap =
|
||||
new WeakHashMap<Account, android.accounts.Account>();
|
||||
|
||||
@Override
|
||||
public boolean add(Account account) {
|
||||
// Cache the account manager account
|
||||
account.mAmAccount = new android.accounts.Account(
|
||||
account.mEmailAddress, getAccountManagerType());
|
||||
mAmMap.put(account, account.getAccountManagerAccount(getAccountManagerType()));
|
||||
super.add(account);
|
||||
return true;
|
||||
}
|
||||
|
||||
public android.accounts.Account getAmAccount(Account account) {
|
||||
return mAmMap.get(account);
|
||||
}
|
||||
|
||||
public boolean contains(long id) {
|
||||
for (Account account : this) {
|
||||
if (account.mId == id) {
|
||||
@ -1766,7 +1773,8 @@ public abstract class SyncManager extends Service implements Runnable {
|
||||
}
|
||||
}
|
||||
// See if "sync automatically" is set; if not, punt
|
||||
if (!ContentResolver.getSyncAutomatically(account.mAmAccount, authority)) {
|
||||
if (!ContentResolver.getSyncAutomatically(mAccountList.getAmAccount(account),
|
||||
authority)) {
|
||||
return false;
|
||||
// See if the calendar is enabled from the Calendar app UI; if not, punt
|
||||
} else if ((type == Mailbox.TYPE_CALENDAR) && !isCalendarEnabled(account.mId)) {
|
||||
@ -1778,7 +1786,7 @@ public abstract class SyncManager extends Service implements Runnable {
|
||||
// For non-outbox, non-account mail, we do two checks:
|
||||
// 1) are we restricted by policy (i.e. manual sync only),
|
||||
// 2) has the user checked the "Sync Email" box in Account Settings, and
|
||||
} else if (!canAutoSync(account) || !canSyncEmail(account.mAmAccount)) {
|
||||
} else if (!canAutoSync(account) || !canSyncEmail(mAccountList.getAmAccount(account))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -38,6 +38,7 @@ import android.text.TextUtils;
|
||||
import com.android.email.activity.setup.AccountSecurity;
|
||||
import com.android.email.activity.setup.AccountSettings;
|
||||
import com.android.email.provider.EmailProvider;
|
||||
import com.android.email.service.EmailServiceUtils;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.provider.EmailContent.Attachment;
|
||||
@ -514,7 +515,10 @@ public class NotificationController {
|
||||
* as well as special login/security notifications.
|
||||
*/
|
||||
public static void cancelNotifications(final Context context, final Account account) {
|
||||
NotificationUtils.clearAccountNotifications(context, account.mAmAccount);
|
||||
final android.accounts.Account notifAccount
|
||||
= account.getAccountManagerAccount(
|
||||
EmailServiceUtils.getServiceInfoForAccount(context, account.mId).accountType);
|
||||
NotificationUtils.clearAccountNotifications(context, notifAccount);
|
||||
|
||||
final NotificationManager notificationManager = getInstance(context).mNotificationManager;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user