Loading src/com/android/server/telecom/Call.java +23 −15 Original line number Original line Diff line number Diff line Loading @@ -780,6 +780,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { return; return; } } updateVideoHistoryViaState(mState, newState); mState = newState; mState = newState; maybeLoadCannedSmsResponses(); maybeLoadCannedSmsResponses(); Loading @@ -792,12 +794,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { mAnalytics.setCallStartTime(mConnectTimeMillis); mAnalytics.setCallStartTime(mConnectTimeMillis); } } // Video state changes are normally tracked against history when a call is active. // When the call goes active we need to be sure we track the history in case the // state never changes during the duration of the call -- we want to ensure we // always know the state at the start of the call. mVideoStateHistory = mVideoStateHistory | mVideoState; // We're clearly not disconnected, so reset the disconnected time. // We're clearly not disconnected, so reset the disconnected time. mDisconnectTimeMillis = 0; mDisconnectTimeMillis = 0; } else if (mState == CallState.DISCONNECTED) { } else if (mState == CallState.DISCONNECTED) { Loading @@ -806,12 +802,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { setLocallyDisconnecting(false); setLocallyDisconnecting(false); fixParentAfterDisconnect(); fixParentAfterDisconnect(); } } if (mState == CallState.DISCONNECTED && (mDisconnectCause.getCode() == DisconnectCause.MISSED || mDisconnectCause.getCode() == DisconnectCause.REJECTED)) { // Ensure when an incoming call is missed that the video state history is updated. mVideoStateHistory |= mVideoState; } // Log the state transition event // Log the state transition event String event = null; String event = null; Loading Loading @@ -2487,13 +2477,14 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { videoState = VideoProfile.STATE_AUDIO_ONLY; videoState = VideoProfile.STATE_AUDIO_ONLY; } } // Track which video states were applicable over the duration of the call. // Track Video State history during the duration of the call. // Only track the call state when the call is active or disconnected. This ensures we do // Only update the history when the call is active or disconnected. This ensures we do // not include the video state when: // not include the video state history when: // - Call is incoming (but not answered). // - Call is incoming (but not answered). // - Call it outgoing (but not answered). // - Call it outgoing (but not answered). // We include the video state when disconnected to ensure that rejected calls reflect the // We include the video state when disconnected to ensure that rejected calls reflect the // appropriate video state. // appropriate video state. // For all other times we add to the video state history, see #setState. if (isActive() || getState() == CallState.DISCONNECTED) { if (isActive() || getState() == CallState.DISCONNECTED) { mVideoStateHistory = mVideoStateHistory | videoState; mVideoStateHistory = mVideoStateHistory | videoState; } } Loading Loading @@ -2740,4 +2731,21 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { l.onHandoverRequested(this, handoverToHandle, videoState, extras); l.onHandoverRequested(this, handoverToHandle, videoState, extras); } } } } /** * Sets the video history based on the state and state transitions of the call. Always add the * current video state to the video state history during a call transition except for the * transitions DIALING->ACTIVE and RINGING->ACTIVE. In these cases, clear the history. If a * call starts dialing/ringing as a VT call and gets downgraded to audio, we need to record * the history as an audio call. */ private void updateVideoHistoryViaState(int oldState, int newState) { if ((oldState == CallState.DIALING || oldState == CallState.RINGING) && newState == CallState.ACTIVE) { mVideoStateHistory = mVideoState; } mVideoStateHistory |= mVideoState; } } } tests/src/com/android/server/telecom/tests/BasicCallTests.java +0 −32 Original line number Original line Diff line number Diff line Loading @@ -870,38 +870,6 @@ public class BasicCallTests extends TelecomSystemTest { assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState()); assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState()); } } /** * Ensure that when an incoming video call is missed, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallMissedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.MISSED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an incoming video call is rejected, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallRejectedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.REJECTED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** /** * Test scenario where the user starts an outgoing video call with no selected PhoneAccount, and * Test scenario where the user starts an outgoing video call with no selected PhoneAccount, and * then subsequently selects a PhoneAccount which does not support video calling. * then subsequently selects a PhoneAccount which does not support video calling. Loading tests/src/com/android/server/telecom/tests/VideoCallTests.java +90 −0 Original line number Original line Diff line number Diff line Loading @@ -18,9 +18,12 @@ package com.android.server.telecom.tests; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.telecom.CallAudioState; import android.telecom.CallAudioState; import android.telecom.DisconnectCause; import android.telecom.VideoProfile; import android.telecom.VideoProfile; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest; import com.android.server.telecom.CallAudioModeStateMachine; import com.android.server.telecom.CallAudioModeStateMachine; Loading Loading @@ -126,6 +129,93 @@ public class VideoCallTests extends TelecomSystemTest { verifyAudioRoute(CallAudioState.ROUTE_EARPIECE); verifyAudioRoute(CallAudioState.ROUTE_EARPIECE); } } /** * Ensure that when an incoming video call is missed, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallMissedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.MISSED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an incoming video call is rejected, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallRejectedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.REJECTED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an outgoing video call is canceled, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testOutgoingVideoCallCanceledCheckVideoHistory() throws Exception { IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA, Process.myUserHandle(), VideoProfile.STATE_BIDIRECTIONAL); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.LOCAL); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an outgoing video call is rejected, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testOutgoingVideoCallRejectedCheckVideoHistory() throws Exception { IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA, Process.myUserHandle(), VideoProfile.STATE_BIDIRECTIONAL); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.REMOTE); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an outgoing video call is answered as audio only, the video state history * shows that the call was audio only. This is important for the call log. */ @LargeTest public void testOutgoingVideoCallAnsweredAsAudio() throws Exception { IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA, Process.myUserHandle(), VideoProfile.STATE_BIDIRECTIONAL); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.mConnectionById.get(ids.mConnectionId).videoState = VideoProfile.STATE_AUDIO_ONLY; mConnectionServiceFixtureA.sendSetVideoState(ids.mConnectionId); mConnectionServiceFixtureA.sendSetActive(ids.mConnectionId); assertFalse(VideoProfile.isVideo(call.getVideoStateHistory())); } /** /** * Verifies that the * Verifies that the * {@link android.telecom.InCallService#onCallAudioStateChanged(CallAudioState)} change is * {@link android.telecom.InCallService#onCallAudioStateChanged(CallAudioState)} change is Loading Loading
src/com/android/server/telecom/Call.java +23 −15 Original line number Original line Diff line number Diff line Loading @@ -780,6 +780,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { return; return; } } updateVideoHistoryViaState(mState, newState); mState = newState; mState = newState; maybeLoadCannedSmsResponses(); maybeLoadCannedSmsResponses(); Loading @@ -792,12 +794,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { mAnalytics.setCallStartTime(mConnectTimeMillis); mAnalytics.setCallStartTime(mConnectTimeMillis); } } // Video state changes are normally tracked against history when a call is active. // When the call goes active we need to be sure we track the history in case the // state never changes during the duration of the call -- we want to ensure we // always know the state at the start of the call. mVideoStateHistory = mVideoStateHistory | mVideoState; // We're clearly not disconnected, so reset the disconnected time. // We're clearly not disconnected, so reset the disconnected time. mDisconnectTimeMillis = 0; mDisconnectTimeMillis = 0; } else if (mState == CallState.DISCONNECTED) { } else if (mState == CallState.DISCONNECTED) { Loading @@ -806,12 +802,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { setLocallyDisconnecting(false); setLocallyDisconnecting(false); fixParentAfterDisconnect(); fixParentAfterDisconnect(); } } if (mState == CallState.DISCONNECTED && (mDisconnectCause.getCode() == DisconnectCause.MISSED || mDisconnectCause.getCode() == DisconnectCause.REJECTED)) { // Ensure when an incoming call is missed that the video state history is updated. mVideoStateHistory |= mVideoState; } // Log the state transition event // Log the state transition event String event = null; String event = null; Loading Loading @@ -2487,13 +2477,14 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { videoState = VideoProfile.STATE_AUDIO_ONLY; videoState = VideoProfile.STATE_AUDIO_ONLY; } } // Track which video states were applicable over the duration of the call. // Track Video State history during the duration of the call. // Only track the call state when the call is active or disconnected. This ensures we do // Only update the history when the call is active or disconnected. This ensures we do // not include the video state when: // not include the video state history when: // - Call is incoming (but not answered). // - Call is incoming (but not answered). // - Call it outgoing (but not answered). // - Call it outgoing (but not answered). // We include the video state when disconnected to ensure that rejected calls reflect the // We include the video state when disconnected to ensure that rejected calls reflect the // appropriate video state. // appropriate video state. // For all other times we add to the video state history, see #setState. if (isActive() || getState() == CallState.DISCONNECTED) { if (isActive() || getState() == CallState.DISCONNECTED) { mVideoStateHistory = mVideoStateHistory | videoState; mVideoStateHistory = mVideoStateHistory | videoState; } } Loading Loading @@ -2740,4 +2731,21 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable { l.onHandoverRequested(this, handoverToHandle, videoState, extras); l.onHandoverRequested(this, handoverToHandle, videoState, extras); } } } } /** * Sets the video history based on the state and state transitions of the call. Always add the * current video state to the video state history during a call transition except for the * transitions DIALING->ACTIVE and RINGING->ACTIVE. In these cases, clear the history. If a * call starts dialing/ringing as a VT call and gets downgraded to audio, we need to record * the history as an audio call. */ private void updateVideoHistoryViaState(int oldState, int newState) { if ((oldState == CallState.DIALING || oldState == CallState.RINGING) && newState == CallState.ACTIVE) { mVideoStateHistory = mVideoState; } mVideoStateHistory |= mVideoState; } } }
tests/src/com/android/server/telecom/tests/BasicCallTests.java +0 −32 Original line number Original line Diff line number Diff line Loading @@ -870,38 +870,6 @@ public class BasicCallTests extends TelecomSystemTest { assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState()); assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState()); } } /** * Ensure that when an incoming video call is missed, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallMissedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.MISSED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an incoming video call is rejected, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallRejectedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.REJECTED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** /** * Test scenario where the user starts an outgoing video call with no selected PhoneAccount, and * Test scenario where the user starts an outgoing video call with no selected PhoneAccount, and * then subsequently selects a PhoneAccount which does not support video calling. * then subsequently selects a PhoneAccount which does not support video calling. Loading
tests/src/com/android/server/telecom/tests/VideoCallTests.java +90 −0 Original line number Original line Diff line number Diff line Loading @@ -18,9 +18,12 @@ package com.android.server.telecom.tests; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.telecom.CallAudioState; import android.telecom.CallAudioState; import android.telecom.DisconnectCause; import android.telecom.VideoProfile; import android.telecom.VideoProfile; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest; import com.android.server.telecom.CallAudioModeStateMachine; import com.android.server.telecom.CallAudioModeStateMachine; Loading Loading @@ -126,6 +129,93 @@ public class VideoCallTests extends TelecomSystemTest { verifyAudioRoute(CallAudioState.ROUTE_EARPIECE); verifyAudioRoute(CallAudioState.ROUTE_EARPIECE); } } /** * Ensure that when an incoming video call is missed, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallMissedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.MISSED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an incoming video call is rejected, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testIncomingVideoCallRejectedCheckVideoHistory() throws Exception { IdPair ids = startIncomingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), VideoProfile.STATE_BIDIRECTIONAL, mConnectionServiceFixtureA); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.REJECTED); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an outgoing video call is canceled, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testOutgoingVideoCallCanceledCheckVideoHistory() throws Exception { IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA, Process.myUserHandle(), VideoProfile.STATE_BIDIRECTIONAL); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.LOCAL); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an outgoing video call is rejected, the video state history still includes * video calling. This is important for the call log. */ @LargeTest public void testOutgoingVideoCallRejectedCheckVideoHistory() throws Exception { IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA, Process.myUserHandle(), VideoProfile.STATE_BIDIRECTIONAL); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.sendSetDisconnected(ids.mConnectionId, DisconnectCause.REMOTE); assertTrue(VideoProfile.isVideo(call.getVideoStateHistory())); } /** * Ensure that when an outgoing video call is answered as audio only, the video state history * shows that the call was audio only. This is important for the call log. */ @LargeTest public void testOutgoingVideoCallAnsweredAsAudio() throws Exception { IdPair ids = startOutgoingPhoneCall("650-555-1212", mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA, Process.myUserHandle(), VideoProfile.STATE_BIDIRECTIONAL); com.android.server.telecom.Call call = mTelecomSystem.getCallsManager().getCalls() .iterator().next(); mConnectionServiceFixtureA.mConnectionById.get(ids.mConnectionId).videoState = VideoProfile.STATE_AUDIO_ONLY; mConnectionServiceFixtureA.sendSetVideoState(ids.mConnectionId); mConnectionServiceFixtureA.sendSetActive(ids.mConnectionId); assertFalse(VideoProfile.isVideo(call.getVideoStateHistory())); } /** /** * Verifies that the * Verifies that the * {@link android.telecom.InCallService#onCallAudioStateChanged(CallAudioState)} change is * {@link android.telecom.InCallService#onCallAudioStateChanged(CallAudioState)} change is Loading