Add Bundle APIs for putting/getting Binder objects.

This is really useful for certain cases, you just need
to be thoughtful and careful about what you are doing.

Change-Id: I314592480e447a6d8346f5089fade35da50b3510
diff --git a/api/current.txt b/api/current.txt
index b510704..282dc4a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15862,6 +15862,7 @@
     method public boolean containsKey(java.lang.String);
     method public int describeContents();
     method public java.lang.Object get(java.lang.String);
+    method public android.os.IBinder getBinder(java.lang.String);
     method public boolean getBoolean(java.lang.String);
     method public boolean getBoolean(java.lang.String, boolean);
     method public boolean[] getBooleanArray(java.lang.String);
@@ -15906,6 +15907,7 @@
     method public boolean isEmpty();
     method public java.util.Set<java.lang.String> keySet();
     method public void putAll(android.os.Bundle);
+    method public void putBinder(java.lang.String, android.os.IBinder);
     method public void putBoolean(java.lang.String, boolean);
     method public void putBooleanArray(java.lang.String, boolean[]);
     method public void putBundle(java.lang.String, android.os.Bundle);
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java
index 65eefcb..18a0018 100644
--- a/core/java/android/os/Bundle.java
+++ b/core/java/android/os/Bundle.java
@@ -742,6 +742,25 @@
     }
 
     /**
+     * Inserts an {@link IBinder} value into the mapping of this Bundle, replacing
+     * any existing value for the given key.  Either key or value may be null.
+     *
+     * <p class="note">You should be very careful when using this function.  In many
+     * places where Bundles are used (such as inside of Intent objects), the Bundle
+     * can live longer inside of another process than the process that had originally
+     * created it.  In that case, the IBinder you supply here will become invalid
+     * when your process goes away, and no longer usable, even if a new process is
+     * created for you later on.</p>
+     *
+     * @param key a String, or null
+     * @param value an IBinder object, or null
+     */
+    public void putBinder(String key, IBinder value) {
+        unparcel();
+        mMap.put(key, value);
+    }
+
+    /**
      * Inserts an IBinder value into the mapping of this Bundle, replacing
      * any existing value for the given key.  Either key or value may be null.
      *
@@ -749,7 +768,7 @@
      * @param value an IBinder object, or null
      *
      * @deprecated
-     * @hide
+     * @hide This is the old name of the function.
      */
     @Deprecated
     public void putIBinder(String key, IBinder value) {
@@ -1543,9 +1562,31 @@
      *
      * @param key a String, or null
      * @return an IBinder value, or null
+     */
+    public IBinder getBinder(String key) {
+        unparcel();
+        Object o = mMap.get(key);
+        if (o == null) {
+            return null;
+        }
+        try {
+            return (IBinder) o;
+        } catch (ClassCastException e) {
+            typeWarning(key, o, "IBinder", e);
+            return null;
+        }
+    }
+
+    /**
+     * Returns the value associated with the given key, or null if
+     * no mapping of the desired type exists for the given key or a null
+     * value is explicitly associated with the key.
+     *
+     * @param key a String, or null
+     * @return an IBinder value, or null
      *
      * @deprecated
-     * @hide
+     * @hide This is the old name of the function.
      */
     @Deprecated
     public IBinder getIBinder(String key) {