Add additional APIs in Call for Bluetooth

Add additional APIs in android.telecom.Call for consumption by Bluetooth
as they move to using an InCallService.

Also refactor ParcelableCall to use a builder pattern

Fixes: 147445725
Fixes: 147445603
Test: atest CallDetailsTest ConferenceTest
Change-Id: I12241b4ceadaa840f6e577bcfa8521375aedcb6a
This commit is contained in:
Hall Liu
2020-01-09 15:22:44 -08:00
parent 38fa60b511
commit ef98bf8300
3 changed files with 361 additions and 31 deletions

View File

@@ -568,6 +568,7 @@ public final class Call {
private final Bundle mExtras;
private final Bundle mIntentExtras;
private final long mCreationTimeMillis;
private final String mContactDisplayName;
private final @CallDirection int mCallDirection;
private final @Connection.VerificationStatus int mCallerNumberVerificationStatus;
@@ -871,6 +872,17 @@ public final class Call {
return mCreationTimeMillis;
}
/**
* Returns the name of the caller on the remote end, as derived from a
* {@link android.provider.ContactsContract} lookup of the call's handle.
* @return The name of the caller, or {@code null} if the lookup is not yet complete, if
* there's no contacts entry for the caller, or if the {@link InCallService} does
* not hold the {@link android.Manifest.permission#READ_CONTACTS} permission.
*/
public @Nullable String getContactDisplayName() {
return mContactDisplayName;
}
/**
* Indicates whether the call is an incoming or outgoing call.
* @return The call's direction.
@@ -909,6 +921,7 @@ public final class Call {
areBundlesEqual(mExtras, d.mExtras) &&
areBundlesEqual(mIntentExtras, d.mIntentExtras) &&
Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis) &&
Objects.equals(mContactDisplayName, d.mContactDisplayName) &&
Objects.equals(mCallDirection, d.mCallDirection) &&
Objects.equals(mCallerNumberVerificationStatus,
d.mCallerNumberVerificationStatus);
@@ -933,6 +946,7 @@ public final class Call {
mExtras,
mIntentExtras,
mCreationTimeMillis,
mContactDisplayName,
mCallDirection,
mCallerNumberVerificationStatus);
}
@@ -955,6 +969,7 @@ public final class Call {
Bundle extras,
Bundle intentExtras,
long creationTimeMillis,
String contactDisplayName,
int callDirection,
int callerNumberVerificationStatus) {
mTelecomCallId = telecomCallId;
@@ -973,6 +988,7 @@ public final class Call {
mExtras = extras;
mIntentExtras = intentExtras;
mCreationTimeMillis = creationTimeMillis;
mContactDisplayName = contactDisplayName;
mCallDirection = callDirection;
mCallerNumberVerificationStatus = callerNumberVerificationStatus;
}
@@ -996,6 +1012,7 @@ public final class Call {
parcelableCall.getExtras(),
parcelableCall.getIntentExtras(),
parcelableCall.getCreationTimeMillis(),
parcelableCall.getContactDisplayName(),
parcelableCall.getCallDirection(),
parcelableCall.getCallerNumberVerificationStatus());
}
@@ -1445,6 +1462,7 @@ public final class Call {
private boolean mChildrenCached;
private String mParentId = null;
private String mActiveGenericConferenceChild = null;
private int mState;
private List<String> mCannedTextResponses = null;
private String mCallingPackage;
@@ -1942,6 +1960,20 @@ public final class Call {
return mState;
}
/**
* Returns the child {@link Call} in a generic conference that is currently active.
* For calls that are not generic conferences, or when the generic conference has more than
* 2 children, returns {@code null}.
* @see Details#PROPERTY_GENERIC_CONFERENCE
* @return The active child call.
*/
public @Nullable Call getGenericConferenceActiveChildCall() {
if (mActiveGenericConferenceChild != null) {
return mPhone.internalGetCallByTelecomId(mActiveGenericConferenceChild);
}
return null;
}
/**
* Obtains a list of canned, pre-configured message responses to present to the user as
* ways of rejecting this {@code Call} using via a text message.
@@ -2190,6 +2222,13 @@ public final class Call {
mChildrenCached = false;
}
String activeChildCallId = parcelableCall.getActiveChildCallId();
boolean activeChildChanged = !Objects.equals(activeChildCallId,
mActiveGenericConferenceChild);
if (activeChildChanged) {
mActiveGenericConferenceChild = activeChildCallId;
}
List<String> conferenceableCallIds = parcelableCall.getConferenceableCallIds();
List<Call> conferenceableCalls = new ArrayList<Call>(conferenceableCallIds.size());
for (String otherId : conferenceableCallIds) {
@@ -2249,7 +2288,7 @@ public final class Call {
if (parentChanged) {
fireParentChanged(getParent());
}
if (childrenChanged) {
if (childrenChanged || activeChildChanged) {
fireChildrenChanged(getChildren());
}
if (isRttChanged) {