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

Commit b5de1cdb authored by Sanket Padawe's avatar Sanket Padawe
Browse files

Add permission checks for old call handover apis.

Bug: 65415068
Test: manual unit tests.
Change-Id: I1ae241059f5d4a3d2d16ea96faf7f86fcf0a89cd
parent bd3cae59
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -2026,17 +2027,35 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mConnectionService.pullExternalCall(this);
    }

    /**
     * Sends a call event to the {@link ConnectionService} for this call. This function is
     * called for event other than {@link Call#EVENT_REQUEST_HANDOVER}
     *
     * @param event The call event.
     * @param extras Associated extras.
     */
    public void sendCallEvent(String event, Bundle extras) {
        sendCallEvent(event, 0/*For Event != EVENT_REQUEST_HANDOVER*/, extras);
    }

    /**
     * Sends a call event to the {@link ConnectionService} for this call.
     *
     * See {@link Call#sendCallEvent(String, Bundle)}.
     *
     * @param event The call event.
     * @param targetSdkVer SDK version of the app calling this api
     * @param extras Associated extras.
     */
    public void sendCallEvent(String event, Bundle extras) {
    public void sendCallEvent(String event, int targetSdkVer, Bundle extras) {
        if (mConnectionService != null) {
            if (android.telecom.Call.EVENT_REQUEST_HANDOVER.equals(event)) {
                if (targetSdkVer > Build.VERSION_CODES.O_MR1) {
                    Log.e(this, new Exception(), "sendCallEvent failed. Use public api handoverTo" +
                            " for API > 27(O-MR1)");
                    // TODO: Add "return" after DUO team adds new API support for handover
                }

                // Handover requests are targeted at Telecom, not the ConnectionService.
                if (extras == null) {
                    Log.w(this, "sendCallEvent: %s event received with null extras.",
+2 −2
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ class InCallAdapter extends IInCallAdapter.Stub {
    }

    @Override
    public void sendCallEvent(String callId, String event, Bundle extras) {
    public void sendCallEvent(String callId, String event, int targetSdkVer, Bundle extras) {
        try {
            Log.startSession("ICA.sCE", mOwnerComponentName);
            long token = Binder.clearCallingIdentity();
@@ -404,7 +404,7 @@ class InCallAdapter extends IInCallAdapter.Stub {
                synchronized (mLock) {
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        call.sendCallEvent(event, extras);
                        call.sendCallEvent(event, targetSdkVer, extras);
                    } else {
                        Log.w(this, "sendCallEvent, unknown call id: %s", callId);
                    }
+2 −2
Original line number Diff line number Diff line
@@ -736,7 +736,7 @@ public class BasicCallTests extends TelecomSystemTest {
                mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
        assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureX.getCall(ids.mCallId).getState());

        mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, null);
        mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, 26, null);
        verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
                .sendCallEvent(eq(ids.mConnectionId), eq(TEST_EVENT), isNull(Bundle.class), any());
    }
@@ -757,7 +757,7 @@ public class BasicCallTests extends TelecomSystemTest {
        testBundle.putString(TEST_BUNDLE_KEY, "TEST");

        ArgumentCaptor<Bundle> bundleArgumentCaptor = ArgumentCaptor.forClass(Bundle.class);
        mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT,
        mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, 26,
                testBundle);
        verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
                .sendCallEvent(eq(ids.mConnectionId), eq(TEST_EVENT),