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,17 +261,25 @@ public class ExchangeService extends Service implements Runnable {
|
|||||||
(INSTANCE == null) ? null: INSTANCE.mCallbackList;
|
(INSTANCE == null) ? null: INSTANCE.mCallbackList;
|
||||||
if (callbackList != null) {
|
if (callbackList != null) {
|
||||||
// Call everyone on our callback list
|
// Call everyone on our callback list
|
||||||
// Exceptions can be safely ignored
|
|
||||||
int count = callbackList.beginBroadcast();
|
int count = callbackList.beginBroadcast();
|
||||||
|
try {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
try {
|
try {
|
||||||
wrapper.call(callbackList.getBroadcastItem(i));
|
wrapper.call(callbackList.getBroadcastItem(i));
|
||||||
} catch (RemoteException e) {
|
} 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void loadAttachmentStatus(final long messageId, final long attachmentId,
|
public void loadAttachmentStatus(final long messageId, final long attachmentId,
|
||||||
final int status, final int progress) {
|
final int status, final int progress) {
|
||||||
|
Loading…
Reference in New Issue
Block a user