diff options
author | Tyler Gunn <tgunn@google.com> | 2016-03-23 16:06:34 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2016-03-23 16:06:34 -0700 |
commit | dee56a8a79f9daa1e597f5d4f399d3a5feedcac4 (patch) | |
tree | 1bdde5cc7cd47822590d5f6ceb515145c6d390aa /telecomm/java/android/telecom/RemoteConnection.java | |
parent | fbc98e1c30e9ef6827f0dcd8024b0fd2de28cf33 (diff) |
Expand call/connection extras API.
Currently, connection extras are propagated up to Telecom as an
entire bundle. This is not ideal, as any time a change is made to
the extras, the bundle needs to be fetched, changed, and then re-set on
the connection, where it is parceled to Telecom as a whole.
Using how extras on an Intent as inspiration, this CL adds separate
putExtras, putExtra, and removeExtra methods to allow manipulation of
the extras bundle without operating on it in its entirety.
This Cl also adds support for Calls modifying the extras bundle, with
changes propagated back down to ConnectionServices.
Bug: 27458894
Change-Id: I152340a3bca2dc03f170b06b172a6823410fb961
Diffstat (limited to 'telecomm/java/android/telecom/RemoteConnection.java')
-rw-r--r-- | telecomm/java/android/telecom/RemoteConnection.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java index 5b602eb49dca..7df6678bd5d3 100644 --- a/telecomm/java/android/telecom/RemoteConnection.java +++ b/telecomm/java/android/telecom/RemoteConnection.java @@ -1302,15 +1302,35 @@ public final class RemoteConnection { } /** @hide */ - void setExtras(final Bundle extras) { - mExtras = extras; + void putExtras(final Bundle extras) { + if (mExtras == null) { + mExtras = new Bundle(); + } + mExtras.putAll(extras); + + notifyExtrasChanged(); + } + + /** @hide */ + void removeExtras(List<String> keys) { + if (mExtras == null || keys == null || keys.isEmpty()) { + return; + } + for (String key : keys) { + mExtras.remove(key); + } + + notifyExtrasChanged(); + } + + private void notifyExtrasChanged() { for (CallbackRecord record : mCallbackRecords) { final RemoteConnection connection = this; final Callback callback = record.getCallback(); record.getHandler().post(new Runnable() { @Override public void run() { - callback.onExtrasChanged(connection, extras); + callback.onExtrasChanged(connection, mExtras); } }); } |