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

Commit 51c6581b authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Clone extras Bundle when operating on it in onExtrasChanged

Currently, we do not make a copy of the extras Bundle when calling
Connection.setConnectionExtras. In rare cases, when multiple
setConnectionExtras events come in at the same time, they are posted
onto a concurrent Handler and the extras Bundle is cleared while being
copied in TelephonyConnection.updateExtras. This causes an
ArrayOutOfBoundsException and causes the Phone process to crash.

We now create a copy of the Bundle when we post it onto the concurrent
Handler to ensure that there is no simultaneous copy/clear operations
happening on the same extras Bundle.

Bug: 28957661
Change-Id: Icc8200b9a73c261acc6f2b94ace6284437e32e6e
parent 4ac3b86a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -751,12 +751,14 @@ public abstract class Connection {

    /**
     * Notifies listeners that connection extras has changed.
     * @param extras New connection extras.
     * @param extras New connection extras. This Bundle will be cloned to ensure that any concurrent
     * modifications to the extras Bundle do not affect Bundle operations in the onExtrasChanged
     * listeners.
     */
    public void setConnectionExtras(Bundle extras) {
        mExtras = extras;
        for (Listener l : mListeners) {
            l.onExtrasChanged(extras);
            l.onExtrasChanged(new Bundle(extras));
        }
    }