From e61d51e94b416a0f4ae97cda727b9241560209ea Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 12 Jul 2017 14:25:24 -0700 Subject: Cache video state to avoid performance issue. This is temporary solution to avoid expansive operation for frequent method calls. In long term we should figure out a better way for such cases. Bug: 62424638,62426694 Test: manual PiperOrigin-RevId: 161717598 Change-Id: I75e6589174b81ae611893e5435a94e7f629f500f --- java/com/android/incallui/CallButtonPresenter.java | 2 +- java/com/android/incallui/call/DialerCall.java | 25 ++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'java/com') diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index e36d9cf9e..dbb6a1c18 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -365,7 +365,7 @@ public class CallButtonPresenter } private void updateUi(InCallState state, DialerCall call) { - LogUtil.v("CallButtonPresenter", "updating call UI for call: ", call); + LogUtil.v("CallButtonPresenter", "updating call UI for call: %s", call); if (mInCallButtonUi == null) { return; diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 88e0dbb5e..2e15264a5 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -152,6 +152,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa // Times when a second call is received but AnswerAndRelease button is not shown // since it's not supported. private int secondCallWithoutAnswerAndReleasedButtonTimes = 0; + private VideoTech videoTech; public static String getNumberFromHandle(Uri handle) { return handle == null ? "" : handle.getSchemeSpecificPart(); @@ -194,14 +195,15 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Override public void onDetailsChanged(Call call, Call.Details details) { - LogUtil.v("TelecomCallCallback.onStateChanged", " call=" + call + " details=" + details); + LogUtil.v( + "TelecomCallCallback.onDetailsChanged", " call=" + call + " details=" + details); update(); } @Override public void onCannedTextResponsesLoaded(Call call, List cannedTextResponses) { LogUtil.v( - "TelecomCallCallback.onStateChanged", + "TelecomCallCallback.onCannedTextResponsesLoaded", "call=" + call + " cannedTextResponses=" + cannedTextResponses); for (CannedTextResponsesLoadedListener listener : mCannedTextResponsesLoadedListeners) { listener.onCannedTextResponsesLoaded(DialerCall.this); @@ -211,7 +213,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Override public void onPostDialWait(Call call, String remainingPostDialSequence) { LogUtil.v( - "TelecomCallCallback.onStateChanged", + "TelecomCallCallback.onPostDialWait", "call=" + call + " remainingPostDialSequence=" + remainingPostDialSequence); update(); } @@ -219,20 +221,20 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Override public void onVideoCallChanged(Call call, VideoCall videoCall) { LogUtil.v( - "TelecomCallCallback.onStateChanged", "call=" + call + " videoCall=" + videoCall); + "TelecomCallCallback.onVideoCallChanged", "call=" + call + " videoCall=" + videoCall); update(); } @Override public void onCallDestroyed(Call call) { - LogUtil.v("TelecomCallCallback.onStateChanged", "call=" + call); + LogUtil.v("TelecomCallCallback.onCallDestroyed", "call=" + call); unregisterCallback(); } @Override public void onConferenceableCallsChanged(Call call, List conferenceableCalls) { LogUtil.v( - "DialerCall.onConferenceableCallsChanged", + "TelecomCallCallback.onConferenceableCallsChanged", "call %s, conferenceable calls: %d", call, conferenceableCalls.size()); @@ -242,7 +244,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Override public void onConnectionEvent(android.telecom.Call call, String event, Bundle extras) { LogUtil.v( - "DialerCall.onConnectionEvent", + "TelecomCallCallback.onConnectionEvent", "Call: " + call + ", Event: " + event + ", Extras: " + extras); switch (event) { // The Previous attempt to Merge two calls together has failed in Telecom. We must @@ -430,6 +432,8 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa private void update() { Trace.beginSection("Update"); int oldState = getState(); + // Clear any cache here that could potentially change on update. + videoTech = null; // We want to potentially register a video call callback here. updateFromTelecomCall(); if (oldState != getState() && getState() == DialerCall.State.DISCONNECTED) { @@ -441,7 +445,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa .unregisterCapabilitiesListener(this); EnrichedCallComponent.get(mContext) .getEnrichedCallManager() - .unregisterCapabilitiesListener(this); + .unregisterStateChangedListener(this); } else { for (DialerCallListener listener : mListeners) { listener.onDialerCallUpdate(); @@ -1114,7 +1118,10 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } public VideoTech getVideoTech() { - return mVideoTechManager.getVideoTech(); + if (videoTech == null) { + videoTech = mVideoTechManager.getVideoTech(); + } + return videoTech; } public String getCallbackNumber() { -- cgit v1.2.3