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

Commit ff0f135d authored by Hall Liu's avatar Hall Liu
Browse files

Don't send BT state when silent ringing is requested

When silent ringing is requested by the call screening service, don't
send the call to the BT headset as a ringing call.

Fixes: 132201912
Test: unit
AOSP: Infeasible due to transitive dependencies on RoleManager
Change-Id: If326ef0b6d0b3e04a627888a05d815165722be20
parent 8078882d
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -583,7 +583,7 @@ public class BluetoothPhoneServiceImpl {
     */
    private void sendClccForCall(Call call, boolean shouldLog) {
        boolean isForeground = mCallsManager.getForegroundCall() == call;
        int state = convertCallState(call.getState(), isForeground);
        int state = getBtCallState(call, isForeground);
        boolean isPartOfConference = false;
        boolean isConferenceWithNoChildren = call.isConference() && call
                .can(Connection.CAPABILITY_CONFERENCE_HAS_NO_CHILDREN);
@@ -707,7 +707,8 @@ public class BluetoothPhoneServiceImpl {
        String ringingAddress = null;
        int ringingAddressType = 128;
        String ringingName = null;
        if (ringingCall != null && ringingCall.getHandle() != null) {
        if (ringingCall != null && ringingCall.getHandle() != null
            && !ringingCall.isSilentRingingRequested()) {
            ringingAddress = ringingCall.getHandle().getSchemeSpecificPart();
            if (ringingAddress != null) {
                ringingAddressType = PhoneNumberUtils.toaFromString(ringingAddress);
@@ -831,7 +832,6 @@ public class BluetoothPhoneServiceImpl {
    }

    private int getBluetoothCallStateForUpdate() {
        CallsManager callsManager = mCallsManager;
        Call ringingCall = mCallsManager.getRingingCall();
        Call dialingCall = mCallsManager.getOutgoingCall();
        boolean hasOnlyDisconnectedCalls = mCallsManager.hasOnlyDisconnectedCalls();
@@ -846,7 +846,7 @@ public class BluetoothPhoneServiceImpl {
        // bluetooth devices (like not getting out of ringing state after answering a call).
        //
        int bluetoothCallState = CALL_STATE_IDLE;
        if (ringingCall != null) {
        if (ringingCall != null && !ringingCall.isSilentRingingRequested()) {
            bluetoothCallState = CALL_STATE_INCOMING;
        } else if (dialingCall != null) {
            bluetoothCallState = CALL_STATE_ALERTING;
@@ -857,8 +857,8 @@ public class BluetoothPhoneServiceImpl {
        return bluetoothCallState;
    }

    private int convertCallState(int callState, boolean isForegroundCall) {
        switch (callState) {
    private int getBtCallState(Call call, boolean isForeground) {
        switch (call.getState()) {
            case CallState.NEW:
            case CallState.ABORTED:
            case CallState.DISCONNECTED:
@@ -885,7 +885,9 @@ public class BluetoothPhoneServiceImpl {

            case CallState.RINGING:
            case CallState.ANSWERED:
                if (isForegroundCall) {
                if (call.isSilentRingingRequested()) {
                    return CALL_STATE_IDLE;
                } else if (isForeground) {
                    return CALL_STATE_INCOMING;
                } else {
                    return CALL_STATE_WAITING;
+32 −1
Original line number Diff line number Diff line
@@ -271,6 +271,26 @@ public class BluetoothPhoneServiceTest extends TelecomTestCase {
        verify(mMockBluetoothHeadset).clccResponse(0, 0, 0, 0, false, null, 0);
    }

    @MediumTest
    @Test
    public void testListCurrentCallsSilentRinging() throws Exception {
        ArrayList<Call> calls = new ArrayList<>();
        Call silentRingingCall = createActiveCall();
        when(silentRingingCall.getState()).thenReturn(CallState.RINGING);
        when(silentRingingCall.isSilentRingingRequested()).thenReturn(true);
        calls.add(silentRingingCall);
        when(silentRingingCall.isConference()).thenReturn(false);
        when(silentRingingCall.getHandle()).thenReturn(Uri.parse("tel:555-000"));
        when(mMockCallsManager.getCalls()).thenReturn(calls);
        when(mMockCallsManager.getRingingCall()).thenReturn(silentRingingCall);

        mBluetoothPhoneService.mBinder.listCurrentCalls();

        verify(mMockBluetoothHeadset, never()).clccResponse(eq(1), eq(0), eq(0), eq(0), eq(false),
            eq("555000"), eq(PhoneNumberUtils.TOA_Unknown));
        verify(mMockBluetoothHeadset).clccResponse(0, 0, 0, 0, false, null, 0);
    }

    @MediumTest
    @Test
    public void testConferenceInProgressCDMA() throws Exception {
@@ -788,7 +808,19 @@ public class BluetoothPhoneServiceTest extends TelecomTestCase {

        verify(mMockBluetoothHeadset).phoneStateChanged(eq(0), eq(0), eq(CALL_STATE_INCOMING),
                eq("555000"), eq(PhoneNumberUtils.TOA_Unknown), nullable(String.class));
    }

    @MediumTest
    @Test
    public void testSilentRingingCallState() throws Exception {
        Call ringingCall = createRingingCall();
        when(ringingCall.isSilentRingingRequested()).thenReturn(true);
        when(ringingCall.getHandle()).thenReturn(Uri.parse("tel:555000"));

        mBluetoothPhoneService.mCallsManagerListener.onCallAdded(ringingCall);

        verify(mMockBluetoothHeadset).phoneStateChanged(eq(0), eq(0), eq(CALL_STATE_IDLE),
            eq(""), eq(128), nullable(String.class));
    }

    @MediumTest
@@ -810,7 +842,6 @@ public class BluetoothPhoneServiceTest extends TelecomTestCase {

        verify(mMockBluetoothHeadset).phoneStateChanged(eq(1), eq(1), eq(CALL_STATE_IDLE),
                eq(""), eq(128), nullable(String.class));

    }

    @MediumTest