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

Commit cb278bde authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Support Call Identification via CallScreeningService.

Support reporting CallIdentification information from a
CallScreeningService.
Adding support for logging this to the call log, as well as exposing
it to the InCallService via the Call.Details object.
Update RoleManagerAdapter to support call proxy app.

Bug: 63966743
Test: Manual with test app.
Merged-In: I896cde3e91c862abdc7bb2a82bb0d85749bfbc11
Change-Id: I896cde3e91c862abdc7bb2a82bb0d85749bfbc11
parent 2d087215
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -297,14 +297,6 @@
            </intent-filter>
        </activity>

        <activity android:name="com.android.server.telecom.components.ChangeDefaultCallScreeningApp"
            android:label="@string/change_default_dialer_dialog_title"
            android:excludeFromRecents="true"
            android:theme="@*android:style/Theme.Material.Light.Dialog.Alert"
            android:priority="1000"
            android:process=":ui">
        </activity>

        <activity android:name=".ui.TelecomDeveloperMenu"
                  android:label="@string/developer_title"
                  android:exported="false"
+32 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.SystemClock;
import android.os.Trace;
import android.provider.ContactsContract.Contacts;
import android.telecom.CallAudioState;
import android.telecom.CallIdentification;
import android.telecom.Conference;
import android.telecom.ConnectionService;
import android.telecom.DisconnectCause;
@@ -141,6 +142,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                                 Bundle extras, boolean isLegacy);
        void onHandoverFailed(Call call, int error);
        void onHandoverComplete(Call call);
        void onCallIdentificationChanged(Call call);
    }

    public abstract static class ListenerBase implements Listener {
@@ -219,6 +221,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        public void onHandoverFailed(Call call, int error) {}
        @Override
        public void onHandoverComplete(Call call) {}
        @Override
        public void onCallIdentificationChanged(Call call) {}
    }

    private final CallerInfoLookupHelper.OnQueryCompleteListener mCallerInfoQueryListener =
@@ -529,6 +533,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    private boolean mIsUsingCallFiltering = false;

    /**
     * {@link CallIdentification} provided by a {@link android.telecom.CallScreeningService}.
     */
    private CallIdentification mCallIdentification = null;

    /**
     * Persists the specified parameters and initializes the new instance.
     * @param context The context.
@@ -3126,4 +3135,27 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    public void setIsUsingCallFiltering(boolean isUsingCallFiltering) {
        mIsUsingCallFiltering = isUsingCallFiltering;
    }

    /**
     * Update the {@link CallIdentification} for a call.
     * @param callIdentification the {@link CallIdentification}.
     */
    public void setCallIdentification(CallIdentification callIdentification) {
        if (callIdentification != null) {
            Log.addEvent(this, LogUtils.Events.CALL_IDENTIFICATION_SET,
                    callIdentification.getCallScreeningPackageName());
        }
        mCallIdentification = callIdentification;

        for (Listener l : mListeners) {
            l.onCallIdentificationChanged(this);
        }
    }

    /**
     * @return Call identification returned by a {@link android.telecom.CallScreeningService}.
     */
    public CallIdentification getCallIdentification() {
        return mCallIdentification;
    }
}
+16 −10
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Looper;
import android.os.UserHandle;
import android.os.PersistableBundle;
import android.provider.CallLog.Calls;
import android.telecom.CallIdentification;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
import android.telecom.Log;
@@ -42,12 +43,8 @@ import com.android.internal.telephony.CallerInfo;
import com.android.server.telecom.callfiltering.CallFilteringResult;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
@@ -85,7 +82,8 @@ public final class CallLogManager extends CallsManagerListenerBase {
                int features, PhoneAccountHandle accountHandle, long creationDate,
                long durationInMillis, Long dataUsage, UserHandle initiatingUser, boolean isRead,
                @Nullable LogCallCompletedListener logCallCompletedListener, int callBlockReason,
                String callScreeningAppName, String callScreeningComponentName) {
                String callScreeningAppName, String callScreeningComponentName,
                CallIdentification callIdentification) {
            this.context = context;
            this.callerInfo = callerInfo;
            this.number = number;
@@ -104,6 +102,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
            this.callBockReason = callBlockReason;
            this.callScreeningAppName = callScreeningAppName;
            this.callScreeningComponentName = callScreeningComponentName;
            this.callIdentification = callIdentification;
        }
        // Since the members are accessed directly, we don't use the
        // mXxxx notation.
