From 79b3317b775810bac088b0998c48eb6506e2578c Mon Sep 17 00:00:00 2001 From: Christopher Tate <ctate@google.com> Date: Mon, 18 Jun 2012 14:54:21 -0700 Subject: Fail immediately if bindService() is passed a null ServiceConnection Or if unbindService() is passed one, naturally. Change-Id: Ib7f1f0b5e12c04e3affbcc9008612801081819d5 --- core/java/android/app/ContextImpl.java | 6 ++++++ core/java/android/content/Context.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'core/java/android') diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 4c35a8c..3a657a7 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1181,6 +1181,9 @@ class ContextImpl extends Context { @Override public boolean bindService(Intent service, ServiceConnection conn, int flags, int userId) { IServiceConnection sd; + if (conn == null) { + throw new IllegalArgumentException("connection is null"); + } if (mPackageInfo != null) { sd = mPackageInfo.getServiceDispatcher(conn, getOuterContext(), mMainThread.getHandler(), flags); @@ -1211,6 +1214,9 @@ class ContextImpl extends Context { @Override public void unbindService(ServiceConnection conn) { + if (conn == null) { + throw new IllegalArgumentException("connection is null"); + } if (mPackageInfo != null) { IServiceConnection sd = mPackageInfo.forgetServiceDispatcher( getOuterContext(), conn); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 4c169d3..93a86c4 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1373,6 +1373,7 @@ public abstract class Context { * description (action, category, etc) to match an * {@link IntentFilter} published by a service. * @param conn Receives information as the service is started and stopped. + * This must be a valid ServiceConnection object; it must not be null. * @param flags Operation options for the binding. May be 0, * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, @@ -1408,7 +1409,7 @@ public abstract class Context { * stop at any time. * * @param conn The connection interface previously supplied to - * bindService(). + * bindService(). This parameter must not be null. * * @see #bindService */ -- cgit v1.1