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

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

Add CallerIdentification to CallScreeningService API.

Updating the CallScreeningService to support passing call identification
information for incoming/outgoing calls.
Updating call log to log call identification information.

Bug: 63966743
Test: Manual with test app.
Merged-In: Ie6c172c09007eb5f4853d36ae0a99b782bfb5ddb
Change-Id: Ie6c172c09007eb5f4853d36ae0a99b782bfb5ddb
parent 69969240
Loading
Loading
Loading
Loading
+36 −2
Original line number Original line Diff line number Diff line
@@ -35176,6 +35176,12 @@ package android.provider {
    field public static final java.lang.String CACHED_NUMBER_TYPE = "numbertype";
    field public static final java.lang.String CACHED_NUMBER_TYPE = "numbertype";
    field public static final java.lang.String CACHED_PHOTO_ID = "photo_id";
    field public static final java.lang.String CACHED_PHOTO_ID = "photo_id";
    field public static final java.lang.String CACHED_PHOTO_URI = "photo_uri";
    field public static final java.lang.String CACHED_PHOTO_URI = "photo_uri";
    field public static final java.lang.String CALL_ID_APP_NAME = "call_id_app_name";
    field public static final java.lang.String CALL_ID_DESCRIPTION = "call_id_description";
    field public static final java.lang.String CALL_ID_DETAILS = "call_id_details";
    field public static final java.lang.String CALL_ID_NAME = "call_id_name";
    field public static final java.lang.String CALL_ID_NUISANCE_CONFIDENCE = "call_id_nuisance_confidence";
    field public static final java.lang.String CALL_ID_PACKAGE_NAME = "call_id_package_name";
    field public static final java.lang.String CALL_SCREENING_APP_NAME = "call_screening_app_name";
    field public static final java.lang.String CALL_SCREENING_APP_NAME = "call_screening_app_name";
    field public static final java.lang.String CALL_SCREENING_COMPONENT_NAME = "call_screening_component_name";
    field public static final java.lang.String CALL_SCREENING_COMPONENT_NAME = "call_screening_component_name";
    field public static final android.net.Uri CONTENT_FILTER_URI;
    field public static final android.net.Uri CONTENT_FILTER_URI;
@@ -41177,6 +41183,7 @@ package android.telecom {
    method public static java.lang.String capabilitiesToString(int);
    method public static java.lang.String capabilitiesToString(int);
    method public android.telecom.PhoneAccountHandle getAccountHandle();
    method public android.telecom.PhoneAccountHandle getAccountHandle();
    method public int getCallCapabilities();
    method public int getCallCapabilities();
    method public android.telecom.CallIdentification getCallIdentification();
    method public int getCallProperties();
    method public int getCallProperties();
    method public java.lang.String getCallerDisplayName();
    method public java.lang.String getCallerDisplayName();
    method public int getCallerDisplayNamePresentation();
    method public int getCallerDisplayNamePresentation();
@@ -41255,6 +41262,34 @@ package android.telecom {
    field public static final int ROUTE_WIRED_OR_EARPIECE = 5; // 0x5
    field public static final int ROUTE_WIRED_OR_EARPIECE = 5; // 0x5
  }
  }
  public final class CallIdentification implements android.os.Parcelable {
    method public int describeContents();
    method public java.lang.String getCallScreeningAppName();
    method public java.lang.String getCallScreeningPackageName();
    method public java.lang.String getDescription();
    method public java.lang.String getDetails();
    method public java.lang.String getName();
    method public int getNuisanceConfidence();
    method public android.graphics.drawable.Icon getPhoto();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CONFIDENCE_LIKELY_NOT_NUISANCE = -1; // 0xffffffff
    field public static final int CONFIDENCE_LIKELY_NUISANCE = 1; // 0x1
    field public static final int CONFIDENCE_NOT_NUISANCE = -2; // 0xfffffffe
    field public static final int CONFIDENCE_NUISANCE = 2; // 0x2
    field public static final int CONFIDENCE_UNKNOWN = 0; // 0x0
    field public static final android.os.Parcelable.Creator<android.telecom.CallIdentification> CREATOR;
  }
  public static class CallIdentification.Builder {
    ctor public CallIdentification.Builder();
    method public android.telecom.CallIdentification build();
    method public android.telecom.CallIdentification.Builder setDescription(java.lang.String);
    method public android.telecom.CallIdentification.Builder setDetails(java.lang.String);
    method public android.telecom.CallIdentification.Builder setName(java.lang.String);
    method public android.telecom.CallIdentification.Builder setNuisanceConfidence(int);
    method public android.telecom.CallIdentification.Builder setPhoto(android.graphics.drawable.Icon);
  }
  public abstract class CallRedirectionService extends android.app.Service {
  public abstract class CallRedirectionService extends android.app.Service {
    ctor public CallRedirectionService();
    ctor public CallRedirectionService();
    method public final void cancelCall();
    method public final void cancelCall();
@@ -41270,6 +41305,7 @@ package android.telecom {
    ctor public CallScreeningService();
    ctor public CallScreeningService();
    method public android.os.IBinder onBind(android.content.Intent);
    method public android.os.IBinder onBind(android.content.Intent);
    method public abstract void onScreenCall(android.telecom.Call.Details);
    method public abstract void onScreenCall(android.telecom.Call.Details);
    method public final void provideCallIdentification(android.telecom.Call.Details, android.telecom.CallIdentification);
    method public final void respondToCall(android.telecom.Call.Details, android.telecom.CallScreeningService.CallResponse);
    method public final void respondToCall(android.telecom.Call.Details, android.telecom.CallScreeningService.CallResponse);
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.CallScreeningService";
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.CallScreeningService";
  }
  }
@@ -41864,7 +41900,6 @@ package android.telecom {
    method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
    method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
    method public boolean handleMmi(java.lang.String);
    method public boolean handleMmi(java.lang.String);
    method public boolean handleMmi(java.lang.String, android.telecom.PhoneAccountHandle);
    method public boolean handleMmi(java.lang.String, android.telecom.PhoneAccountHandle);
    method public boolean isDefaultCallScreeningApp(android.content.ComponentName);
    method public boolean isInCall();
    method public boolean isInCall();
    method public boolean isInManagedCall();
    method public boolean isInManagedCall();
    method public boolean isIncomingCallPermitted(android.telecom.PhoneAccountHandle);
    method public boolean isIncomingCallPermitted(android.telecom.PhoneAccountHandle);
@@ -41873,7 +41908,6 @@ package android.telecom {
    method public boolean isVoiceMailNumber(android.telecom.PhoneAccountHandle, java.lang.String);
    method public boolean isVoiceMailNumber(android.telecom.PhoneAccountHandle, java.lang.String);
    method public void placeCall(android.net.Uri, android.os.Bundle);
    method public void placeCall(android.net.Uri, android.os.Bundle);
    method public void registerPhoneAccount(android.telecom.PhoneAccount);
    method public void registerPhoneAccount(android.telecom.PhoneAccount);
    method public void requestChangeDefaultCallScreeningApp(android.content.ComponentName);
    method public void showInCallScreen(boolean);
    method public void showInCallScreen(boolean);
    method public void silenceRinger();
    method public void silenceRinger();
    method public void unregisterPhoneAccount(android.telecom.PhoneAccountHandle);
    method public void unregisterPhoneAccount(android.telecom.PhoneAccountHandle);
+1 −1
Original line number Original line Diff line number Diff line
@@ -5035,7 +5035,7 @@ package android.telecom {
    method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
    method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
    method public boolean isInEmergencyCall();
    method public boolean isInEmergencyCall();
    method public boolean isRinging();
    method public boolean isRinging();
    method public boolean setDefaultDialer(java.lang.String);
    method public deprecated boolean setDefaultDialer(java.lang.String);
    field public static final java.lang.String EXTRA_CALL_BACK_INTENT = "android.telecom.extra.CALL_BACK_INTENT";
    field public static final java.lang.String EXTRA_CALL_BACK_INTENT = "android.telecom.extra.CALL_BACK_INTENT";
    field public static final java.lang.String EXTRA_CLEAR_MISSED_CALLS_INTENT = "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT";
    field public static final java.lang.String EXTRA_CLEAR_MISSED_CALLS_INTENT = "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT";
    field public static final java.lang.String EXTRA_CONNECTION_SERVICE = "android.telecom.extra.CONNECTION_SERVICE";
    field public static final java.lang.String EXTRA_CONNECTION_SERVICE = "android.telecom.extra.CONNECTION_SERVICE";
+100 −4
Original line number Original line Diff line number Diff line
@@ -28,12 +28,14 @@ import android.database.Cursor;
import android.location.Country;
import android.location.Country;
import android.location.CountryDetector;
import android.location.CountryDetector;
import android.net.Uri;
import android.net.Uri;
import android.os.Build;
import android.os.UserHandle;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.provider.ContactsContract.CommonDataKinds.Callable;
import android.provider.ContactsContract.CommonDataKinds.Callable;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.DataUsageFeedback;
import android.provider.ContactsContract.DataUsageFeedback;
import android.telecom.CallIdentification;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.TelecomManager;
@@ -602,6 +604,69 @@ public class CallLog {
         */
         */
        public static final String BLOCK_REASON = "block_reason";
        public static final String BLOCK_REASON = "block_reason";


        /**
         * The package name of the {@link android.telecom.CallScreeningService} which provided
         * {@link android.telecom.CallIdentification} for this call.
         * <P>Type: TEXT</P>
         */
        public static final String CALL_ID_PACKAGE_NAME = "call_id_package_name";

        /**
         * The app name of the {@link android.telecom.CallScreeningService} which provided
         * {@link android.telecom.CallIdentification} for this call.
         * <P>Type: TEXT</P>
         */
        public static final String CALL_ID_APP_NAME = "call_id_app_name";

        /**
         * The {@link CallIdentification#getName() name} of a call, as provided by the
         * {@link android.telecom.CallScreeningService}.
         * <p>
         * The name is provided by the app identified by {@link #CALL_ID_PACKAGE_NAME} and
         * {@link #CALL_ID_APP_NAME}.
         * <P>Type: TEXT</P>
         */
        public static final String CALL_ID_NAME = "call_id_name";

        /**
         * The {@link CallIdentification#getDescription() description} of a call, as provided by the
         * {@link android.telecom.CallScreeningService}.
         * <p>
         * The description is provided by the app identified by {@link #CALL_ID_PACKAGE_NAME} and
         * {@link #CALL_ID_APP_NAME}.
         * <P>Type: TEXT</P>
         */
        public static final String CALL_ID_DESCRIPTION = "call_id_description";

        /**
         * The {@link CallIdentification#getDetails() details} of a call, as provided by the
         * {@link android.telecom.CallScreeningService}.
         * <p>
         * The details field is provided by the app identified by {@link #CALL_ID_PACKAGE_NAME} and
         * {@link #CALL_ID_APP_NAME}.
         * <P>Type: TEXT</P>
         */
        public static final String CALL_ID_DETAILS = "call_id_details";

        /**
         * The {@link CallIdentification#getNuisanceConfidence() nuisance confidence} of a call, as
         * provided by the {@link android.telecom.CallScreeningService}.
         * <p>
         * Valid values are defined in {@link CallIdentification}, and include:
         * <ul>
         *     <li>{@link CallIdentification#CONFIDENCE_NOT_NUISANCE}</li>
         *     <li>{@link CallIdentification#CONFIDENCE_LIKELY_NOT_NUISANCE}</li>
         *     <li>{@link CallIdentification#CONFIDENCE_UNKNOWN}</li>
         *     <li>{@link CallIdentification#CONFIDENCE_LIKELY_NUISANCE}</li>
         *     <li>{@link CallIdentification#CONFIDENCE_NUISANCE}</li>
         * </ul>
         * <p>
         * The nuisance confidence is provided by the app identified by
         * {@link #CALL_ID_PACKAGE_NAME} and {@link #CALL_ID_APP_NAME}.
         * <P>Type: INTEGER</P>
         */
        public static final String CALL_ID_NUISANCE_CONFIDENCE = "call_id_nuisance_confidence";

        /**
        /**
         * Adds a call to the call log.
         * Adds a call to the call log.
         *
         *
@@ -631,7 +696,8 @@ public class CallLog {
                presentation, callType, features, accountHandle, start, duration,
                presentation, callType, features, accountHandle, start, duration,
                dataUsage, false /* addForAllUsers */, null /* userToBeInsertedTo */,
                dataUsage, false /* addForAllUsers */, null /* userToBeInsertedTo */,
                false /* isRead */, Calls.BLOCK_REASON_NOT_BLOCKED /* callBlockReason */,
                false /* isRead */, Calls.BLOCK_REASON_NOT_BLOCKED /* callBlockReason */,
                null /* callScreeningAppName */, null /* callScreeningComponentName */);
                null /* callScreeningAppName */, null /* callScreeningComponentName */,
                null /* callIdentification */);
        }
        }




@@ -671,7 +737,8 @@ public class CallLog {
                features, accountHandle, start, duration, dataUsage, addForAllUsers,
                features, accountHandle, start, duration, dataUsage, addForAllUsers,
                userToBeInsertedTo, false /* isRead */ , Calls.BLOCK_REASON_NOT_BLOCKED
                userToBeInsertedTo, false /* isRead */ , Calls.BLOCK_REASON_NOT_BLOCKED
                /* callBlockReason */, null /* callScreeningAppName */,
                /* callBlockReason */, null /* callScreeningAppName */,
                null /* callScreeningComponentName */);
                null /* callScreeningComponentName */,
                null /* callIdentification */);
        }
        }


        /**
        /**
@@ -705,19 +772,32 @@ public class CallLog {
         * @param callBlockReason The reason why the call is blocked.
         * @param callBlockReason The reason why the call is blocked.
         * @param callScreeningAppName The call screening application name which block the call.
         * @param callScreeningAppName The call screening application name which block the call.
         * @param callScreeningComponentName The call screening component name which block the call.
         * @param callScreeningComponentName The call screening component name which block the call.
         * @param callIdPackageName The package name of the
         *      {@link android.telecom.CallScreeningService} which provided
         *      {@link CallIdentification}.
         * @param callIdAppName The app name of the {@link android.telecom.CallScreeningService}
         *                      which provided {@link CallIdentification}.
         * @param callIdName The caller name provided by the
         *      {@link android.telecom.CallScreeningService}.
         * @param callIdDescription The caller description provided by the
         *      {@link android.telecom.CallScreeningService}.
         * @param callIdDetails The caller details provided by the
         *      {@link android.telecom.CallScreeningService}.
         * @param callIdCallType The caller type provided by the
         *      {@link android.telecom.CallScreeningService}.
         *
         *
         * @result The URI of the call log entry belonging to the user that made or received this
         * @result The URI of the call log entry belonging to the user that made or received this
         *        call.  This could be of the shadow provider.  Do not return it to non-system apps,
         *        call.  This could be of the shadow provider.  Do not return it to non-system apps,
         *        as they don't have permissions.
         *        as they don't have permissions.
         * {@hide}
         * {@hide}
         */
         */
        @UnsupportedAppUsage
        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
        public static Uri addCall(CallerInfo ci, Context context, String number,
        public static Uri addCall(CallerInfo ci, Context context, String number,
                String postDialDigits, String viaNumber, int presentation, int callType,
                String postDialDigits, String viaNumber, int presentation, int callType,
                int features, PhoneAccountHandle accountHandle, long start, int duration,
                int features, PhoneAccountHandle accountHandle, long start, int duration,
                Long dataUsage, boolean addForAllUsers, UserHandle userToBeInsertedTo,
                Long dataUsage, boolean addForAllUsers, UserHandle userToBeInsertedTo,
                boolean isRead, int callBlockReason, String callScreeningAppName,
                boolean isRead, int callBlockReason, String callScreeningAppName,
                String callScreeningComponentName) {
                String callScreeningComponentName, CallIdentification callIdentification) {
            if (VERBOSE_LOG) {
            if (VERBOSE_LOG) {
                Log.v(LOG_TAG, String.format("Add call: number=%s, user=%s, for all=%s",
                Log.v(LOG_TAG, String.format("Add call: number=%s, user=%s, for all=%s",
                        number, userToBeInsertedTo, addForAllUsers));
                        number, userToBeInsertedTo, addForAllUsers));
@@ -799,6 +879,22 @@ public class CallLog {
            values.put(CALL_SCREENING_APP_NAME, callScreeningAppName);
            values.put(CALL_SCREENING_APP_NAME, callScreeningAppName);
            values.put(CALL_SCREENING_COMPONENT_NAME, callScreeningComponentName);
            values.put(CALL_SCREENING_COMPONENT_NAME, callScreeningComponentName);


            if (callIdentification != null) {
                values.put(CALL_ID_PACKAGE_NAME, callIdentification.getCallScreeningPackageName());
                values.put(CALL_ID_APP_NAME, callIdentification.getCallScreeningAppName());
                values.put(CALL_ID_NAME, callIdentification.getName());
                values.put(CALL_ID_DESCRIPTION, callIdentification.getDescription());
                values.put(CALL_ID_DETAILS, callIdentification.getDetails());
                values.put(CALL_ID_NUISANCE_CONFIDENCE, callIdentification.getNuisanceConfidence());
            } else {
                values.putNull(CALL_ID_PACKAGE_NAME);
                values.putNull(CALL_ID_APP_NAME);
                values.putNull(CALL_ID_NAME);
                values.putNull(CALL_ID_DESCRIPTION);
                values.putNull(CALL_ID_DETAILS);
                values.putNull(CALL_ID_NUISANCE_CONFIDENCE);
            }

            if ((ci != null) && (ci.contactIdOrZero > 0)) {
            if ((ci != null) && (ci.contactIdOrZero > 0)) {
                // Update usage information for the number associated with the contact ID.
                // Update usage information for the number associated with the contact ID.
                // We need to use both the number and the ID for obtaining a data ID since other
                // We need to use both the number and the ID for obtaining a data ID since other
+33 −4
Original line number Original line Diff line number Diff line
@@ -518,6 +518,7 @@ public final class Call {
        private final Bundle mExtras;
        private final Bundle mExtras;
        private final Bundle mIntentExtras;
        private final Bundle mIntentExtras;
        private final long mCreationTimeMillis;
        private final long mCreationTimeMillis;
        private final CallIdentification mCallIdentification;


        /**
        /**
         * Whether the supplied capabilities  supports the specified capability.
         * Whether the supplied capabilities  supports the specified capability.
@@ -699,6 +700,12 @@ public final class Call {
        }
        }


        /**
        /**
         * The display name for the caller.
         * <p>
         * This is the name as reported by the {@link ConnectionService} associated with this call.
         * The name reported by a {@link CallScreeningService} can be retrieved using
         * {@link CallIdentification#getName()}.
         *
         * @return The display name for the caller.
         * @return The display name for the caller.
         */
         */
        public String getCallerDisplayName() {
        public String getCallerDisplayName() {
@@ -814,6 +821,23 @@ public final class Call {
            return mCreationTimeMillis;
            return mCreationTimeMillis;
        }
        }


        /**
         * Returns {@link CallIdentification} information provided by a
         * {@link CallScreeningService} for this call.
         * <p>
         * {@link InCallService} implementations should display the {@link CallIdentification} for
         * calls.  The name of the call screening service is provided in
         * {@link CallIdentification#getCallScreeningAppName()} and should be used to attribute the
         * call identification information.
         *
         * @return The {@link CallIdentification} if it was provided by a
         * {@link CallScreeningService}, or {@code null} if no {@link CallScreeningService} has
         * provided {@link CallIdentification} information for the call.
         */
        public @Nullable CallIdentification getCallIdentification() {
            return mCallIdentification;
        }

        @Override
        @Override
        public boolean equals(Object o) {
        public boolean equals(Object o) {
            if (o instanceof Details) {
            if (o instanceof Details) {
@@ -834,7 +858,8 @@ public final class Call {
                        Objects.equals(mStatusHints, d.mStatusHints) &&
                        Objects.equals(mStatusHints, d.mStatusHints) &&
                        areBundlesEqual(mExtras, d.mExtras) &&
                        areBundlesEqual(mExtras, d.mExtras) &&
                        areBundlesEqual(mIntentExtras, d.mIntentExtras) &&
                        areBundlesEqual(mIntentExtras, d.mIntentExtras) &&
                        Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis);
                        Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis) &&
                        Objects.equals(mCallIdentification, d.mCallIdentification);
            }
            }
            return false;
            return false;
        }
        }
@@ -855,7 +880,8 @@ public final class Call {
                            mStatusHints,
                            mStatusHints,
                            mExtras,
                            mExtras,
                            mIntentExtras,
                            mIntentExtras,
                            mCreationTimeMillis);
                            mCreationTimeMillis,
                            mCallIdentification);
        }
        }


        /** {@hide} */
        /** {@hide} */
@@ -875,7 +901,8 @@ public final class Call {
                StatusHints statusHints,
                StatusHints statusHints,
                Bundle extras,
                Bundle extras,
                Bundle intentExtras,
                Bundle intentExtras,
                long creationTimeMillis) {
                long creationTimeMillis,
                CallIdentification callIdentification) {
            mTelecomCallId = telecomCallId;
            mTelecomCallId = telecomCallId;
            mHandle = handle;
            mHandle = handle;
            mHandlePresentation = handlePresentation;
            mHandlePresentation = handlePresentation;
@@ -892,6 +919,7 @@ public final class Call {
            mExtras = extras;
            mExtras = extras;
            mIntentExtras = intentExtras;
            mIntentExtras = intentExtras;
            mCreationTimeMillis = creationTimeMillis;
            mCreationTimeMillis = creationTimeMillis;
            mCallIdentification = callIdentification;
        }
        }


        /** {@hide} */
        /** {@hide} */
@@ -912,7 +940,8 @@ public final class Call {
                    parcelableCall.getStatusHints(),
                    parcelableCall.getStatusHints(),
                    parcelableCall.getExtras(),
                    parcelableCall.getExtras(),
                    parcelableCall.getIntentExtras(),
                    parcelableCall.getIntentExtras(),
                    parcelableCall.getCreationTimeMillis());
                    parcelableCall.getCreationTimeMillis(),
                    parcelableCall.getCallIdentification());
        }
        }


        @Override
        @Override
+22 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2018, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telecom;

/**
 * {@hide}
 */
parcelable CallIdentification;
Loading