diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-12-08 19:45:14 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-12-14 15:03:35 -0800 |
commit | 1c633fc89bae9bf0af6fe643ac7ad2e744f27bed (patch) | |
tree | ba72742fc17755ec69996ad3dd6a6f82f445a2ab /core/java | |
parent | 19553241513bd2ee2610026ebbce8c45c7ae0dbc (diff) | |
download | frameworks_base-1c633fc89bae9bf0af6fe643ac7ad2e744f27bed.zip frameworks_base-1c633fc89bae9bf0af6fe643ac7ad2e744f27bed.tar.gz frameworks_base-1c633fc89bae9bf0af6fe643ac7ad2e744f27bed.tar.bz2 |
Implement API to have new broadcasts replace existing broadcasts.
Use this in various places where it should serve no purpose to deliver
both broadcasts. This is intended to reduce somewhat the flurry of
broadcasts that we churn through during boot.
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/content/Intent.java | 20 | ||||
-rw-r--r-- | core/java/android/server/search/SearchManagerService.java | 5 |
2 files changed, 20 insertions, 5 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index dfdfa15..d784759 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1181,7 +1181,7 @@ public class Intent implements Parcelable { * by the system. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String ACTION_USER_PRESENT= "android.intent.action.USER_PRESENT"; + public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; /** * Broadcast Action: The current time has changed. Sent every @@ -2399,6 +2399,20 @@ public class Intent implements Parcelable { */ public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; /** + * If set, when sending a broadcast the new broadcast will replace + * any existing pending broadcast that matches it. Matching is defined + * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning + * true for the intents of the two broadcasts. When a match is found, + * the new broadcast (and receivers associated with it) will replace the + * existing one in the pending broadcast list, remaining at the same + * position in the list. + * + * <p>This flag is most typically used with sticky broadcasts, which + * only care about delivering the most recent values of the broadcast + * to their receivers. + */ + public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; + /** * If set, when sending a broadcast <i>before boot has completed</i> only * registered receivers will be called -- no BroadcastReceiver components * will be launched. Sticky intent state will be recorded properly even @@ -2411,14 +2425,14 @@ public class Intent implements Parcelable { * * @hide */ - public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x20000000; + public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000; /** * Set when this broadcast is for a boot upgrade, a special mode that * allows the broadcast to be sent before the system is ready and launches * the app process with no providers running in it. * @hide */ - public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x10000000; + public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000; /** * @hide Flags that can't be changed with PendingIntent. diff --git a/core/java/android/server/search/SearchManagerService.java b/core/java/android/server/search/SearchManagerService.java index 6e8b7ee..f9a0b93 100644 --- a/core/java/android/server/search/SearchManagerService.java +++ b/core/java/android/server/search/SearchManagerService.java @@ -150,8 +150,9 @@ public class SearchManagerService extends ISearchManager.Stub { * Informs all listeners that the list of searchables has been updated. */ void broadcastSearchablesChanged() { - mContext.sendBroadcast( - new Intent(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED)); + Intent intent = new Intent(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED); + intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); + mContext.sendBroadcast(intent); } // |