diff options
Diffstat (limited to 'core/java/android/content/BroadcastReceiver.java')
-rw-r--r-- | core/java/android/content/BroadcastReceiver.java | 32 |
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; } |