diff options
-rw-r--r-- | core/api/current.txt | 2 | ||||
-rw-r--r-- | telecomm/java/android/telecom/CallControl.java | 129 | ||||
-rw-r--r-- | telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java | 3 |
3 files changed, 49 insertions, 85 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 15c054f0b5e8..6a1f2a3b7ae6 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -41650,10 +41650,10 @@ 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 @FlaggedApi("com.android.server.telecom.flags.set_mute_state") public void requestMuteState(boolean, @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 @FlaggedApi("com.android.server.telecom.flags.set_mute_state") public void setMuteState(boolean, @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>); } diff --git a/telecomm/java/android/telecom/CallControl.java b/telecomm/java/android/telecom/CallControl.java index fe699af86f1d..a14078697c71 100644 --- a/telecomm/java/android/telecom/CallControl.java +++ b/telecomm/java/android/telecom/CallControl.java @@ -21,7 +21,6 @@ import static android.telecom.CallException.TRANSACTION_EXCEPTION_KEY; import android.annotation.CallbackExecutor; import android.annotation.FlaggedApi; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.SuppressLint; import android.os.Binder; import android.os.Bundle; @@ -31,7 +30,6 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.text.TextUtils; -import com.android.internal.telecom.ClientTransactionalServiceRepository; import com.android.internal.telecom.ICallControl; import com.android.server.telecom.flags.Flags; @@ -52,20 +50,13 @@ import java.util.concurrent.Executor; @SuppressLint("NotCloseable") public final class CallControl { private static final String TAG = CallControl.class.getSimpleName(); - private static final String INTERFACE_ERROR_MSG = "Call Control is not available"; private final String mCallId; private final ICallControl mServerInterface; - private final PhoneAccountHandle mPhoneAccountHandle; - private final ClientTransactionalServiceRepository mRepository; /** @hide */ - public CallControl(@NonNull String callId, @Nullable ICallControl serverInterface, - @NonNull ClientTransactionalServiceRepository repository, - @NonNull PhoneAccountHandle pah) { + public CallControl(@NonNull String callId, @NonNull ICallControl serverInterface) { mCallId = callId; mServerInterface = serverInterface; - mRepository = repository; - mPhoneAccountHandle = pah; } /** @@ -97,16 +88,14 @@ public final class CallControl { */ public void setActive(@CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<Void, CallException> callback) { - if (mServerInterface != null) { - try { - mServerInterface.setActive(mCallId, - new CallControlResultReceiver("setActive", executor, callback)); + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + try { + mServerInterface.setActive(mCallId, + new CallControlResultReceiver("setActive", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -134,16 +123,12 @@ public final class CallControl { validateVideoState(videoState); Objects.requireNonNull(executor); Objects.requireNonNull(callback); - if (mServerInterface != null) { - try { - mServerInterface.answer(videoState, mCallId, - new CallControlResultReceiver("answer", executor, callback)); + try { + mServerInterface.answer(videoState, mCallId, + new CallControlResultReceiver("answer", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -165,16 +150,14 @@ public final class CallControl { */ public void setInactive(@CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<Void, CallException> callback) { - if (mServerInterface != null) { - try { - mServerInterface.setInactive(mCallId, - new CallControlResultReceiver("setInactive", executor, callback)); + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + try { + mServerInterface.setInactive(mCallId, + new CallControlResultReceiver("setInactive", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -213,15 +196,11 @@ public final class CallControl { Objects.requireNonNull(executor); Objects.requireNonNull(callback); validateDisconnectCause(disconnectCause); - if (mServerInterface != null) { - try { - mServerInterface.disconnect(mCallId, disconnectCause, - new CallControlResultReceiver("disconnect", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + try { + mServerInterface.disconnect(mCallId, disconnectCause, + new CallControlResultReceiver("disconnect", executor, callback)); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -245,15 +224,13 @@ public final class CallControl { */ public void startCallStreaming(@CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<Void, CallException> callback) { - if (mServerInterface != null) { - try { - mServerInterface.startCallStreaming(mCallId, - new CallControlResultReceiver("startCallStreaming", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + Objects.requireNonNull(executor); + Objects.requireNonNull(callback); + try { + mServerInterface.startCallStreaming(mCallId, + new CallControlResultReceiver("startCallStreaming", executor, callback)); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -281,15 +258,11 @@ public final class CallControl { Objects.requireNonNull(callEndpoint); Objects.requireNonNull(executor); Objects.requireNonNull(callback); - if (mServerInterface != null) { - try { - mServerInterface.requestCallEndpointChange(callEndpoint, - new CallControlResultReceiver("endpointChange", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + try { + mServerInterface.requestCallEndpointChange(callEndpoint, + new CallControlResultReceiver("requestCallEndpointChange", executor, callback)); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -313,20 +286,16 @@ public final class CallControl { * passed that details why the operation failed. */ @FlaggedApi(Flags.FLAG_SET_MUTE_STATE) - public void setMuteState(boolean isMuted, @CallbackExecutor @NonNull Executor executor, + public void requestMuteState(boolean isMuted, @CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<Void, CallException> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); - if (mServerInterface != null) { - try { - mServerInterface.setMuteState(isMuted, - new CallControlResultReceiver("setMuteState", executor, callback)); + try { + mServerInterface.setMuteState(isMuted, + new CallControlResultReceiver("requestMuteState", executor, callback)); - } catch (RemoteException e) { - throw e.rethrowAsRuntimeException(); - } - } else { - throw new IllegalStateException(INTERFACE_ERROR_MSG); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } @@ -352,14 +321,10 @@ public final class CallControl { 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); + try { + mServerInterface.sendEvent(mCallId, event, extras); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); } } diff --git a/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java b/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java index 71e9184b7c54..467e89c78810 100644 --- a/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java +++ b/telecomm/java/com/android/internal/telecom/ClientTransactionalServiceWrapper.java @@ -208,8 +208,7 @@ public class ClientTransactionalServiceWrapper { if (resultCode == TELECOM_TRANSACTION_SUCCESS) { // create the interface object that the client will interact with - CallControl control = new CallControl(callId, callControl, mRepository, - mPhoneAccountHandle); + CallControl control = new CallControl(callId, callControl); // give the client the object via the OR that was passed into addCall pendingControl.onResult(control); |