Skip to content

Commit 59cb2cf

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Revert fix to issue #6880627: PendingIntent.getService() returns..." into jb-mr1-dev
2 parents f15005e + 861a3b2 commit 59cb2cf

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,48 +3930,54 @@ private final boolean forceStopPackageLocked(String name, int appId,
39303930
removeDyingProviderLocked(null, providers.get(i), true);
39313931
}
39323932

3933-
if (mIntentSenderRecords.size() > 0) {
3934-
Iterator<WeakReference<PendingIntentRecord>> it
3935-
= mIntentSenderRecords.values().iterator();
3936-
while (it.hasNext()) {
3937-
WeakReference<PendingIntentRecord> wpir = it.next();
3938-
if (wpir == null) {
3939-
it.remove();
3940-
continue;
3941-
}
3942-
PendingIntentRecord pir = wpir.get();
3943-
if (pir == null) {
3944-
it.remove();
3945-
continue;
3946-
}
3947-
if (name == null) {
3948-
// Stopping user, remove all objects for the user.
3949-
if (pir.key.userId != userId) {
3950-
// Not the same user, skip it.
3933+
if (name == null) {
3934+
// Remove pending intents. For now we only do this when force
3935+
// stopping users, because we have some problems when doing this
3936+
// for packages -- app widgets are not currently cleaned up for
3937+
// such packages, so they can be left with bad pending intents.
3938+
if (mIntentSenderRecords.size() > 0) {
3939+
Iterator<WeakReference<PendingIntentRecord>> it
3940+
= mIntentSenderRecords.values().iterator();
3941+
while (it.hasNext()) {
3942+
WeakReference<PendingIntentRecord> wpir = it.next();
3943+
if (wpir == null) {
3944+
it.remove();
39513945
continue;
39523946
}
3953-
} else {
3954-
if (UserHandle.getAppId(pir.uid) != appId) {
3955-
// Different app id, skip it.
3947+
PendingIntentRecord pir = wpir.get();
3948+
if (pir == null) {
3949+
it.remove();
39563950
continue;
39573951
}
3958-
if (userId != UserHandle.USER_ALL && pir.key.userId != userId) {
3959-
// Different user, skip it.
3960-
continue;
3952+
if (name == null) {
3953+
// Stopping user, remove all objects for the user.
3954+
if (pir.key.userId != userId) {
3955+
// Not the same user, skip it.
3956+
continue;
3957+
}
3958+
} else {
3959+
if (UserHandle.getAppId(pir.uid) != appId) {
3960+
// Different app id, skip it.
3961+
continue;
3962+
}
3963+
if (userId != UserHandle.USER_ALL && pir.key.userId != userId) {
3964+
// Different user, skip it.
3965+
continue;
3966+
}
3967+
if (!pir.key.packageName.equals(name)) {
3968+
// Different package, skip it.
3969+
continue;
3970+
}
39613971
}
3962-
if (!pir.key.packageName.equals(name)) {
3963-
// Different package, skip it.
3964-
continue;
3972+
if (!doit) {
3973+
return true;
3974+
}
3975+
didSomething = true;
3976+
it.remove();
3977+
pir.canceled = true;
3978+
if (pir.key.activity != null) {
3979+
pir.key.activity.pendingResults.remove(pir.ref);
39653980
}
3966-
}
3967-
if (!doit) {
3968-
return true;
3969-
}
3970-
didSomething = true;
3971-
it.remove();
3972-
pir.canceled = true;
3973-
if (pir.key.activity != null) {
3974-
pir.key.activity.pendingResults.remove(pir.ref);
39753981
}
39763982
}
39773983
}

0 commit comments

Comments
 (0)