Merge "Add silence support to CallScreeningService/Call API"
This commit is contained in:
@@ -41143,6 +41143,7 @@ package android.telecom {
|
|||||||
method public void unregisterCallback(android.telecom.Call.Callback);
|
method public void unregisterCallback(android.telecom.Call.Callback);
|
||||||
field @Deprecated public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts";
|
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_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 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_ACTIVE = 4; // 0x4
|
||||||
field public static final int STATE_CONNECTING = 9; // 0x9
|
field public static final int STATE_CONNECTING = 9; // 0x9
|
||||||
@@ -41291,6 +41292,7 @@ package android.telecom {
|
|||||||
public static class CallScreeningService.CallResponse {
|
public static class CallScreeningService.CallResponse {
|
||||||
method public boolean getDisallowCall();
|
method public boolean getDisallowCall();
|
||||||
method public boolean getRejectCall();
|
method public boolean getRejectCall();
|
||||||
|
method public boolean getSilenceCall();
|
||||||
method public boolean getSkipCallLog();
|
method public boolean getSkipCallLog();
|
||||||
method public boolean getSkipNotification();
|
method public boolean getSkipNotification();
|
||||||
}
|
}
|
||||||
@@ -41300,6 +41302,7 @@ package android.telecom {
|
|||||||
method public android.telecom.CallScreeningService.CallResponse build();
|
method public android.telecom.CallScreeningService.CallResponse build();
|
||||||
method public android.telecom.CallScreeningService.CallResponse.Builder setDisallowCall(boolean);
|
method public android.telecom.CallScreeningService.CallResponse.Builder setDisallowCall(boolean);
|
||||||
method public android.telecom.CallScreeningService.CallResponse.Builder setRejectCall(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 setSkipCallLog(boolean);
|
||||||
method public android.telecom.CallScreeningService.CallResponse.Builder setSkipNotification(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 =
|
public static final String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS =
|
||||||
"android.telecom.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
|
* 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
|
* Telecom that the user has requested that the current {@link Call} should be handed over
|
||||||
|
|||||||
@@ -137,12 +137,14 @@ public abstract class CallScreeningService extends Service {
|
|||||||
public static class CallResponse {
|
public static class CallResponse {
|
||||||
private final boolean mShouldDisallowCall;
|
private final boolean mShouldDisallowCall;
|
||||||
private final boolean mShouldRejectCall;
|
private final boolean mShouldRejectCall;
|
||||||
|
private final boolean mShouldSilenceCall;
|
||||||
private final boolean mShouldSkipCallLog;
|
private final boolean mShouldSkipCallLog;
|
||||||
private final boolean mShouldSkipNotification;
|
private final boolean mShouldSkipNotification;
|
||||||
|
|
||||||
private CallResponse(
|
private CallResponse(
|
||||||
boolean shouldDisallowCall,
|
boolean shouldDisallowCall,
|
||||||
boolean shouldRejectCall,
|
boolean shouldRejectCall,
|
||||||
|
boolean shouldSilenceCall,
|
||||||
boolean shouldSkipCallLog,
|
boolean shouldSkipCallLog,
|
||||||
boolean shouldSkipNotification) {
|
boolean shouldSkipNotification) {
|
||||||
if (!shouldDisallowCall
|
if (!shouldDisallowCall
|
||||||
@@ -154,6 +156,7 @@ public abstract class CallScreeningService extends Service {
|
|||||||
mShouldRejectCall = shouldRejectCall;
|
mShouldRejectCall = shouldRejectCall;
|
||||||
mShouldSkipCallLog = shouldSkipCallLog;
|
mShouldSkipCallLog = shouldSkipCallLog;
|
||||||
mShouldSkipNotification = shouldSkipNotification;
|
mShouldSkipNotification = shouldSkipNotification;
|
||||||
|
mShouldSilenceCall = shouldSilenceCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -171,6 +174,13 @@ public abstract class CallScreeningService extends Service {
|
|||||||
return mShouldRejectCall;
|
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.
|
* @return Whether the incoming call should not be displayed in the call log.
|
||||||
*/
|
*/
|
||||||
@@ -188,6 +198,7 @@ public abstract class CallScreeningService extends Service {
|
|||||||
public static class Builder {
|
public static class Builder {
|
||||||
private boolean mShouldDisallowCall;
|
private boolean mShouldDisallowCall;
|
||||||
private boolean mShouldRejectCall;
|
private boolean mShouldRejectCall;
|
||||||
|
private boolean mShouldSilenceCall;
|
||||||
private boolean mShouldSkipCallLog;
|
private boolean mShouldSkipCallLog;
|
||||||
private boolean mShouldSkipNotification;
|
private boolean mShouldSkipNotification;
|
||||||
|
|
||||||
@@ -208,6 +219,21 @@ public abstract class CallScreeningService extends Service {
|
|||||||
return this;
|
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
|
* 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.
|
* should only be set to true if the call is disallowed.
|
||||||
@@ -234,6 +260,7 @@ public abstract class CallScreeningService extends Service {
|
|||||||
return new CallResponse(
|
return new CallResponse(
|
||||||
mShouldDisallowCall,
|
mShouldDisallowCall,
|
||||||
mShouldRejectCall,
|
mShouldRejectCall,
|
||||||
|
mShouldSilenceCall,
|
||||||
mShouldSkipCallLog,
|
mShouldSkipCallLog,
|
||||||
mShouldSkipNotification);
|
mShouldSkipNotification);
|
||||||
}
|
}
|
||||||
@@ -285,10 +312,11 @@ public abstract class CallScreeningService extends Service {
|
|||||||
public abstract void onScreenCall(@NonNull Call.Details callDetails);
|
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>
|
* <p>
|
||||||
* The {@link CallScreeningService} calls this method to inform the system whether the call
|
* 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>
|
* <p>
|
||||||
* Calls to this method are ignored unless the {@link Call.Details#getCallDirection()} is
|
* Calls to this method are ignored unless the {@link Call.Details#getCallDirection()} is
|
||||||
* {@link Call.Details#DIRECTION_INCOMING}.
|
* {@link Call.Details#DIRECTION_INCOMING}.
|
||||||
@@ -310,6 +338,8 @@ public abstract class CallScreeningService extends Service {
|
|||||||
!response.getSkipCallLog(),
|
!response.getSkipCallLog(),
|
||||||
!response.getSkipNotification(),
|
!response.getSkipNotification(),
|
||||||
new ComponentName(getPackageName(), getClass().getName()));
|
new ComponentName(getPackageName(), getClass().getName()));
|
||||||
|
} else if (response.getSilenceCall()) {
|
||||||
|
mCallScreeningAdapter.silenceCall(callDetails.getTelecomCallId());
|
||||||
} else {
|
} else {
|
||||||
mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId());
|
mCallScreeningAdapter.allowCall(callDetails.getTelecomCallId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.content.ComponentName;
|
|||||||
oneway interface ICallScreeningAdapter {
|
oneway interface ICallScreeningAdapter {
|
||||||
void allowCall(String callId);
|
void allowCall(String callId);
|
||||||
|
|
||||||
|
void silenceCall(String callId);
|
||||||
|
|
||||||
void disallowCall(
|
void disallowCall(
|
||||||
String callId,
|
String callId,
|
||||||
boolean shouldReject,
|
boolean shouldReject,
|
||||||
|
|||||||
Reference in New Issue
Block a user