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

Commit 7f32c0aa authored by Thomas Stuart's avatar Thomas Stuart
Browse files

Add CTS coverage for CallExceptions

changes:
- TSW will propogate the CallException
- All VoIP transactions do not use RESULT_FAILED
- CTS coverage for some CallExceptions

bug: 264468805
Test: CTS
Change-Id: Ic15092a9700fa68bf2c51b01aed1759edae83bd2
parent c75c5d1a
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.telecom.CallStreamingService;
import android.telecom.DisconnectCause;
import android.telecom.Log;
import android.telecom.PhoneAccountHandle;
import android.text.TextUtils;

import androidx.annotation.VisibleForTesting;

@@ -263,8 +264,15 @@ public class TransactionalServiceWrapper implements
                        break;
                }
            } else {
                Log.i(TAG, action + ": mCallsManager does not contain call with id=" + callId);
                callback.send(CODE_CALL_IS_NOT_BEING_TRACKED, new Bundle());
                Bundle exceptionBundle = new Bundle();
                exceptionBundle.putParcelable(TRANSACTION_EXCEPTION_KEY,
                        new CallException(TextUtils.formatSimple(
                        "Telecom cannot process [%s] because the call with id=[%s] is no longer "
                                + "being tracked. This is most likely a result of the call "
                                + "already being disconnected and removed. Try re-adding the call"
                                + " via TelecomManager#addCall", action, callId),
                                CODE_CALL_IS_NOT_BEING_TRACKED));
                callback.send(CODE_CALL_IS_NOT_BEING_TRACKED, exceptionBundle);
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class HoldActiveCallForNewCallTransaction extends VoipCallTransaction {
            public void onError(CallException exception) {
                Log.d(TAG, "processTransaction: onError");
                future.complete(new VoipCallTransactionResult(
                        VoipCallTransactionResult.RESULT_FAILED, null));
                       exception.getCode(), exception.getMessage()));
            }
        });

+13 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.telecom.voip;

import android.telecom.CallException;
import android.util.Log;

import com.android.server.telecom.Call;
@@ -38,11 +39,17 @@ public class HoldCallTransaction extends VoipCallTransaction {
    @Override
    public CompletionStage<VoipCallTransactionResult> processTransaction(Void v) {
        Log.d(TAG, "processTransaction");
        CompletableFuture<VoipCallTransactionResult> future = new CompletableFuture<>();

        if (mCallsManager.canHold(mCall)) {
            mCallsManager.markCallAsOnHold(mCall);

        return CompletableFuture.completedFuture(
                new VoipCallTransactionResult(VoipCallTransactionResult.RESULT_SUCCEED,
                        "holdCallTransaction complete"));
            future.complete(new VoipCallTransactionResult(
                    VoipCallTransactionResult.RESULT_SUCCEED, null));
        } else {
            Log.d(TAG, "processTransaction: onError");
            future.complete(new VoipCallTransactionResult(
                    CallException.CODE_CANNOT_HOLD_CURRENT_ACTIVE_CALL, "cannot hold call"));
        }
        return future;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -53,9 +53,8 @@ public class RequestFocusTransaction extends VoipCallTransaction {
            @Override
            public void onError(CallException exception) {
                Log.d(TAG, "processTransaction: onError");

                future.complete(new VoipCallTransactionResult(
                        VoipCallTransactionResult.RESULT_FAILED, null));
                        exception.getCode(), exception.getMessage()));
            }
        });

+3 −10
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.telecom.tests;

import static android.telecom.CallException.CODE_CALL_CANNOT_BE_SET_TO_ACTIVE;
import static android.telecom.CallException.CODE_ERROR_UNKNOWN;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.times;
@@ -50,14 +51,6 @@ public class CallExceptionTests extends TelecomTestCase {
        super.tearDown();
    }

    @Test
    public void testSimpleException() {
        String message = "test message";
        CallException exception = new CallException(message);
        assertTrue(exception.getMessage().contains(message));
        assertEquals(CallException.CODE_ERROR_UNKNOWN, exception.getCode());
    }

    @Test
    public void testExceptionWithCode() {
        String message = "test message";
@@ -69,7 +62,7 @@ public class CallExceptionTests extends TelecomTestCase {
    @Test
    public void testDescribeContents() {
        String message = "test message";
        CallException exception = new CallException(message);
        CallException exception = new CallException(message, CODE_ERROR_UNKNOWN);
        assertEquals(0, exception.describeContents());
    }

@@ -77,7 +70,7 @@ public class CallExceptionTests extends TelecomTestCase {
    public void testWriteToParcel() {
        // GIVEN
        String message = "test message";
        CallException exception = new CallException(message);
        CallException exception = new CallException(message, CODE_ERROR_UNKNOWN);

        // WHEN
        exception.writeToParcel(mParcel, 0);
Loading