summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android/incallui/CallCardPresenter.java
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2015-04-30 10:39:11 -0700
committerTyler Gunn <tgunn@google.com>2015-04-30 10:39:11 -0700
commitec3a0803d99d202fc4bc9085e185b11300eade00 (patch)
tree8c70468468f499f2903938e37142f71eb79b6ec8 /InCallUI/src/com/android/incallui/CallCardPresenter.java
parent7fdc543855a81ed71e19c958bca2e6e0f4a5c106 (diff)
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 89cb659d0..c5407df9c 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -45,6 +45,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;
@@ -55,7 +56,7 @@ import com.google.common.base.Preconditions;
*/
public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
implements InCallStateListener, IncomingCallListener, InCallDetailsListener,
- InCallEventListener {
+ InCallEventListener, CallList.CallUpdateListener {
private static final String TAG = CallCardPresenter.class.getSimpleName();
private static final long CALL_TIME_UPDATE_INTERVAL_MS = 1000;
@@ -65,8 +66,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;
@@ -111,6 +112,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()) {
@@ -146,6 +148,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;
@@ -192,6 +197,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:
@@ -200,6 +206,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();
@@ -250,7 +261,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),
@@ -267,6 +277,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
@@ -310,11 +346,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;
+ }
}
/**
@@ -640,7 +686,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