Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1f0d576 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "IMS-VT: Moving upgradeVideoRequest handling to InCallPresenter" into nyc-dev

parents 3fc59a42 207029be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.
+9 −2
Original line number Diff line number Diff line
@@ -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.
     */
+23 −1
Original line number Diff line number Diff line
@@ -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.
     */
+3 −18
Original line number Diff line number Diff line
@@ -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);
    }
+2 −60
Original line number Diff line number Diff line
@@ -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);
    }

    /**
Loading