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

Commit 2f20a866 authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Auto-enable speakerphone when upgrading to a video call."

parents 68e008c8 e4fc5e0c
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -3195,4 +3195,18 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    public CallIdentification getCallIdentification() {
        return mCallIdentification;
    }

    /**
     * When upgrading a call to video via
     * {@link VideoProviderProxy#onSendSessionModifyRequest(VideoProfile, VideoProfile)}, if the
     * upgrade is from audio to video, potentially auto-engage the speakerphone.
     * @param newVideoState The proposed new video state for the call.
     */
    public void maybeEnableSpeakerForVideoUpgrade(@VideoProfile.VideoState int newVideoState) {
        if (mCallsManager.isSpeakerphoneAutoEnabledForVideoCalls(newVideoState)) {
            Log.i(this, "maybeEnableSpeakerForVideoCall; callId=%s, auto-enable speaker for call"
                            + " upgraded to video.");
            mCallsManager.setAudioRoute(CallAudioState.ROUTE_SPEAKER, null);
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -438,6 +438,11 @@ public class VideoProviderProxy extends Connection.VideoProvider {
            logFromInCall("sendSessionModifyRequest: from=" + fromProfile + " to=" + toProfile);
            Log.addEvent(mCall, LogUtils.Events.SEND_VIDEO_REQUEST,
                    VideoProfile.videoStateToString(toProfile.getVideoState()));
            if (!VideoProfile.isVideo(fromProfile.getVideoState())
                    && VideoProfile.isVideo(toProfile.getVideoState())) {
                // Upgrading to video; change to speaker potentially.
                mCall.maybeEnableSpeakerForVideoUpgrade(toProfile.getVideoState());
            }
            mCall.getAnalytics().addVideoEvent(
                    Analytics.SEND_LOCAL_SESSION_MODIFY_REQUEST,
                    toProfile.getVideoState());
+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.telecom.tests;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -62,6 +63,7 @@ public class VideoProviderProxyTest extends TelecomTestCase {
        doNothing().when(mIBinder).linkToDeath(any(), anyInt());
        when(mCall.getAnalytics()).thenReturn(mCallInfo);
        doNothing().when(mCallInfo).addVideoEvent(anyInt(), anyInt());
        doNothing().when(mCall).maybeEnableSpeakerForVideoUpgrade(anyInt());
        mVideoProviderProxy = new VideoProviderProxy(mLock, mVideoProvider, mCall,
                mCurrentUserProxy);
        mVideoProviderProxy.addListener(mListener);
@@ -116,4 +118,17 @@ public class VideoProviderProxyTest extends TelecomTestCase {
        verify(mListener).onSessionModifyRequestReceived(any(), capturedProfile.capture());
        assertEquals(VideoProfile.STATE_BIDIRECTIONAL, capturedProfile.getValue().getVideoState());
    }

    /**
     * Tests the case where dialer requests an upgrade to video; we should try to change to speaker.
     * @throws Exception
     */
    @SmallTest
    @Test
    public void testTryToEnableSpeakerOnVideoUpgrade() throws Exception {
        mVideoProviderProxy.onSendSessionModifyRequest(
                new VideoProfile(VideoProfile.STATE_AUDIO_ONLY),
                new VideoProfile(VideoProfile.STATE_BIDIRECTIONAL));
        verify(mCall).maybeEnableSpeakerForVideoUpgrade(eq(VideoProfile.STATE_BIDIRECTIONAL));
    }
}