Prevent NPE while getting service

Bug: 6989095
Change-Id: I646e393ec77a2e31c92011868f705e0936e41d88
This commit is contained in:
Marc Blank 2012-08-16 10:13:00 -07:00
parent ed4017a6ea
commit cf3b3ae987

View File

@ -165,13 +165,15 @@ public class EmailServiceUtils {
public static EmailServiceProxy getService(Context context, IEmailServiceCallback callback, public static EmailServiceProxy getService(Context context, IEmailServiceCallback callback,
String protocol) { String protocol) {
EmailServiceInfo info = null;
// Handle the degenerate case here (account might have been deleted) // 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); Log.w(Logging.LOG_TAG, "Returning NullService for " + protocol);
return new EmailServiceProxy(context, NullService.class, null); return new EmailServiceProxy(context, NullService.class, null);
} } else if (info.klass != null) {
EmailServiceInfo info = getServiceInfo(context, protocol);
if (info.klass != null) {
return new EmailServiceProxy(context, info.klass, callback); return new EmailServiceProxy(context, info.klass, callback);
} else { } else {
return new EmailServiceProxy(context, info.intentAction, callback); return new EmailServiceProxy(context, info.intentAction, callback);