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

Commit a59a8226 authored by Thomas Stuart's avatar Thomas Stuart
Browse files

requesting the current active endpoint as new should call onResult

Ideally, onResult should be called when a client requests an endpoint
change that is the current active endpoint. This will suppress confusion
and makes more sense.

Fixes: 279499243
Test: manual
Change-Id: I41eb40c23232ec55ce8f1084e3258de85c97234f
parent 94990ef8
Loading
Loading
Loading
Loading
+33 −7
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ import android.telecom.CallAudioState;
import android.telecom.CallEndpoint;
import android.telecom.CallEndpointException;
import android.telecom.Log;

import com.android.internal.annotations.VisibleForTesting;

import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
@@ -96,6 +98,12 @@ public class CallEndpointController extends CallsManagerListenerBase {
            return;
        }

        if (isCurrentEndpointRequestedEndpoint(route, bluetoothAddress)) {
            Log.d(this, "requestCallEndpointChange: requested endpoint is already active");
            callback.send(CallEndpoint.ENDPOINT_OPERATION_SUCCESS, new Bundle());
            return;
        }

        if (mPendingChangeRequest != null && !mPendingChangeRequest.isDone()) {
            mPendingChangeRequest.complete(RESULT_ANOTHER_REQUEST);
            mPendingChangeRequest = null;
@@ -116,6 +124,27 @@ public class CallEndpointController extends CallsManagerListenerBase {
        mCallsManager.getCallAudioManager().setAudioRoute(route, bluetoothAddress);
    }

    public boolean isCurrentEndpointRequestedEndpoint(int requestedRoute, String requestedAddress) {
        if (mCallsManager.getCallAudioManager() == null
                || mCallsManager.getCallAudioManager().getCallAudioState() == null) {
            return false;
        }
        CallAudioState currentAudioState = mCallsManager.getCallAudioManager().getCallAudioState();
        // requested non-bt endpoint is already active
        if (requestedRoute != CallAudioState.ROUTE_BLUETOOTH &&
                requestedRoute == currentAudioState.getRoute()) {
            return true;
        }
        // requested bt endpoint is already active
        if (requestedRoute == CallAudioState.ROUTE_BLUETOOTH &&
                currentAudioState.getActiveBluetoothDevice() != null &&
                requestedAddress.equals(
                        currentAudioState.getActiveBluetoothDevice().getAddress())) {
            return true;
        }
        return false;
    }

    private Bundle getErrorResult(int result) {
        String message;
        int resultCode;
@@ -165,8 +194,7 @@ public class CallEndpointController extends CallsManagerListenerBase {
        for (Call call : calls) {
            if (call != null && call.getConnectionService() != null) {
                call.getConnectionService().onCallEndpointChanged(call, mActiveCallEndpoint);
            }
            else if (call != null && call.getTransactionServiceWrapper() != null) {
            } else if (call != null && call.getTransactionServiceWrapper() != null) {
                call.getTransactionServiceWrapper()
                        .onCallEndpointChanged(call, mActiveCallEndpoint);
            }
@@ -181,8 +209,7 @@ public class CallEndpointController extends CallsManagerListenerBase {
            if (call != null && call.getConnectionService() != null) {
                call.getConnectionService().onAvailableCallEndpointsChanged(call,
                        mAvailableCallEndpoints);
            }
            else if (call != null && call.getTransactionServiceWrapper() != null) {
            } else if (call != null && call.getTransactionServiceWrapper() != null) {
                call.getTransactionServiceWrapper()
                        .onAvailableCallEndpointsChanged(call, mAvailableCallEndpoints);
            }
@@ -196,8 +223,7 @@ public class CallEndpointController extends CallsManagerListenerBase {
        for (Call call : calls) {
            if (call != null && call.getConnectionService() != null) {
                call.getConnectionService().onMuteStateChanged(call, isMuted);
            }
            else if (call != null && call.getTransactionServiceWrapper() != null) {
            } else if (call != null && call.getTransactionServiceWrapper() != null) {
                call.getTransactionServiceWrapper().onMuteStateChanged(call, isMuted);
            }
        }
+3 −3
Original line number Diff line number Diff line
@@ -254,14 +254,14 @@ public class InCallActivity extends Activity {
                new OutcomeReceiver<Void, CallException>() {
                    @Override
                    public void onResult(Void result) {
                        Log.i(TAG, String.format("success w/ %s", tag));
                        Log.i(TAG, String.format("requestEndpointChange: success w/ %s", tag));
                        updateCurrentEndpointWithOnResult(endpoint);
                    }

                    @Override
                    public void onError(CallException e) {
                        Log.i(TAG, String.format("%s :failed to switch to endpoint=[%s],"
                                + " due to exception=[%s]", tag, endpoint, e.toString()));
                        Log.i(TAG, String.format("requestEndpointChange: %s failed to switch to "
                                + "endpoint=[%s] due to exception=[%s]", tag, endpoint, e));
                    }
                });
    }