Merge "Add CallerIdentification to CallScreeningService API."
This commit is contained in:
@@ -35184,6 +35184,12 @@ package android.provider {
|
||||
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_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_COMPONENT_NAME = "call_screening_component_name";
|
||||
field public static final android.net.Uri CONTENT_FILTER_URI;
|
||||
@@ -41185,6 +41191,7 @@ package android.telecom {
|
||||
method public static java.lang.String capabilitiesToString(int);
|
||||
method public android.telecom.PhoneAccountHandle getAccountHandle();
|
||||
method public int getCallCapabilities();
|
||||
method public android.telecom.CallIdentification getCallIdentification();
|
||||
method public int getCallProperties();
|
||||
method public java.lang.String getCallerDisplayName();
|
||||
method public int getCallerDisplayNamePresentation();
|
||||
@@ -41263,6 +41270,34 @@ package android.telecom {
|
||||
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 {
|
||||
ctor public CallRedirectionService();
|
||||
method public final void cancelCall();
|
||||
@@ -41278,6 +41313,7 @@ package android.telecom {
|
||||
ctor public CallScreeningService();
|
||||
method public android.os.IBinder onBind(android.content.Intent);
|
||||
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);
|
||||
field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.CallScreeningService";
|
||||
}
|
||||
@@ -41875,7 +41911,6 @@ package android.telecom {
|
||||
method public java.lang.String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
|
||||
method public boolean handleMmi(java.lang.String);
|
||||
method public boolean handleMmi(java.lang.String, android.telecom.PhoneAccountHandle);
|
||||
method public boolean isDefaultCallScreeningApp(android.content.ComponentName);
|
||||
method public boolean isInCall();
|
||||
method public boolean isInManagedCall();
|
||||
method public boolean isIncomingCallPermitted(android.telecom.PhoneAccountHandle);
|
||||
@@ -41884,7 +41919,6 @@ package android.telecom {
|
||||
method public boolean isVoiceMailNumber(android.telecom.PhoneAccountHandle, java.lang.String);
|
||||
method public void placeCall(android.net.Uri, android.os.Bundle);
|
||||
method public void registerPhoneAccount(android.telecom.PhoneAccount);
|
||||
method public void requestChangeDefaultCallScreeningApp(android.content.ComponentName);
|
||||
method public void showInCallScreen(boolean);
|
||||
method public void silenceRinger();
|
||||
method public void unregisterPhoneAccount(android.telecom.PhoneAccountHandle);
|
||||
|
||||
@@ -5052,7 +5052,7 @@ package android.telecom {
|
||||
method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
|
||||
method public boolean isInEmergencyCall();
|
||||
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_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";
|
||||
|
||||
@@ -28,12 +28,14 @@ import android.database.Cursor;
|
||||
import android.location.Country;
|
||||
import android.location.CountryDetector;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.ContactsContract.CommonDataKinds.Callable;
|
||||
import android.provider.ContactsContract.CommonDataKinds.Phone;
|
||||
import android.provider.ContactsContract.Data;
|
||||
import android.provider.ContactsContract.DataUsageFeedback;
|
||||
import android.telecom.CallIdentification;
|
||||
import android.telecom.PhoneAccount;
|
||||
import android.telecom.PhoneAccountHandle;
|
||||
import android.telecom.TelecomManager;
|
||||
@@ -602,6 +604,69 @@ public class CallLog {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@@ -631,7 +696,8 @@ public class CallLog {
|
||||
presentation, callType, features, accountHandle, start, duration,
|
||||
dataUsage, false /* addForAllUsers */, null /* userToBeInsertedTo */,
|
||||
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,
|
||||
userToBeInsertedTo, false /* isRead */ , Calls.BLOCK_REASON_NOT_BLOCKED
|
||||
/* 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 callScreeningAppName The call screening application 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
|
||||
* call. This could be of the shadow provider. Do not return it to non-system apps,
|
||||
* as they don't have permissions.
|
||||
* {@hide}
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public static Uri addCall(CallerInfo ci, Context context, String number,
|
||||
String postDialDigits, String viaNumber, int presentation, int callType,
|
||||
int features, PhoneAccountHandle accountHandle, long start, int duration,
|
||||
Long dataUsage, boolean addForAllUsers, UserHandle userToBeInsertedTo,
|
||||
boolean isRead, int callBlockReason, String callScreeningAppName,
|
||||
String callScreeningComponentName) {
|
||||
String callScreeningComponentName, CallIdentification callIdentification) {
|
||||
if (VERBOSE_LOG) {
|
||||
Log.v(LOG_TAG, String.format("Add call: number=%s, user=%s, for all=%s",
|
||||
number, userToBeInsertedTo, addForAllUsers));
|
||||
@@ -799,6 +879,22 @@ public class CallLog {
|
||||
values.put(CALL_SCREENING_APP_NAME, callScreeningAppName);
|
||||
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)) {
|
||||
// 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
|
||||
|
||||
@@ -518,6 +518,7 @@ public final class Call {
|
||||
private final Bundle mExtras;
|
||||
private final Bundle mIntentExtras;
|
||||
private final long mCreationTimeMillis;
|
||||
private final CallIdentification mCallIdentification;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public String getCallerDisplayName() {
|
||||
@@ -814,6 +821,23 @@ public final class Call {
|
||||
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
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Details) {
|
||||
@@ -834,7 +858,8 @@ public final class Call {
|
||||
Objects.equals(mStatusHints, d.mStatusHints) &&
|
||||
areBundlesEqual(mExtras, d.mExtras) &&
|
||||
areBundlesEqual(mIntentExtras, d.mIntentExtras) &&
|
||||
Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis);
|
||||
Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis) &&
|
||||
Objects.equals(mCallIdentification, d.mCallIdentification);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -855,7 +880,8 @@ public final class Call {
|
||||
mStatusHints,
|
||||
mExtras,
|
||||
mIntentExtras,
|
||||
mCreationTimeMillis);
|
||||
mCreationTimeMillis,
|
||||
mCallIdentification);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@@ -875,7 +901,8 @@ public final class Call {
|
||||
StatusHints statusHints,
|
||||
Bundle extras,
|
||||
Bundle intentExtras,
|
||||
long creationTimeMillis) {
|
||||
long creationTimeMillis,
|
||||
CallIdentification callIdentification) {
|
||||
mTelecomCallId = telecomCallId;
|
||||
mHandle = handle;
|
||||
mHandlePresentation = handlePresentation;
|
||||
@@ -892,6 +919,7 @@ public final class Call {
|
||||
mExtras = extras;
|
||||
mIntentExtras = intentExtras;
|
||||
mCreationTimeMillis = creationTimeMillis;
|
||||
mCallIdentification = callIdentification;
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@@ -912,7 +940,8 @@ public final class Call {
|
||||
parcelableCall.getStatusHints(),
|
||||
parcelableCall.getExtras(),
|
||||
parcelableCall.getIntentExtras(),
|
||||
parcelableCall.getCreationTimeMillis());
|
||||
parcelableCall.getCreationTimeMillis(),
|
||||
parcelableCall.getCallIdentification());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
22
telecomm/java/android/telecom/CallIdentification.aidl
Normal file
22
telecomm/java/android/telecom/CallIdentification.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
433
telecomm/java/android/telecom/CallIdentification.java
Normal file
433
telecomm/java/android/telecom/CallIdentification.java
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
* Copyright (C) 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;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Encapsulates information about an incoming or outgoing {@link Call} provided by a
|
||||
* {@link CallScreeningService}.
|
||||
* <p>
|
||||
* Call identified information is consumed by the {@link InCallService dialer} app to provide the
|
||||
* user with more information about a call. This can include information such as the name of the
|
||||
* caller, address, etc. Call identification information is persisted to the
|
||||
* {@link android.provider.CallLog}.
|
||||
*/
|
||||
public final class CallIdentification implements Parcelable {
|
||||
/**
|
||||
* Builder for {@link CallIdentification} instances.
|
||||
* <p>
|
||||
* A {@link CallScreeningService} uses this class to create new instances of
|
||||
* {@link CallIdentification} for a screened call.
|
||||
*/
|
||||
public static class Builder {
|
||||
private String mName;
|
||||
private String mDescription;
|
||||
private String mDetails;
|
||||
private Icon mPhoto;
|
||||
private int mNuisanceConfidence = CallIdentification.CONFIDENCE_UNKNOWN;
|
||||
private String mPackageName;
|
||||
private String mAppName;
|
||||
|
||||
/**
|
||||
* Default builder constructor.
|
||||
*/
|
||||
public Builder() {
|
||||
// Default constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Create instance of call identification with specified package/app name.
|
||||
*
|
||||
* @param callIdPackageName The package name.
|
||||
* @param callIdAppName The app name.
|
||||
* @hide
|
||||
*/
|
||||
public Builder(String callIdPackageName, String callIdAppName) {
|
||||
mPackageName = callIdPackageName;
|
||||
mAppName = callIdAppName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name associated with the {@link CallIdentification} being built.
|
||||
* <p>
|
||||
* Could be a business name, for example.
|
||||
*
|
||||
* @param name The name associated with the call, or {@code null} if none is provided.
|
||||
* @return Builder instance.
|
||||
*/
|
||||
public Builder setName(@Nullable String name) {
|
||||
mName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description associated with the {@link CallIdentification} being built.
|
||||
* <p>
|
||||
* A description of the call as identified by a {@link CallScreeningService}. The
|
||||
* description is typically presented by Dialer apps after the
|
||||
* {@link CallIdentification#getName() name} to provide a short piece of relevant
|
||||
* information about the call. This could include a location, address, or a message
|
||||
* regarding the potential nature of the call (e.g. potential telemarketer).
|
||||
*
|
||||
* @param description The call description, or {@code null} if none is provided.
|
||||
* @return Builder instance.
|
||||
*/
|
||||
public Builder setDescription(@Nullable String description) {
|
||||
mDescription = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the details associated with the {@link CallIdentification} being built.
|
||||
* <p>
|
||||
* The details is typically presented by Dialer apps after the
|
||||
* {@link CallIdentification#getName() name} and
|
||||
* {@link CallIdentification#getDescription() description} to provide further clarifying
|
||||
* information about the call. This could include, for example, the opening hours of a
|
||||
* business, or a stats about the number of times a call has been reported as spam.
|
||||
*
|
||||
* @param details The call details, or {@code null} if none is provided.
|
||||
* @return Builder instance.
|
||||
*/
|
||||
public Builder setDetails(@Nullable String details) {
|
||||
mDetails = details;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the photo associated with the {@link CallIdentification} being built.
|
||||
* <p>
|
||||
* This could be, for example, a business logo, or a photo of the caller.
|
||||
*
|
||||
* @param photo The photo associated with the call, or {@code null} if none was provided.
|
||||
* @return Builder instance.
|
||||
*/
|
||||
public Builder setPhoto(@Nullable Icon photo) {
|
||||
mPhoto = photo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the nuisance confidence with the {@link CallIdentification} being built.
|
||||
* <p>
|
||||
* This can be used to specify how confident the {@link CallScreeningService} is that a call
|
||||
* is or is not a nuisance call.
|
||||
*
|
||||
* @param nuisanceConfidence The nuisance confidence.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setNuisanceConfidence(@NuisanceConfidence int nuisanceConfidence) {
|
||||
mNuisanceConfidence = nuisanceConfidence;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link CallIdentification} based on the parameters set in this
|
||||
* builder.
|
||||
*
|
||||
* @return {@link CallIdentification} instance.
|
||||
*/
|
||||
public CallIdentification build() {
|
||||
return new CallIdentification(mName, mDescription, mDetails, mPhoto,
|
||||
mNuisanceConfidence, mPackageName, mAppName);
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(
|
||||
prefix = { "CONFIDENCE_" },
|
||||
value = {CONFIDENCE_NUISANCE, CONFIDENCE_LIKELY_NUISANCE, CONFIDENCE_UNKNOWN,
|
||||
CONFIDENCE_LIKELY_NOT_NUISANCE, CONFIDENCE_NOT_NUISANCE})
|
||||
public @interface NuisanceConfidence {}
|
||||
|
||||
/**
|
||||
* Call has been identified as a nuisance call.
|
||||
* <p>
|
||||
* Returned from {@link #getNuisanceConfidence()} to indicate that a
|
||||
* {@link CallScreeningService} to indicate how confident it is that a call is or is not a
|
||||
* nuisance call.
|
||||
*/
|
||||
public static final int CONFIDENCE_NUISANCE = 2;
|
||||
|
||||
/**
|
||||
* Call has been identified as a likely nuisance call.
|
||||
* <p>
|
||||
* Returned from {@link #getNuisanceConfidence()} to indicate that a
|
||||
* {@link CallScreeningService} to indicate how confident it is that a call is or is not a
|
||||
* nuisance call.
|
||||
*/
|
||||
public static final int CONFIDENCE_LIKELY_NUISANCE = 1;
|
||||
|
||||
/**
|
||||
* Call could not be classified as nuisance or non-nuisance.
|
||||
* <p>
|
||||
* Returned from {@link #getNuisanceConfidence()} to indicate that a
|
||||
* {@link CallScreeningService} to indicate how confident it is that a call is or is not a
|
||||
* nuisance call.
|
||||
*/
|
||||
public static final int CONFIDENCE_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* Call has been identified as not likely to be a nuisance call.
|
||||
* <p>
|
||||
* Returned from {@link #getNuisanceConfidence()} to indicate that a
|
||||
* {@link CallScreeningService} to indicate how confident it is that a call is or is not a
|
||||
* nuisance call.
|
||||
*/
|
||||
public static final int CONFIDENCE_LIKELY_NOT_NUISANCE = -1;
|
||||
|
||||
/**
|
||||
* Call has been identified as not a nuisance call.
|
||||
* <p>
|
||||
* Returned from {@link #getNuisanceConfidence()} to indicate that a
|
||||
* {@link CallScreeningService} to indicate how confident it is that a call is or is not a
|
||||
* nuisance call.
|
||||
*/
|
||||
public static final int CONFIDENCE_NOT_NUISANCE = -2;
|
||||
|
||||
/**
|
||||
* Default constructor for {@link CallIdentification}.
|
||||
*
|
||||
* @param name The name.
|
||||
* @param description The description.
|
||||
* @param details The details.
|
||||
* @param photo The photo.
|
||||
* @param nuisanceConfidence Confidence that this is a nuisance call.
|
||||
* @hide
|
||||
*/
|
||||
private CallIdentification(@Nullable String name, @Nullable String description,
|
||||
@Nullable String details, @Nullable Icon photo,
|
||||
@NuisanceConfidence int nuisanceConfidence) {
|
||||
this(name, description, details, photo, nuisanceConfidence, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for {@link CallIdentification}.
|
||||
*
|
||||
* @param name The name.
|
||||
* @param description The description.
|
||||
* @param details The details.
|
||||
* @param photo The photo.
|
||||
* @param nuisanceConfidence Confidence that this is a nuisance call.
|
||||
* @param callScreeningPackageName Package name of the {@link CallScreeningService} which
|
||||
* provided the call identification.
|
||||
* @param callScreeningAppName App name of the {@link CallScreeningService} which provided the
|
||||
* call identification.
|
||||
* @hide
|
||||
*/
|
||||
private CallIdentification(@Nullable String name, @Nullable String description,
|
||||
@Nullable String details, @Nullable Icon photo,
|
||||
@NuisanceConfidence int nuisanceConfidence, @NonNull String callScreeningPackageName,
|
||||
@NonNull String callScreeningAppName) {
|
||||
mName = name;
|
||||
mDescription = description;
|
||||
mDetails = details;
|
||||
mPhoto = photo;
|
||||
mNuisanceConfidence = nuisanceConfidence;
|
||||
mCallScreeningAppName = callScreeningPackageName;
|
||||
mCallScreeningPackageName = callScreeningAppName;
|
||||
}
|
||||
|
||||
private String mName;
|
||||
private String mDescription;
|
||||
private String mDetails;
|
||||
private Icon mPhoto;
|
||||
private int mNuisanceConfidence;
|
||||
private String mCallScreeningPackageName;
|
||||
private String mCallScreeningAppName;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeString(mName);
|
||||
parcel.writeString(mDescription);
|
||||
parcel.writeString(mDetails);
|
||||
parcel.writeParcelable(mPhoto, 0);
|
||||
parcel.writeInt(mNuisanceConfidence);
|
||||
parcel.writeString(mCallScreeningPackageName);
|
||||
parcel.writeString(mCallScreeningAppName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Responsible for creating CallIdentification objects for deserialized Parcels.
|
||||
*/
|
||||
public static final Parcelable.Creator<CallIdentification> CREATOR =
|
||||
new Parcelable.Creator<CallIdentification> () {
|
||||
|
||||
@Override
|
||||
public CallIdentification createFromParcel(Parcel source) {
|
||||
String name = source.readString();
|
||||
String description = source.readString();
|
||||
String details = source.readString();
|
||||
Icon photo = source.readParcelable(ClassLoader.getSystemClassLoader());
|
||||
int nuisanceConfidence = source.readInt();
|
||||
String callScreeningPackageName = source.readString();
|
||||
String callScreeningAppName = source.readString();
|
||||
return new CallIdentification(name, description, details, photo,
|
||||
nuisanceConfidence, callScreeningPackageName, callScreeningAppName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallIdentification[] newArray(int size) {
|
||||
return new CallIdentification[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The name associated with the number.
|
||||
* <p>
|
||||
* The name of the call as identified by a {@link CallScreeningService}. Could be a business
|
||||
* name, for example.
|
||||
*
|
||||
* @return The name associated with the number, or {@code null} if none was provided.
|
||||
*/
|
||||
public final @Nullable String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the call.
|
||||
* <p>
|
||||
* A description of the call as identified by a {@link CallScreeningService}. The description
|
||||
* is typically presented by Dialer apps after the {@link #getName() name} to provide a short
|
||||
* piece of relevant information about the call. This could include a location, address, or a
|
||||
* message regarding the potential nature of the call (e.g. potential telemarketer).
|
||||
*
|
||||
* @return The call description, or {@code null} if none was provided.
|
||||
*/
|
||||
public final @Nullable String getDescription() {
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the call.
|
||||
* <p>
|
||||
* Details of the call as identified by a {@link CallScreeningService}. The details
|
||||
* are typically presented by Dialer apps after the {@link #getName() name} and
|
||||
* {@link #getDescription() description} to provide further clarifying information about the
|
||||
* call. This could include, for example, the opening hours of a business, or stats about
|
||||
* the number of times a call has been reported as spam.
|
||||
*
|
||||
* @return The call details, or {@code null} if none was provided.
|
||||
*/
|
||||
public final @Nullable String getDetails() {
|
||||
return mDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Photo associated with the call.
|
||||
* <p>
|
||||
* A photo associated with the call as identified by a {@link CallScreeningService}. This
|
||||
* could be, for example, a business logo, or a photo of the caller.
|
||||
*
|
||||
* @return The photo associated with the call, or {@code null} if none was provided.
|
||||
*/
|
||||
public final @Nullable Icon getPhoto() {
|
||||
return mPhoto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the likelihood that this call is a nuisance call.
|
||||
* <p>
|
||||
* How likely the call is a nuisance call, as identified by a {@link CallScreeningService}.
|
||||
*
|
||||
* @return The nuisance confidence.
|
||||
*/
|
||||
public final @NuisanceConfidence
|
||||
int getNuisanceConfidence() {
|
||||
return mNuisanceConfidence;
|
||||
}
|
||||
|
||||
/**
|
||||
* The package name of the {@link CallScreeningService} which provided the
|
||||
* {@link CallIdentification}.
|
||||
* <p>
|
||||
* A {@link CallScreeningService} may not set this property; it is set by the system.
|
||||
* @return the package name
|
||||
*/
|
||||
public final @NonNull String getCallScreeningPackageName() {
|
||||
return mCallScreeningPackageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link android.content.pm.PackageManager#getApplicationLabel(ApplicationInfo) name} of
|
||||
* the {@link CallScreeningService} which provided the {@link CallIdentification}.
|
||||
* <p>
|
||||
* A {@link CallScreeningService} may not set this property; it is set by the system.
|
||||
*
|
||||
* @return The name of the app.
|
||||
*/
|
||||
public final @NonNull String getCallScreeningAppName() {
|
||||
return mCallScreeningAppName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the package name of the {@link CallScreeningService} which provided this information.
|
||||
*
|
||||
* @param callScreeningPackageName The package name.
|
||||
* @hide
|
||||
*/
|
||||
public void setCallScreeningPackageName(@NonNull String callScreeningPackageName) {
|
||||
mCallScreeningPackageName = callScreeningPackageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the app name of the {@link CallScreeningService} which provided this information.
|
||||
*
|
||||
* @param callScreeningAppName The app name.
|
||||
* @hide
|
||||
*/
|
||||
public void setCallScreeningAppName(@NonNull String callScreeningAppName) {
|
||||
mCallScreeningAppName = callScreeningAppName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CallIdentification that = (CallIdentification) o;
|
||||
// Note: mPhoto purposely omit as no good comparison exists.
|
||||
return mNuisanceConfidence == that.mNuisanceConfidence
|
||||
&& Objects.equals(mName, that.mName)
|
||||
&& Objects.equals(mDescription, that.mDescription)
|
||||
&& Objects.equals(mDetails, that.mDetails)
|
||||
&& Objects.equals(mCallScreeningAppName, that.mCallScreeningAppName)
|
||||
&& Objects.equals(mCallScreeningPackageName, that.mCallScreeningPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mName, mDescription, mDetails, mPhoto, mNuisanceConfidence,
|
||||
mCallScreeningAppName, mCallScreeningPackageName);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telecom;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
@@ -46,6 +47,15 @@ import com.android.internal.telecom.ICallScreeningService;
|
||||
* </service>
|
||||
* }
|
||||
* </pre>
|
||||
* <p>
|
||||
* A CallScreeningService performs two functions:
|
||||
* <ol>
|
||||
* <li>Call blocking/screening - the service can choose which calls will ring on the user's
|
||||
* device, and which will be silently sent to voicemail.</li>
|
||||
* <li>Call identification - the service can optionally provide {@link CallIdentification}
|
||||
* information about a {@link Call.Details call} which will be shown to the user in the
|
||||
* Dialer app.</li>
|
||||
* </ol>
|
||||
*/
|
||||
public abstract class CallScreeningService extends Service {
|
||||
/**
|
||||
@@ -229,16 +239,23 @@ public abstract class CallScreeningService extends Service {
|
||||
*
|
||||
* @param callDetails Information about a new incoming call, see {@link Call.Details}.
|
||||
*/
|
||||
public abstract void onScreenCall(Call.Details callDetails);
|
||||
public abstract void onScreenCall(@NonNull Call.Details callDetails);
|
||||
|
||||
/**
|
||||
* Responds to the given call, either allowing it or disallowing it.
|
||||
* <p>
|
||||
* The {@link CallScreeningService} calls this method to inform the system whether the call
|
||||
* should be silently blocked or not.
|
||||
*
|
||||
* @param callDetails The call to allow.
|
||||
* <p>
|
||||
* Must be the same {@link Call.Details call} which was provided to the
|
||||
* {@link CallScreeningService} via {@link #onScreenCall(Call.Details)}.
|
||||
* @param response The {@link CallScreeningService.CallResponse} which contains information
|
||||
* about how to respond to a call.
|
||||
*/
|
||||
public final void respondToCall(Call.Details callDetails, CallResponse response) {
|
||||
public final void respondToCall(@NonNull Call.Details callDetails,
|
||||
@NonNull CallResponse response) {
|
||||
try {
|
||||
if (response.getDisallowCall()) {
|
||||
mCallScreeningAdapter.disallowCall(
|
||||
@@ -253,4 +270,32 @@ public abstract class CallScreeningService extends Service {
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide {@link CallIdentification} information about a {@link Call.Details call}.
|
||||
* <p>
|
||||
* The {@link CallScreeningService} calls this method to provide information it has identified
|
||||
* about a {@link Call.Details call}. This information will potentially be shown to the user
|
||||
* in the {@link InCallService dialer} app. It will be logged to the
|
||||
* {@link android.provider.CallLog}.
|
||||
* <p>
|
||||
* A {@link CallScreeningService} should only call this method for calls for which it is able to
|
||||
* provide some {@link CallIdentification} for. {@link CallIdentification} instances with no
|
||||
* fields set will be ignored by the system.
|
||||
*
|
||||
* @param callDetails The call to provide information for.
|
||||
* <p>
|
||||
* Must be the same {@link Call.Details call} which was provided to the
|
||||
* {@link CallScreeningService} via {@link #onScreenCall(Call.Details)}.
|
||||
* @param identification An instance of {@link CallIdentification} with information about the
|
||||
* {@link Call.Details call}.
|
||||
*/
|
||||
public final void provideCallIdentification(@NonNull Call.Details callDetails,
|
||||
@NonNull CallIdentification identification) {
|
||||
try {
|
||||
mCallScreeningAdapter.provideCallIdentification(callDetails.getTelecomCallId(),
|
||||
identification);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telecom;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -62,6 +63,7 @@ public final class ParcelableCall implements Parcelable {
|
||||
private final Bundle mIntentExtras;
|
||||
private final Bundle mExtras;
|
||||
private final long mCreationTimeMillis;
|
||||
private final CallIdentification mCallIdentification;
|
||||
|
||||
public ParcelableCall(
|
||||
String id,
|
||||
@@ -89,7 +91,8 @@ public final class ParcelableCall implements Parcelable {
|
||||
List<String> conferenceableCallIds,
|
||||
Bundle intentExtras,
|
||||
Bundle extras,
|
||||
long creationTimeMillis) {
|
||||
long creationTimeMillis,
|
||||
CallIdentification callIdentification) {
|
||||
mId = id;
|
||||
mState = state;
|
||||
mDisconnectCause = disconnectCause;
|
||||
@@ -116,6 +119,7 @@ public final class ParcelableCall implements Parcelable {
|
||||
mIntentExtras = intentExtras;
|
||||
mExtras = extras;
|
||||
mCreationTimeMillis = creationTimeMillis;
|
||||
mCallIdentification = callIdentification;
|
||||
}
|
||||
|
||||
/** The unique ID of the call. */
|
||||
@@ -133,7 +137,7 @@ public final class ParcelableCall implements Parcelable {
|
||||
* Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
|
||||
* when call state is {@link CallState#DISCONNECTED}.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public DisconnectCause getDisconnectCause() {
|
||||
return mDisconnectCause;
|
||||
}
|
||||
@@ -159,13 +163,13 @@ public final class ParcelableCall implements Parcelable {
|
||||
}
|
||||
|
||||
/** The time that the call switched to the active state. */
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public long getConnectTimeMillis() {
|
||||
return mConnectTimeMillis;
|
||||
}
|
||||
|
||||
/** The endpoint to which the call is connected. */
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public Uri getHandle() {
|
||||
return mHandle;
|
||||
}
|
||||
@@ -305,8 +309,17 @@ public final class ParcelableCall implements Parcelable {
|
||||
return mCreationTimeMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains call identification information returned by a {@link CallScreeningService}.
|
||||
* @return The {@link CallIdentification} for this call, or {@code null} if a
|
||||
* {@link CallScreeningService} did not provide information.
|
||||
*/
|
||||
public @Nullable CallIdentification getCallIdentification() {
|
||||
return mCallIdentification;
|
||||
}
|
||||
|
||||
/** Responsible for creating ParcelableCall objects for deserialized Parcels. */
|
||||
@UnsupportedAppUsage
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
public static final Parcelable.Creator<ParcelableCall> CREATOR =
|
||||
new Parcelable.Creator<ParcelableCall> () {
|
||||
@Override
|
||||
@@ -342,6 +355,7 @@ public final class ParcelableCall implements Parcelable {
|
||||
boolean isRttCallChanged = source.readByte() == 1;
|
||||
ParcelableRttCall rttCall = source.readParcelable(classLoader);
|
||||
long creationTimeMillis = source.readLong();
|
||||
CallIdentification callIdentification = source.readParcelable(classLoader);
|
||||
return new ParcelableCall(
|
||||
id,
|
||||
state,
|
||||
@@ -368,7 +382,8 @@ public final class ParcelableCall implements Parcelable {
|
||||
conferenceableCallIds,
|
||||
intentExtras,
|
||||
extras,
|
||||
creationTimeMillis);
|
||||
creationTimeMillis,
|
||||
callIdentification);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -413,6 +428,7 @@ public final class ParcelableCall implements Parcelable {
|
||||
destination.writeByte((byte) (mIsRttCallChanged ? 1 : 0));
|
||||
destination.writeParcelable(mRttCall, 0);
|
||||
destination.writeLong(mCreationTimeMillis);
|
||||
destination.writeParcelable(mCallIdentification, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -42,6 +43,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Provides access to information about active calls and registration/call-management functionality.
|
||||
@@ -1184,8 +1186,10 @@ public class TelecomManager {
|
||||
* Requires permission: {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}
|
||||
*
|
||||
* @hide
|
||||
* @deprecated Use RoleManager instead.
|
||||
*/
|
||||
@SystemApi
|
||||
@Deprecated
|
||||
@RequiresPermission(allOf = {
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE,
|
||||
android.Manifest.permission.WRITE_SECURE_SETTINGS})
|
||||
@@ -1216,79 +1220,6 @@ public class TelecomManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to trigger display of the ChangeDefaultCallScreeningApp activity to prompt the user to
|
||||
* change the call screening app.
|
||||
*
|
||||
* A {@link SecurityException} will be thrown if calling package name doesn't match the package
|
||||
* of the passed {@link ComponentName}
|
||||
*
|
||||
* @param componentName to verify that the calling package name matches the package of the
|
||||
* passed ComponentName.
|
||||
*/
|
||||
public void requestChangeDefaultCallScreeningApp(@NonNull ComponentName componentName) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().requestChangeDefaultCallScreeningApp(componentName, mContext
|
||||
.getOpPackageName());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG,
|
||||
"RemoteException calling ITelecomService#requestChangeDefaultCallScreeningApp.",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to verify that the passed ComponentName is default call screening app.
|
||||
*
|
||||
* @param componentName to verify that the package of the passed ComponentName matched the default
|
||||
* call screening packageName.
|
||||
*
|
||||
* @return {@code true} if the passed componentName matches the default call screening's, {@code
|
||||
* false} if the passed componentName is null, or it doesn't match default call screening's.
|
||||
*/
|
||||
public boolean isDefaultCallScreeningApp(ComponentName componentName) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isDefaultCallScreeningApp(componentName);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG,
|
||||
"RemoteException calling ITelecomService#isDefaultCallScreeningApp.",
|
||||
e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the default call screening package.
|
||||
*
|
||||
* Requires permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE} Requires
|
||||
* permission: {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}
|
||||
*
|
||||
* A {@link IllegalArgumentException} will be thrown if the specified package and component name
|
||||
* of {@link ComponentName} does't exist, or the specified component of {@link ComponentName}
|
||||
* does't have {@link android.Manifest.permission#BIND_SCREENING_SERVICE}.
|
||||
*
|
||||
* @param componentName to set the default call screening to.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(anyOf = {
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE,
|
||||
android.Manifest.permission.WRITE_SECURE_SETTINGS
|
||||
})
|
||||
public void setDefaultCallScreeningApp(ComponentName componentName) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().setDefaultCallScreeningApp(componentName);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG,
|
||||
"RemoteException calling ITelecomService#setDefaultCallScreeningApp.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a given phone number is the configured voicemail number for a
|
||||
* particular phone account.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.internal.telecom;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.telecom.CallIdentification;
|
||||
|
||||
/**
|
||||
* Internal remote callback interface for call screening services.
|
||||
@@ -34,4 +35,8 @@ oneway interface ICallScreeningAdapter {
|
||||
boolean shouldAddToCallLog,
|
||||
boolean shouldShowNotification,
|
||||
in ComponentName componentName);
|
||||
|
||||
void provideCallIdentification(
|
||||
String callId,
|
||||
in CallIdentification callIdentification);
|
||||
}
|
||||
|
||||
@@ -255,21 +255,6 @@ interface ITelecomService {
|
||||
*/
|
||||
boolean setDefaultDialer(in String packageName);
|
||||
|
||||
/**
|
||||
* @see TelecomServiceImpl#requestChangeDefaultCallScreeningApp
|
||||
*/
|
||||
void requestChangeDefaultCallScreeningApp(in ComponentName componentNamem, String callingPackage);
|
||||
|
||||
/**
|
||||
* @see TelecomServiceImpl#isDefaultCallScreeningApp
|
||||
*/
|
||||
boolean isDefaultCallScreeningApp(in ComponentName componentName);
|
||||
|
||||
/**
|
||||
* @see TelecomServiceImpl#setDefaultCallScreeningApp
|
||||
*/
|
||||
void setDefaultCallScreeningApp(in ComponentName componentName);
|
||||
|
||||
/**
|
||||
* @see TelecomServiceImpl#createManageBlockedNumbersIntent
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user