Skip to content

Commit 4ea6069

Browse files
author
Amith Yamasani
committed
Fix PendingIntent caching for multiuser
Store the userId in the PendingIntentRecord.Key, so that it doesn't match an identical pending intent from another user. Change-Id: Icfc39e0f717c902dc3a60bdf5283a3402bbd2eaa
1 parent 70574ef commit 4ea6069

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4430,7 +4430,8 @@ IIntentSender getIntentSenderLocked(int type,
44304430

44314431
PendingIntentRecord.Key key = new PendingIntentRecord.Key(
44324432
type, packageName, activity, resultWho,
4433-
requestCode, intents, resolvedTypes, flags, options);
4433+
requestCode, intents, resolvedTypes, flags, options,
4434+
UserHandle.getUserId(callingUid));
44344435
WeakReference<PendingIntentRecord> ref;
44354436
ref = mIntentSenderRecords.get(key);
44364437
PendingIntentRecord rec = ref != null ? ref.get() : null;

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ final static class Key {
5454
String[] allResolvedTypes;
5555
final int flags;
5656
final int hashCode;
57+
final int userId;
5758

5859
private static final int ODD_PRIME_NUMBER = 37;
5960

6061
Key(int _t, String _p, ActivityRecord _a, String _w,
61-
int _r, Intent[] _i, String[] _it, int _f, Bundle _o) {
62+
int _r, Intent[] _i, String[] _it, int _f, Bundle _o, int _userId) {
6263
type = _t;
6364
packageName = _p;
6465
activity = _a;
@@ -70,10 +71,12 @@ final static class Key {
7071
allResolvedTypes = _it;
7172
flags = _f;
7273
options = _o;
73-
74+
userId = _userId;
75+
7476
int hash = 23;
7577
hash = (ODD_PRIME_NUMBER*hash) + _f;
7678
hash = (ODD_PRIME_NUMBER*hash) + _r;
79+
hash = (ODD_PRIME_NUMBER*hash) + _userId;
7780
if (_w != null) {
7881
hash = (ODD_PRIME_NUMBER*hash) + _w.hashCode();
7982
}
@@ -102,6 +105,9 @@ public boolean equals(Object otherObj) {
102105
if (type != other.type) {
103106
return false;
104107
}
108+
if (userId != other.userId){
109+
return false;
110+
}
105111
if (!packageName.equals(other.packageName)) {
106112
return false;
107113
}
@@ -156,7 +162,7 @@ public String toString() {
156162
+ " intent="
157163
+ (requestIntent != null
158164
? requestIntent.toShortString(false, true, false, false) : "<null>")
159-
+ " flags=0x" + Integer.toHexString(flags) + "}";
165+
+ " flags=0x" + Integer.toHexString(flags) + " u=" + userId + "}";
160166
}
161167

162168
String typeName() {

0 commit comments

Comments
 (0)