Add extras to Connections/Calls. (1/3)

Two major changes:
1) Add the notion of extras to a Connection.  These extras will be
parceled through to InCallService as Call.getExtras()
2) The previously existing Call.getExtras() has been renamed to
getIntentExtras(). This name better describes the fact that these
particular extras are from the original CALL or INCOMING_CALL intents.

Change-Id: I08c1baf4f08d54757f98012f0c08b423a707c53d
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index fba4e6a..f9e48b6 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -20,8 +20,10 @@
 import com.android.internal.telecom.IVideoCallback;
 import com.android.internal.telecom.IVideoProvider;
 
+import android.annotation.Nullable;
 import android.annotation.SystemApi;
 import android.net.Uri;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
@@ -334,6 +336,7 @@
                 List<ConferenceParticipant> participants) {}
         public void onConferenceStarted() {}
         public void onConferenceMergeFailed(Connection c) {}
+        public void onExtrasChanged(Connection c, Bundle extras) {}
     }
 
     public static abstract class VideoProvider {
@@ -832,6 +835,7 @@
     private DisconnectCause mDisconnectCause;
     private Conference mConference;
     private ConnectionService mConnectionService;
+    private Bundle mExtras;
 
     /**
      * Create a new Connection.
@@ -942,6 +946,13 @@
     }
 
     /**
+     * @return The extras associated with this connection.
+     */
+    public final Bundle getExtras() {
+        return mExtras;
+    }
+
+    /**
      * Assign a listener to be notified of state changes.
      *
      * @param l A listener.
@@ -1371,6 +1382,21 @@
     }
 
     /**
+     * Set some extras that can be associated with this {@code Connection}. No assumptions should
+     * be made as to how an In-Call UI or service will handle these extras.
+     * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
+     *
+     * @param extras The extras associated with this {@code Connection}.
+     */
+    public final void setExtras(@Nullable Bundle extras) {
+        checkImmutable();
+        mExtras = extras;
+        for (Listener l : mListeners) {
+            l.onExtrasChanged(this, extras);
+        }
+    }
+
+    /**
      * Notifies this Connection that the {@link #getAudioState()} property has a new value.
      *
      * @param state The new connection audio state.