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:
@ -813,6 +813,7 @@ public final class Call {
|
||||
private String mRemainingPostDialSequence;
|
||||
private VideoCallImpl mVideoCallImpl;
|
||||
private Details mDetails;
|
||||
private Bundle mExtras;
|
||||
|
||||
/**
|
||||
* Obtains the post-dial sequence remaining to be emitted by this {@code Call}, if any.
|
||||
@ -987,6 +988,89 @@ public final class Call {
|
||||
mInCallAdapter.sendCallEvent(mTelecomCallId, event, extras);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds some extras to this {@link Call}. Existing keys are replaced and new ones are
|
||||
* added.
|
||||
* <p>
|
||||
* No assumptions should be made as to how an In-Call UI or service will handle these
|
||||
* extras. Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
|
||||
*
|
||||
* @param extras The extras to add.
|
||||
*/
|
||||
public final void putExtras(Bundle extras) {
|
||||
if (extras == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mExtras == null) {
|
||||
mExtras = new Bundle();
|
||||
}
|
||||
mExtras.putAll(extras);
|
||||
mInCallAdapter.putExtras(mTelecomCallId, extras);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a boolean extra to this {@link Call}.
|
||||
*
|
||||
* @param key The extra key.
|
||||
* @param value The value.
|
||||
* @hide
|
||||
*/
|
||||
public final void putExtra(String key, boolean value) {
|
||||
if (mExtras == null) {
|
||||
mExtras = new Bundle();
|
||||
}
|
||||
mExtras.putBoolean(key, value);
|
||||
mInCallAdapter.putExtra(mTelecomCallId, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an integer extra to this {@code Connection}.
|
||||
*
|
||||
* @param key The extra key.
|
||||
* @param value The value.
|
||||
* @hide
|
||||
*/
|
||||
public final void putExtra(String key, int value) {
|
||||
if (mExtras == null) {
|
||||
mExtras = new Bundle();
|
||||
}
|
||||
mExtras.putInt(key, value);
|
||||
mInCallAdapter.putExtra(mTelecomCallId, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a string extra to this {@code Connection}.
|
||||
*
|
||||
* @param key The extra key.
|
||||
* @param value The value.
|
||||
* @hide
|
||||
*/
|
||||
public final void putExtra(String key, String value) {
|
||||
if (mExtras == null) {
|
||||
mExtras = new Bundle();
|
||||
}
|
||||
mExtras.putString(key, value);
|
||||
mInCallAdapter.putExtra(mTelecomCallId, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes extras from this {@code Connection}.
|
||||
*
|
||||
* @param keys The keys of the extras to remove.
|
||||
*/
|
||||
public final void removeExtras(List<String> keys) {
|
||||
if (mExtras != null) {
|
||||
for (String key : keys) {
|
||||
mExtras.remove(key);
|
||||
}
|
||||
if (mExtras.size() == 0) {
|
||||
mExtras = null;
|
||||
}
|
||||
}
|
||||
mInCallAdapter.removeExtras(mTelecomCallId, keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the parent of this {@code Call} in a conference, if any.
|
||||
*
|
||||
|
Reference in New Issue
Block a user