From 473ce1fa354c81fd7d5bbd84b6a85d629a039e72 Mon Sep 17 00:00:00 2001 From: Tony Mantler Date: Thu, 21 Aug 2014 16:30:49 -0700 Subject: [PATCH] Fix some AOSP NPEs In AOSP the account types of IMAP and POP overlap so we can't reverse the protocol from the account type. This is OK since all we care about is if it's Exchange or not. b/17183137 Change-Id: I112e56c9a0c0009a74f391749d535ada9f0f99ba (cherry picked from commit 18663ef54ed2d7217d0176b4c5928380deaf9f64) --- src/com/android/email/provider/AccountReconciler.java | 4 ++-- src/com/android/email/service/AuthenticatorService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/provider/AccountReconciler.java b/src/com/android/email/provider/AccountReconciler.java index 531436a8a..c8cfc8ef7 100644 --- a/src/com/android/email/provider/AccountReconciler.java +++ b/src/com/android/email/provider/AccountReconciler.java @@ -249,11 +249,11 @@ public class AccountReconciler { final String protocol = EmailServiceUtils.getProtocolFromAccountType( context, accountType); final EmailServiceInfo info = EmailServiceUtils.getServiceInfo(context, protocol); - if (!info.syncCalendar) { + if (info == null || !info.syncCalendar) { ContentResolver.setIsSyncable(accountManagerAccount, CalendarContract.AUTHORITY, 0); } - if (!info.syncContacts) { + if (info == null || !info.syncContacts) { ContentResolver.setIsSyncable(accountManagerAccount, ContactsContract.AUTHORITY, 0); } diff --git a/src/com/android/email/service/AuthenticatorService.java b/src/com/android/email/service/AuthenticatorService.java index 7add271e9..c69bb93e6 100644 --- a/src/com/android/email/service/AuthenticatorService.java +++ b/src/com/android/email/service/AuthenticatorService.java @@ -73,7 +73,7 @@ public class AuthenticatorService extends Service { account, options.getString(OPTIONS_PASSWORD), null); // Set up contacts syncing, if appropriate - if (info.syncContacts) { + if (info != null && info.syncContacts) { boolean syncContacts = options.getBoolean(OPTIONS_CONTACTS_SYNC_ENABLED, false); ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, @@ -81,7 +81,7 @@ public class AuthenticatorService extends Service { } // Set up calendar syncing, if appropriate - if (info.syncCalendar) { + if (info != null && info.syncCalendar) { boolean syncCalendar = options.getBoolean(OPTIONS_CALENDAR_SYNC_ENABLED, false); ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY,