Merge "Include Video history in Rejected calls" into oc-dr1-dev
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 41832da..ad9ac35 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -807,7 +807,8 @@
                 fixParentAfterDisconnect();
             }
             if (mState == CallState.DISCONNECTED &&
-                    mDisconnectCause.getCode() == DisconnectCause.MISSED) {
+                    (mDisconnectCause.getCode() == DisconnectCause.MISSED ||
+                            mDisconnectCause.getCode() == DisconnectCause.REJECTED)) {
                 // Ensure when an incoming call is missed that the video state history is updated.
                 mVideoStateHistory |= mVideoState;
             }
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index ce774a7..749f3c6 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -871,6 +871,38 @@
     }
 
     /**
+     * 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
      * then subsequently selects a PhoneAccount which does not support video calling.
      * @throws Exception