Merge "make CallerInfo as SystemAPI" am: 7e902363a6 am: 3f1055a2ba

am: 610244cd4f

Change-Id: I6a3335b42a072522956e747835737e2af455bf38
This commit is contained in:
Chen Xu
2019-10-25 11:10:42 -07:00
committed by android-build-merger
7 changed files with 128 additions and 40 deletions

View File

@@ -7202,6 +7202,13 @@ package android.telephony {
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallQuality> CREATOR; 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 { public class CarrierConfigManager {
method @NonNull public static android.os.PersistableBundle getDefaultConfig(); method @NonNull public static android.os.PersistableBundle getDefaultConfig();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void overrideConfig(int, @Nullable android.os.PersistableBundle); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void overrideConfig(int, @Nullable android.os.PersistableBundle);

View File

@@ -255,7 +255,7 @@ com.android.internal.os.SomeArgs
com.android.internal.policy.DecorView com.android.internal.policy.DecorView
com.android.internal.statusbar.IStatusBarService com.android.internal.statusbar.IStatusBarService
com.android.internal.telephony.AppSmsManager com.android.internal.telephony.AppSmsManager
com.android.internal.telephony.CallerInfoAsyncQuery$OnQueryCompleteListener android.telephony.CallerInfoAsyncQuery$OnQueryCompleteListener
com.android.internal.telephony.CarrierActionAgent com.android.internal.telephony.CarrierActionAgent
com.android.internal.telephony.cat.CatService com.android.internal.telephony.cat.CatService
com.android.internal.telephony.cat.IconLoader com.android.internal.telephony.cat.IconLoader

View File

@@ -1167,9 +1167,6 @@ Lcom/android/internal/telephony/Call$State;->INCOMING:Lcom/android/internal/tele
Lcom/android/internal/telephony/Call$State;->values()[Lcom/android/internal/telephony/Call$State; 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$State;->WAITING:Lcom/android/internal/telephony/Call$State;
Lcom/android/internal/telephony/Call;-><init>()V 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/CallForwardInfo;-><init>()V
Lcom/android/internal/telephony/CallTracker;-><init>()V Lcom/android/internal/telephony/CallTracker;-><init>()V
Lcom/android/internal/telephony/cat/AppInterface$CommandType;->values()[Lcom/android/internal/telephony/cat/AppInterface$CommandType; Lcom/android/internal/telephony/cat/AppInterface$CommandType;->values()[Lcom/android/internal/telephony/cat/AppInterface$CommandType;

View File

@@ -4695,7 +4695,7 @@ com.android.internal.telephony.CallManager$CallManagerHandler
com.android.internal.telephony.CallManager com.android.internal.telephony.CallManager
com.android.internal.telephony.CallStateException com.android.internal.telephony.CallStateException
com.android.internal.telephony.CallTracker 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$1
com.android.internal.telephony.CarrierActionAgent com.android.internal.telephony.CarrierActionAgent
com.android.internal.telephony.CarrierAppUtils com.android.internal.telephony.CarrierAppUtils

View File

@@ -42,7 +42,7 @@ import android.telephony.PhoneNumberUtils;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.android.internal.telephony.CallerInfo; import android.telephony.CallerInfo;
import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants;
import java.util.List; import java.util.List;
@@ -728,10 +728,11 @@ public class CallLog {
String accountAddress = getLogAccountAddress(context, accountHandle); String accountAddress = getLogAccountAddress(context, accountHandle);
int numberPresentation = getLogNumberPresentation(number, presentation); int numberPresentation = getLogNumberPresentation(number, presentation);
String name = (ci != null) ? ci.getName() : "";
if (numberPresentation != PRESENTATION_ALLOWED) { if (numberPresentation != PRESENTATION_ALLOWED) {
number = ""; number = "";
if (ci != null) { if (ci != null) {
ci.name = ""; name = "";
} }
} }
@@ -760,9 +761,7 @@ public class CallLog {
values.put(PHONE_ACCOUNT_ID, accountId); values.put(PHONE_ACCOUNT_ID, accountId);
values.put(PHONE_ACCOUNT_ADDRESS, accountAddress); values.put(PHONE_ACCOUNT_ADDRESS, accountAddress);
values.put(NEW, Integer.valueOf(1)); values.put(NEW, Integer.valueOf(1));
if ((ci != null) && (ci.name != null)) { values.put(CACHED_NAME, name);
values.put(CACHED_NAME, ci.name);
}
values.put(ADD_FOR_ALL_USERS, addForAllUsers ? 1 : 0); values.put(ADD_FOR_ALL_USERS, addForAllUsers ? 1 : 0);
if (callType == MISSED_TYPE) { if (callType == MISSED_TYPE) {
@@ -773,7 +772,7 @@ public class CallLog {
values.put(CALL_SCREENING_APP_NAME, charSequenceToString(callScreeningAppName)); values.put(CALL_SCREENING_APP_NAME, charSequenceToString(callScreeningAppName));
values.put(CALL_SCREENING_COMPONENT_NAME, callScreeningComponentName); 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. // 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
// contacts may have the same number. // contacts may have the same number.
@@ -787,17 +786,18 @@ public class CallLog {
cursor = resolver.query(Phone.CONTENT_URI, cursor = resolver.query(Phone.CONTENT_URI,
new String[] { Phone._ID }, new String[] { Phone._ID },
Phone.CONTACT_ID + " =? AND " + Phone.NORMALIZED_NUMBER + " =?", Phone.CONTACT_ID + " =? AND " + Phone.NORMALIZED_NUMBER + " =?",
new String[] { String.valueOf(ci.contactIdOrZero), new String[] { String.valueOf(ci.getContactId()),
normalizedPhoneNumber}, normalizedPhoneNumber},
null); null);
} else { } else {
final String phoneNumber = ci.phoneNumber != null ? ci.phoneNumber : number; final String phoneNumber = ci.getPhoneNumber() != null
? ci.getPhoneNumber() : number;
cursor = resolver.query( cursor = resolver.query(
Uri.withAppendedPath(Callable.CONTENT_FILTER_URI, Uri.withAppendedPath(Callable.CONTENT_FILTER_URI,
Uri.encode(phoneNumber)), Uri.encode(phoneNumber)),
new String[] { Phone._ID }, new String[] { Phone._ID },
Phone.CONTACT_ID + " =?", Phone.CONTACT_ID + " =?",
new String[] { String.valueOf(ci.contactIdOrZero) }, new String[] { String.valueOf(ci.getContactId()) },
null); null);
} }

View File

@@ -14,8 +14,10 @@
* limitations under the License. * 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.annotation.UnsupportedAppUsage;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.ContentResolver; import android.content.ContentResolver;
@@ -31,10 +33,6 @@ import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data; import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.RawContacts; 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.text.TextUtils;
import android.util.Log; import android.util.Log;
@@ -43,6 +41,7 @@ import com.android.i18n.phonenumbers.PhoneNumberUtil;
import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber; import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder; import com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder;
import com.android.internal.annotations.VisibleForTesting;
import java.util.Locale; import java.util.Locale;
@@ -51,11 +50,14 @@ import java.util.Locale;
* *
* {@hide} * {@hide}
*/ */
@SystemApi
public class CallerInfo { public class CallerInfo {
private static final String TAG = "CallerInfo"; private static final String TAG = "CallerInfo";
private static final boolean VDBG = Rlog.isLoggable(TAG, Log.VERBOSE); private static final boolean VDBG = Rlog.isLoggable(TAG, Log.VERBOSE);
/** @hide */
public static final long USER_TYPE_CURRENT = 0; public static final long USER_TYPE_CURRENT = 0;
/** @hide */
public static final long USER_TYPE_WORK = 1; public static final long USER_TYPE_WORK = 1;
/** /**
@@ -85,49 +87,61 @@ public class CallerInfo {
* field here, NOT name. We're NOT always guaranteed to have a name * field here, NOT name. We're NOT always guaranteed to have a name
* for a connection, but the number should be displayable. * for a connection, but the number should be displayable.
*/ */
@UnsupportedAppUsage private String name;
public String name; private String phoneNumber;
@UnsupportedAppUsage /** @hide */
public String phoneNumber;
public String normalizedNumber; public String normalizedNumber;
/** @hide */
public String geoDescription; public String geoDescription;
/** @hide */
public String cnapName; public String cnapName;
/** @hide */
public int numberPresentation; public int numberPresentation;
/** @hide */
public int namePresentation; public int namePresentation;
/** @hide */
public boolean contactExists; public boolean contactExists;
/** @hide */
public String phoneLabel; 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 @UnsupportedAppUsage
public int numberType; public int numberType;
/** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage
public String numberLabel; public String numberLabel;
/** @hide */
public int photoResource; public int photoResource;
// Contact ID, which will be 0 if a contact comes from the corp CP2. // Contact ID, which will be 0 if a contact comes from the corp CP2.
@UnsupportedAppUsage private long contactIdOrZero;
public long contactIdOrZero; /** @hide */
public boolean needUpdate; public boolean needUpdate;
/** @hide */
public Uri contactRefUri; public Uri contactRefUri;
/** @hide */
public String lookupKey; public String lookupKey;
/** @hide */
public ComponentName preferredPhoneAccountComponent; public ComponentName preferredPhoneAccountComponent;
/** @hide */
public String preferredPhoneAccountId; public String preferredPhoneAccountId;
/** @hide */
public long userType; public long userType;
/** /**
* Contact display photo URI. If a contact has no display photo but a thumbnail, it'll be * Contact display photo URI. If a contact has no display photo but a thumbnail, it'll be
* the thumbnail URI instead. * the thumbnail URI instead.
*/ */
public Uri contactDisplayPhotoUri; private Uri contactDisplayPhotoUri;
// fields to hold individual contact preference data, // fields to hold individual contact preference data,
// including the send to voicemail flag and the ringtone // including the send to voicemail flag and the ringtone
// uri reference. // uri reference.
/** @hide */
public Uri contactRingtoneUri; public Uri contactRingtoneUri;
/** @hide */
public boolean shouldSendToVoicemail; public boolean shouldSendToVoicemail;
/** /**
@@ -141,6 +155,8 @@ public class CallerInfo {
* *
* The {@link #isCachedPhotoCurrent} flag indicates if the image * The {@link #isCachedPhotoCurrent} flag indicates if the image
* data needs to be reloaded. * data needs to be reloaded.
*
* @hide
*/ */
public Drawable cachedPhoto; public Drawable cachedPhoto;
/** /**
@@ -153,18 +169,23 @@ public class CallerInfo {
* *
* The {@link #isCachedPhotoCurrent} flag indicates if the image * The {@link #isCachedPhotoCurrent} flag indicates if the image
* data needs to be reloaded. * data needs to be reloaded.
*
* @hide
*/ */
public Bitmap cachedPhotoIcon; public Bitmap cachedPhotoIcon;
/** /**
* Boolean which indicates if {@link #cachedPhoto} and * Boolean which indicates if {@link #cachedPhoto} and
* {@link #cachedPhotoIcon} is fresh enough. If it is false, * {@link #cachedPhotoIcon} is fresh enough. If it is false,
* those images aren't pointing to valid objects. * those images aren't pointing to valid objects.
*
* @hide
*/ */
public boolean isCachedPhotoCurrent; public boolean isCachedPhotoCurrent;
private boolean mIsEmergency; private boolean mIsEmergency;
private boolean mIsVoiceMail; private boolean mIsVoiceMail;
/** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage
public CallerInfo() { public CallerInfo() {
// TODO: Move all the basic initialization here? // TODO: Move all the basic initialization here?
@@ -180,6 +201,8 @@ public class CallerInfo {
* @param cursor the first object in the cursor is used to build the CallerInfo object. * @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 * @return the CallerInfo which contains the caller id for the given
* number. The returned CallerInfo is null if no number is supplied. * number. The returned CallerInfo is null if no number is supplied.
*
* @hide
*/ */
public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) { public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) {
CallerInfo info = new CallerInfo(); CallerInfo info = new CallerInfo();
@@ -321,6 +344,8 @@ public class CallerInfo {
* @param contactRef the URI used to lookup caller id * @param contactRef the URI used to lookup caller id
* @return the CallerInfo which contains the caller id for the given * @return the CallerInfo which contains the caller id for the given
* number. The returned CallerInfo is null if no number is supplied. * number. The returned CallerInfo is null if no number is supplied.
*
* @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage
public static CallerInfo getCallerInfo(Context context, Uri contactRef) { public static CallerInfo getCallerInfo(Context context, Uri contactRef) {
@@ -346,6 +371,8 @@ public class CallerInfo {
* number. The returned CallerInfo is null if no number is supplied. If * 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, * a matching number is not found, then a generic caller info is returned,
* with all relevant fields empty or null. * with all relevant fields empty or null.
*
* @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage
public static CallerInfo getCallerInfo(Context context, String number) { public static CallerInfo getCallerInfo(Context context, String number) {
@@ -365,6 +392,8 @@ public class CallerInfo {
* number. The returned CallerInfo is null if no number is supplied. If * 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, * a matching number is not found, then a generic caller info is returned,
* with all relevant fields empty or null. * with all relevant fields empty or null.
*
* @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage
public static CallerInfo getCallerInfo(Context context, String number, int subId) { public static CallerInfo getCallerInfo(Context context, String number, int subId) {
@@ -397,6 +426,59 @@ public class CallerInfo {
return info; return info;
} }
/**
* @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 * 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 * and the peer's username is all numeric. Look up the username as it
@@ -425,6 +507,7 @@ public class CallerInfo {
/** /**
* @return true if the caller info is an emergency number. * @return true if the caller info is an emergency number.
* @hide
*/ */
public boolean isEmergencyNumber() { public boolean isEmergencyNumber() {
return mIsEmergency; return mIsEmergency;
@@ -432,6 +515,7 @@ public class CallerInfo {
/** /**
* @return true if the caller info is a voicemail number. * @return true if the caller info is a voicemail number.
* @hide
*/ */
public boolean isVoiceMailNumber() { public boolean isVoiceMailNumber() {
return mIsVoiceMail; return mIsVoiceMail;
@@ -591,6 +675,7 @@ public class CallerInfo {
* @param context the context used to look up the current locale / country * @param context the context used to look up the current locale / country
* @param fallbackNumber if this CallerInfo's phoneNumber field is empty, * @param fallbackNumber if this CallerInfo's phoneNumber field is empty,
* this specifies a fallback number to use instead. * this specifies a fallback number to use instead.
* @hide
*/ */
public void updateGeoDescription(Context context, String fallbackNumber) { public void updateGeoDescription(Context context, String fallbackNumber) {
String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber; String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber;
@@ -600,6 +685,8 @@ public class CallerInfo {
/** /**
* @return a geographical description string for the specified number. * @return a geographical description string for the specified number.
* @see com.android.i18n.phonenumbers.PhoneNumberOfflineGeocoder * @see com.android.i18n.phonenumbers.PhoneNumberOfflineGeocoder
*
* @hide
*/ */
public static String getGeoDescription(Context context, String number) { public static String getGeoDescription(Context context, String number) {
if (VDBG) Rlog.v(TAG, "getGeoDescription('" + number + "')..."); if (VDBG) Rlog.v(TAG, "getGeoDescription('" + number + "')...");
@@ -657,6 +744,7 @@ public class CallerInfo {
return countryIso; return countryIso;
} }
/** @hide */
protected static String getCurrentCountryIso(Context context) { protected static String getCurrentCountryIso(Context context) {
return getCurrentCountryIso(context, Locale.getDefault()); return getCurrentCountryIso(context, Locale.getDefault());
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.internal.telephony; package android.telephony;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.AsyncQueryHandler; import android.content.AsyncQueryHandler;
@@ -31,11 +31,7 @@ import android.os.SystemClock;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.PhoneLookup;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils; import android.text.TextUtils;
import android.telephony.Rlog;
import android.telephony.SubscriptionManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -340,16 +336,16 @@ public class CallerInfoAsyncQuery {
// Use the number entered by the user for display. // Use the number entered by the user for display.
if (!TextUtils.isEmpty(cw.number)) { if (!TextUtils.isEmpty(cw.number)) {
mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number, mCallerInfo.setPhoneNumber(PhoneNumberUtils.formatNumber(cw.number,
mCallerInfo.normalizedNumber, mCallerInfo.normalizedNumber,
CallerInfo.getCurrentCountryIso(mContext)); CallerInfo.getCurrentCountryIso(mContext)));
} }
// This condition refer to the google default code for geo. // This condition refer to the google default code for geo.
// If the number exists in Contacts, the CallCard would never show // If the number exists in Contacts, the CallCard would never show
// the geo description, so it would be unnecessary to query it. // the geo description, so it would be unnecessary to query it.
if (ENABLE_UNKNOWN_NUMBER_GEO_DESCRIPTION) { 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"); if (DBG) Rlog.d(LOG_TAG, "start querying geo description");
cw.event = EVENT_GET_GEO_DESCRIPTION; cw.event = EVENT_GET_GEO_DESCRIPTION;
startQuery(token, cw, null, null, null, null, null); startQuery(token, cw, null, null, null, null, null);