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

Commit 5d1caf60 authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk Committed by Grzegorz Kolodziejczyk
Browse files

tbs: Implement call join with conference call

This extends InCallService with join calls possibility that is done with
conference call.

Tag: #feature
Bug: 273759352
Test: atest BluetoothInCallServiceTest
Change-Id: I33c9720465d93989152d38775f9baf68f8d359ae
parent 70bee993
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.bluetooth.telephony;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothHeadset;
@@ -1561,5 +1562,48 @@ public class BluetoothInCallService extends InCallService {
        public void onPlaceCall(int requestId, UUID callId, String uri) {
            mBluetoothLeCallControl.requestResult(requestId, BluetoothLeCallControl.RESULT_ERROR_APPLICATION);
        }

        @Override
        public void onJoinCalls(int requestId, @NonNull List<UUID> callIds) {
            synchronized (LOCK) {
                Log.i(TAG, "TBS - onJoinCalls");
                int result = BluetoothLeCallControl.RESULT_SUCCESS;
                List<UUID> alreadyJoinedCalls = new ArrayList<>();
                BluetoothCall baseCallInstance = null;

                if (callIds.size() < 2) {
                    Log.e(TAG, "TBS - onJoinCalls, join call number is invalid: " + callIds.size());
                    result = BluetoothLeCallControl.RESULT_ERROR_UNKNOWN_CALL_ID;
                    mBluetoothLeCallControl.requestResult(requestId, result);
                    return;
                }

                for (UUID callToJoinUuid : callIds) {
                    BluetoothCall callToJoinInstance = mCallInfo.getCallByCallId(callToJoinUuid);

                    /* Skip invalid and already add device */
                    if ((callToJoinInstance == null)
                            || (alreadyJoinedCalls.contains(callToJoinUuid))) {
                        continue;
                    }

                    /* Lets make first valid call the base call */
                    if (baseCallInstance == null) {
                        baseCallInstance = callToJoinInstance;
                        alreadyJoinedCalls.add(callToJoinUuid);
                        continue;
                    }

                    baseCallInstance.conference(callToJoinInstance);
                    alreadyJoinedCalls.add(callToJoinUuid);
                }

                if ((baseCallInstance == null) || (alreadyJoinedCalls.size() < 2)) {
                    result = BluetoothLeCallControl.RESULT_ERROR_UNKNOWN_CALL_ID;
                }

                mBluetoothLeCallControl.requestResult(requestId, result);
            }
        }
    };
}
+205 −86

File changed.

Preview size limit exceeded, changes collapsed.