Merge "add capability to send and receive events" into udc-dev

This commit is contained in:
Thomas Stuart
2023-02-22 18:04:32 +00:00
committed by Android (Google) Code Review
6 changed files with 71 additions and 2 deletions

View File

@@ -42056,6 +42056,7 @@ package android.telecom {
method public void disconnect(@NonNull android.telecom.DisconnectCause, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method @NonNull public android.os.ParcelUuid getCallId();
method public void requestCallEndpointChange(@NonNull android.telecom.CallEndpoint, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void sendEvent(@NonNull String, @NonNull android.os.Bundle);
method public void setActive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void setInactive(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
method public void startCallStreaming(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telecom.CallException>);
@@ -42102,6 +42103,7 @@ package android.telecom {
method public void onAvailableCallEndpointsChanged(@NonNull java.util.List<android.telecom.CallEndpoint>);
method public void onCallEndpointChanged(@NonNull android.telecom.CallEndpoint);
method public void onCallStreamingFailed(int);
method public void onEvent(@NonNull String, @NonNull android.os.Bundle);
method public void onMuteStateChanged(boolean);
}

View File

@@ -147,10 +147,8 @@ public final class CallControl {
* <li>{@link DisconnectCause#REJECTED}</li>
* <li>{@link DisconnectCause#MISSED}</li>
* </ul>
*
* @param executor The {@link Executor} on which the {@link OutcomeReceiver} callback
* will be called on.
*
* @param callback That will be completed on the Telecom side that details success or
* failure of the requested operation.
*
@@ -253,6 +251,36 @@ public final class CallControl {
}
}
/**
* Raises an event to the {@link android.telecom.InCallService} implementations tracking this
* call via {@link android.telecom.Call.Callback#onConnectionEvent(Call, String, Bundle)}.
* These events and the associated extra keys for the {@code Bundle} parameter are defined
* in Android X. This API is used to relay additional information about a call other than
* what is specified in the {@link android.telecom.CallAttributes} to
* {@link android.telecom.InCallService}s. This might include, for example, a change to the list
* of participants in a meeting, or the name of the speakers who have their hand raised. Where
* appropriate, the {@link InCallService}s tracking this call may choose to render this
* additional information about the call. An automotive calling UX, for example may have enough
* screen real estate to indicate the number of participants in a meeting, but to prevent
* distractions could suppress the list of participants.
*
* @param event that is defined in AndroidX (ex. The number of participants changed)
* @param extras the updated value in relation to the event (ex. 4 participants)
*/
public void sendEvent(@NonNull String event, @NonNull Bundle extras) {
Objects.requireNonNull(event);
Objects.requireNonNull(extras);
if (mServerInterface != null) {
try {
mServerInterface.sendEvent(mCallId, event, extras);
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
} else {
throw new IllegalStateException(INTERFACE_ERROR_MSG);
}
}
/**
* Since {@link OutcomeReceiver}s cannot be passed via AIDL, a ResultReceiver (which can) must
* wrap the Clients {@link OutcomeReceiver} passed in and await for the Telecom Server side

View File

@@ -17,6 +17,7 @@
package android.telecom;
import android.annotation.NonNull;
import android.os.Bundle;
import java.util.List;
@@ -56,4 +57,17 @@ public interface CallEventCallback {
* @param reason Code to indicate the reason of this failure
*/
void onCallStreamingFailed(@CallStreamingService.StreamingFailedReason int reason);
/**
* Informs this {@link android.telecom.CallEventCallback} on events raised from a
* {@link android.telecom.InCallService} presenting this call. The event key and extra values
* are defined in AndroidX. This enables alternative calling surfaces, such as an automotive
* UI, to relay requests to perform other non-standard call actions to the app. For example,
* an automotive calling solution may offer the ability for the user to raise their hand
* during a meeting.
*
* @param event that is defined in AndroidX (ex. the number of participants changed)
* @param extras the updated value in relation to the event (ex. 4 participants)
*/
void onEvent(@NonNull String event, @NonNull Bundle extras);
}

View File

@@ -19,6 +19,7 @@ package com.android.internal.telecom;
import static android.telecom.TelecomManager.TELECOM_TRANSACTION_SUCCESS;
import android.os.Binder;
import android.os.Bundle;
import android.os.OutcomeReceiver;
import android.os.ResultReceiver;
import android.telecom.CallAttributes;
@@ -148,6 +149,7 @@ public class ClientTransactionalServiceWrapper {
private static final String ON_AVAILABLE_CALL_ENDPOINTS = "onAvailableCallEndpointsChanged";
private static final String ON_MUTE_STATE_CHANGED = "onMuteStateChanged";
private static final String ON_CALL_STREAMING_FAILED = "onCallStreamingFailed";
private static final String ON_EVENT = "onEvent";
private void handleHandshakeCallback(String action, String callId, int code,
ResultReceiver ackResultReceiver) {
@@ -314,5 +316,23 @@ public class ClientTransactionalServiceWrapper {
Log.i(TAG, TextUtils.formatSimple("oCSF: id=[%s], reason=[%s]", callId, reason));
handleEventCallback(callId, ON_CALL_STREAMING_FAILED, reason);
}
@Override
public void onEvent(String callId, String event, Bundle extras) {
// lookup the callEventCallback associated with the particular call
TransactionalCall call = mCallIdToTransactionalCall.get(callId);
if (call != null) {
CallEventCallback callback = call.getCallStateCallback();
Executor executor = call.getExecutor();
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
callback.onEvent(event, extras);
});
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}
};
}

View File

@@ -16,6 +16,7 @@
package com.android.internal.telecom;
import android.os.Bundle;
import android.telecom.CallControl;
import android.telecom.CallEndpoint;
import android.telecom.DisconnectCause;
@@ -30,4 +31,5 @@ oneway interface ICallControl {
void disconnect(String callId, in DisconnectCause disconnectCause, in ResultReceiver callback);
void startCallStreaming(String callId, in ResultReceiver callback);
void requestCallEndpointChange(in CallEndpoint callEndpoint, in ResultReceiver callback);
void sendEvent(String callId, String event, in Bundle extras);
}

View File

@@ -16,6 +16,7 @@
package com.android.internal.telecom;
import android.os.Bundle;
import android.telecom.CallControl;
import android.telecom.CallEndpoint;
import com.android.internal.telecom.ICallControl;
@@ -44,6 +45,8 @@ oneway interface ICallEventCallback {
void onCallEndpointChanged(String callId, in CallEndpoint endpoint);
void onAvailableCallEndpointsChanged(String callId, in List<CallEndpoint> endpoint);
void onMuteStateChanged(String callId, boolean isMuted);
// -- Events
void onEvent(String callId, String event, in Bundle extras);
// hidden methods that help with cleanup
void removeCallFromTransactionalServiceWrapper(String callId);
}