Harden a few calls in Controller

* Check for null account (situation in which the Account has been
  deleted)

Change-Id: Iabd949c32443c7496a249ac5b7cdca22fc920a18
This commit is contained in:
Marc Blank 2009-09-25 09:24:56 -07:00
parent 1033fe606c
commit e892f6f978

View File

@ -741,7 +741,7 @@ public class Controller {
private IEmailService getServiceForAccount(long accountId) {
// TODO make this more efficient, caching the account, MUCH smaller lookup here, etc.
Account account = EmailContent.Account.restoreAccountWithId(mProviderContext, accountId);
if (isMessagingController(account)) {
if (account == null || isMessagingController(account)) {
return null;
} else {
return new EmailServiceProxy(mContext, SyncManager.class, mServiceCallback);
@ -755,6 +755,7 @@ public class Controller {
* TODO this should use a cache because we'll be doing this a lot
*/
public boolean isMessagingController(EmailContent.Account account) {
if (account == null) return false;
Store.StoreInfo info =
Store.StoreInfo.getStoreInfo(account.getStoreUri(mProviderContext), mContext);
// This null happens in testing.