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

Commit 6edb5d63 authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Merge "Support passing verification status through Telecom."

am: 667897b8

Change-Id: I1c247e30777058a046e50964fe6117802fc5368a
parents c3142e64 667897b8
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -325,6 +325,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    private int mHandlePresentation;

    /**
     * The verification status for an incoming call's number.
     */
    private @Connection.VerificationStatus int mCallerNumberVerificationStatus;

    /** The caller display name (CNAP) set by the connection service. */
    private String mCallerDisplayName;

@@ -1085,6 +1090,14 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return mHandlePresentation;
    }

    public void setCallerNumberVerificationStatus(
            @Connection.VerificationStatus int callerNumberVerificationStatus) {
        mCallerNumberVerificationStatus = callerNumberVerificationStatus;
    }

    public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
        return mCallerNumberVerificationStatus;
    }

    void setHandle(Uri handle) {
        setHandle(handle, TelecomManager.PRESENTATION_ALLOWED);
@@ -1836,6 +1849,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,

        switch (mCallDirection) {
            case CALL_DIRECTION_INCOMING:
                setCallerNumberVerificationStatus(connection.getCallerNumberVerificationStatus());

                // Listeners (just CallsManager for now) will be responsible for checking whether
                // the call should be blocked.
                for (Listener l : mListeners) {
+9 −2
Original line number Diff line number Diff line
@@ -29,10 +29,14 @@ import android.telecom.ParcelableRttCall;
import android.telecom.TelecomManager;
import android.text.TextUtils;

import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Utilities dealing with {@link ParcelableCall}.
@@ -254,7 +258,8 @@ public class ParcelableCallUtils {
                call.getIntentExtras(),
                extras,
                call.getCreationTimeMillis(),
                callDirection);
                callDirection,
                call.getCallerNumberVerificationStatus());
    }

    /**
@@ -267,6 +272,7 @@ public class ParcelableCallUtils {
     *     <li>Connection time</li>
     *     <li>Handle (phone number)</li>
     *     <li>Handle (phone number) presentation</li>
     *     <li>Caller number verification status (verstat)</li>
     * </ul>
     * All other fields are nulled or set to 0 values.
     * Where the call screening service is part of the system dialer, the
@@ -324,7 +330,8 @@ public class ParcelableCallUtils {
                null, /* intentExtras */
                callExtras, /* callExtras */
                call.getCreationTimeMillis(),
                callDirection);
                callDirection,
                call.getCallerNumberVerificationStatus());
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -424,6 +424,7 @@ public class ConnectionServiceFixture implements TestFixture<IConnectionService>
        boolean isVoipAudioMode;
        Bundle extras;
        boolean isConferenceCreated;
        int callerNumberVerificationStatus;
    }

    public class ConferenceInfo {
@@ -712,6 +713,7 @@ public class ConnectionServiceFixture implements TestFixture<IConnectionService>
                c.statusHints,
                c.disconnectCause,
                c.conferenceableConnectionIds,
                c.extras);
                c.extras,
                c.callerNumberVerificationStatus);
    }
}
+43 −5
Original line number Diff line number Diff line
@@ -2,22 +2,19 @@ package com.android.server.telecom.tests;

import static com.android.server.telecom.TelecomSystem.*;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;

import android.content.ComponentName;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.telecom.Connection;
import android.telecom.GatewayInfo;
import android.telecom.ParcelableCall;
import android.telecom.PhoneAccountHandle;
import android.test.suitebuilder.annotation.SmallTest;
@@ -26,7 +23,6 @@ import com.android.server.telecom.Call;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.CallsManager;
import com.android.server.telecom.ClockProxy;
import com.android.server.telecom.ConnectionServiceRepository;
import com.android.server.telecom.ParcelableCallUtils;
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.PhoneNumberUtilsAdapter;
@@ -149,6 +145,48 @@ public class ParcelableCallUtilsTest extends TelecomTestCase {
        assertFalse(parceledExtras.containsKey(Connection.EXTRA_CALL_SUBJECT));
    }

    @SmallTest
    @Test
    public void testVerificationStatusParcelingForScreening() {
        checkVerStatParcelingForCallScreening(Connection.VERIFICATION_STATUS_NOT_VERIFIED, false);
        checkVerStatParcelingForCallScreening(Connection.VERIFICATION_STATUS_NOT_VERIFIED, true);
        checkVerStatParcelingForCallScreening(Connection.VERIFICATION_STATUS_PASSED, false);
        checkVerStatParcelingForCallScreening(Connection.VERIFICATION_STATUS_PASSED, true);
        checkVerStatParcelingForCallScreening(Connection.VERIFICATION_STATUS_FAILED, false);
        checkVerStatParcelingForCallScreening(Connection.VERIFICATION_STATUS_FAILED, true);
    }

    @SmallTest
    @Test
    public void testVerificationStatusParcelingForDialer() {
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_NOT_VERIFIED, false);
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_NOT_VERIFIED, true);
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_PASSED, false);
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_PASSED, true);
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_FAILED, false);
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_FAILED, true);
    }

    private void checkVerStatParcelingForCallScreening(int connectionVerificationStatus,
            boolean isForSystemDialer) {
        mCall.setCallerNumberVerificationStatus(connectionVerificationStatus);
        ParcelableCall call = ParcelableCallUtils.toParcelableCallForScreening(mCall,
                isForSystemDialer /* isPartOfSystemDialer */);
        assertEquals(connectionVerificationStatus, call.getCallerNumberVerificationStatus());
    }

    private void checkVerStatParcelingForDialer(int connectionVerificationStatus,
            boolean isForSystemDialer) {
        mCall.setCallerNumberVerificationStatus(connectionVerificationStatus);
        ParcelableCall call = ParcelableCallUtils.toParcelableCall(mCall,
                false /* includevideoProvider */,
                null /* phoneAccountRegistrar */,
                false /* supportsExternalCalls */,
                false /* includeRttCall */,
                isForSystemDialer /* isForSystemDialer */);
        assertEquals(connectionVerificationStatus, call.getCallerNumberVerificationStatus());
    }

    private Bundle getSomeExtras() {
        Bundle extras = new Bundle();
        extras.putString(Connection.EXTRA_SIP_INVITE, "scary data");