From b040158d7bb2f5c7d06bd2c1db5e96adafbcff3e Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Tue, 5 May 2015 12:22:38 -0700 Subject: DO NOT MERGE Video call upgrade/dowgrade request changes. - fixed potential NPE in VideoCallFragment when setting preview size. - moved photo load into the postExecute for the async task -- it is already threaded and I was seeing intermittent concurrency issues. - Changed CallButtonFragment to retrieve max # of buttons from config.xml. - Added override for wider screens (e.g. N6 and wider) to show an extra button. - Reorganized call buttons so that the "Camera on/off" button is adjacent to the flip camera button. - Changed answer Glowpad to pass correct video state so that accepting a video request uses the correct state (important for accepting requests to turn camera back on). - added new Session modification state REQUEST_REJECTED for when the remote user explicitly declines the request. This is used to trigger a "video request rejected" message when the remote party rejects the request. Bug: 20257400 Change-Id: Ibe25eb045ee868748f91bf411f285629d36ebcd2 --- .../com/android/incallui/CallCardPresenter.java | 64 +++++++++++++++++++--- 1 file changed, 55 insertions(+), 9 deletions(-) (limited to 'InCallUI/src/com/android/incallui/CallCardPresenter.java') diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index ee13e061f..b233ad56b 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -48,6 +48,7 @@ import com.android.incallui.InCallPresenter.IncomingCallListener; import com.android.incalluibind.ObjectFactory; import java.lang.ref.WeakReference; +import java.util.Objects; import com.google.common.base.Preconditions; @@ -58,7 +59,7 @@ import com.google.common.base.Preconditions; */ public class CallCardPresenter extends Presenter implements InCallStateListener, IncomingCallListener, InCallDetailsListener, - InCallEventListener { + InCallEventListener, CallList.CallUpdateListener { public interface EmergencyCallListener { public void onCallUpdated(BaseFragment fragment, boolean isEmergency); @@ -75,8 +76,8 @@ public class CallCardPresenter extends Presenter private ContactCacheEntry mPrimaryContactInfo; private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; - private Context mContext; + private boolean mSpinnerShowing = false; public static class ContactLookupCallback implements ContactInfoCacheCallback { private final WeakReference mCallCardPresenter; @@ -121,6 +122,7 @@ public class CallCardPresenter extends Presenter // Call may be null if disconnect happened already. if (call != null) { mPrimary = call; + CallList.getInstance().addCallUpdateListener(call.getId(), this); // start processing lookups right away. if (!call.isConferenceCall()) { @@ -158,6 +160,9 @@ public class CallCardPresenter extends Presenter InCallPresenter.getInstance().removeIncomingCallListener(this); InCallPresenter.getInstance().removeDetailsListener(this); InCallPresenter.getInstance().removeInCallEventListener(this); + if (mPrimary != null) { + CallList.getInstance().removeCallUpdateListener(mPrimary.getId(), this); + } mPrimary = null; mPrimaryContactInfo = null; @@ -204,6 +209,7 @@ public class CallCardPresenter extends Presenter final boolean secondaryChanged = !Call.areSame(mSecondary, secondary); mSecondary = secondary; + Call previousPrimary = mPrimary; mPrimary = primary; // Refresh primary call information if either: @@ -212,6 +218,11 @@ public class CallCardPresenter extends Presenter if (mPrimary != null && (primaryChanged || ui.isManageConferenceVisible() != shouldShowManageConference())) { // primary call has changed + if (previousPrimary != null) { + CallList.getInstance().removeCallUpdateListener(previousPrimary.getId(), this); + } + CallList.getInstance().addCallUpdateListener(mPrimary.getId(), this); + mPrimaryContactInfo = ContactInfoCache.buildCacheEntryFromCall(mContext, mPrimary, mPrimary.getState() == Call.State.INCOMING); updatePrimaryDisplayInfo(); @@ -262,7 +273,6 @@ public class CallCardPresenter extends Presenter } maybeShowManageConferenceCallButton(); - maybeShowProgressSpinner(); // Hide the end call button instantly if we're receiving an incoming call. getUi().setEndCallButtonEnabled(shouldShowEndCallButton(mPrimary, callState), @@ -279,6 +289,32 @@ public class CallCardPresenter extends Presenter } } + @Override + public void onCallChanged(Call call) { + // No-op; specific call updates handled elsewhere. + } + + /** + * Handles a change to the session modification state for a call. Triggers showing the progress + * spinner, as well as updating the call state label. + * + * @param sessionModificationState The new session modification state. + */ + @Override + public void onSessionModificationStateChange(int sessionModificationState) { + Log.d(this, "onSessionModificationStateChange : sessionModificationState = " + + sessionModificationState); + + if (mPrimary == null) { + return; + } + maybeShowProgressSpinner(mPrimary.getState(), sessionModificationState); + getUi().setEndCallButtonEnabled(sessionModificationState != + Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST, + true /* shouldAnimate */); + updatePrimaryCallState(); + } + private String getSubscriptionNumber() { // If it's an emergency call, and they're not populating the callback number, // then try to fall back to the phone sub info (to hopefully get the SIM's @@ -322,11 +358,21 @@ public class CallCardPresenter extends Presenter getUi().showManageConferenceCallButton(shouldShowManageConference()); } - private void maybeShowProgressSpinner() { - final boolean show = mPrimary != null && mPrimary.getSessionModificationState() - == Call.SessionModificationState.WAITING_FOR_RESPONSE - && mPrimary.getState() == Call.State.ACTIVE; - getUi().setProgressSpinnerVisible(show); + /** + * Determines if a pending session modification exists for the current call. If so, the + * progress spinner is shown, and the call state is updated. + * + * @param callState The call state. + * @param sessionModificationState The session modification state. + */ + private void maybeShowProgressSpinner(int callState, int sessionModificationState) { + final boolean show = sessionModificationState == + Call.SessionModificationState.WAITING_FOR_RESPONSE + && callState == Call.State.ACTIVE; + if (show != mSpinnerShowing) { + getUi().setProgressSpinnerVisible(show); + mSpinnerShowing = show; + } } /** @@ -657,7 +703,7 @@ public class CallCardPresenter extends Presenter } private boolean hasOutgoingGatewayCall() { - // We only display the gateway information while STATE_DIALING so return false for any othe + // We only display the gateway information while STATE_DIALING so return false for any other // call state. // TODO: mPrimary can be null because this is called from updatePrimaryDisplayInfo which // is also called after a contact search completes (call is not present yet). Split the -- cgit v1.2.3