OSDN Git Service

Make sure to call the original reply-to receiver when...
authorMakoto Onuki <omakoto@google.com>
Thu, 2 Mar 2017 23:33:17 +0000 (15:33 -0800)
committerMakoto Onuki <omakoto@google.com>
Fri, 3 Mar 2017 00:58:14 +0000 (16:58 -0800)
commit3e7d845161870f6289aeecdf4bfd762097f487d6
treee897cfea12da21896b96ac2fb186791a9cc3551e
parentd1c7bb771c76bbd24d070821b0734be9a68c3daa
Make sure to call the original reply-to receiver when...

replacing a queued broadcast.

- Also don't replace a broadcast for a different user.

Test: Manual test with the following test code:

Intent intent = new Intent(Intent.ACTION_PROVIDER_CHANGED)
        .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
AlarmManager alm = this.getSystemService(AlarmManager.class);
long time = SystemClock.elapsedRealtime() + 5 * 1000;
for (int i = 0; i < 5; i++) {
    alm.setExact(AlarmManager.ELAPSED_REALTIME, time,
            PendingIntent.getBroadcast(this, i, intent, PendingIntent.FLAG_UPDATE_CURRENT));
}

Without this CL, after the alarm fires, AlarmManagerService.mBroadcastRefCount
is left > 0 and the wake lock is held forever.

With this CL, mBroadcastRefCount eventually gets back to 0.

Bug: 35779096
Change-Id: I4e21c94b08f25f9ca1242182670ff4a69f8bd9f2
services/core/java/com/android/server/AlarmManagerService.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/am/BroadcastQueue.java