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
1 changed files with 8 additions and 3 deletions

View File

@ -104,9 +104,14 @@ public abstract class ServiceProxy {
// Each ServiceProxy handles just one task, so we unbind after we're
// done with our work.
mContext.unbindService(mConnection);
} catch (IllegalArgumentException e) {
// This can happen if the user ended the activity that was using the
// service. This is harmless, but we've got to catch it.
} catch (RuntimeException e) {
// The exceptions that are thrown here look like IllegalStateException,
// 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;
synchronized(mConnection) {