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

Commit 47e43a8c authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Catch exceptions when comparing bundles." into main

parents d7a5466d f0d6e1c5
Loading
Loading
Loading
Loading
+35 −25
Original line number Diff line number Diff line
@@ -2912,7 +2912,7 @@ public final class Call {
        if (bundle.size() != newBundle.size()) {
            return false;
        }

        try {
            for (String key : bundle.keySet()) {
                if (key != null) {
                    if (!newBundle.containsKey(key)) {
@@ -2937,14 +2937,24 @@ public final class Call {
                        }
                    } catch (BadParcelableException e) {
                        return false;
                } catch (ClassCastException e) {
                    Log.e(LOG_TAG, e, "areBundlesEqual: failure comparing bundle key %s", key);
                    // until we know what is causing this, we should rethrow -- this is still not
                    // expected.
                    throw e;
                    }
                }
            }
        } catch (ClassCastException | ArrayIndexOutOfBoundsException e) {
            // Unfortunately this may get raised when accessing the bundle's keyset, so we cannot
            // determine WHY a class cast exception is happening.  We had tried in the past to do
            // this down in the for loop so we could figure out which key is causing an issue.
            // Bundles are not thread safe, so the most likely issue here is that the InCallService
            // implementation is accessing the Bundle WHILE an incoming Telecom update comes in to
            // potentially replace the Bundle.  We call "areBundlesEqual" to see if the newly
            // unparceled Call.Details is the same as what is already in the current Call instance.
            // If those two operations overleave, I can see the potential for concurrent
            // modification and edit of the Bundle.  So we'll just catch here and assume the Bundles
            // are not the same.  This means a Call.CallBack may fire the onCallDetails changed
            // callback when the Bundle didn't actually change.
            Log.e(LOG_TAG, e, "areBundlesEqual: failed!");
            return false;
        }
        return true;
    }
}