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

Commit 06a9f628 authored by Grace Jia's avatar Grace Jia
Browse files

Throw timeout exception as CallException in TransactionManager.

Currently when a transaction timed out, we also treat it as a completed
transaction with a failed result. Change this to directly throw a
CallException when timed out.

Bug: 271109344
Test: atest VoipCallTransactionTest
Change-Id: I0b91d0c509a8a7a852187465a226594ee88142b6
parent 4a0f46a2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.telecom.voip;

import static android.telecom.CallException.CODE_OPERATION_TIMED_OUT;

import android.os.OutcomeReceiver;
import android.telecom.TelecomManager;
import android.telecom.CallException;
@@ -79,8 +81,8 @@ public class TransactionManager {

                @Override
                public void onTransactionTimeout(String transactionName){
                    receiver.onResult(new VoipCallTransactionResult(
                            VoipCallTransactionResult.RESULT_FAILED, transactionName + " timeout"));
                    receiver.onError(new CallException(transactionName + " timeout",
                            CODE_OPERATION_TIMED_OUT));
                    finishTransaction();
                }
            });
+15 −7
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ public class VoipCallTransactionTest extends TelecomTestCase {
        subTransactions.add(t3);
        CompletableFuture<String> exceptionFuture = new CompletableFuture<>();
        OutcomeReceiver<VoipCallTransactionResult, CallException> outcomeReceiver =
                new OutcomeReceiver<VoipCallTransactionResult, CallException>() {
                new OutcomeReceiver<>() {
            @Override
            public void onResult(VoipCallTransactionResult result) {

@@ -234,12 +234,20 @@ public class VoipCallTransactionTest extends TelecomTestCase {
            throws ExecutionException, InterruptedException, TimeoutException {
        VoipCallTransaction t = new TestVoipCallTransaction("t", 10000L,
                TestVoipCallTransaction.SUCCESS);
        CompletableFuture<VoipCallTransactionResult> resultFuture = new CompletableFuture<>();
        CompletableFuture<String> exceptionFuture = new CompletableFuture<>();
        OutcomeReceiver<VoipCallTransactionResult, CallException> outcomeReceiver =
                resultFuture::complete;
        mTransactionManager.addTransaction(t, outcomeReceiver);
        VoipCallTransactionResult result = resultFuture.get(7000L, TimeUnit.MILLISECONDS);
        assertEquals(VoipCallTransactionResult.RESULT_FAILED, result.getResult());
        assertTrue(result.getMessage().contains("timeout"));
                new OutcomeReceiver<>() {
                    @Override
                    public void onResult(VoipCallTransactionResult result) {

                    }

                    @Override
                    public void onError(CallException e) {
                        exceptionFuture.complete(e.getMessage());
                    }
                };        mTransactionManager.addTransaction(t, outcomeReceiver);
        String message = exceptionFuture.get(7000L, TimeUnit.MILLISECONDS);
        assertTrue(message.contains("timeout"));
    }
}