summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/BroadcastReceiver.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-10-05 13:58:17 -0700
committerDianne Hackborn <hackbod@google.com>2009-10-05 15:52:32 -0700
commit68d881cf2d2b252f6f795cd64d43e316a1d736e5 (patch)
tree3d0f7cb91e612df7a5663ceefec0b5439c907642 /core/java/android/content/BroadcastReceiver.java
parent71060f29855745893c122e8b93cf7a723186931b (diff)
downloadframeworks_base-68d881cf2d2b252f6f795cd64d43e316a1d736e5.zip
frameworks_base-68d881cf2d2b252f6f795cd64d43e316a1d736e5.tar.gz
frameworks_base-68d881cf2d2b252f6f795cd64d43e316a1d736e5.tar.bz2
Fix issue #2166755: BroadcastReceiver trying to return result during a non-ordered broadcast
Tell the broadcast receiver whether it is getting an initial sticky value, so it will be quiet about attempts to do ordered broadcast stuff. Note that the original bug being reported was not actually a crash, just an error log. So all we are doing here is making the log quieter. Change-Id: Iaf1b718d82093ec1197142410a64feff47eb3859
Diffstat (limited to 'core/java/android/content/BroadcastReceiver.java')
-rw-r--r--core/java/android/content/BroadcastReceiver.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/core/java/android/content/BroadcastReceiver.java b/core/java/android/content/BroadcastReceiver.java
index b391c57..b63d026 100644
--- a/core/java/android/content/BroadcastReceiver.java
+++ b/core/java/android/content/BroadcastReceiver.java
@@ -384,6 +384,24 @@ public abstract class BroadcastReceiver {
}
/**
+ * Returns true if the receiver is currently processing an ordered
+ * broadcast.
+ */
+ public final boolean isOrderedBroadcast() {
+ return mOrderedHint;
+ }
+
+ /**
+ * Returns true if the receiver is currently processing the initial
+ * value of a sticky broadcast -- that is, the value that was last
+ * broadcast and is currently held in the sticky cache, so this is
+ * not directly the result of a broadcast right now.
+ */
+ public final boolean isInitialStickyBroadcast() {
+ return mInitialStickyHint;
+ }
+
+ /**
* For internal use, sets the hint about whether this BroadcastReceiver is
* running in ordered mode.
*/
@@ -392,6 +410,14 @@ public abstract class BroadcastReceiver {
}
/**
+ * For internal use, sets the hint about whether this BroadcastReceiver is
+ * receiving the initial sticky broadcast value. @hide
+ */
+ public final void setInitialStickyHint(boolean isInitialSticky) {
+ mInitialStickyHint = isInitialSticky;
+ }
+
+ /**
* Control inclusion of debugging help for mismatched
* calls to {@ Context#registerReceiver(BroadcastReceiver, IntentFilter)
* Context.registerReceiver()}.
@@ -414,7 +440,10 @@ public abstract class BroadcastReceiver {
}
void checkSynchronousHint() {
- if (mOrderedHint) {
+ // Note that we don't assert when receiving the initial sticky value,
+ // since that may have come from an ordered broadcast. We'll catch
+ // them later when the real broadcast happens again.
+ if (mOrderedHint || mInitialStickyHint) {
return;
}
RuntimeException e = new RuntimeException(
@@ -429,5 +458,6 @@ public abstract class BroadcastReceiver {
private boolean mAbortBroadcast;
private boolean mDebugUnregister;
private boolean mOrderedHint;
+ private boolean mInitialStickyHint;
}