summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android/incallui/CallCardPresenter.java
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2015-05-05 12:22:38 -0700
committerTyler Gunn <tgunn@google.com>2015-05-05 12:22:38 -0700
commitb040158d7bb2f5c7d06bd2c1db5e96adafbcff3e (patch)
tree575325aa5b00fbeef17e3cfd00271751bdc0bab3 /InCallUI/src/com/android/incallui/CallCardPresenter.java
parent99e4144119af04c2269bc3c6f1151c1be9714857 (diff)
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
Diffstat (limited to 'InCallUI/src/com/android/incallui/CallCardPresenter.java')
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java64
1 files changed, 55 insertions, 9 deletions
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<CallCardPresenter.CallCardUi>
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<CallCardPresenter.CallCardUi>
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<CallCardPresenter> mCallCardPresenter;
@@ -121,6 +122,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
// 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<CallCardPresenter.CallCardUi>
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<CallCardPresenter.CallCardUi>
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<CallCardPresenter.CallCardUi>
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<CallCardPresenter.CallCardUi>
}
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<CallCardPresenter.CallCardUi>
}
}
+ @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<CallCardPresenter.CallCardUi>
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<CallCardPresenter.CallCardUi>
}
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