Loading src/com/android/server/telecom/Call.java +14 −0 Original line number Diff line number Diff line Loading @@ -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); } } } src/com/android/server/telecom/VideoProviderProxy.java +5 −0 Original line number Diff line number Diff line Loading @@ -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()); Loading tests/src/com/android/server/telecom/tests/VideoProviderProxyTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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)); } } Loading
src/com/android/server/telecom/Call.java +14 −0 Original line number Diff line number Diff line Loading @@ -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); } } }
src/com/android/server/telecom/VideoProviderProxy.java +5 −0 Original line number Diff line number Diff line Loading @@ -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()); Loading
tests/src/com/android/server/telecom/tests/VideoProviderProxyTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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)); } }