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.
This commit is contained in:
Dianne Hackborn
2009-12-08 19:45:14 -08:00
parent 1955324151
commit 1c633fc89b
16 changed files with 117 additions and 37 deletions

View File

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