From 207029be4c95b6d66ef4bd3c2277a9ba9e0c62a1 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 17 Feb 2016 15:18:36 -0800 Subject: 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 --- .../src/com/android/incallui/AnswerPresenter.java | 2 +- .../com/android/incallui/CallCardPresenter.java | 11 +++- .../src/com/android/incallui/InCallPresenter.java | 24 ++++++++- .../android/incallui/InCallVideoCallCallback.java | 21 ++------ .../incallui/InCallVideoCallCallbackNotifier.java | 62 +--------------------- .../com/android/incallui/VideoCallPresenter.java | 54 ------------------- .../com/android/incallui/VideoPauseController.java | 45 +--------------- 7 files changed, 39 insertions(+), 180 deletions(-) (limited to 'InCallUI/src') 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 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 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 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 } } + 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 @@ -134,39 +134,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. * @@ -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 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