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

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

Merge "BluetoothInCallService: Change isConferenceWithNoChildren logic. ...

Merge "BluetoothInCallService: Change isConferenceWithNoChildren logic.  Besides checking if the call is a conference call and the property CAPABILITY_CONFERENCE_HAS_NO_CHILDREN, we should actually check if the call has childrens" into tm-qpr-dev
parents 6107007e 71b1656a
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -676,15 +676,22 @@ public class BluetoothInCallService extends InCallService {
        mClccIndexMap.clear();
    }

    private static boolean isConferenceWithNoChildren(BluetoothCall call) {
        return call.isConference()
            && (call.can(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
                    || call.getChildrenIds().isEmpty());
    }

    private void sendListOfCalls(boolean shouldLog) {
        Collection<BluetoothCall> calls = mCallInfo.getBluetoothCalls();
        for (BluetoothCall call : calls) {
            // We don't send the parent conference BluetoothCall to the bluetooth device.
            // We do, however want to send conferences that have no children to the bluetooth
            // device (e.g. IMS Conference).
            if (!call.isConference()
                    || (call.isConference()
                            && call.can(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN))) {
            boolean isConferenceWithNoChildren = isConferenceWithNoChildren(call);
            Log.i(TAG, "sendListOfCalls isConferenceWithNoChildren " + isConferenceWithNoChildren 
                + ", call.getChildrenIds() size " + call.getChildrenIds().size());
            if (!call.isConference() || isConferenceWithNoChildren) {
                sendClccForCall(call, shouldLog);
            }
        }
@@ -705,8 +712,7 @@ public class BluetoothInCallService extends InCallService {
        boolean isForeground = mCallInfo.getForegroundCall() == call;
        int state = getBtCallState(call, isForeground);
        boolean isPartOfConference = false;
        boolean isConferenceWithNoChildren = call.isConference()
                && call.can(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN);
        boolean isConferenceWithNoChildren = isConferenceWithNoChildren(call);

        if (state == CALL_STATE_IDLE) {
            return;
@@ -1364,8 +1370,7 @@ public class BluetoothInCallService extends InCallService {
    private BluetoothLeCall createTbsCall(BluetoothCall call) {
        Integer state = getTbsCallState(call);
        boolean isPartOfConference = false;
        boolean isConferenceWithNoChildren = call.isConference()
                && call.can(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN);
        boolean isConferenceWithNoChildren = isConferenceWithNoChildren(call);

        if (state == null) {
            return null;
+26 −1
Original line number Diff line number Diff line
@@ -702,13 +702,15 @@ public class BluetoothInCallServiceTest {
        Integer parentId = parentCall.getId();
        when(childCall1.getParentId()).thenReturn(parentId);
        when(childCall2.getParentId()).thenReturn(parentId);
        List<Integer> childrenIds = Arrays.asList(childCall1.getId(),
                childCall2.getId());
        when(parentCall.getChildrenIds()).thenReturn(childrenIds);

        when(parentCall.isConference()).thenReturn(true);
        when(parentCall.getState()).thenReturn(Call.STATE_HOLDING);
        when(childCall1.getState()).thenReturn(Call.STATE_ACTIVE);
        when(childCall2.getState()).thenReturn(Call.STATE_ACTIVE);
        when(parentCall.hasProperty(Call.Details.PROPERTY_GENERIC_CONFERENCE)).thenReturn(true);

        when(parentCall.isIncoming()).thenReturn(true);
        when(mMockCallInfo.getBluetoothCalls()).thenReturn(calls);

@@ -722,6 +724,29 @@ public class BluetoothInCallServiceTest {
        verify(mMockBluetoothHeadset).clccResponse(0, 0, 0, 0, false, null, 0);
    }

    @Test
    public void testListCurrentCallsConferenceGetChildrenIsEmpty() throws Exception {
        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);
        when(conferenceCall.hasProperty(Call.Details.PROPERTY_GENERIC_CONFERENCE)).thenReturn(true);
        when(conferenceCall.can(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN))
          .thenReturn(false);
        when(conferenceCall.isIncoming()).thenReturn(true);
        when(mMockCallInfo.getBluetoothCalls()).thenReturn(calls);

        clearInvocations(mMockBluetoothHeadset);
        mBluetoothInCallService.listCurrentCalls();
        verify(mMockBluetoothHeadset).clccResponse(
                eq(1), eq(1), eq(0), eq(0), eq(true), eq("5551234"), eq(129));
    }

    @Test
    public void testQueryPhoneState() throws Exception {
        BluetoothCall ringingCall = createRingingCall();