In 4.4 unbindService can return other RuntimeExceptions outside of

IllegalArgumentException.  Make sure we catch it.

This fix comes from Motorola 0007-IKXREL1KK-3886 but part of that
patch was reverted because we already had found and fixed the
other problem.

Change-Id: I0b6aa1f91e7d2fa4dfc3af5ff590781c8812c14e
This commit is contained in:
Anthony Lee 2014-02-12 11:37:06 -08:00
parent 1e05bc7d73
commit 6ef1621f44

View File

@ -104,9 +104,14 @@ public abstract class ServiceProxy {
// Each ServiceProxy handles just one task, so we unbind after we're // Each ServiceProxy handles just one task, so we unbind after we're
// done with our work. // done with our work.
mContext.unbindService(mConnection); mContext.unbindService(mConnection);
} catch (IllegalArgumentException e) { } catch (RuntimeException e) {
// This can happen if the user ended the activity that was using the // The exceptions that are thrown here look like IllegalStateException,
// service. This is harmless, but we've got to catch it. // IllegalArgumentException and RuntimeException. Catching RuntimeException
// which get them all. Reasons for these exceptions include services that
// have already been stopped or unbound. This can happen if the user ended
// the activity that was using the service. This is harmless, but we've got
// to catch it.
LogUtils.e(mTag, e, "RuntimeException when trying to unbind from service");
} }
mTaskCompleted = true; mTaskCompleted = true;
synchronized(mConnection) { synchronized(mConnection) {