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
This commit is contained in:
Tyler Gunn
2016-03-23 16:06:34 -07:00
parent fbc98e1c30
commit dee56a8a79
16 changed files with 743 additions and 46 deletions

View File

@@ -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);
}
});
}