@@ -128,6 +127,8 @@ public final class CallLogManager extends CallsManagerListenerBase {
        public final int callBockReason;
        public final String callScreeningAppName;
        public final String callScreeningComponentName;

        public final CallIdentification callIdentification;
    }

    private static final String TAG = CallLogManager.class.getSimpleName();
@@ -256,20 +257,22 @@ public final class CallLogManager extends CallsManagerListenerBase {
                        Connection.PROPERTY_ASSISTED_DIALING_USED,
                call.wasEverRttCall());

        CallIdentification callIdentification = call.getCallIdentification();

        if (callLogType == Calls.BLOCKED_TYPE) {
            logCall(call.getCallerInfo(), logNumber, call.getPostDialDigits(), formattedViaNumber,
                    call.getHandlePresentation(), callLogType, callFeatures, accountHandle,
                    creationTime, age, callDataUsage, call.isEmergencyCall(),
                    call.getInitiatingUser(), call.isSelfManaged(), logCallCompletedListener,
                    result.mCallBlockReason, result.mCallScreeningAppName,
                    result.mCallScreeningComponentName);
                    result.mCallScreeningComponentName, callIdentification);
        } else {
            logCall(call.getCallerInfo(), logNumber, call.getPostDialDigits(), formattedViaNumber,
                    call.getHandlePresentation(), callLogType, callFeatures, accountHandle,
                    creationTime, age, callDataUsage, call.isEmergencyCall(),
                    call.getInitiatingUser(), call.isSelfManaged(), logCallCompletedListener,
                    Calls.BLOCK_REASON_NOT_BLOCKED, null /*callScreeningAppName*/,
                    null /*callScreeningComponentName*/);
                    null /*callScreeningComponentName*/, callIdentification);
        }
    }

@@ -293,6 +296,8 @@ public final class CallLogManager extends CallsManagerListenerBase {
     * @param callBlockReason The reason why the call is blocked.
     * @param callScreeningAppName The call screening application name which block the call.
     * @param callScreeningComponentName The call screening component name which block the call.
     * @param callIdentification Call identification information, if provided by a call screening
     *                           service.
     */
    private void logCall(
            CallerInfo callerInfo,
@@ -312,7 +317,8 @@ public final class CallLogManager extends CallsManagerListenerBase {
            @Nullable LogCallCompletedListener logCallCompletedListener,
            int callBlockReason,
            String callScreeningAppName,
            String callScreeningComponentName) {
            String callScreeningComponentName,
            @Nullable CallIdentification callIdentification) {

        // On some devices, to avoid accidental redialing of emergency numbers, we *never* log
        // emergency calls to the Call Log.  (This behavior is set on a per-product basis, based
@@ -346,7 +352,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
            AddCallArgs args = new AddCallArgs(mContext, callerInfo, number, postDialDigits,
                    viaNumber, presentation, callType, features, accountHandle, start, duration,
                    dataUsage, initiatingUser, isRead, logCallCompletedListener, callBlockReason,
                    callScreeningAppName, callScreeningComponentName);
                    callScreeningAppName, callScreeningComponentName, callIdentification);
            logCallAsync(args);
        } else {
          Log.d(TAG, "Not adding emergency call to call log.");
@@ -508,7 +514,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
                    c.presentation, c.callType, c.features, c.accountHandle, c.timestamp,
                    c.durationInSec, c.dataUsage, userToBeInserted == null,
                    userToBeInserted, c.isRead, c.callBockReason, c.callScreeningAppName,
                    c.callScreeningComponentName);
                    c.callScreeningComponentName, c.callIdentification);
        }


+5 −0
Original line number Diff line number Diff line
@@ -696,6 +696,11 @@ public class InCallController extends CallsManagerListenerBase {
        public void onRemoteRttRequest(Call call, int requestId) {
            notifyRemoteRttRequest(call, requestId);
        }

        @Override
        public void onCallIdentificationChanged(Call call) {
            updateCall(call);
        }
    };

    private final SystemStateListener mSystemStateListener = new SystemStateListener() {
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class LogUtils {
        public static final String CONTROLLER_SCREENING_COMPLETED =
                "CONTROLLER_SCREENING_COMPLETED";
        public static final String SCREENING_COMPLETED = "SCREENING_COMPLETED";
        public static final String CALL_IDENTIFICATION_SET = "CALL_IDENTIFICATION_SET";
        public static final String BLOCK_CHECK_INITIATED = "BLOCK_CHECK_INITIATED";
        public static final String BLOCK_CHECK_FINISHED = "BLOCK_CHECK_FINISHED";
        public static final String DIRECT_TO_VM_INITIATED = "DIRECT_TO_VM_INITIATED";
Loading