From cf3b3ae987e73453f2265673a7ba3a72a1a6b4ed Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Thu, 16 Aug 2012 10:13:00 -0700 Subject: [PATCH] Prevent NPE while getting service Bug: 6989095 Change-Id: I646e393ec77a2e31c92011868f705e0936e41d88 --- src/com/android/email/service/EmailServiceUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java index e0d857ab0..5335cf82b 100644 --- a/src/com/android/email/service/EmailServiceUtils.java +++ b/src/com/android/email/service/EmailServiceUtils.java @@ -165,13 +165,15 @@ public class EmailServiceUtils { public static EmailServiceProxy getService(Context context, IEmailServiceCallback callback, String protocol) { + EmailServiceInfo info = null; // Handle the degenerate case here (account might have been deleted) - if (protocol == null) { + if (protocol != null) { + info = getServiceInfo(context, protocol); + } + if (info == null) { Log.w(Logging.LOG_TAG, "Returning NullService for " + protocol); return new EmailServiceProxy(context, NullService.class, null); - } - EmailServiceInfo info = getServiceInfo(context, protocol); - if (info.klass != null) { + } else if (info.klass != null) { return new EmailServiceProxy(context, info.klass, callback); } else { return new EmailServiceProxy(context, info.intentAction, callback);