From 1e9bfc6461d3fe5455c9d7a21414ec66695b5798 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 19 Aug 2015 11:18:58 -0700 Subject: Fix incorrect android.telecom.Call.Details equality check. The the android.telecom.Call.Details class provides its own equals implementation. Recently added in M is to also check if the mExtras and mIntentExtras are different. Unfortunately, Bundles do not implement equals. As a result when Telecom calls are parceled and sent to the InCallServices, this means that the internalUpdate method will always assume that the Details of a call have changed, even if they have not. This was causing a LOT of extra calls to onUpdate in the InCall UI (2x the amount). Although there is still room for improvement in the number of callbacks from Telecom, this fix prevents a pretty significant regression on that front. Bug: 23218195 Change-Id: I128e996faf60376ed3df1dc848a97c4a7b0482ee --- telecomm/java/android/telecom/Call.java | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'telecomm/java/android') diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 4569549..0a1dbf6 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -512,8 +512,8 @@ public final class Call { Objects.equals(mGatewayInfo, d.mGatewayInfo) && Objects.equals(mVideoState, d.mVideoState) && Objects.equals(mStatusHints, d.mStatusHints) && - Objects.equals(mExtras, d.mExtras) && - Objects.equals(mIntentExtras, d.mIntentExtras); + areBundlesEqual(mExtras, d.mExtras) && + areBundlesEqual(mIntentExtras, d.mIntentExtras); } return false; } @@ -1245,4 +1245,32 @@ public final class Call { }); } } + + /** + * Determines if two bundles are equal. + * + * @param bundle The original bundle. + * @param newBundle The bundle to compare with. + * @retrun {@code true} if the bundles are equal, {@code false} otherwise. + */ + private static boolean areBundlesEqual(Bundle bundle, Bundle newBundle) { + if (bundle == null || newBundle == null) { + return bundle == newBundle; + } + + if (bundle.size() != newBundle.size()) { + return false; + } + + for(String key : bundle.keySet()) { + if (key != null) { + final Object value = bundle.get(key); + final Object newValue = newBundle.get(key); + if (!Objects.equals(value, newValue)) { + return false; + } + } + } + return true; + } } -- cgit v1.1