From 6ef1621f444538337253f3aeae63dfe0098e238b Mon Sep 17 00:00:00 2001 From: Anthony Lee Date: Wed, 12 Feb 2014 11:37:06 -0800 Subject: [PATCH] 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 --- .../com/android/emailcommon/service/ServiceProxy.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java index 2cdc2d0ae..354d70ef1 100644 --- a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java @@ -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) {