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

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

Merge "Auto reject video requests for secondary user." into nyc-mr1-dev

parents 72f08516 13e8a693
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1158,8 +1158,7 @@ public class Call implements CreateConnectionResponse {
        setConnectionCapabilities(connection.getConnectionCapabilities());
        setConnectionProperties(connection.getConnectionProperties());
        setVideoProvider(connection.getVideoProvider());
        setVideoState(mCallsManager.getCheckedVideoState(connection.getVideoState(),
                connection.getPhoneAccount()));
        setVideoState(connection.getVideoState());
        setRingbackRequested(connection.isRingbackRequested());
        setIsVoipAudioMode(connection.getIsVoipAudioMode());
        setStatusHints(connection.getStatusHints());
@@ -1334,6 +1333,11 @@ public class Call implements CreateConnectionResponse {
        // Check to verify that the call is still in the ringing state. A call can change states
        // between the time the user hits 'answer' and Telecom receives the command.
        if (isRinging("answer")) {
            if (!isVideoCallingSupported() && VideoProfile.isVideo(videoState)) {
                // Video calling is not supported, yet the InCallService is attempting to answer as
                // video.  We will simply answer as audio-only.
                videoState = VideoProfile.STATE_AUDIO_ONLY;
            }
            // At this point, we are asking the connection service to answer but we don't assume
            // that it will work. Instead, we wait until confirmation from the connectino service
            // that the call is in a non-STATE_RINGING state before changing the UI. See
@@ -1931,6 +1935,12 @@ public class Call implements CreateConnectionResponse {
     * @param videoState The video state for the call.
     */
    public void setVideoState(int videoState) {
        // If the phone account associated with this call does not support video calling, then we
        // will automatically set the video state to audio-only.
        if (!isVideoCallingSupported()) {
            videoState = VideoProfile.STATE_AUDIO_ONLY;
        }

        // Track which video states were applicable over the duration of the call.
        // Only track the call state when the call is active or disconnected.  This ensures we do
        // not include the video state when:
+1 −25
Original line number Diff line number Diff line
@@ -1648,8 +1648,7 @@ public class CallsManager extends Call.ListenerBase
                "new conference call");
        call.setConnectionCapabilities(parcelableConference.getConnectionCapabilities());
        call.setConnectionProperties(parcelableConference.getConnectionProperties());
        call.setVideoState(
                getCheckedVideoState(parcelableConference.getVideoState(), phoneAccount));
        call.setVideoState(parcelableConference.getVideoState());
        call.setVideoProvider(parcelableConference.getVideoProvider());
        call.setStatusHints(parcelableConference.getStatusHints());
        call.putExtras(Call.SOURCE_CONNECTION_SERVICE, parcelableConference.getExtras());
@@ -2172,27 +2171,4 @@ public class CallsManager extends Call.ListenerBase

      call.setIntentExtras(extras);
    }

    /**
     * Given a video state and phone account handle, converts the passed video state to
     * {@link VideoProfile#STATE_AUDIO_ONLY} if the phone account does not support video calling.
     *
     * Used to ensure that calls added by a connection service don't try to use video calling if
     * they have not advertised that they can.
     *
     * @param videoState The video state.
     * @param phoneAccountHandle The phone account handle.
     * @return {@link VideoProfile#STATE_AUDIO_ONLY} if the phone account does not support video,
     *      or the original videoState otherwise.
     */
    public int getCheckedVideoState(int videoState, PhoneAccountHandle phoneAccountHandle) {
        if (VideoProfile.isVideo(videoState) && phoneAccountHandle != null) {
            PhoneAccount account = mPhoneAccountRegistrar.getPhoneAccountUnchecked(
                    phoneAccountHandle);
            if (!account.hasCapabilities(PhoneAccount.CAPABILITY_VIDEO_CALLING)) {
                return VideoProfile.STATE_AUDIO_ONLY;
            }
        }
        return videoState;
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -135,6 +135,26 @@ public class VideoProviderProxy extends Connection.VideoProvider {
                    mCall.getAnalytics().addVideoEvent(
                            Analytics.RECEIVE_REMOTE_SESSION_MODIFY_REQUEST,
                            videoProfile.getVideoState());

                    if (!mCall.isVideoCallingSupported() &&
                            VideoProfile.isVideo(videoProfile.getVideoState())) {
                        // If video calling is not supported by the phone account, and we receive
                        // a request to upgrade to video, automatically reject it without informing
                        // the InCallService.

                        Log.event(mCall, Log.Events.SEND_VIDEO_RESPONSE, "video not supported");
                        VideoProfile responseProfile = new VideoProfile(
                                VideoProfile.STATE_AUDIO_ONLY);
                        try {
                            mConectionServiceVideoProvider.sendSessionModifyResponse(
                                    responseProfile);
                        } catch (RemoteException e) {
                        }

                        // Don't want to inform listeners of the request as we've just rejected it.
                        return;
                    }

                    // Inform other Telecom components of the session modification request.
                    for (Listener listener : mListeners) {
                        listener.onSessionModifyRequestReceived(mCall, videoProfile);