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

Commit 833adffe authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "Add new SystemApi methods for mainline"

parents f96b36fb e2f17aad
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -7490,13 +7490,6 @@ package android.telephony {
    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);
@@ -8128,6 +8121,12 @@ package android.telephony {
    field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PhoneNumberRange> CREATOR;
  }
  public class PhoneNumberUtils {
    method @NonNull public static String getUsernameFromUriNumber(@NonNull String);
    method public static boolean isUriNumber(@Nullable String);
    method public static boolean isVoiceMailNumber(@NonNull android.content.Context, int, @Nullable String);
  }
  public class PhoneStateListener {
    method public void onCallAttributesChanged(@NonNull android.telephony.CallAttributes);
    method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onCallDisconnectCauseChanged(int, int);
@@ -8410,6 +8409,7 @@ package android.telephony {
  public final class SmsManager {
    method public boolean disableCellBroadcastRange(int, int, int);
    method public boolean enableCellBroadcastRange(int, int, int);
    method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List<java.lang.String>, java.util.List<android.app.PendingIntent>, java.util.List<android.app.PendingIntent>);
  }
@@ -8427,6 +8427,7 @@ package android.telephony {
    method public void requestEmbeddedSubscriptionInfoListRefresh(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultDataSubId(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultSmsSubId(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultVoiceSubscriptionId(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPreferredDataSubscriptionId(int, boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int, boolean);
    field @NonNull public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
@@ -8496,11 +8497,13 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getDataActivationState();
    method @Deprecated public boolean getDataEnabled();
    method @Deprecated public boolean getDataEnabled(int);
    method @Nullable public static android.content.ComponentName getDefaultRespondViaMessageApplication(@NonNull android.content.Context, boolean);
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDeviceSoftwareVersion(int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean getEmergencyCallbackMode();
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain();
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst();
    method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Map<java.lang.Integer,java.lang.Integer> getLogicalToPhysicalSlotMapping();
    method public int getMaxNumberOfSimultaneouslyActiveSims();
    method public static long getMaxNumberVerificationTimeoutMillis();
    method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getNetworkCountryIso(int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmask();
+6 −0
Original line number Diff line number Diff line
@@ -3020,6 +3020,9 @@ package android.telephony {

  public class PhoneNumberUtils {
    method public static int getMinMatchForTest();
    method @NonNull public static String getUsernameFromUriNumber(@NonNull String);
    method public static boolean isUriNumber(@Nullable String);
    method public static boolean isVoiceMailNumber(@NonNull android.content.Context, int, @Nullable String);
    method public static void setMinMatchForTest(int);
  }

@@ -3043,6 +3046,7 @@ package android.telephony {

  public final class SmsManager {
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int checkSmsShortCodeDestination(String, String);
    method public void sendMultipartTextMessage(@NonNull String, @NonNull String, @NonNull java.util.List<java.lang.String>, @Nullable java.util.List<android.app.PendingIntent>, @Nullable java.util.List<android.app.PendingIntent>, @NonNull String);
    field public static final int SMS_CATEGORY_FREE_SHORT_CODE = 1; // 0x1
    field public static final int SMS_CATEGORY_NOT_SHORT_CODE = 0; // 0x0
    field public static final int SMS_CATEGORY_POSSIBLE_PREMIUM_SHORT_CODE = 3; // 0x3
@@ -3051,6 +3055,7 @@ package android.telephony {
  }

  public class SubscriptionManager {
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultVoiceSubscriptionId(int);
    field @NonNull public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
    field @NonNull public static final android.net.Uri VT_ENABLED_CONTENT_URI;
    field @NonNull public static final android.net.Uri WFC_ENABLED_CONTENT_URI;
@@ -3063,6 +3068,7 @@ package android.telephony {
    method public int checkCarrierPrivilegesForPackage(String);
    method public int getCarrierIdListVersion();
    method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
    method @Nullable public static android.content.ComponentName getDefaultRespondViaMessageApplication(@NonNull android.content.Context, boolean);
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag();
    method @NonNull @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getNetworkCountryIso(int);
    method public android.util.Pair<java.lang.Integer,java.lang.Integer> getRadioHalVersion();
+1 −1
Original line number Diff line number Diff line
@@ -35,10 +35,10 @@ 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.CallerInfo;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.CallerInfo;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.Log;
+32 −48
Original line number Diff line number Diff line
@@ -14,10 +14,9 @@
 * limitations under the License.
 */

package android.telephony;
package android.telecom;

import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -33,8 +32,10 @@ import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.RawContacts;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

import com.android.i18n.phonenumbers.NumberParseException;
import com.android.i18n.phonenumbers.PhoneNumberUtil;
@@ -50,10 +51,9 @@ import java.util.Locale;
 *
 * {@hide}
 */
@SystemApi
public class CallerInfo {
    private static final String TAG = "CallerInfo";
    private static final boolean VDBG = Rlog.isLoggable(TAG, Log.VERBOSE);
    private static final boolean VDBG = Log.VERBOSE;

    /** @hide */
    public static final long USER_TYPE_CURRENT = 0;
@@ -215,7 +215,7 @@ public class CallerInfo {
        info.contactExists = false;
        info.userType = USER_TYPE_CURRENT;

        if (VDBG) Rlog.v(TAG, "getCallerInfo() based on cursor...");
        if (VDBG) Log.v(TAG, "getCallerInfo() based on cursor...");

        if (cursor != null) {
            if (cursor.moveToFirst()) {
@@ -263,7 +263,7 @@ public class CallerInfo {
                    if (contactId != 0 && !Contacts.isEnterpriseContactId(contactId)) {
                        info.contactIdOrZero = contactId;
                        if (VDBG) {
                            Rlog.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero);
                            Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero);
                        }
                    }
                    if (Contacts.isEnterpriseContactId(contactId)) {
@@ -271,7 +271,7 @@ public class CallerInfo {
                    }
                } else {
                    // No valid columnIndex, so we can't look up person_id.
                    Rlog.w(TAG, "Couldn't find contact_id column for " + contactRef);
                    Log.w(TAG, "Couldn't find contact_id column for " + contactRef);
                    // Watch out: this means that anything that depends on
                    // person_id will be broken (like contact photo lookups in
                    // the in-call UI, for example.)
@@ -356,7 +356,7 @@ public class CallerInfo {
                info = getCallerInfo(context, contactRef,
                        cr.query(contactRef, null, null, null, null));
            } catch (RuntimeException re) {
                Rlog.e(TAG, "Error getting caller info.", re);
                Log.e(TAG, re, "Error getting caller info.");
            }
        }
        return info;
@@ -376,7 +376,7 @@ public class CallerInfo {
     */
    @UnsupportedAppUsage
    public static CallerInfo getCallerInfo(Context context, String number) {
        if (VDBG) Rlog.v(TAG, "getCallerInfo() based on number...");
        if (VDBG) Log.v(TAG, "getCallerInfo() based on number...");

        int subId = SubscriptionManager.getDefaultSubscriptionId();
        return getCallerInfo(context, number, subId);
@@ -407,8 +407,8 @@ public class CallerInfo {
        // shortcut and skip the query.
        if (PhoneNumberUtils.isLocalEmergencyNumber(context, number)) {
            return new CallerInfo().markAsEmergency(context);
        } else if (PhoneNumberUtils.isVoiceMailNumber(subId, number)) {
            return new CallerInfo().markAsVoiceMail();
        } else if (PhoneNumberUtils.isVoiceMailNumber(null, subId, number)) {
            return new CallerInfo().markAsVoiceMail(context, subId);
        }

        Uri contactUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
@@ -542,36 +542,20 @@ public class CallerInfo {
    }


    /**
     * Mark this CallerInfo as a voicemail call. The voicemail label
     * is obtained from the telephony manager. Caller must hold the
     * READ_PHONE_STATE permission otherwise the phoneNumber will be
     * set to null.
     * @return this instance.
     */
    // TODO: As in the emergency number handling, we end up writing a
    // string in the phone number field.
    /* package */ CallerInfo markAsVoiceMail() {

        int subId = SubscriptionManager.getDefaultSubscriptionId();
        return markAsVoiceMail(subId);

    }

    /* package */ CallerInfo markAsVoiceMail(int subId) {
    /* package */ CallerInfo markAsVoiceMail(Context context, int subId) {
        mIsVoiceMail = true;

        try {
            String voiceMailLabel = TelephonyManager.getDefault().getVoiceMailAlphaTag(subId);

            phoneNumber = voiceMailLabel;
            phoneNumber = context.getSystemService(TelephonyManager.class)
                    .createForSubscriptionId(subId)
                    .getVoiceMailAlphaTag();
        } catch (SecurityException se) {
            // Should never happen: if this process does not have
            // permission to retrieve VM tag, it should not have
            // permission to retrieve VM number and would not call
            // this method.
            // Leave phoneNumber untouched.
            Rlog.e(TAG, "Cannot access VoiceMail.", se);
            Log.e(TAG, se, "Cannot access VoiceMail.");
        }
        // TODO: There is no voicemail picture?
        // FIXME: FIND ANOTHER ICON
@@ -630,10 +614,10 @@ public class CallerInfo {
        // So instead, figure out the column to use for person_id by just
        // looking at the URI itself.

        if (VDBG) Rlog.v(TAG, "- getColumnIndexForPersonId: contactRef URI = '"
        if (VDBG) Log.v(TAG, "- getColumnIndexForPersonId: contactRef URI = '"
                        + contactRef + "'...");
        // Warning: Do not enable the following logging (due to ANR risk.)
        // if (VDBG) Rlog.v(TAG, "- MIME type: "
        // if (VDBG) Log.v(TAG, "- MIME type: "
        //                 + context.getContentResolver().getType(contactRef));

        String url = contactRef.toString();
@@ -641,25 +625,25 @@ public class CallerInfo {
        if (url.startsWith("content://com.android.contacts/data/phones")) {
            // Direct lookup in the Phone table.
            // MIME type: Phone.CONTENT_ITEM_TYPE (= "vnd.android.cursor.item/phone_v2")
            if (VDBG) Rlog.v(TAG, "'data/phones' URI; using RawContacts.CONTACT_ID");
            if (VDBG) Log.v(TAG, "'data/phones' URI; using RawContacts.CONTACT_ID");
            columnName = RawContacts.CONTACT_ID;
        } else if (url.startsWith("content://com.android.contacts/data")) {
            // Direct lookup in the Data table.
            // MIME type: Data.CONTENT_TYPE (= "vnd.android.cursor.dir/data")
            if (VDBG) Rlog.v(TAG, "'data' URI; using Data.CONTACT_ID");
            if (VDBG) Log.v(TAG, "'data' URI; using Data.CONTACT_ID");
            // (Note Data.CONTACT_ID and RawContacts.CONTACT_ID are equivalent.)
            columnName = Data.CONTACT_ID;
        } else if (url.startsWith("content://com.android.contacts/phone_lookup")) {
            // Lookup in the PhoneLookup table, which provides "fuzzy matching"
            // for phone numbers.
            // MIME type: PhoneLookup.CONTENT_TYPE (= "vnd.android.cursor.dir/phone_lookup")
            if (VDBG) Rlog.v(TAG, "'phone_lookup' URI; using PhoneLookup._ID");
            if (VDBG) Log.v(TAG, "'phone_lookup' URI; using PhoneLookup._ID");
            columnName = PhoneLookup._ID;
        } else {
            Rlog.w(TAG, "Unexpected prefix for contactRef '" + url + "'");
            Log.w(TAG, "Unexpected prefix for contactRef '" + url + "'");
        }
        int columnIndex = (columnName != null) ? cursor.getColumnIndex(columnName) : -1;
        if (VDBG) Rlog.v(TAG, "==> Using column '" + columnName
        if (VDBG) Log.v(TAG, "==> Using column '" + columnName
                        + "' (columnIndex = " + columnIndex + ") for person_id lookup...");
        return columnIndex;
    }
@@ -689,7 +673,7 @@ public class CallerInfo {
     * @hide
     */
    public static String getGeoDescription(Context context, String number) {
        if (VDBG) Rlog.v(TAG, "getGeoDescription('" + number + "')...");
        if (VDBG) Log.v(TAG, "getGeoDescription('" + number + "')...");

        if (TextUtils.isEmpty(number)) {
            return null;
@@ -702,18 +686,18 @@ public class CallerInfo {
        String countryIso = getCurrentCountryIso(context, locale);
        PhoneNumber pn = null;
        try {
            if (VDBG) Rlog.v(TAG, "parsing '" + number
            if (VDBG) Log.v(TAG, "parsing '" + number
                            + "' for countryIso '" + countryIso + "'...");
            pn = util.parse(number, countryIso);
            if (VDBG) Rlog.v(TAG, "- parsed number: " + pn);
            if (VDBG) Log.v(TAG, "- parsed number: " + pn);
        } catch (NumberParseException e) {
            Rlog.w(TAG, "getGeoDescription: NumberParseException for incoming number '"
                    + Rlog.pii(TAG, number) + "'");
            Log.w(TAG, "getGeoDescription: NumberParseException for incoming number '"
                    + Log.pii(number) + "'");
        }

        if (pn != null) {
            String description = geocoder.getDescriptionForNumber(pn, locale);
            if (VDBG) Rlog.v(TAG, "- got description: '" + description + "'");
            if (VDBG) Log.v(TAG, "- got description: '" + description + "'");
            return description;
        } else {
            return null;
@@ -733,12 +717,12 @@ public class CallerInfo {
            if (country != null) {
                countryIso = country.getCountryIso();
            } else {
                Rlog.e(TAG, "CountryDetector.detectCountry() returned null.");
                Log.e(TAG, new Exception(), "CountryDetector.detectCountry() returned null.");
            }
        }
        if (countryIso == null) {
            countryIso = locale.getCountry();
            Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: "
            Log.w(TAG, "No CountryDetector; falling back to countryIso based on locale: "
                    + countryIso);
        }
        return countryIso;
Loading