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

Commit 4c099d01 authored by Chen Chen's avatar Chen Chen Committed by Android (Google) Code Review
Browse files

Merge "BluetoothInCallService: Make sure non conference calls have indices...

Merge "BluetoothInCallService: Make sure non conference calls have indices starting from 1" into tm-qpr-dev
parents 23fee4e8 9ed889d6
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ public class BluetoothInCallService extends InCallService {

    protected boolean mOnCreateCalled = false;

    private int mMaxNumberOfCalls = 0;

    /**
     * Listens to connections and disconnections of bluetooth headsets.  We need to save the current
     * bluetooth headset so that we know where to send BluetoothCall updates.
@@ -557,6 +559,9 @@ public class BluetoothInCallService extends InCallService {
            call.registerCallback(callback);

            mBluetoothCallHashMap.put(call.getId(), call);
            if (!call.isConference()) {
                mMaxNumberOfCalls = Integer.max(mMaxNumberOfCalls, mBluetoothCallHashMap.size());
            }
            updateHeadsetWithCallState(false /* force */);

            BluetoothLeCall tbsCall = createTbsCall(call);
@@ -687,6 +692,7 @@ public class BluetoothInCallService extends InCallService {
        mCallbacks.clear();
        mBluetoothCallHashMap.clear();
        mClccIndexMap.clear();
        mMaxNumberOfCalls = 0;
    }

    private static boolean isConferenceWithNoChildren(BluetoothCall call) {
@@ -844,15 +850,20 @@ public class BluetoothInCallService extends InCallService {
        if (mClccIndexMap.containsKey(key)) {
            return mClccIndexMap.get(key);
        }

        int i = 1;  // Indexes for bluetooth clcc are 1-based.
        while (mClccIndexMap.containsValue(i)) {
            i++;
        int index = 1; // Indexes for bluetooth clcc are 1-based.
        if (call.isConference()) {
            index = mMaxNumberOfCalls + 1; // The conference call should have a higher index
            Log.i(TAG,
                  "getIndexForCall for conference call starting from "
                  + mMaxNumberOfCalls);
        }
        while (mClccIndexMap.containsValue(index)) {
            index++;
        }

        // NOTE: Indexes are removed in {@link #onCallRemoved}.
        mClccIndexMap.put(key, i);
        return i;
        mClccIndexMap.put(key, index);
        return index;
    }

    private boolean _processChld(int chld) {
+6 −4
Original line number Diff line number Diff line
@@ -679,8 +679,6 @@ public class BluetoothInCallServiceTest {
    public void testListCurrentCallsImsConference() throws Exception {
        ArrayList<BluetoothCall> calls = new ArrayList<>();
        BluetoothCall parentCall = createActiveCall();
        calls.add(parentCall);
        mBluetoothInCallService.onCallAdded(parentCall);

        addCallCapability(parentCall, Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN);
        when(parentCall.isConference()).thenReturn(true);
@@ -689,6 +687,9 @@ public class BluetoothInCallServiceTest {
        when(parentCall.getHandle()).thenReturn(Uri.parse("tel:555-0000"));
        when(mMockCallInfo.getBluetoothCalls()).thenReturn(calls);

        calls.add(parentCall);
        mBluetoothInCallService.onCallAdded(parentCall);

        clearInvocations(mMockBluetoothHeadset);
        mBluetoothInCallService.listCurrentCalls();

@@ -745,9 +746,7 @@ public class BluetoothInCallServiceTest {
        ArrayList<BluetoothCall> calls = new ArrayList<>();
        BluetoothCall conferenceCall = createActiveCall();
        when(conferenceCall.getHandle()).thenReturn(Uri.parse("tel:555-1234"));
        calls.add(conferenceCall);

        mBluetoothInCallService.onCallAdded(conferenceCall);
        addCallCapability(conferenceCall, Connection.CAPABILITY_MANAGE_CONFERENCE);
        when(conferenceCall.isConference()).thenReturn(true);
        when(conferenceCall.getState()).thenReturn(Call.STATE_ACTIVE);
@@ -757,6 +756,9 @@ public class BluetoothInCallServiceTest {
        when(conferenceCall.isIncoming()).thenReturn(true);
        when(mMockCallInfo.getBluetoothCalls()).thenReturn(calls);

        calls.add(conferenceCall);
        mBluetoothInCallService.onCallAdded(conferenceCall);

        clearInvocations(mMockBluetoothHeadset);
        mBluetoothInCallService.listCurrentCalls();
        verify(mMockBluetoothHeadset).clccResponse(