Merge "make CallerInfo as SystemAPI"
diff --git a/api/system-current.txt b/api/system-current.txt
index b81dec0..a9fd0cd 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -7202,6 +7202,13 @@
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallQuality> CREATOR;
}
+ public class CallerInfo {
+ method @Nullable public android.net.Uri getContactDisplayPhotoUri();
+ method public long getContactId();
+ method @Nullable public String getName();
+ method @Nullable public String getPhoneNumber();
+ }
+
public class CarrierConfigManager {
method @NonNull public static android.os.PersistableBundle getDefaultConfig();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void overrideConfig(int, @Nullable android.os.PersistableBundle);
diff --git a/config/dirty-image-objects b/config/dirty-image-objects
index ec2568d..2dfe019 100644
--- a/config/dirty-image-objects
+++ b/config/dirty-image-objects
@@ -255,7 +255,7 @@
com.android.internal.policy.DecorView
com.android.internal.statusbar.IStatusBarService
com.android.internal.telephony.AppSmsManager
-com.android.internal.telephony.CallerInfoAsyncQuery$OnQueryCompleteListener
+android.telephony.CallerInfoAsyncQuery$OnQueryCompleteListener
com.android.internal.telephony.CarrierActionAgent
com.android.internal.telephony.cat.CatService
com.android.internal.telephony.cat.IconLoader
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index e8b2648..3e00bfe 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1167,9 +1167,6 @@
Lcom/android/internal/telephony/Call$State;->values()[Lcom/android/internal/telephony/Call$State;
Lcom/android/internal/telephony/Call$State;->WAITING:Lcom/android/internal/telephony/Call$State;
Lcom/android/internal/telephony/Call;-><init>()V
-Lcom/android/internal/telephony/CallerInfoAsyncQuery$CallerInfoAsyncQueryHandler;-><init>(Lcom/android/internal/telephony/CallerInfoAsyncQuery;Landroid/content/Context;)V
-Lcom/android/internal/telephony/CallerInfoAsyncQuery$CookieWrapper;-><init>()V
-Lcom/android/internal/telephony/CallerInfoAsyncQuery;->release()V
Lcom/android/internal/telephony/CallForwardInfo;-><init>()V
Lcom/android/internal/telephony/CallTracker;-><init>()V
Lcom/android/internal/telephony/cat/AppInterface$CommandType;->values()[Lcom/android/internal/telephony/cat/AppInterface$CommandType;
diff --git a/config/preloaded-classes b/config/preloaded-classes
index b4fd031..5d97c85 100644
--- a/config/preloaded-classes
+++ b/config/preloaded-classes
@@ -4695,7 +4695,7 @@
com.android.internal.telephony.CallManager
com.android.internal.telephony.CallStateException
com.android.internal.telephony.CallTracker
-com.android.internal.telephony.CallerInfoAsyncQuery$OnQueryCompleteListener
+android.telephony.CallerInfoAsyncQuery$OnQueryCompleteListener
com.android.internal.telephony.CarrierActionAgent$1
com.android.internal.telephony.CarrierActionAgent
com.android.internal.telephony.CarrierAppUtils
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index 0827fd6..0973a64 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -42,7 +42,7 @@
import android.text.TextUtils;
import android.util.Log;
-import com.android.internal.telephony.CallerInfo;
+import android.telephony.CallerInfo;
import com.android.internal.telephony.PhoneConstants;
import java.util.List;
@@ -728,10 +728,11 @@
String accountAddress = getLogAccountAddress(context, accountHandle);
int numberPresentation = getLogNumberPresentation(number, presentation);
+ String name = (ci != null) ? ci.getName() : "";
if (numberPresentation != PRESENTATION_ALLOWED) {
number = "";
if (ci != null) {
- ci.name = "";
+ name = "";
}
}
@@ -760,9 +761,7 @@
values.put(PHONE_ACCOUNT_ID, accountId);
values.put(PHONE_ACCOUNT_ADDRESS, accountAddress);
values.put(NEW, Integer.valueOf(1));
- if ((ci != null) && (ci.name != null)) {
- values.put(CACHED_NAME, ci.name);
- }
+ values.put(CACHED_NAME, name);
values.put(ADD_FOR_ALL_USERS, addForAllUsers ? 1 : 0);
if (callType == MISSED_TYPE) {
@@ -773,7 +772,7 @@
values.put(CALL_SCREENING_APP_NAME, charSequenceToString(callScreeningAppName));
values.put(CALL_SCREENING_COMPONENT_NAME, callScreeningComponentName);
- if ((ci != null) && (ci.contactIdOrZero > 0)) {
+ if ((ci != null) && (ci.getContactId() > 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
// contacts may have the same number.
@@ -787,17 +786,18 @@
cursor = resolver.query(Phone.CONTENT_URI,
new String[] { Phone._ID },
Phone.CONTACT_ID + " =? AND " + Phone.NORMALIZED_NUMBER + " =?",
- new String[] { String.valueOf(ci.contactIdOrZero),
+ new String[] { String.valueOf(ci.getContactId()),
normalizedPhoneNumber},
null);
} else {
- final String phoneNumber = ci.phoneNumber != null ? ci.phoneNumber : number;
+ final String phoneNumber = ci.getPhoneNumber() != null
+ ? ci.getPhoneNumber() : number;
cursor = resolver.query(
Uri.withAppendedPath(Callable.CONTENT_FILTER_URI,
Uri.encode(phoneNumber)),
new String[] { Phone._ID },
Phone.CONTACT_ID + " =?",
- new String[] { String.valueOf(ci.contactIdOrZero) },
+ new String[] { String.valueOf(ci.getContactId()) },
null);
}
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/android/telephony/CallerInfo.java
similarity index 93%
rename from telephony/java/com/android/internal/telephony/CallerInfo.java
rename to telephony/java/android/telephony/CallerInfo.java
index 13539b8..f87ac50 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/android/telephony/CallerInfo.java
@@ -14,8 +14,10 @@
* limitations under the License.
*/
-package com.android.internal.telephony;
+package android.telephony;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -31,10 +33,6 @@
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.RawContacts;
-import android.telephony.PhoneNumberUtils;
-import android.telephony.Rlog;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -43,6 +41,7 @@
import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder;
+import com.android.internal.annotations.VisibleForTesting;
import java.util.Locale;
@@ -51,11 +50,14 @@
*
* {@hide}
*/
+@SystemApi
public class CallerInfo {
private static final String TAG = "CallerInfo";
private static final boolean VDBG = Rlog.isLoggable(TAG, Log.VERBOSE);
+ /** @hide */
public static final long USER_TYPE_CURRENT = 0;
+ /** @hide */
public static final long USER_TYPE_WORK = 1;
/**
@@ -85,49 +87,61 @@
* field here, NOT name. We're NOT always guaranteed to have a name
* for a connection, but the number should be displayable.
*/
- @UnsupportedAppUsage
- public String name;
- @UnsupportedAppUsage
- public String phoneNumber;
+ private String name;
+ private String phoneNumber;
+ /** @hide */
public String normalizedNumber;
+ /** @hide */
public String geoDescription;
-
+ /** @hide */
public String cnapName;
+ /** @hide */
public int numberPresentation;
+ /** @hide */
public int namePresentation;
+ /** @hide */
public boolean contactExists;
-
+ /** @hide */
public String phoneLabel;
- /* Split up the phoneLabel into number type and label name */
+ /**
+ * Split up the phoneLabel into number type and label name.
+ * @hide
+ */
@UnsupportedAppUsage
public int numberType;
+ /** @hide */
@UnsupportedAppUsage
public String numberLabel;
-
+ /** @hide */
public int photoResource;
// Contact ID, which will be 0 if a contact comes from the corp CP2.
- @UnsupportedAppUsage
- public long contactIdOrZero;
+ private long contactIdOrZero;
+ /** @hide */
public boolean needUpdate;
+ /** @hide */
public Uri contactRefUri;
+ /** @hide */
public String lookupKey;
-
+ /** @hide */
public ComponentName preferredPhoneAccountComponent;
+ /** @hide */
public String preferredPhoneAccountId;
-
+ /** @hide */
public long userType;
/**
* Contact display photo URI. If a contact has no display photo but a thumbnail, it'll be
* the thumbnail URI instead.
*/
- public Uri contactDisplayPhotoUri;
+ private Uri contactDisplayPhotoUri;
// fields to hold individual contact preference data,
// including the send to voicemail flag and the ringtone
// uri reference.
+ /** @hide */
public Uri contactRingtoneUri;
+ /** @hide */
public boolean shouldSendToVoicemail;
/**
@@ -141,6 +155,8 @@
*
* The {@link #isCachedPhotoCurrent} flag indicates if the image
* data needs to be reloaded.
+ *
+ * @hide
*/
public Drawable cachedPhoto;
/**
@@ -153,18 +169,23 @@
*
* The {@link #isCachedPhotoCurrent} flag indicates if the image
* data needs to be reloaded.
+ *
+ * @hide
*/
public Bitmap cachedPhotoIcon;
/**
* Boolean which indicates if {@link #cachedPhoto} and
* {@link #cachedPhotoIcon} is fresh enough. If it is false,
* those images aren't pointing to valid objects.
+ *
+ * @hide
*/
public boolean isCachedPhotoCurrent;
private boolean mIsEmergency;
private boolean mIsVoiceMail;
+ /** @hide */
@UnsupportedAppUsage
public CallerInfo() {
// TODO: Move all the basic initialization here?
@@ -180,6 +201,8 @@
* @param cursor the first object in the cursor is used to build the CallerInfo object.
* @return the CallerInfo which contains the caller id for the given
* number. The returned CallerInfo is null if no number is supplied.
+ *
+ * @hide
*/
public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) {
CallerInfo info = new CallerInfo();
@@ -321,6 +344,8 @@
* @param contactRef the URI used to lookup caller id
* @return the CallerInfo which contains the caller id for the given
* number. The returned CallerInfo is null if no number is supplied.
+ *
+ * @hide
*/
@UnsupportedAppUsage
public static CallerInfo getCallerInfo(Context context, Uri contactRef) {
@@ -346,6 +371,8 @@
* number. The returned CallerInfo is null if no number is supplied. If
* a matching number is not found, then a generic caller info is returned,
* with all relevant fields empty or null.
+ *
+ * @hide
*/
@UnsupportedAppUsage
public static CallerInfo getCallerInfo(Context context, String number) {
@@ -365,6 +392,8 @@
* number. The returned CallerInfo is null if no number is supplied. If
* a matching number is not found, then a generic caller info is returned,
* with all relevant fields empty or null.
+ *
+ * @hide
*/
@UnsupportedAppUsage
public static CallerInfo getCallerInfo(Context context, String number, int subId) {
@@ -398,6 +427,59 @@
}
/**
+ * @return Name assocaited with this caller.
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set caller Info Name.
+ * @param name caller Info Name
+ *
+ * @hide
+ */
+ public void setName(@Nullable String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Phone number assocaited with this caller.
+ */
+ @Nullable
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ /** @hide */
+ public void setPhoneNumber(String number) {
+ phoneNumber = number;
+ }
+
+ /**
+ * @return Contact ID, which will be 0 if a contact comes from the corp Contacts Provider.
+ */
+ public long getContactId() {
+ return contactIdOrZero;
+ }
+
+ /**
+ * @return Contact display photo URI. If a contact has no display photo but a thumbnail,
+ * it'll the thumbnail URI instead.
+ */
+ @Nullable
+ public Uri getContactDisplayPhotoUri() {
+ return contactDisplayPhotoUri;
+ }
+
+ /** @hide */
+ @VisibleForTesting
+ public void SetContactDisplayPhotoUri(Uri photoUri) {
+ contactDisplayPhotoUri = photoUri;
+ }
+
+ /**
* Performs another lookup if previous lookup fails and it's a SIP call
* and the peer's username is all numeric. Look up the username as it
* could be a PSTN number in the contact database.
@@ -425,6 +507,7 @@
/**
* @return true if the caller info is an emergency number.
+ * @hide
*/
public boolean isEmergencyNumber() {
return mIsEmergency;
@@ -432,6 +515,7 @@
/**
* @return true if the caller info is a voicemail number.
+ * @hide
*/
public boolean isVoiceMailNumber() {
return mIsVoiceMail;
@@ -591,6 +675,7 @@
* @param context the context used to look up the current locale / country
* @param fallbackNumber if this CallerInfo's phoneNumber field is empty,
* this specifies a fallback number to use instead.
+ * @hide
*/
public void updateGeoDescription(Context context, String fallbackNumber) {
String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber;
@@ -600,6 +685,8 @@
/**
* @return a geographical description string for the specified number.
* @see com.android.i18n.phonenumbers.PhoneNumberOfflineGeocoder
+ *
+ * @hide
*/
public static String getGeoDescription(Context context, String number) {
if (VDBG) Rlog.v(TAG, "getGeoDescription('" + number + "')...");
@@ -657,6 +744,7 @@
return countryIso;
}
+ /** @hide */
protected static String getCurrentCountryIso(Context context) {
return getCurrentCountryIso(context, Locale.getDefault());
}
diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/android/telephony/CallerInfoAsyncQuery.java
similarity index 98%
rename from telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
rename to telephony/java/android/telephony/CallerInfoAsyncQuery.java
index e9a177d..87a6376 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
+++ b/telephony/java/android/telephony/CallerInfoAsyncQuery.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.internal.telephony;
+package android.telephony;
import android.app.ActivityManager;
import android.content.AsyncQueryHandler;
@@ -31,11 +31,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.ContactsContract.PhoneLookup;
-import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
-import android.telephony.Rlog;
-import android.telephony.SubscriptionManager;
-
import java.util.ArrayList;
import java.util.List;
@@ -340,16 +336,16 @@
// Use the number entered by the user for display.
if (!TextUtils.isEmpty(cw.number)) {
- mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number,
+ mCallerInfo.setPhoneNumber(PhoneNumberUtils.formatNumber(cw.number,
mCallerInfo.normalizedNumber,
- CallerInfo.getCurrentCountryIso(mContext));
+ CallerInfo.getCurrentCountryIso(mContext)));
}
// This condition refer to the google default code for geo.
// If the number exists in Contacts, the CallCard would never show
// the geo description, so it would be unnecessary to query it.
if (ENABLE_UNKNOWN_NUMBER_GEO_DESCRIPTION) {
- if (TextUtils.isEmpty(mCallerInfo.name)) {
+ if (TextUtils.isEmpty(mCallerInfo.getName())) {
if (DBG) Rlog.d(LOG_TAG, "start querying geo description");
cw.event = EVENT_GET_GEO_DESCRIPTION;
startQuery(token, cw, null, null, null, null, null);