Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cbdddbd authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

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
parent f4b36ad1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -15862,6 +15862,7 @@ package android.os {
    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 @@ package android.os {
    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);
+43 −2
Original line number Diff line number Diff line
@@ -741,6 +741,25 @@ public final class Bundle implements Parcelable, Cloneable {
        mMap.put(key, value);
    }

    /**
     * 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 @@ public final class Bundle implements Parcelable, Cloneable {
     * @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) {
@@ -1536,6 +1555,28 @@ public final class Bundle implements Parcelable, Cloneable {
        }
    }

    /**
     * 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
     */
    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
@@ -1545,7 +1586,7 @@ public final class Bundle implements Parcelable, Cloneable {
     * @return an IBinder value, or null
     *
     * @deprecated
     * @hide
     * @hide This is the old name of the function.
     */
    @Deprecated
    public IBinder getIBinder(String key) {