summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-07-13 13:07:51 -0700
committerDianne Hackborn <hackbod@google.com>2009-07-14 11:37:11 -0700
commitb06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0 (patch)
tree2fcae8f89195ef4b162627892aeca97f06d42ef7 /core/java/android/os
parent3660c09500a4d01eb6a733b5f0b15545855f8fe8 (diff)
downloadframeworks_base-b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0.zip
frameworks_base-b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0.tar.gz
frameworks_base-b06ea706530e6d19eb2a1a9a7ae6c5dd77d80af0.tar.bz2
Add reporting of activity movement for search manager.
This adds a new API with the activity manager to find out about movement between activities. For my sanity, the old IActivityWatcher is now renamed to IActivityController, and the new activity movement interface is named IActivityWatcher. This changes the search manager itself to use the new API to manage its state. Note that there are still problems when going back to the search dialog after it was hidden -- the suggestions window no longer appears until you explicitly dismiss and re-show it.
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/RemoteCallbackList.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/core/java/android/os/RemoteCallbackList.java b/core/java/android/os/RemoteCallbackList.java
index 23c0a7b..584224f 100644
--- a/core/java/android/os/RemoteCallbackList.java
+++ b/core/java/android/os/RemoteCallbackList.java
@@ -50,6 +50,7 @@ public class RemoteCallbackList<E extends IInterface> {
/*package*/ HashMap<IBinder, Callback> mCallbacks
= new HashMap<IBinder, Callback>();
private Object[] mActiveBroadcast;
+ private int mBroadcastCount = -1;
private boolean mKilled = false;
private final class Callback implements IBinder.DeathRecipient {
@@ -195,15 +196,16 @@ public class RemoteCallbackList<E extends IInterface> {
* This creates a copy of the callback list, which you can retrieve items
* from using {@link #getBroadcastItem}. Note that only one broadcast can
* be active at a time, so you must be sure to always call this from the
- * same thread (usually by scheduling with {@link Handler} or
+ * same thread (usually by scheduling with {@link Handler}) or
* do your own synchronization. You must call {@link #finishBroadcast}
* when done.
*
* <p>A typical loop delivering a broadcast looks like this:
*
* <pre>
- * final int N = callbacks.beginBroadcast();
- * for (int i=0; i<N; i++) {
+ * int i = callbacks.beginBroadcast();
+ * while (i > 0) {
+ * i--;
* try {
* callbacks.getBroadcastItem(i).somethingHappened();
* } catch (RemoteException e) {
@@ -222,7 +224,12 @@ public class RemoteCallbackList<E extends IInterface> {
*/
public int beginBroadcast() {
synchronized (mCallbacks) {
- final int N = mCallbacks.size();
+ if (mBroadcastCount > 0) {
+ throw new IllegalStateException(
+ "beginBroadcast() called while already in a broadcast");
+ }
+
+ final int N = mBroadcastCount = mCallbacks.size();
if (N <= 0) {
return 0;
}
@@ -281,12 +288,19 @@ public class RemoteCallbackList<E extends IInterface> {
* @see #beginBroadcast
*/
public void finishBroadcast() {
+ if (mBroadcastCount < 0) {
+ throw new IllegalStateException(
+ "finishBroadcast() called outside of a broadcast");
+ }
+
Object[] active = mActiveBroadcast;
if (active != null) {
- final int N = active.length;
+ final int N = mBroadcastCount;
for (int i=0; i<N; i++) {
active[i] = null;
}
}
+
+ mBroadcastCount = -1;
}
}