diff options
Diffstat (limited to 'telecomm/java/android/telecom/CallScreeningService.java')
-rw-r--r-- | telecomm/java/android/telecom/CallScreeningService.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/telecomm/java/android/telecom/CallScreeningService.java b/telecomm/java/android/telecom/CallScreeningService.java index e4f8d118e7df..ef1c790dcc83 100644 --- a/telecomm/java/android/telecom/CallScreeningService.java +++ b/telecomm/java/android/telecom/CallScreeningService.java @@ -18,6 +18,8 @@ package android.telecom; import android.annotation.NonNull; import android.annotation.SdkConstant; +import android.annotation.SystemApi; +import android.annotation.TestApi; import android.app.Service; import android.content.ComponentName; import android.content.Intent; @@ -136,23 +138,30 @@ public abstract class CallScreeningService extends Service { private final boolean mShouldSilenceCall; private final boolean mShouldSkipCallLog; private final boolean mShouldSkipNotification; + private final boolean mShouldScreenCallFurther; private CallResponse( boolean shouldDisallowCall, boolean shouldRejectCall, boolean shouldSilenceCall, boolean shouldSkipCallLog, - boolean shouldSkipNotification) { + boolean shouldSkipNotification, + boolean shouldScreenCallFurther) { if (!shouldDisallowCall && (shouldRejectCall || shouldSkipCallLog || shouldSkipNotification)) { throw new IllegalStateException("Invalid response state for allowed call."); } + if (shouldDisallowCall && shouldScreenCallFurther) { + throw new IllegalStateException("Invalid response state for allowed call."); + } + mShouldDisallowCall = shouldDisallowCall; mShouldRejectCall = shouldRejectCall; mShouldSkipCallLog = shouldSkipCallLog; mShouldSkipNotification = shouldSkipNotification; mShouldSilenceCall = shouldSilenceCall; + mShouldScreenCallFurther = shouldScreenCallFurther; } /* @@ -191,12 +200,22 @@ public abstract class CallScreeningService extends Service { return mShouldSkipNotification; } + /** + * @return Whether we should enter the {@link Call#STATE_AUDIO_PROCESSING} state to allow + * for further screening of the call. + * @hide + */ + public boolean getShouldScreenCallFurther() { + return mShouldScreenCallFurther; + } + public static class Builder { private boolean mShouldDisallowCall; private boolean mShouldRejectCall; private boolean mShouldSilenceCall; private boolean mShouldSkipCallLog; private boolean mShouldSkipNotification; + private boolean mShouldScreenCallFurther; /** * Sets whether the incoming call should be blocked. @@ -252,13 +271,32 @@ public abstract class CallScreeningService extends Service { return this; } + /** + * Sets whether to request background audio processing so that the in-call service can + * screen the call further. If set to {@code true}, {@link #setDisallowCall} should be + * called with {@code false}, and all other parameters in this builder will be ignored. + * + * This request will only be honored if the {@link CallScreeningService} shares the same + * uid as the default dialer app. Otherwise, the call will go through as usual. + * + * @param shouldScreenCallFurther Whether to request further call screening. + * @hide + */ + @SystemApi + @TestApi + public Builder setShouldScreenCallFurther(boolean shouldScreenCallFurther) { + mShouldScreenCallFurther = shouldScreenCallFurther; + return this; + } + public CallResponse build() { return new CallResponse( mShouldDisallowCall, mShouldRejectCall, mShouldSilenceCall, mShouldSkipCallLog, - mShouldSkipNotification); + mShouldSkipNotification, + mShouldScreenCallFurther); } } } @@ -336,6 +374,8 @@ public abstract class CallScreeningService extends Service { new ComponentName(getPackageName(), getClass().getName())); } else if (response.getSilenceCall()) { mCallScreeningAdapter.silenceCall(callDetails.getTelecomCallId()); + } else if (response.getShouldScreenCallFurther()) { + mCallScreeningAdapter.screenCallFurther(callDetails.getTelecomCallId()); } else { mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId()); } |