OSDN Git Service

[ActivityManager] Distinguish FG or BG receiver finished
authorriddle_hsu <riddle_hsu@htc.com>
Sat, 3 Jan 2015 07:38:21 +0000 (15:38 +0800)
committerriddle_hsu <riddle_hsu@htc.com>
Sat, 3 Jan 2015 07:38:21 +0000 (15:38 +0800)
commit1f5ac4d322d76ca76fdf5dee40fe9549aad7437e
tree068aa441af936858f9764c0333a91080e46c0799
parent38c2dae5f12003ff39a5b1a5e46f079174fcedca
[ActivityManager] Distinguish FG or BG receiver finished

Symptom:
Assume a foreground broadcast FG and a background BG.
If a recevier registers both FG and BG. When sending
BG and FG to the receiver, and the receiver BG receiver
completes first, its finishReceiver will trigger next FG
receiver rather than BG, and also deliver wrong result
code/data to the next.

More detail and sample:
https://code.google.com/p/android/issues/detail?id=92917

Root cause:
Due to BroadcastQueue:getMatchingOrderedReceiver will match
by receiver(IBinder), so the caller ActivityManagerService:
broadcastRecordForReceiverLocked will always match the first
queue(fg) if a receiver is both receiving fg and bg.

Solution:
Add a parameter flags to finishReceiver, then server side
could know the finished receiver should belong to which queue.

Another general solution but with bigger scope:
I60dce4a48e20c1002a61a979e4d78b9b0a8b94a0

Change-Id: I913ca6f101ac8ec6c7a8e42754e6781f80247b7f
core/java/android/app/ActivityManagerNative.java
core/java/android/app/ActivityThread.java
core/java/android/app/IActivityManager.java
core/java/android/app/LoadedApk.java
core/java/android/content/BroadcastReceiver.java
services/core/java/com/android/server/am/ActivityManagerService.java [changed mode: 0755->0644]