Support indicating call direction on existing connections.

This is important for ensuring the original call direction for existing
connections added from Conference Event Packages matches the call direction
of the original calls merged into the conference.

Also moved a utility function into ConferenceParticipant from
ConferenceParticipantConnection to make it generically usable inside
Telephony.

Test: Run all unit tests.
Test: Manual testing using VoLTE conference calls with mix of MO and MT
calls; verify call logging is appropriate.
Bug: 134471046

Change-Id: Iab09397b811782ab0f876aac02070e3447d81f09
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 47587c5..0983eea 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -1793,6 +1793,11 @@
     private ConnectionService mConnectionService;
     private Bundle mExtras;
     private final Object mExtrasLock = new Object();
+    /**
+     * The direction of the connection; used where an existing connection is created and we need to
+     * communicate to Telecom whether its incoming or outgoing.
+     */
+    private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
 
     /**
      * Tracks the key set for the extras bundle provided on the last invocation of
@@ -3357,4 +3362,21 @@
             l.onConnectionEvent(this, event, extras);
         }
     }
+
+    /**
+     * @return The direction of the call.
+     * @hide
+     */
+    public final @Call.Details.CallDirection int getCallDirection() {
+        return mCallDirection;
+    }
+
+    /**
+     * Sets the direction of this connection.
+     * @param callDirection The direction of this connection.
+     * @hide
+     */
+    public void setCallDirection(@Call.Details.CallDirection int callDirection) {
+        mCallDirection = callDirection;
+    }
 }