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

Commit 8b047190 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10035032 from ff02ff08 to udc-release

Change-Id: I71d52f5adb71b630cc7cff779e084cda325af98e
parents 5dda17ef ff02ff08
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));
                    }
                });
    }