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
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 6e4759d..368db26 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -4430,7 +4430,8 @@
PendingIntentRecord.Key key = new PendingIntentRecord.Key(
type, packageName, activity, resultWho,
- requestCode, intents, resolvedTypes, flags, options);
+ requestCode, intents, resolvedTypes, flags, options,
+ UserHandle.getUserId(callingUid));
WeakReference<PendingIntentRecord> ref;
ref = mIntentSenderRecords.get(key);
PendingIntentRecord rec = ref != null ? ref.get() : null;
diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java
index d3b8510..8e70376 100644
--- a/services/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/java/com/android/server/am/PendingIntentRecord.java
@@ -54,11 +54,12 @@
String[] allResolvedTypes;
final int flags;
final int hashCode;
+ final int userId;
private static final int ODD_PRIME_NUMBER = 37;
Key(int _t, String _p, ActivityRecord _a, String _w,
- int _r, Intent[] _i, String[] _it, int _f, Bundle _o) {
+ int _r, Intent[] _i, String[] _it, int _f, Bundle _o, int _userId) {
type = _t;
packageName = _p;
activity = _a;
@@ -70,10 +71,12 @@
allResolvedTypes = _it;
flags = _f;
options = _o;
-
+ userId = _userId;
+
int hash = 23;
hash = (ODD_PRIME_NUMBER*hash) + _f;
hash = (ODD_PRIME_NUMBER*hash) + _r;
+ hash = (ODD_PRIME_NUMBER*hash) + _userId;
if (_w != null) {
hash = (ODD_PRIME_NUMBER*hash) + _w.hashCode();
}
@@ -102,6 +105,9 @@
if (type != other.type) {
return false;
}
+ if (userId != other.userId){
+ return false;
+ }
if (!packageName.equals(other.packageName)) {
return false;
}
@@ -156,7 +162,7 @@
+ " intent="
+ (requestIntent != null
? requestIntent.toShortString(false, true, false, false) : "<null>")
- + " flags=0x" + Integer.toHexString(flags) + "}";
+ + " flags=0x" + Integer.toHexString(flags) + " u=" + userId + "}";
}
String typeName() {