diff options
| -rwxr-xr-x | api/current.txt | 3 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/Call.java | 10 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/CallScreeningService.java | 34 | ||||
| -rw-r--r-- | telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl | 2 |
4 files changed, 47 insertions, 2 deletions
diff --git a/api/current.txt b/api/current.txt index 55d3f9b626cd..9bee5ecd6fd7 100755 --- a/api/current.txt +++ b/api/current.txt @@ -41143,6 +41143,7 @@ package android.telecom { method public void unregisterCallback(android.telecom.Call.Callback); field @Deprecated public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; field public static final String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS = "android.telecom.extra.LAST_EMERGENCY_CALLBACK_TIME_MILLIS"; + field public static final String EXTRA_SILENT_RINGING_REQUESTED = "android.telecom.extra.SILENT_RINGING_REQUESTED"; field public static final String EXTRA_SUGGESTED_PHONE_ACCOUNTS = "android.telecom.extra.SUGGESTED_PHONE_ACCOUNTS"; field public static final int STATE_ACTIVE = 4; // 0x4 field public static final int STATE_CONNECTING = 9; // 0x9 @@ -41291,6 +41292,7 @@ package android.telecom { public static class CallScreeningService.CallResponse { method public boolean getDisallowCall(); method public boolean getRejectCall(); + method public boolean getSilenceCall(); method public boolean getSkipCallLog(); method public boolean getSkipNotification(); } @@ -41300,6 +41302,7 @@ package android.telecom { method public android.telecom.CallScreeningService.CallResponse build(); method public android.telecom.CallScreeningService.CallResponse.Builder setDisallowCall(boolean); method public android.telecom.CallScreeningService.CallResponse.Builder setRejectCall(boolean); + method @NonNull public android.telecom.CallScreeningService.CallResponse.Builder setSilenceCall(boolean); method public android.telecom.CallScreeningService.CallResponse.Builder setSkipCallLog(boolean); method public android.telecom.CallScreeningService.CallResponse.Builder setSkipNotification(boolean); } diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 9adeea04f5df..1822cee89eaa 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -144,6 +144,16 @@ public final class Call { public static final String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS = "android.telecom.extra.LAST_EMERGENCY_CALLBACK_TIME_MILLIS"; + + /** + * Extra key used to indicate whether a {@link CallScreeningService} has requested to silence + * the ringtone for a call. If the {@link InCallService} declares + * {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} in its manifest, it should not + * play a ringtone for an incoming call with this extra key set. + */ + public static final String EXTRA_SILENT_RINGING_REQUESTED = + "android.telecom.extra.SILENT_RINGING_REQUESTED"; + /** * Call event sent from a {@link Call} via {@link #sendCallEvent(String, Bundle)} to inform * Telecom that the user has requested that the current {@link Call} should be handed over diff --git a/telecomm/java/android/telecom/CallScreeningService.java b/telecomm/java/android/telecom/CallScreeningService.java index 27a8638cdc75..8b04b0109f02 100644 --- a/telecomm/java/android/telecom/CallScreeningService.java +++ b/telecomm/java/android/telecom/CallScreeningService.java @@ -137,12 +137,14 @@ public abstract class CallScreeningService extends Service { public static class CallResponse { private final boolean mShouldDisallowCall; private final boolean mShouldRejectCall; + private final boolean mShouldSilenceCall; private final boolean mShouldSkipCallLog; private final boolean mShouldSkipNotification; private CallResponse( boolean shouldDisallowCall, boolean shouldRejectCall, + boolean shouldSilenceCall, boolean shouldSkipCallLog, boolean shouldSkipNotification) { if (!shouldDisallowCall @@ -154,6 +156,7 @@ public abstract class CallScreeningService extends Service { mShouldRejectCall = shouldRejectCall; mShouldSkipCallLog = shouldSkipCallLog; mShouldSkipNotification = shouldSkipNotification; + mShouldSilenceCall = shouldSilenceCall; } /* @@ -172,6 +175,13 @@ public abstract class CallScreeningService extends Service { } /* + * @return Whether the ringtone should be silenced for the incoming call. + */ + public boolean getSilenceCall() { + return mShouldSilenceCall; + } + + /* * @return Whether the incoming call should not be displayed in the call log. */ public boolean getSkipCallLog() { @@ -188,6 +198,7 @@ public abstract class CallScreeningService extends Service { public static class Builder { private boolean mShouldDisallowCall; private boolean mShouldRejectCall; + private boolean mShouldSilenceCall; private boolean mShouldSkipCallLog; private boolean mShouldSkipNotification; @@ -209,6 +220,21 @@ public abstract class CallScreeningService extends Service { } /** + * Sets whether ringing should be silenced for the incoming call. When set + * to {@code true}, the Telecom framework will not play a ringtone for the call. + * The call will, however, still be sent to the default dialer app if it is not blocked. + * A {@link CallScreeningService} can use this to ensure a potential nuisance call is + * still surfaced to the user, but in a less intrusive manner. + * + * Setting this to true only makes sense when the call has not been disallowed + * using {@link #setDisallowCall(boolean)}. + */ + public @NonNull Builder setSilenceCall(boolean shouldSilenceCall) { + mShouldSilenceCall = shouldSilenceCall; + return this; + } + + /** * Sets whether the incoming call should not be displayed in the call log. This property * should only be set to true if the call is disallowed. * <p> @@ -234,6 +260,7 @@ public abstract class CallScreeningService extends Service { return new CallResponse( mShouldDisallowCall, mShouldRejectCall, + mShouldSilenceCall, mShouldSkipCallLog, mShouldSkipNotification); } @@ -285,10 +312,11 @@ public abstract class CallScreeningService extends Service { public abstract void onScreenCall(@NonNull Call.Details callDetails); /** - * Responds to the given incoming call, either allowing it or disallowing it. + * Responds to the given incoming call, either allowing it, silencing it or disallowing it. * <p> * The {@link CallScreeningService} calls this method to inform the system whether the call - * should be silently blocked or not. + * should be silently blocked or not. In the event that it should not be blocked, it may + * also be requested to ring silently. * <p> * Calls to this method are ignored unless the {@link Call.Details#getCallDirection()} is * {@link Call.Details#DIRECTION_INCOMING}. @@ -310,6 +338,8 @@ public abstract class CallScreeningService extends Service { !response.getSkipCallLog(), !response.getSkipNotification(), new ComponentName(getPackageName(), getClass().getName())); + } else if (response.getSilenceCall()) { + mCallScreeningAdapter.silenceCall(callDetails.getTelecomCallId()); } else { mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId()); } diff --git a/telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl b/telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl index d255ed169c98..3ee3285793c4 100644 --- a/telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl +++ b/telecomm/java/com/android/internal/telecom/ICallScreeningAdapter.aidl @@ -28,6 +28,8 @@ import android.content.ComponentName; oneway interface ICallScreeningAdapter { void allowCall(String callId); + void silenceCall(String callId); + void disallowCall( String callId, boolean shouldReject, |