summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tyler Gunn <tgunn@google.com> 2021-03-18 16:47:14 -0700
committer Tyler Gunn <tgunn@google.com> 2021-03-18 16:47:14 -0700
commit1e406ca2359897be977f45ed992220f52c6720de (patch)
tree6a308512c22d90e262c2353b3eb0b994787e7f6c
parent6989c4d019ea2a157bcd4f4055678bb88bd70239 (diff)
Move Call state into Call.Details
The Telecom Call object is primarily a control object which allows control of a call and receipt of events related to a call. The actual properties and data pertaining to a call all exists in Call.Details... except for the call state (RINGING,ACTIVE, HOLD, etc). This CL moves the call state to the Call.Details class to remove this one dangling property of the base Call class. Test: Run Telecom CTS test suite. Bug: 163085177 Change-Id: I59413d3e14d03b48263a5cb351fe4e9a553b578e
-rw-r--r--core/api/current.txt3
-rwxr-xr-xtelecomm/java/android/telecom/Call.java70
-rw-r--r--telecomm/java/android/telecom/ParcelableCall.java2
3 files changed, 69 insertions, 6 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 2b5196b3b5f7..6ac38e5f21b1 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -39093,7 +39093,7 @@ package android.telecom {
method public android.telecom.Call getParent();
method public String getRemainingPostDialSequence();
method @Nullable public android.telecom.Call.RttCall getRttCall();
- method public int getState();
+ method @Deprecated public int getState();
method public android.telecom.InCallService.VideoCall getVideoCall();
method public void handoverTo(android.telecom.PhoneAccountHandle, int, android.os.Bundle);
method public void hold();
@@ -39188,6 +39188,7 @@ package android.telecom {
method public android.net.Uri getHandle();
method public int getHandlePresentation();
method public android.os.Bundle getIntentExtras();
+ method public final int getState();
method public android.telecom.StatusHints getStatusHints();
method public int getVideoState();
method public static boolean hasProperty(int, int);
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index 2a5ddfd891b1..4e64838d99ce 100755
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -138,6 +138,27 @@ public final class Call {
public static final int STATE_SIMULATED_RINGING = 13;
/**
+ * @hide
+ */
+ @IntDef(prefix = { "STATE_" },
+ value = {
+ STATE_NEW,
+ STATE_DIALING,
+ STATE_RINGING,
+ STATE_HOLDING,
+ STATE_ACTIVE,
+ STATE_DISCONNECTED,
+ STATE_SELECT_PHONE_ACCOUNT,
+ STATE_CONNECTING,
+ STATE_DISCONNECTING,
+ STATE_PULLING_CALL,
+ STATE_AUDIO_PROCESSING,
+ STATE_SIMULATED_RINGING
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface CallState {};
+
+ /**
* The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call
* extras. Used to pass the phone accounts to display on the front end to the user in order to
* select phone accounts to (for example) place a call.
@@ -674,6 +695,7 @@ public final class Call {
// Next PROPERTY value: 0x00004000
//******************************************************************************************
+ private final @CallState int mState;
private final String mTelecomCallId;
private final Uri mHandle;
private final int mHandlePresentation;
@@ -868,6 +890,13 @@ public final class Call {
return builder.toString();
}
+ /**
+ * @return the state of the {@link Call} represented by this {@link Call.Details}.
+ */
+ public final @CallState int getState() {
+ return mState;
+ }
+
/** {@hide} */
@TestApi
public String getTelecomCallId() {
@@ -1069,6 +1098,7 @@ public final class Call {
if (o instanceof Details) {
Details d = (Details) o;
return
+ Objects.equals(mState, d.mState) &&
Objects.equals(mHandle, d.mHandle) &&
Objects.equals(mHandlePresentation, d.mHandlePresentation) &&
Objects.equals(mCallerDisplayName, d.mCallerDisplayName) &&
@@ -1095,7 +1125,8 @@ public final class Call {
@Override
public int hashCode() {
- return Objects.hash(mHandle,
+ return Objects.hash(mState,
+ mHandle,
mHandlePresentation,
mCallerDisplayName,
mCallerDisplayNamePresentation,
@@ -1117,6 +1148,7 @@ public final class Call {
/** {@hide} */
public Details(
+ @CallState int state,
String telecomCallId,
Uri handle,
int handlePresentation,
@@ -1136,6 +1168,7 @@ public final class Call {
String contactDisplayName,
int callDirection,
int callerNumberVerificationStatus) {
+ mState = state;
mTelecomCallId = telecomCallId;
mHandle = handle;
mHandlePresentation = handlePresentation;
@@ -1160,6 +1193,7 @@ public final class Call {
/** {@hide} */
public static Details createFromParcelableCall(ParcelableCall parcelableCall) {
return new Details(
+ parcelableCall.getState(),
parcelableCall.getId(),
parcelableCall.getHandle(),
parcelableCall.getHandlePresentation(),
@@ -1186,6 +1220,8 @@ public final class Call {
StringBuilder sb = new StringBuilder();
sb.append("[id: ");
sb.append(mTelecomCallId);
+ sb.append(", state: ");
+ sb.append(Call.stateToString(mState));
sb.append(", pa: ");
sb.append(mAccountHandle);
sb.append(", hdl: ");
@@ -1302,7 +1338,7 @@ public final class Call {
* @param call The {@code Call} invoking this method.
* @param state The new state of the {@code Call}.
*/
- public void onStateChanged(Call call, int state) {}
+ public void onStateChanged(Call call, @CallState int state) {}
/**
* Invoked when the parent of this {@code Call} has changed. See {@link #getParent()}.
@@ -2171,9 +2207,11 @@ public final class Call {
/**
* Obtains the state of this {@code Call}.
*
- * @return A state value, chosen from the {@code STATE_*} constants.
+ * @return The call state.
+ * @deprecated The call state is available via {@link Call.Details#getState()}.
*/
- public int getState() {
+ @Deprecated
+ public @CallState int getState() {
return mState;
}
@@ -2551,6 +2589,30 @@ public final class Call {
final void internalSetDisconnected() {
if (mState != Call.STATE_DISCONNECTED) {
mState = Call.STATE_DISCONNECTED;
+ if (mDetails != null) {
+ mDetails = new Details(mState,
+ mDetails.getTelecomCallId(),
+ mDetails.getHandle(),
+ mDetails.getHandlePresentation(),
+ mDetails.getCallerDisplayName(),
+ mDetails.getCallerDisplayNamePresentation(),
+ mDetails.getAccountHandle(),
+ mDetails.getCallCapabilities(),
+ mDetails.getCallProperties(),
+ mDetails.getDisconnectCause(),
+ mDetails.getConnectTimeMillis(),
+ mDetails.getGatewayInfo(),
+ mDetails.getVideoState(),
+ mDetails.getStatusHints(),
+ mDetails.getExtras(),
+ mDetails.getIntentExtras(),
+ mDetails.getCreationTimeMillis(),
+ mDetails.getContactDisplayName(),
+ mDetails.getCallDirection(),
+ mDetails.getCallerNumberVerificationStatus()
+ );
+ fireDetailsChanged(mDetails);
+ }
fireStateChanged(mState);
fireCallDestroyed();
}
diff --git a/telecomm/java/android/telecom/ParcelableCall.java b/telecomm/java/android/telecom/ParcelableCall.java
index 182dc8bb8325..320308c9e926 100644
--- a/telecomm/java/android/telecom/ParcelableCall.java
+++ b/telecomm/java/android/telecom/ParcelableCall.java
@@ -399,7 +399,7 @@ public final class ParcelableCall implements Parcelable {
}
/** The current state of the call. */
- public int getState() {
+ public @Call.CallState int getState() {
return mState;
}