Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 501ab33a authored by Thomas Stuart's avatar Thomas Stuart Committed by Android (Google) Code Review
Browse files

Merge "CallControl#setMuteState API changes" into main

parents 2ba54b52 0bc7c58a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41703,10 +41703,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>);
  }
+47 −82
Original line number Diff line number Diff line
@@ -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,7 +88,8 @@ public final class CallControl {
     */
    public void setActive(@CallbackExecutor @NonNull Executor executor,
            @NonNull OutcomeReceiver<Void, CallException> callback) {
        if (mServerInterface != null) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(callback);
        try {
            mServerInterface.setActive(mCallId,
                    new CallControlResultReceiver("setActive", executor, callback));
@@ -105,9 +97,6 @@ public final class CallControl {
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        } else {
            throw new IllegalStateException(INTERFACE_ERROR_MSG);
        }
    }

    /**
@@ -134,7 +123,6 @@ 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));
@@ -142,9 +130,6 @@ public final class CallControl {
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        } else {
            throw new IllegalStateException(INTERFACE_ERROR_MSG);
        }
    }

    /**
@@ -165,7 +150,8 @@ public final class CallControl {
     */
    public void setInactive(@CallbackExecutor @NonNull Executor executor,
            @NonNull OutcomeReceiver<Void, CallException> callback) {
        if (mServerInterface != null) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(callback);
        try {
            mServerInterface.setInactive(mCallId,
                    new CallControlResultReceiver("setInactive", executor, callback));
@@ -173,9 +159,6 @@ public final class CallControl {
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        } else {
            throw new IllegalStateException(INTERFACE_ERROR_MSG);
        }
    }

    /**
@@ -213,16 +196,12 @@ 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);
        }
    }

    /**
@@ -245,16 +224,14 @@ public final class CallControl {
     */
    public void startCallStreaming(@CallbackExecutor @NonNull Executor executor,
            @NonNull OutcomeReceiver<Void, CallException> callback) {
        if (mServerInterface != null) {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(callback);
        try {
            mServerInterface.startCallStreaming(mCallId,
                    new CallControlResultReceiver("startCallStreaming", executor, callback));
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        } else {
            throw new IllegalStateException(INTERFACE_ERROR_MSG);
        }
    }

    /**
@@ -281,16 +258,12 @@ 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));
                    new CallControlResultReceiver("requestCallEndpointChange", executor, callback));
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        } else {
            throw new IllegalStateException(INTERFACE_ERROR_MSG);
        }
    }

    /**
@@ -313,21 +286,17 @@ 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));
                    new CallControlResultReceiver("requestMuteState", executor, callback));

        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        } else {
            throw new IllegalStateException(INTERFACE_ERROR_MSG);
        }
    }

    /**
@@ -352,15 +321,11 @@ 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);
        }
    }

    /**
+1 −2
Original line number Diff line number Diff line
@@ -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);