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

Commit 250985f5 authored by Christopher Tate's avatar Christopher Tate
Browse files

Handle interaction of Bundle.hasFileDescriptors() with removal

Removing entries from a Bundle may change its has-FDs state, so now
induce a recheck after removals.  In support of that, make the
recheck set the known state in all cases, not just in the has-FDs
case; and note that filterValues() inherently produces a result that
is known to have no FDs.

Bug 26676151

Change-Id: Ida07b77ad2046aeafb98e0b164cd571ce45d064f
parent 1f44c75e
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -207,6 +207,18 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
        mFlags = FLAG_HAS_FDS_KNOWN | FLAG_ALLOW_FDS;
    }

    /**
     * Removes any entry with the given key from the mapping of this Bundle.
     *
     * @param key a String key
     */
    public void remove(String key) {
        super.remove(key);
        if ((mFlags & FLAG_HAS_FDS) != 0) {
            mFlags &= ~FLAG_HAS_FDS_KNOWN;
        }
    }

    /**
     * Inserts all mappings from the given Bundle into this Bundle.
     *
@@ -288,6 +300,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {

            if (fdFound) {
                mFlags |= FLAG_HAS_FDS;
            } else {
                mFlags &= ~FLAG_HAS_FDS;
            }
            mFlags |= FLAG_HAS_FDS_KNOWN;
        }
@@ -315,6 +329,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
                mMap.removeAt(i);
            }
        }
        mFlags |= FLAG_HAS_FDS_KNOWN;
        mFlags &= ~FLAG_HAS_FDS;
    }

    /**