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

Commit 049bfca9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "requesting the current active endpoint as new should call onResult"...

Merge "requesting the current active endpoint as new should call onResult" into udc-dev am: ff02ff08 am: a605aee2

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/22872159



Change-Id: I981c1ac3212bdd89f8f5d9c71b07b496a7e35382
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a670cbf1 a605aee2
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));
                    }
                });
    }