summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2016-02-17 15:18:36 -0800
committerTyler Gunn <tgunn@google.com>2016-02-18 10:42:35 -0800
commit207029be4c95b6d66ef4bd3c2277a9ba9e0c62a1 (patch)
tree10dc904dcea1917bdfcca362f7684ffaa7905e92
parent9172c905b311816eba1d24659f02facfab95b0b3 (diff)
IMS-VT: Moving upgradeVideoRequest handling to InCallPresenter
When user pressed back key InCallActviity will be destroyed and corresponding listeners in VideoCallPresenter will be removed. Due to this we are unable to process the upgrade request. Moving handling of upgrade Video Call request handling from VideoCallPresenter to InCallPresenter as InCallPresenter will be available even InCallActivity is destroyed. Bug: 27130345 Change-Id: Idbd3348cea9d712c8391319d091642d1fd60964f
-rw-r--r--InCallUI/src/com/android/incallui/AnswerPresenter.java2
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java11
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java24
-rw-r--r--InCallUI/src/com/android/incallui/InCallVideoCallCallback.java21
-rw-r--r--InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java62
-rw-r--r--InCallUI/src/com/android/incallui/VideoCallPresenter.java54
-rw-r--r--InCallUI/src/com/android/incallui/VideoPauseController.java45
7 files changed, 39 insertions, 180 deletions
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index 6e1fb3cfb..2bd3629e7 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -77,7 +77,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
showAnswerUi(false);
Log.d(this, "declining upgrade request id: ");
CallList.getInstance().removeCallUpdateListener(mCallId, this);
- InCallPresenter.getInstance().declineUpgradeRequest(getUi().getContext());
+ InCallPresenter.getInstance().declineUpgradeRequest();
}
if (!call.getId().equals(mCallId)) {
// A new call is coming in.
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 7749118de..2acdc470f 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -278,7 +278,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
mPrimary.getState() == Call.State.INCOMING);
updatePrimaryDisplayInfo();
maybeStartSearch(mPrimary, true);
- mPrimary.setSessionModificationState(Call.SessionModificationState.NO_REQUEST);
+ maybeClearSessionModificationState(mPrimary);
}
if (previousPrimary != null && mPrimary == null) {
@@ -298,7 +298,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
mSecondary.getState() == Call.State.INCOMING);
updateSecondaryDisplayInfo();
maybeStartSearch(mSecondary, false);
- mSecondary.setSessionModificationState(Call.SessionModificationState.NO_REQUEST);
+ maybeClearSessionModificationState(mSecondary);
}
// Start/stop timers.
@@ -563,6 +563,13 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
}
}
+ private void maybeClearSessionModificationState(Call call) {
+ if (call.getSessionModificationState() !=
+ Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) {
+ call.setSessionModificationState(Call.SessionModificationState.NO_REQUEST);
+ }
+ }
+
/**
* Starts a query for more contact data for the save primary and secondary calls.
*/
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index f50da8dbd..c51a561bf 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -78,7 +78,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
* TODO: This class has become more of a state machine at this point. Consider renaming.
*/
public class InCallPresenter implements CallList.Listener,
- CircularRevealFragment.OnCircularRevealCompleteListener {
+ CircularRevealFragment.OnCircularRevealCompleteListener,
+ InCallVideoCallCallbackNotifier.SessionModificationListener {
private static final String EXTRA_FIRST_TIME_SHOWN =
"com.android.incallui.intent.extra.FIRST_TIME_SHOWN";
@@ -387,6 +388,7 @@ public class InCallPresenter implements CallList.Listener,
mCallList.addListener(this);
VideoPauseController.getInstance().setUp(this);
+ InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this);
mFilteredQueryHandler = new FilteredNumberAsyncQueryHandler(context.getContentResolver());
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
@@ -413,6 +415,7 @@ public class InCallPresenter implements CallList.Listener,
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
VideoPauseController.getInstance().tearDown();
+ InCallVideoCallCallbackNotifier.getInstance().removeSessionModificationListener(this);
}
private void attemptFinishActivity() {
@@ -726,6 +729,17 @@ public class InCallPresenter implements CallList.Listener,
}
}
+ @Override
+ public void onUpgradeToVideoRequest(Call call, int videoState) {
+ Log.d(this, "onUpgradeToVideoRequest call = " + call + " video state = " + videoState);
+
+ if (call == null) {
+ return;
+ }
+
+ call.setRequestedVideoState(videoState);
+ }
+
/**
* Given the call list, return the state in which the in-call screen should be.
*/
@@ -980,6 +994,14 @@ public class InCallPresenter implements CallList.Listener,
}
}
+ /*package*/
+ void declineUpgradeRequest() {
+ // Pass mContext if InCallActivity is destroyed.
+ // Ex: When user pressed back key while in active call and
+ // then modify request is received followed by MT call.
+ declineUpgradeRequest(mInCallActivity != null ? mInCallActivity : mContext);
+ }
+
/**
* Returns true if the incall app is the foreground application.
*/
diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java b/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java
index 76f8c09fc..99e6d5129 100644
--- a/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java
+++ b/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java
@@ -55,10 +55,8 @@ public class InCallVideoCallCallback extends VideoCall.Callback {
boolean wasVideoCall = VideoUtils.isVideoCall(previousVideoState);
boolean isVideoCall = VideoUtils.isVideoCall(newVideoState);
- // Check for upgrades to video and downgrades to audio.
- if (wasVideoCall && !isVideoCall) {
- InCallVideoCallCallbackNotifier.getInstance().downgradeToAudio(mCall);
- } else if (previousVideoState != newVideoState) {
+ // Check for upgrades to video.
+ if (!wasVideoCall && isVideoCall && previousVideoState != newVideoState) {
InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoRequest(mCall,
newVideoState);
}
@@ -93,21 +91,8 @@ public class InCallVideoCallCallback extends VideoCall.Callback {
Call.SessionModificationState.REQUEST_FAILED);
}
}
- InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoFail(status, mCall);
- } else if (requestedProfile != null && responseProfile != null) {
- boolean modifySucceeded = requestedProfile.getVideoState() ==
- responseProfile.getVideoState();
- boolean isVideoCall = VideoUtils.isVideoCall(responseProfile.getVideoState());
- if (modifySucceeded && isVideoCall) {
- InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoSuccess(mCall);
- } else if (!modifySucceeded && isVideoCall) {
- InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoFail(status, mCall);
- } else if (modifySucceeded && !isVideoCall) {
- InCallVideoCallCallbackNotifier.getInstance().downgradeToAudio(mCall);
- }
- } else {
- Log.d(this, "onSessionModifyResponseReceived request and response Profiles are null");
}
+
// Finally clear the outstanding request.
mCall.setSessionModificationState(Call.SessionModificationState.NO_REQUEST);
}
diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java b/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java
index dfb645bfc..bb7529205 100644
--- a/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java
+++ b/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java
@@ -135,39 +135,6 @@ public class InCallVideoCallCallbackNotifier {
}
/**
- * Inform listeners of a successful response to a video request for a call.
- *
- * @param call The call.
- */
- public void upgradeToVideoSuccess(Call call) {
- for (SessionModificationListener listener : mSessionModificationListeners) {
- listener.onUpgradeToVideoSuccess(call);
- }
- }
-
- /**
- * Inform listeners of an unsuccessful response to a video request for a call.
- *
- * @param call The call.
- */
- public void upgradeToVideoFail(int status, Call call) {
- for (SessionModificationListener listener : mSessionModificationListeners) {
- listener.onUpgradeToVideoFail(status, call);
- }
- }
-
- /**
- * Inform listeners of a downgrade to audio.
- *
- * @param call The call.
- */
- public void downgradeToAudio(Call call) {
- for (SessionModificationListener listener : mSessionModificationListeners) {
- listener.onDowngradeToAudio(call);
- }
- }
-
- /**
* Inform listeners of a call session event.
*
* @param event The call session event.
@@ -240,41 +207,16 @@ public class InCallVideoCallCallbackNotifier {
}
/**
- * Listener interface for any class that wants to be notified of upgrade to video and downgrade
- * to audio session modification requests.
+ * Listener interface for any class that wants to be notified of upgrade to video request.
*/
public interface SessionModificationListener {
/**
* Called when a peer request is received to upgrade an audio-only call to a video call.
*
* @param call The call the request was received for.
- * @param videoState The video state that the request wants to upgrade to.
+ * @param videoState The requested video state.
*/
public void onUpgradeToVideoRequest(Call call, int videoState);
-
- /**
- * Called when a request to a peer to upgrade an audio-only call to a video call is
- * successful.
- *
- * @param call The call the request was successful for.
- */
- public void onUpgradeToVideoSuccess(Call call);
-
- /**
- * Called when a request to a peer to upgrade an audio-only call to a video call is
- * NOT successful. This can be if the peer chooses rejects the the video call, or if the
- * peer does not support video calling, or if there is some error in sending the request.
- *
- * @param call The call the request was successful for.
- */
- public void onUpgradeToVideoFail(int status, Call call);
-
- /**
- * Called when a call has been downgraded to audio-only.
- *
- * @param call The call which was downgraded to audio-only.
- */
- public void onDowngradeToAudio(Call call);
}
/**
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index ebdf82048..2b6bc09a2 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -68,7 +68,6 @@ import java.util.Objects;
public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi> implements
IncomingCallListener, InCallOrientationListener, InCallStateListener,
InCallDetailsListener, SurfaceChangeListener, VideoEventListener,
- InCallVideoCallCallbackNotifier.SessionModificationListener,
InCallPresenter.InCallEventListener {
public static final String TAG = "VideoCallPresenter";
@@ -241,7 +240,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
// Register for surface and video events from {@link InCallVideoCallListener}s.
InCallVideoCallCallbackNotifier.getInstance().addSurfaceChangeListener(this);
InCallVideoCallCallbackNotifier.getInstance().addVideoEventListener(this);
- InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this);
mCurrentVideoState = VideoProfile.STATE_AUDIO_ONLY;
mCurrentCallState = Call.State.INVALID;
}
@@ -268,7 +266,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
InCallVideoCallCallbackNotifier.getInstance().removeSurfaceChangeListener(this);
InCallVideoCallCallbackNotifier.getInstance().removeVideoEventListener(this);
- InCallVideoCallCallbackNotifier.getInstance().removeSessionModificationListener(this);
}
/**
@@ -992,57 +989,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
}
/**
- * Handles an incoming upgrade to video request.
- *
- * @param call The call the request was received for.
- * @param videoState The video state that the request wants to upgrade to.
- */
- @Override
- public void onUpgradeToVideoRequest(Call call, int videoState) {
- Log.d(this, "onUpgradeToVideoRequest call = " + call + " new video state = " + videoState);
- if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) {
- Log.w(this, "UpgradeToVideoRequest received for non-primary call");
- }
-
- if (call == null) {
- return;
- }
-
- call.setRequestedVideoState(videoState);
- }
-
- @Override
- public void onUpgradeToVideoSuccess(Call call) {
- Log.d(this, "onUpgradeToVideoSuccess call=" + call);
- if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) {
- Log.w(this, "UpgradeToVideoSuccess received for non-primary call");
- }
-
- if (call == null) {
- return;
- }
- }
-
- @Override
- public void onUpgradeToVideoFail(int status, Call call) {
- Log.d(this, "onUpgradeToVideoFail call=" + call);
- if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) {
- Log.w(this, "UpgradeToVideoFail received for non-primary call");
- }
-
- if (call == null) {
- return;
- }
- }
-
- @Override
- public void onDowngradeToAudio(Call call) {
- call.setSessionModificationState(Call.SessionModificationState.NO_REQUEST);
- // exit video mode
- exitVideoMode();
- }
-
- /**
* Sets the preview surface size based on the current device orientation.
* See: {@link InCallOrientationEventListener#SCREEN_ORIENTATION_0},
* {@link InCallOrientationEventListener#SCREEN_ORIENTATION_90},
diff --git a/InCallUI/src/com/android/incallui/VideoPauseController.java b/InCallUI/src/com/android/incallui/VideoPauseController.java
index 070448ee9..a529d20d3 100644
--- a/InCallUI/src/com/android/incallui/VideoPauseController.java
+++ b/InCallUI/src/com/android/incallui/VideoPauseController.java
@@ -27,8 +27,7 @@ import com.google.common.base.Preconditions;
* This class is responsible for generating video pause/resume requests when the InCall UI is sent
* to the background and subsequently brought back to the foreground.
*/
-class VideoPauseController implements InCallStateListener, IncomingCallListener,
- SessionModificationListener {
+class VideoPauseController implements InCallStateListener, IncomingCallListener {
private static final String TAG = "VideoPauseController";
/**
@@ -105,7 +104,6 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener,
mInCallPresenter = Preconditions.checkNotNull(inCallPresenter);
mInCallPresenter.addListener(this);
mInCallPresenter.addIncomingCallListener(this);
- InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this);
}
/**
@@ -114,7 +112,6 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener,
*/
public void tearDown() {
log("tearDown...");
- InCallVideoCallCallbackNotifier.getInstance().removeSessionModificationListener(this);
mInCallPresenter.removeListener(this);
mInCallPresenter.removeIncomingCallListener(this);
clear();
@@ -260,46 +257,6 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener,
}
/**
- * Handles requests to upgrade to video.
- *
- * @param call The call the request was received for.
- * @param videoState The video state that the request wants to upgrade to.
- */
- @Override
- public void onUpgradeToVideoRequest(Call call, int videoState) {
- // Not used.
- }
-
- /**
- * Handles successful upgrades to video.
- * @param call The call the request was successful for.
- */
- @Override
- public void onUpgradeToVideoSuccess(Call call) {
- // Not used.
- }
-
- /**
- * Handles a failure to upgrade a call to video.
- *
- * @param status The failure status.
- * @param call The call the request was successful for.
- */
- @Override
- public void onUpgradeToVideoFail(int status, Call call) {
- // TODO (ims-vt) Automatically bring in call ui to foreground.
- }
-
- /**
- * Handles a downgrade of a call to audio-only.
- *
- * @param call The call which was downgraded to audio-only.
- */
- @Override
- public void onDowngradeToAudio(Call call) {
- }
-
- /**
* Called when UI is brought to the foreground. Sends a session modification request to resume
* the outgoing video.
*/