Change deleteAccountPIMData to take emailAddress, not id.
By the time the remote call actually runs, the account may be deleted from the DB, so the account id is likely useless. Bug: 9021105 Change-Id: If28b4b8c4b5c52be35c6ff68b326c4ea28d7f7b4
This commit is contained in:
parent
0a68a255c5
commit
9a1f00bee4
|
@ -401,14 +401,14 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
|||
* service or its sync adapters and 3) not stored in the EmailProvider database (e.g. contact
|
||||
* and calendar information).
|
||||
*
|
||||
* @param accountId the account whose data is to be deleted
|
||||
* @param emailAddress the email address for the account whose data should be deleted
|
||||
*/
|
||||
@Override
|
||||
public void deleteAccountPIMData(final long accountId) throws RemoteException {
|
||||
public void deleteAccountPIMData(final String emailAddress) throws RemoteException {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException {
|
||||
mService.deleteAccountPIMData(accountId);
|
||||
mService.deleteAccountPIMData(emailAddress);
|
||||
}
|
||||
}, "deleteAccountPIMData");
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ interface IEmailService {
|
|||
|
||||
// Must not be oneway; unless an exception is thrown, the caller is guaranteed that the action
|
||||
// has been completed
|
||||
void deleteAccountPIMData(long accountId);
|
||||
void deleteAccountPIMData(String emailAddress);
|
||||
|
||||
int getApiLevel();
|
||||
|
||||
|
|
|
@ -4558,7 +4558,20 @@ public class EmailProvider extends ContentProvider {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/** Projection used for getting email address for an account. */
|
||||
private static final String[] ACCOUNT_EMAIL_PROJECTION = { AccountColumns.EMAIL_ADDRESS };
|
||||
|
||||
private static void deleteAccountData(Context context, long accountId) {
|
||||
// We will delete PIM data, but by the time the asynchronous call to do that happens,
|
||||
// the account may have been deleted from the DB. Therefore we have to get the email
|
||||
// address now and send that, rather than the account id.
|
||||
final String emailAddress = Utility.getFirstRowString(context, Account.CONTENT_URI,
|
||||
ACCOUNT_EMAIL_PROJECTION, Account.ID_SELECTION,
|
||||
new String[] {Long.toString(accountId)}, null, 0);
|
||||
if (emailAddress == null) {
|
||||
LogUtils.e(TAG, "Could not find email address for account %d", accountId);
|
||||
}
|
||||
|
||||
// Delete synced attachments
|
||||
AttachmentUtilities.deleteAllAccountAttachmentFiles(context, accountId);
|
||||
|
||||
|
@ -4573,12 +4586,15 @@ public class EmailProvider extends ContentProvider {
|
|||
resolver.update(Account.CONTENT_URI, cv, Account.ID_SELECTION, accountIdArgs);
|
||||
|
||||
// Delete PIM data (contacts, calendar), stop syncs, etc. if applicable
|
||||
IEmailService service = EmailServiceUtils.getServiceForAccount(context, null, accountId);
|
||||
if (service != null) {
|
||||
try {
|
||||
service.deleteAccountPIMData(accountId);
|
||||
} catch (RemoteException e) {
|
||||
// Can't do anything about this
|
||||
if (emailAddress != null) {
|
||||
final IEmailService service =
|
||||
EmailServiceUtils.getServiceForAccount(context, null, accountId);
|
||||
if (service != null) {
|
||||
try {
|
||||
service.deleteAccountPIMData(emailAddress);
|
||||
} catch (final RemoteException e) {
|
||||
// Can't do anything about this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -476,7 +476,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteAccountPIMData(long accountId) throws RemoteException {
|
||||
public void deleteAccountPIMData(final String emailAddress) throws RemoteException {
|
||||
MailService.reconcileLocalAccountsSync(mContext);
|
||||
}
|
||||
|
||||
|
|
|
@ -658,7 +658,7 @@ public class EmailServiceUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteAccountPIMData(long accountId) throws RemoteException {
|
||||
public void deleteAccountPIMData(final String emailAddress) throws RemoteException {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue