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

Commit 144827dc authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Call Sequencing CUJ Tests

This CUJ test ensures that each combination of 3 tuples of calls
works as expected with sequencing. This CUJ also goes over the single
call scenario for the different types of calls.

Bug: 379937921
Test: atest CtsTelecomCujTestCases:CallSequencingTests
Flag: com.android.server.telecom.flags.enable_call_sequencing
Change-Id: Ia42a46e0ade5066f8df20fc27f074ba2415005a1
parent 35c9a70f
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -54,17 +54,17 @@ public class CallEventCallbackAckTransaction extends CallTransaction {
            CODE_OPERATION_TIMED_OUT, "failed to complete the operation before timeout");

    private static class AckResultReceiver extends ResultReceiver {
        CountDownLatch mCountDownLatch;
        CompletableFuture<Boolean> mCompletableFuture;

        public AckResultReceiver(CountDownLatch latch) {
        public AckResultReceiver(CompletableFuture<Boolean> future) {
            super(null);
            mCountDownLatch = latch;
            mCompletableFuture = future;
        }

        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            if (resultCode == TELECOM_TRANSACTION_SUCCESS) {
                mCountDownLatch.countDown();
                mCompletableFuture.complete(true);
            }
        }
    }
@@ -99,9 +99,10 @@ public class CallEventCallbackAckTransaction extends CallTransaction {

    @Override
    public CompletionStage<CallTransactionResult> processTransaction(Void v) {
        Log.d(TAG, "processTransaction");
        CountDownLatch latch = new CountDownLatch(1);
        ResultReceiver receiver = new AckResultReceiver(latch);
        Log.d(TAG, "processTransaction: action [" + mAction + "]");
        CompletableFuture<Boolean> future = new CompletableFuture<Boolean>()
                .completeOnTimeout(false, mTransactionTimeoutMs, TimeUnit.MILLISECONDS);
        ResultReceiver receiver = new AckResultReceiver(future);

        try {
            switch (mAction) {
@@ -125,9 +126,7 @@ public class CallEventCallbackAckTransaction extends CallTransaction {
            return CompletableFuture.completedFuture(TRANSACTION_FAILED);
        }

        try {
            // wait for the client to ack that CallEventCallback
            boolean success = latch.await(mTransactionTimeoutMs, TimeUnit.MILLISECONDS);
        return future.thenCompose((success) -> {
            if (!success) {
                // client send onError and failed to complete transaction
                Log.i(TAG, String.format("CallEventCallbackAckTransaction:"
@@ -139,8 +138,6 @@ public class CallEventCallbackAckTransaction extends CallTransaction {
                        new CallTransactionResult(CallTransactionResult.RESULT_SUCCEED,
                                "success"));
            }
        } catch (InterruptedException ie) {
            return CompletableFuture.completedFuture(TRANSACTION_FAILED);
        }
        });
    }
}