Add silence support to CallScreeningService/Call API
Test: CTS Test: Unit Tests Test: Manual Bug: 126590377 Bug: 122671585 Change-Id: I4e7c67784198678eef1926759ec1d8afb98438f4
This commit is contained in:
@@ -43214,6 +43214,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
|
||||
@@ -43401,6 +43402,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();
|
||||
}
|
||||
@@ -43410,6 +43412,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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -259,12 +259,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
|
||||
@@ -276,6 +278,7 @@ public abstract class CallScreeningService extends Service {
|
||||
mShouldRejectCall = shouldRejectCall;
|
||||
mShouldSkipCallLog = shouldSkipCallLog;
|
||||
mShouldSkipNotification = shouldSkipNotification;
|
||||
mShouldSilenceCall = shouldSilenceCall;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -293,6 +296,13 @@ public abstract class CallScreeningService extends Service {
|
||||
return mShouldRejectCall;
|
||||
}
|
||||
|
||||
/*
|
||||
* @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.
|
||||
*/
|
||||
@@ -310,6 +320,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;
|
||||
|
||||
@@ -330,6 +341,21 @@ public abstract class CallScreeningService extends Service {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -356,6 +382,7 @@ public abstract class CallScreeningService extends Service {
|
||||
return new CallResponse(
|
||||
mShouldDisallowCall,
|
||||
mShouldRejectCall,
|
||||
mShouldSilenceCall,
|
||||
mShouldSkipCallLog,
|
||||
mShouldSkipNotification);
|
||||
}
|
||||
@@ -411,10 +438,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}.
|
||||
@@ -436,6 +464,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());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import android.telecom.CallIdentification;
|
||||
oneway interface ICallScreeningAdapter {
|
||||
void allowCall(String callId);
|
||||
|
||||
void silenceCall(String callId);
|
||||
|
||||
void disallowCall(
|
||||
String callId,
|
||||
boolean shouldReject,
|
||||
|
||||
Reference in New Issue
Block a user