Merge "Fix PendingIntent caching for multiuser" into jb-mr1-dev

This commit is contained in:
Amith Yamasani
2012-08-28 16:56:18 -07:00
committed by Android (Google) Code Review
2 changed files with 11 additions and 4 deletions

View File

@ -4430,7 +4430,8 @@ public final class ActivityManagerService extends ActivityManagerNative
PendingIntentRecord.Key key = new PendingIntentRecord.Key( PendingIntentRecord.Key key = new PendingIntentRecord.Key(
type, packageName, activity, resultWho, type, packageName, activity, resultWho,
requestCode, intents, resolvedTypes, flags, options); requestCode, intents, resolvedTypes, flags, options,
UserHandle.getUserId(callingUid));
WeakReference<PendingIntentRecord> ref; WeakReference<PendingIntentRecord> ref;
ref = mIntentSenderRecords.get(key); ref = mIntentSenderRecords.get(key);
PendingIntentRecord rec = ref != null ? ref.get() : null; PendingIntentRecord rec = ref != null ? ref.get() : null;

View File

@ -54,11 +54,12 @@ class PendingIntentRecord extends IIntentSender.Stub {
String[] allResolvedTypes; String[] allResolvedTypes;
final int flags; final int flags;
final int hashCode; final int hashCode;
final int userId;
private static final int ODD_PRIME_NUMBER = 37; private static final int ODD_PRIME_NUMBER = 37;
Key(int _t, String _p, ActivityRecord _a, String _w, 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; type = _t;
packageName = _p; packageName = _p;
activity = _a; activity = _a;
@ -70,10 +71,12 @@ class PendingIntentRecord extends IIntentSender.Stub {
allResolvedTypes = _it; allResolvedTypes = _it;
flags = _f; flags = _f;
options = _o; options = _o;
userId = _userId;
int hash = 23; int hash = 23;
hash = (ODD_PRIME_NUMBER*hash) + _f; hash = (ODD_PRIME_NUMBER*hash) + _f;
hash = (ODD_PRIME_NUMBER*hash) + _r; hash = (ODD_PRIME_NUMBER*hash) + _r;
hash = (ODD_PRIME_NUMBER*hash) + _userId;
if (_w != null) { if (_w != null) {
hash = (ODD_PRIME_NUMBER*hash) + _w.hashCode(); hash = (ODD_PRIME_NUMBER*hash) + _w.hashCode();
} }
@ -102,6 +105,9 @@ class PendingIntentRecord extends IIntentSender.Stub {
if (type != other.type) { if (type != other.type) {
return false; return false;
} }
if (userId != other.userId){
return false;
}
if (!packageName.equals(other.packageName)) { if (!packageName.equals(other.packageName)) {
return false; return false;
} }
@ -156,7 +162,7 @@ class PendingIntentRecord extends IIntentSender.Stub {
+ " intent=" + " intent="
+ (requestIntent != null + (requestIntent != null
? requestIntent.toShortString(false, true, false, false) : "<null>") ? requestIntent.toShortString(false, true, false, false) : "<null>")
+ " flags=0x" + Integer.toHexString(flags) + "}"; + " flags=0x" + Integer.toHexString(flags) + " u=" + userId + "}";
} }
String typeName() { String typeName() {