diff options
author | Steven Laver <lavers@google.com> | 2019-11-05 13:42:59 -0800 |
---|---|---|
committer | Steven Laver <lavers@google.com> | 2019-11-09 01:16:30 +0000 |
commit | 7c6cc72e18cc1df5205fd2bc47664e6cc2534ad2 (patch) | |
tree | fc34e4ad6037cf231cccc3b56ccd13e82917520a /telecomm/java/android/telecom/Call.java | |
parent | 8f4f93bf3ba75d8e83cb0a8618cb80f226ada5ac (diff) | |
parent | da5e1bd24a9a0ca24e7e49fad9e604409e573376 (diff) |
Merge RP1A.191024.001
Change-Id: I5cda3bba276e99d948b752be87d4599e9f882e0f
Diffstat (limited to 'telecomm/java/android/telecom/Call.java')
-rw-r--r-- | telecomm/java/android/telecom/Call.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 9a5ba8bd7c02..f1fe5b16b24f 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -19,6 +19,7 @@ package android.telecom; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.net.Uri; import android.os.Build; @@ -119,6 +120,20 @@ public final class Call { public static final int STATE_PULLING_CALL = 11; /** + * The state of a call that is active with the network, but the audio from the call is + * being intercepted by an app on the local device. Telecom does not hold audio focus in this + * state, and the call will be invisible to the user except for a persistent notification. + */ + public static final int STATE_AUDIO_PROCESSING = 12; + + /** + * The state of a call that is being presented to the user after being in + * {@link #STATE_AUDIO_PROCESSING}. The call is still active with the network in this case, and + * Telecom will hold audio focus and play a ringtone if appropriate. + */ + public static final int STATE_SIMULATED_RINGING = 13; + + /** * 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. @@ -732,6 +747,7 @@ public final class Call { } /** {@hide} */ + @TestApi public String getTelecomCallId() { return mTelecomCallId; } @@ -1498,6 +1514,49 @@ public final class Call { } /** + * Instructs Telecom to put the call into the background audio processing state. + * + * This method can be called either when the call is in {@link #STATE_RINGING} or + * {@link #STATE_ACTIVE}. After Telecom acknowledges the request by setting the call's state to + * {@link #STATE_AUDIO_PROCESSING}, your app may setup the audio paths with the audio stack in + * order to capture and play audio on the call stream. + * + * This method can only be called by the default dialer app. + * @hide + */ + @SystemApi + @TestApi + //@RequiresPermission(android.Manifest.permission.BACKGROUND_CALL_AUDIO) + public void enterBackgroundAudioProcessing() { + if (mState != STATE_ACTIVE && mState != STATE_RINGING) { + throw new IllegalStateException("Call must be active or ringing"); + } + mInCallAdapter.enterBackgroundAudioProcessing(mTelecomCallId); + } + + /** + * Instructs Telecom to come out of the background audio processing state requested by + * {@link #enterBackgroundAudioProcessing()} or from the call screening service. + * + * This method can only be called when the call is in {@link #STATE_AUDIO_PROCESSING}. + * + * @param shouldRing If true, Telecom will put the call into the + * {@link #STATE_SIMULATED_RINGING} state and notify other apps that there is + * a ringing call. Otherwise, the call will go into {@link #STATE_ACTIVE} + * immediately. + * @hide + */ + @SystemApi + @TestApi + //@RequiresPermission(android.Manifest.permission.BACKGROUND_CALL_AUDIO) + public void exitBackgroundAudioProcessing(boolean shouldRing) { + if (mState != STATE_AUDIO_PROCESSING) { + throw new IllegalStateException("Call must in the audio processing state"); + } + mInCallAdapter.exitBackgroundAudioProcessing(mTelecomCallId, shouldRing); + } + + /** * Instructs this {@code Call} to play a dual-tone multi-frequency signaling (DTMF) tone. * * Any other currently playing DTMF tone in the specified call is immediately stopped. @@ -2009,6 +2068,10 @@ public final class Call { return "DISCONNECTING"; case STATE_SELECT_PHONE_ACCOUNT: return "SELECT_PHONE_ACCOUNT"; + case STATE_SIMULATED_RINGING: + return "SIMULATED_RINGING"; + case STATE_AUDIO_PROCESSING: + return "AUDIO_PROCESSING"; default: Log.w(Call.class, "Unknown state %d", state); return "UNKNOWN"; @@ -2098,6 +2161,9 @@ public final class Call { } int state = parcelableCall.getState(); + if (mTargetSdkVersion < Phone.SDK_VERSION_R && state == Call.STATE_SIMULATED_RINGING) { + state = Call.STATE_RINGING; + } boolean stateChanged = mState != state; if (stateChanged) { mState = state; |