diff options
author | Kenji Sugimoto <kenji.xb.sugimoto@sonymobile.com> | 2014-07-17 14:50:41 +0900 |
---|---|---|
committer | Craig Mautner <cmautner@google.com> | 2014-12-03 17:53:06 -0800 |
commit | 4472fa97800fb20b045f1907372f75d2b37b137e (patch) | |
tree | 57bb5e3f7c8f59a44e2ff0ffb5b5621c373ba6a3 | |
parent | ccce6e0f9f6f4da95d61fb2cfb1253ac662fba30 (diff) | |
download | frameworks_base-4472fa97800fb20b045f1907372f75d2b37b137e.zip frameworks_base-4472fa97800fb20b045f1907372f75d2b37b137e.tar.gz frameworks_base-4472fa97800fb20b045f1907372f75d2b37b137e.tar.bz2 |
Prevent ANR when broadcast receiver is killed
If the process of a BroacastReceiver is dying at the same time
as the system is trying to send an ordered broadcast to the
receiver, the system will try to start the process again. The
BroadcastQueue will store the BroadcastRecord in mPendingBroadcast
to be able to handle it again when the process is awake. A
timeout Message is posted to the handler of the BroadcastQueue.
As part of the shutdown sequence skipCurrentReceiver is called for
the ProcessRecord. This will check if there is a curReceiver set
for the application and make sure to finish the receiver.
Each of the foreground and background BroadcastQueues have their
own handler for managing broadcast timeouts. If the wrong
BroadcastQueue finishes the receiver, the pending timeout Message
will never be cancelled, leading to an ANR report for a receiver
that has already been finished.
Change-Id: I960c0d8f1a8b739b54a8f09f496b32a3498b9e9a
-rw-r--r-- | services/core/java/com/android/server/am/BroadcastQueue.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java index 3b774e1..9b7d0b2 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -296,7 +296,7 @@ public final class BroadcastQueue { public void skipCurrentReceiverLocked(ProcessRecord app) { boolean reschedule = false; BroadcastRecord r = app.curReceiver; - if (r != null) { + if (r != null && r.queue == this) { // The current broadcast is waiting for this app's receiver // to be finished. Looks like that's not going to happen, so // let the broadcast continue. |