From b9103042d4e81e2a462b2c29eccddc91f2f1ffc8 Mon Sep 17 00:00:00 2001 From: yueg Date: Fri, 30 Mar 2018 12:12:25 -0700 Subject: Move update color code from CallCardPresenter to InCallPresenter. Bug: 74022483 Test: manual PiperOrigin-RevId: 191098829 Change-Id: I715a97ba48db9a3a81ef7b27750131a3a3a331b7 --- java/com/android/incallui/CallCardPresenter.java | 55 ++------------------ java/com/android/incallui/InCallPresenter.java | 64 ++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 52 deletions(-) (limited to 'java') diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index 9c5e0623e..2f88c8836 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -271,10 +271,10 @@ public class CallCardPresenter // getCallToDisplay doesn't go through outgoing or incoming calls. It will return the // highest priority call to display as the secondary call. - secondary = getCallToDisplay(callList, null, true); + secondary = InCallPresenter.getCallToDisplay(callList, null, true); } else if (newState == InCallState.INCALL) { - primary = getCallToDisplay(callList, null, false); - secondary = getCallToDisplay(callList, primary, true); + primary = InCallPresenter.getCallToDisplay(callList, null, false); + secondary = InCallPresenter.getCallToDisplay(callList, primary, true); } LogUtil.v("CallCardPresenter.onStateChange", "primary call: " + primary); @@ -302,7 +302,6 @@ public class CallCardPresenter this.primaryNumber = primaryNumber; if (this.primary != null) { - InCallPresenter.getInstance().onForegroundCallChanged(this.primary); inCallScreen.updateInCallScreenColors(); } @@ -636,54 +635,6 @@ public class CallCardPresenter } } - /** - * Get the highest priority call to display. Goes through the calls and chooses which to return - * based on priority of which type of call to display to the user. Callers can use the "ignore" - * feature to get the second best call by passing a previously found primary call as ignore. - * - * @param ignore A call to ignore if found. - */ - private DialerCall getCallToDisplay( - CallList callList, DialerCall ignore, boolean skipDisconnected) { - // Active calls come second. An active call always gets precedent. - DialerCall retval = callList.getActiveCall(); - if (retval != null && retval != ignore) { - return retval; - } - - // Sometimes there is intemediate state that two calls are in active even one is about - // to be on hold. - retval = callList.getSecondActiveCall(); - if (retval != null && retval != ignore) { - return retval; - } - - // Disconnected calls get primary position if there are no active calls - // to let user know quickly what call has disconnected. Disconnected - // calls are very short lived. - if (!skipDisconnected) { - retval = callList.getDisconnectingCall(); - if (retval != null && retval != ignore) { - return retval; - } - retval = callList.getDisconnectedCall(); - if (retval != null && retval != ignore) { - return retval; - } - } - - // Then we go to background call (calls on hold) - retval = callList.getBackgroundCall(); - if (retval != null && retval != ignore) { - return retval; - } - - // Lastly, we go to a second background call. - retval = callList.getSecondBackgroundCall(); - - return retval; - } - private void updatePrimaryDisplayInfo() { if (inCallScreen == null) { // TODO: May also occur if search result comes back after ui is destroyed. Look into diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index 2e98a969d..e11b376c1 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -771,6 +771,22 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud "Phone switching state: " + oldState + " -> " + newState); inCallState = newState; + // Foreground call changed + DialerCall primary = null; + if (newState == InCallState.INCOMING) { + primary = callList.getIncomingCall(); + } else if (newState == InCallState.PENDING_OUTGOING || newState == InCallState.OUTGOING) { + primary = callList.getOutgoingCall(); + if (primary == null) { + primary = callList.getPendingOutgoingCall(); + } + } else if (newState == InCallState.INCALL) { + primary = getCallToDisplay(callList, null, false); + } + if (primary != null) { + onForegroundCallChanged(primary); + } + // notify listeners of new state for (InCallStateListener listener : listeners) { LogUtil.d( @@ -787,6 +803,54 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud Trace.endSection(); } + /** + * Get the highest priority call to display. Goes through the calls and chooses which to return + * based on priority of which type of call to display to the user. Callers can use the "ignore" + * feature to get the second best call by passing a previously found primary call as ignore. + * + * @param ignore A call to ignore if found. + */ + static DialerCall getCallToDisplay( + CallList callList, DialerCall ignore, boolean skipDisconnected) { + // Active calls come second. An active call always gets precedent. + DialerCall retval = callList.getActiveCall(); + if (retval != null && retval != ignore) { + return retval; + } + + // Sometimes there is intemediate state that two calls are in active even one is about + // to be on hold. + retval = callList.getSecondActiveCall(); + if (retval != null && retval != ignore) { + return retval; + } + + // Disconnected calls get primary position if there are no active calls + // to let user know quickly what call has disconnected. Disconnected + // calls are very short lived. + if (!skipDisconnected) { + retval = callList.getDisconnectingCall(); + if (retval != null && retval != ignore) { + return retval; + } + retval = callList.getDisconnectedCall(); + if (retval != null && retval != ignore) { + return retval; + } + } + + // Then we go to background call (calls on hold) + retval = callList.getBackgroundCall(); + if (retval != null && retval != ignore) { + return retval; + } + + // Lastly, we go to a second background call. + retval = callList.getSecondBackgroundCall(); + + return retval; + } + /** Called when there is a new incoming call. */ @Override public void onIncomingCall(DialerCall call) { -- cgit v1.2.3