Fix potential mismatched caller information
This fixes a bug where caller information returned for a call
waiting would be mistakenedly applied to an existing call by
ensuring that the returned contact information is only assigned
to the call that initiated the lookup.
1) Active call A is in progress
2) Incoming call B (call waiting)
3) Contact info lookup is initiated for call B
4) Call B is rejected
5) Contact info is returned
6) UI for call A is updated with the returned info
Bug: 24591055
Change-Id: I41e0741d8bc01a2fe98d77cb080d1df455b1e5df
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 0cc5da1..d597218 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -513,7 +513,15 @@
}
private void onContactInfoComplete(String callId, ContactCacheEntry entry, boolean isPrimary) {
- updateContactEntry(entry, isPrimary);
+ final boolean entryMatchesExistingCall =
+ (isPrimary && mPrimary != null && TextUtils.equals(callId, mPrimary.getId())) ||
+ (!isPrimary && mSecondary != null && TextUtils.equals(callId, mSecondary.getId()));
+ if (entryMatchesExistingCall) {
+ updateContactEntry(entry, isPrimary);
+ } else {
+ Log.w(this, "Dropping stale contact lookup info for " + callId);
+ }
+
if (entry.name != null) {
Log.d(TAG, "Contact found: " + entry);
}