Merge change Iaf1f0918 into eclair-mr2

* changes:
  Implement API to have new broadcasts replace existing broadcasts.
This commit is contained in:
Android (Google) Code Review
2009-12-14 16:06:49 -08:00
16 changed files with 117 additions and 37 deletions

View File

@@ -37304,6 +37304,17 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="FLAG_RECEIVER_REPLACE_PENDING"
type="int"
transient="false"
volatile="false"
value="536870912"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="METADATA_DOCK_HOME" <field name="METADATA_DOCK_HOME"
type="java.lang.String" type="java.lang.String"
transient="false" transient="false"

View File

@@ -1181,7 +1181,7 @@ public class Intent implements Parcelable {
* by the system. * by the system.
*/ */
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @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 * Broadcast Action: The current time has changed. Sent every
@@ -2398,6 +2398,20 @@ public class Intent implements Parcelable {
* called -- no BroadcastReceiver components will be launched. * called -- no BroadcastReceiver components will be launched.
*/ */
public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 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 * If set, when sending a broadcast <i>before boot has completed</i> only
* registered receivers will be called -- no BroadcastReceiver components * registered receivers will be called -- no BroadcastReceiver components
@@ -2411,14 +2425,14 @@ public class Intent implements Parcelable {
* *
* @hide * @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 * 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 * allows the broadcast to be sent before the system is ready and launches
* the app process with no providers running in it. * the app process with no providers running in it.
* @hide * @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. * @hide Flags that can't be changed with PendingIntent.

View File

@@ -150,8 +150,9 @@ public class SearchManagerService extends ISearchManager.Stub {
* Informs all listeners that the list of searchables has been updated. * Informs all listeners that the list of searchables has been updated.
*/ */
void broadcastSearchablesChanged() { void broadcastSearchablesChanged() {
mContext.sendBroadcast( Intent intent = new Intent(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED);
new Intent(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED)); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
mContext.sendBroadcast(intent);
} }
// //

View File

@@ -892,14 +892,14 @@ public class AudioService extends IAudioService.Stub {
private void broadcastRingerMode() { private void broadcastRingerMode() {
// Send sticky broadcast // Send sticky broadcast
if (ActivityManagerNative.isSystemReady()) {
Intent broadcast = new Intent(AudioManager.RINGER_MODE_CHANGED_ACTION); Intent broadcast = new Intent(AudioManager.RINGER_MODE_CHANGED_ACTION);
broadcast.putExtra(AudioManager.EXTRA_RINGER_MODE, mRingerMode); broadcast.putExtra(AudioManager.EXTRA_RINGER_MODE, mRingerMode);
broadcast.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
| Intent.FLAG_RECEIVER_REPLACE_PENDING);
long origCallerIdentityToken = Binder.clearCallingIdentity(); long origCallerIdentityToken = Binder.clearCallingIdentity();
mContext.sendStickyBroadcast(broadcast); mContext.sendStickyBroadcast(broadcast);
Binder.restoreCallingIdentity(origCallerIdentityToken); Binder.restoreCallingIdentity(origCallerIdentityToken);
} }
}
private void broadcastVibrateSetting(int vibrateType) { private void broadcastVibrateSetting(int vibrateType) {
// Send broadcast // Send broadcast

View File

@@ -127,8 +127,9 @@ class AlarmManagerService extends IAlarmManager.Stub {
mTimeTickSender = PendingIntent.getBroadcast(context, 0, mTimeTickSender = PendingIntent.getBroadcast(context, 0,
new Intent(Intent.ACTION_TIME_TICK).addFlags( new Intent(Intent.ACTION_TIME_TICK).addFlags(
Intent.FLAG_RECEIVER_REGISTERED_ONLY), 0); Intent.FLAG_RECEIVER_REGISTERED_ONLY), 0);
mDateChangeSender = PendingIntent.getBroadcast(context, 0, Intent intent = new Intent(Intent.ACTION_DATE_CHANGED);
new Intent(Intent.ACTION_DATE_CHANGED), 0); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
mDateChangeSender = PendingIntent.getBroadcast(context, 0, intent, 0);
// now that we have initied the driver schedule the alarm // now that we have initied the driver schedule the alarm
mClockReceiver= new ClockReceiver(); mClockReceiver= new ClockReceiver();
@@ -272,6 +273,7 @@ class AlarmManagerService extends IAlarmManager.Stub {
if (timeZoneWasChanged) { if (timeZoneWasChanged) {
Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED); Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra("time-zone", zone.getID()); intent.putExtra("time-zone", zone.getID());
mContext.sendBroadcast(intent); mContext.sendBroadcast(intent);
} }
@@ -609,7 +611,9 @@ class AlarmManagerService extends IAlarmManager.Stub {
if ((result & TIME_CHANGED_MASK) != 0) { if ((result & TIME_CHANGED_MASK) != 0) {
remove(mTimeTickSender); remove(mTimeTickSender);
mClockReceiver.scheduleTimeTickEvent(); mClockReceiver.scheduleTimeTickEvent();
mContext.sendBroadcast(new Intent(Intent.ACTION_TIME_CHANGED)); Intent intent = new Intent(Intent.ACTION_TIME_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
mContext.sendBroadcast(intent);
} }
synchronized (mLock) { synchronized (mLock) {

View File

@@ -327,7 +327,8 @@ class BatteryService extends Binder {
private final void sendIntent() { private final void sendIntent() {
// Pack up the values and broadcast them to everyone // Pack up the values and broadcast them to everyone
Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED); Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
| Intent.FLAG_RECEIVER_REPLACE_PENDING);
try { try {
mBatteryStats.setOnBattery(mPlugType == BATTERY_PLUGGED_NONE, mBatteryLevel); mBatteryStats.setOnBattery(mPlugType == BATTERY_PLUGGED_NONE, mBatteryLevel);
} catch (RemoteException e) { } catch (RemoteException e) {

View File

@@ -98,7 +98,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private List mFeatureUsers; private List mFeatureUsers;
private boolean mSystemReady; private boolean mSystemReady;
private ArrayList<Intent> mDeferredBroadcasts; private Intent mInitialBroadcast;
private static class NetworkAttributes { private static class NetworkAttributes {
/** /**
@@ -786,6 +786,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION); Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info); intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
if (info.isFailover()) { if (info.isFailover()) {
intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true);
@@ -885,6 +886,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private void sendConnectedBroadcast(NetworkInfo info) { private void sendConnectedBroadcast(NetworkInfo info) {
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION); Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info); intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
if (info.isFailover()) { if (info.isFailover()) {
intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true); intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true);
@@ -922,6 +924,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} }
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION); Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info); intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
if (getActiveNetworkInfo() == null) { if (getActiveNetworkInfo() == null) {
intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true); intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true);
@@ -941,26 +944,20 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private void sendStickyBroadcast(Intent intent) { private void sendStickyBroadcast(Intent intent) {
synchronized(this) { synchronized(this) {
if (mSystemReady) { if (!mSystemReady) {
mInitialBroadcast = new Intent(intent);
}
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent);
} else {
if (mDeferredBroadcasts == null) {
mDeferredBroadcasts = new ArrayList<Intent>();
}
mDeferredBroadcasts.add(intent);
}
} }
} }
void systemReady() { void systemReady() {
synchronized(this) { synchronized(this) {
mSystemReady = true; mSystemReady = true;
if (mDeferredBroadcasts != null) { if (mInitialBroadcast != null) {
int count = mDeferredBroadcasts.size(); mContext.sendStickyBroadcast(mInitialBroadcast);
for (int i = 0; i < count; i++) { mInitialBroadcast = null;
mContext.sendStickyBroadcast(mDeferredBroadcasts.get(i));
}
mDeferredBroadcasts = null;
} }
} }
} }

View File

@@ -179,6 +179,7 @@ class DockObserver extends UEventObserver {
} }
// Pack up the values and broadcast them to everyone // Pack up the values and broadcast them to everyone
Intent intent = new Intent(Intent.ACTION_DOCK_EVENT); Intent intent = new Intent(Intent.ACTION_DOCK_EVENT);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Intent.EXTRA_DOCK_STATE, mDockState); intent.putExtra(Intent.EXTRA_DOCK_STATE, mDockState);
// Check if this is Bluetooth Dock // Check if this is Bluetooth Dock

View File

@@ -949,6 +949,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if (ActivityManagerNative.isSystemReady()) { if (ActivityManagerNative.isSystemReady()) {
Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED); Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra("input_method_id", id); intent.putExtra("input_method_id", id);
mContext.sendBroadcast(intent); mContext.sendBroadcast(intent);
} }

View File

@@ -485,6 +485,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Bundle data = new Bundle(); Bundle data = new Bundle();
state.fillInNotifierBundle(data); state.fillInNotifierBundle(data);
intent.putExtras(data); intent.putExtras(data);
@@ -502,6 +503,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Bundle data = new Bundle(); Bundle data = new Bundle();
signalStrength.fillInNotifierBundle(data); signalStrength.fillInNotifierBundle(data);
intent.putExtras(data); intent.putExtras(data);
@@ -523,6 +525,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString()); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString());
if (!TextUtils.isEmpty(incomingNumber)) { if (!TextUtils.isEmpty(incomingNumber)) {
intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
@@ -537,6 +540,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
// status bar takes care of that after taking into account all of the // status bar takes care of that after taking into account all of the
// required info. // required info.
Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString()); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString());
if (!isDataConnectivityPossible) { if (!isDataConnectivityPossible) {
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, true); intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, true);
@@ -559,6 +563,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
private void broadcastDataConnectionFailed(String reason) { private void broadcastDataConnectionFailed(String reason) {
Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.FAILURE_REASON_KEY, reason); intent.putExtra(Phone.FAILURE_REASON_KEY, reason);
mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent);
} }

View File

@@ -11844,6 +11844,12 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
// pm is in same process, this will never happen. // pm is in same process, this will never happen.
} }
final boolean replacePending =
(intent.getFlags()&Intent.FLAG_RECEIVER_REPLACE_PENDING) != 0;
if (DEBUG_BROADCAST) Log.v(TAG, "Enqueing broadcast: " + intent.getAction()
+ " replacePending=" + replacePending);
int NR = registeredReceivers != null ? registeredReceivers.size() : 0; int NR = registeredReceivers != null ? registeredReceivers.size() : 0;
if (!ordered && NR > 0) { if (!ordered && NR > 0) {
// If we are not serializing this broadcast, then send the // If we are not serializing this broadcast, then send the
@@ -11856,8 +11862,22 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
if (DEBUG_BROADCAST) Log.v( if (DEBUG_BROADCAST) Log.v(
TAG, "Enqueueing parallel broadcast " + r TAG, "Enqueueing parallel broadcast " + r
+ ": prev had " + mParallelBroadcasts.size()); + ": prev had " + mParallelBroadcasts.size());
boolean replaced = false;
if (replacePending) {
for (int i=mParallelBroadcasts.size()-1; i>=0; i--) {
if (intent.filterEquals(mParallelBroadcasts.get(i).intent)) {
if (DEBUG_BROADCAST) Log.v(TAG,
"***** DROPPING PARALLEL: " + intent);
mParallelBroadcasts.set(i, r);
replaced = true;
break;
}
}
}
if (!replaced) {
mParallelBroadcasts.add(r); mParallelBroadcasts.add(r);
scheduleBroadcastsLocked(); scheduleBroadcastsLocked();
}
registeredReceivers = null; registeredReceivers = null;
NR = 0; NR = 0;
} }
@@ -11940,9 +11960,23 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
int seq = r.intent.getIntExtra("seq", -1); int seq = r.intent.getIntExtra("seq", -1);
Log.i(TAG, "Enqueueing broadcast " + r.intent.getAction() + " seq=" + seq); Log.i(TAG, "Enqueueing broadcast " + r.intent.getAction() + " seq=" + seq);
} }
boolean replaced = false;
if (replacePending) {
for (int i=mOrderedBroadcasts.size()-1; i>=0; i--) {
if (intent.filterEquals(mOrderedBroadcasts.get(i).intent)) {
if (DEBUG_BROADCAST) Log.v(TAG,
"***** DROPPING ORDERED: " + intent);
mOrderedBroadcasts.set(i, r);
replaced = true;
break;
}
}
}
if (!replaced) {
mOrderedBroadcasts.add(r); mOrderedBroadcasts.add(r);
scheduleBroadcastsLocked(); scheduleBroadcastsLocked();
} }
}
return BROADCAST_SUCCESS; return BROADCAST_SUCCESS;
} }
@@ -12837,7 +12871,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
} }
} }
Intent intent = new Intent(Intent.ACTION_CONFIGURATION_CHANGED); Intent intent = new Intent(Intent.ACTION_CONFIGURATION_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
| Intent.FLAG_RECEIVER_REPLACE_PENDING);
broadcastIntentLocked(null, null, intent, null, null, 0, null, null, broadcastIntentLocked(null, null, intent, null, null, 0, null, null,
null, false, false, MY_PID, Process.SYSTEM_UID); null, false, false, MY_PID, Process.SYSTEM_UID);
if ((changes&ActivityInfo.CONFIG_LOCALE) != 0) { if ((changes&ActivityInfo.CONFIG_LOCALE) != 0) {

View File

@@ -468,6 +468,7 @@ public abstract class IccCard {
public void broadcastIccStateChangedIntent(String value, String reason) { public void broadcastIccStateChangedIntent(String value, String reason) {
Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.PHONE_NAME_KEY, mPhone.getPhoneName()); intent.putExtra(Phone.PHONE_NAME_KEY, mPhone.getPhoneName());
intent.putExtra(INTENT_KEY_ICC_STATE, value); intent.putExtra(INTENT_KEY_ICC_STATE, value);
intent.putExtra(INTENT_KEY_LOCKED_REASON, reason); intent.putExtra(INTENT_KEY_LOCKED_REASON, reason);

View File

@@ -134,6 +134,7 @@ public class PhoneProxy extends Handler implements Phone {
//Send an Intent to the PhoneApp that we had a radio technology change //Send an Intent to the PhoneApp that we had a radio technology change
Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED); Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Phone.PHONE_NAME_KEY, mActivePhone.getPhoneName()); intent.putExtra(Phone.PHONE_NAME_KEY, mActivePhone.getPhoneName());
ActivityManagerNative.broadcastStickyIntent(intent, null); ActivityManagerNative.broadcastStickyIntent(intent, null);
break; break;

View File

@@ -597,6 +597,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|| !TextUtils.equals(spn, curSpn) || !TextUtils.equals(spn, curSpn)
|| !TextUtils.equals(plmn, curPlmn)) { || !TextUtils.equals(plmn, curPlmn)) {
Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION); Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn); intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn);
intent.putExtra(Intents.EXTRA_SPN, spn); intent.putExtra(Intents.EXTRA_SPN, spn);
intent.putExtra(Intents.EXTRA_SHOW_PLMN, showPlmn); intent.putExtra(Intents.EXTRA_SHOW_PLMN, showPlmn);
@@ -1523,6 +1524,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
(AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE); (AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(zoneId); alarm.setTimeZone(zoneId);
Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE); Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra("time-zone", zoneId); intent.putExtra("time-zone", zoneId);
phone.getContext().sendStickyBroadcast(intent); phone.getContext().sendStickyBroadcast(intent);
} }
@@ -1536,6 +1538,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
private void setAndBroadcastNetworkSetTime(long time) { private void setAndBroadcastNetworkSetTime(long time) {
SystemClock.setCurrentTimeMillis(time); SystemClock.setCurrentTimeMillis(time);
Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME); Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra("time", time); intent.putExtra("time", time);
phone.getContext().sendStickyBroadcast(intent); phone.getContext().sendStickyBroadcast(intent);
} }

View File

@@ -557,6 +557,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
boolean showPlmn = boolean showPlmn =
(rule & SIMRecords.SPN_RULE_SHOW_PLMN) == SIMRecords.SPN_RULE_SHOW_PLMN; (rule & SIMRecords.SPN_RULE_SHOW_PLMN) == SIMRecords.SPN_RULE_SHOW_PLMN;
Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION); Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn); intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn);
intent.putExtra(Intents.EXTRA_SPN, spn); intent.putExtra(Intents.EXTRA_SPN, spn);
intent.putExtra(Intents.EXTRA_SHOW_PLMN, showPlmn); intent.putExtra(Intents.EXTRA_SHOW_PLMN, showPlmn);
@@ -1488,6 +1489,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
(AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE); (AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(zoneId); alarm.setTimeZone(zoneId);
Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE); Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra("time-zone", zoneId); intent.putExtra("time-zone", zoneId);
phone.getContext().sendStickyBroadcast(intent); phone.getContext().sendStickyBroadcast(intent);
} }
@@ -1501,6 +1503,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
private void setAndBroadcastNetworkSetTime(long time) { private void setAndBroadcastNetworkSetTime(long time) {
SystemClock.setCurrentTimeMillis(time); SystemClock.setCurrentTimeMillis(time);
Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME); Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra("time", time); intent.putExtra("time", time);
phone.getContext().sendStickyBroadcast(intent); phone.getContext().sendStickyBroadcast(intent);
} }

View File

@@ -973,7 +973,8 @@ public class WifiStateTracker extends NetworkStateTracker {
mDisconnectExpected = false; mDisconnectExpected = false;
intent = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); intent = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
| Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(WifiManager.EXTRA_NEW_STATE, (Parcelable)newState); intent.putExtra(WifiManager.EXTRA_NEW_STATE, (Parcelable)newState);
if (failedToAuthenticate) { if (failedToAuthenticate) {
if (LOCAL_LOGD) Log.d(TAG, "Failed to authenticate, disabling network " + networkId); if (LOCAL_LOGD) Log.d(TAG, "Failed to authenticate, disabling network " + networkId);
@@ -1443,7 +1444,8 @@ public class WifiStateTracker extends NetworkStateTracker {
private void sendNetworkStateChangeBroadcast(String bssid) { private void sendNetworkStateChangeBroadcast(String bssid) {
Intent intent = new Intent(WifiManager.NETWORK_STATE_CHANGED_ACTION); Intent intent = new Intent(WifiManager.NETWORK_STATE_CHANGED_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
| Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(WifiManager.EXTRA_NETWORK_INFO, mNetworkInfo); intent.putExtra(WifiManager.EXTRA_NETWORK_INFO, mNetworkInfo);
if (bssid != null) if (bssid != null)
intent.putExtra(WifiManager.EXTRA_BSSID, bssid); intent.putExtra(WifiManager.EXTRA_BSSID, bssid);