Ensure that finishBroadcast is called in broadcastCallbacks
* An unexpected (runtime) exception during a callback left the broadcast unfinished, leading to a fatal exception * Ensure that we always call finishBroadcast() * Catch RuntimeException in a broadcast call, so that other calls can be executed * Addresses one of two issues in the referenced bug Bug: 3142618 Change-Id: I77166bf927560681a2b189906cd687a6e3585223
This commit is contained in:
parent
affe44f14c
commit
4f1480369c
@ -261,15 +261,23 @@ public class ExchangeService extends Service implements Runnable {
|
||||
(INSTANCE == null) ? null: INSTANCE.mCallbackList;
|
||||
if (callbackList != null) {
|
||||
// Call everyone on our callback list
|
||||
// Exceptions can be safely ignored
|
||||
int count = callbackList.beginBroadcast();
|
||||
for (int i = 0; i < count; i++) {
|
||||
try {
|
||||
wrapper.call(callbackList.getBroadcastItem(i));
|
||||
} catch (RemoteException e) {
|
||||
try {
|
||||
for (int i = 0; i < count; i++) {
|
||||
try {
|
||||
wrapper.call(callbackList.getBroadcastItem(i));
|
||||
} catch (RemoteException e) {
|
||||
// Safe to ignore
|
||||
} catch (RuntimeException e) {
|
||||
// We don't want an exception in one call to prevent other calls, so
|
||||
// we'll just log this and continue
|
||||
Log.e(TAG, "Caught RuntimeException in broadcast", e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// No matter what, we need to finish the broadcast
|
||||
callbackList.finishBroadcast();
|
||||
}
|
||||
callbackList.finishBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user