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

Commit aca87aef authored by Tyler Gunn's avatar Tyler Gunn Committed by Automerger Merge Worker
Browse files

Merge "Fix issue with sending BluetoothCallQualityReport to Telecom." am: 99d32a39

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1831254

Change-Id: I8cc64d1908a662f8652f6fccdb67bba7118d12b7
parents 2bf6df7c 99d32a39
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ public class BluetoothCall {
        return mCall;
    }

    public boolean isCallNull() {
        return mCall == null;
    }

    public void setCall(Call call) {
        mCall = call;
    }
+2 −2
Original line number Diff line number Diff line
@@ -500,7 +500,7 @@ public class BluetoothInCallService extends InCallService {
                        .setSnrDb(snr)
                        .setRetransmittedPacketsCount(retransmissionCount)
                        .setPacketsNotReceivedCount(packetsNotReceiveCount)
                        .setPacketsNotReceivedCount(negativeAcknowledgementCount)
                        .setNegativeAcknowledgementCount(negativeAcknowledgementCount)
                        .build());
        call.sendCallEvent(
                BluetoothCallQualityReport.EVENT_BLUETOOTH_CALL_QUALITY_REPORT, b);
@@ -1155,7 +1155,7 @@ public class BluetoothInCallService extends InCallService {
        }

        public boolean isNullCall(BluetoothCall call) {
            return call == null || call.getCall() == null;
            return call == null || call.isCallNull();
        }
    };
};
+37 −0
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.telecom.BluetoothCallQualityReport;
import android.telecom.Call;
import android.telecom.Connection;
import android.telecom.GatewayInfo;
@@ -49,6 +51,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

@@ -256,6 +259,40 @@ public class BluetoothInCallServiceTest {
        verify(mMockBluetoothHeadset).clccResponse(0, 0, 0, 0, false, null, 0);
    }

    /**
     * Verifies bluetooth call quality reports are properly parceled and set as a call event to
     * Telecom.
     */
    @Test
    public void testBluetoothCallQualityReport() {
        BluetoothCall activeCall = createForegroundCall();
        when(activeCall.isCallNull()).thenReturn(false);
        mBluetoothInCallService.onCallAdded(activeCall);

        mBluetoothInCallService.sendBluetoothCallQualityReport(
                10, // long timestamp
                20, // int rssi
                30, // int snr
                40, // int retransmissionCount
                50, // int packetsNotReceiveCount
                60 // int negativeAcknowledgementCount
        );

        ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
        verify(activeCall).sendCallEvent(
                eq(BluetoothCallQualityReport.EVENT_BLUETOOTH_CALL_QUALITY_REPORT),
                bundleCaptor.capture());
        Bundle bundle = bundleCaptor.getValue();
        BluetoothCallQualityReport report = (BluetoothCallQualityReport) bundle.get(
                BluetoothCallQualityReport.EXTRA_BLUETOOTH_CALL_QUALITY_REPORT);
        Assert.assertEquals(10, report.getSentTimestampMillis());
        Assert.assertEquals(20, report.getRssiDbm());
        Assert.assertEquals(30, report.getSnrDb());
        Assert.assertEquals(40, report.getRetransmittedPacketsCount());
        Assert.assertEquals(50, report.getPacketsNotReceivedCount());
        Assert.assertEquals(60, report.getNegativeAcknowledgementCount());
    }

    @Test
    public void testListCurrentCallsSilentRinging() throws Exception {
        ArrayList<BluetoothCall> calls = new ArrayList<>();