diff options
Diffstat (limited to 'telephony')
14 files changed, 246 insertions, 112 deletions
diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java index dbd48d9..b39b4c7 100644 --- a/telephony/java/android/telephony/CellIdentityCdma.java +++ b/telephony/java/android/telephony/CellIdentityCdma.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity is to represent a unique CDMA cell */ @@ -137,27 +139,25 @@ public final class CellIdentityCdma implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mNetworkId * primeNum) + (mSystemId * primeNum) + (mBasestationId * primeNum) + - (mLatitude * primeNum) + (mLongitude * primeNum); + return Objects.hash(mNetworkId, mSystemId, mBasestationId, mLatitude, mLongitude); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityCdma o = (CellIdentityCdma)other; - return mNetworkId == o.mNetworkId && - mSystemId == o.mSystemId && - mBasestationId == o.mBasestationId && - mLatitude == o.mLatitude && - mLongitude == o.mLongitude; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityCdma)) { return false; } + + CellIdentityCdma o = (CellIdentityCdma) other; + return mNetworkId == o.mNetworkId && + mSystemId == o.mSystemId && + mBasestationId == o.mBasestationId && + mLatitude == o.mLatitude && + mLongitude == o.mLongitude; } @Override diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index 6f8cc91..90d2aa0 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity to represent a unique GSM cell */ @@ -113,25 +115,24 @@ public final class CellIdentityGsm implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum); + return Objects.hash(mMcc, mMnc, mLac, mCid); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityGsm o = (CellIdentityGsm)other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mLac == o.mLac && - mCid == o.mCid; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityGsm)) { return false; } + + CellIdentityGsm o = (CellIdentityGsm) other; + return mMcc == o.mMcc && + mMnc == o.mMnc && + mLac == o.mLac && + mCid == o.mCid; } @Override diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index 72578a4..1e7ac08 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity is to represent a unique LTE cell */ @@ -117,27 +119,25 @@ public final class CellIdentityLte implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mMcc * primeNum) + (mMnc * primeNum) + (mCi * primeNum) + (mPci * primeNum) + - (mTac * primeNum); + return Objects.hash(mMcc, mMnc, mCi, mPci, mTac); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityLte o = (CellIdentityLte)other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mCi == o.mCi && - mPci == o.mPci && - mTac == o.mTac; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityLte)) { return false; } + + CellIdentityLte o = (CellIdentityLte) other; + return mMcc == o.mMcc && + mMnc == o.mMnc && + mCi == o.mCi && + mPci == o.mPci && + mTac == o.mTac; } @Override diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 2f8fa42..56ee8c9 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity to represent a unique UMTS cell */ @@ -118,27 +120,25 @@ public final class CellIdentityWcdma implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum) + - (mPsc * primeNum); + return Objects.hash(mMcc, mMnc, mLac, mCid, mPsc); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityWcdma o = (CellIdentityWcdma)other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mLac == o.mLac && - mCid == o.mCid && - mPsc == o.mPsc; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityWcdma)) { return false; } + + CellIdentityWcdma o = (CellIdentityWcdma) other; + return mMcc == o.mMcc && + mMnc == o.mMnc && + mLac == o.mLac && + mCid == o.mCid && + mPsc == o.mPsc; } @Override diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 729eefa..aae3ff6 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -34,11 +34,9 @@ import android.text.Editable; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.TextUtils; -import android.telephony.Rlog; import android.text.style.TtsSpan; import android.util.SparseIntArray; -import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY; import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_IDP_STRING; import java.util.Locale; @@ -1143,6 +1141,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static String formatNumber(String source) { SpannableStringBuilder text = new SpannableStringBuilder(source); formatNumber(text, getFormatTypeForLocale(Locale.getDefault())); @@ -1161,6 +1160,7 @@ public class PhoneNumberUtils * @hide * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static String formatNumber(String source, int defaultFormattingType) { SpannableStringBuilder text = new SpannableStringBuilder(source); formatNumber(text, defaultFormattingType); @@ -1176,6 +1176,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static int getFormatTypeForLocale(Locale locale) { String country = locale.getCountry(); @@ -1192,6 +1193,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static void formatNumber(Editable text, int defaultFormattingType) { int formatType = defaultFormattingType; @@ -1240,6 +1242,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static void formatNanpNumber(Editable text) { int length = text.length(); if (length > "+1-nnn-nnn-nnnn".length()) { @@ -1355,6 +1358,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static void formatJapaneseNumber(Editable text) { JapanesePhoneNumberFormatter.format(text); } @@ -1376,32 +1380,52 @@ public class PhoneNumberUtils } /** - * Format the given phoneNumber to the E.164 representation. + * Formats the specified {@code phoneNumber} to the E.164 representation. + * + * @param phoneNumber the phone number to format. + * @param defaultCountryIso the ISO 3166-1 two letters country code. + * @return the E.164 representation, or null if the given phone number is not valid. + */ + public static String formatNumberToE164(String phoneNumber, String defaultCountryIso) { + return formatNumberInternal(phoneNumber, defaultCountryIso, PhoneNumberFormat.E164); + } + + /** + * Formats the specified {@code phoneNumber} to the RFC3966 representation. + * + * @param phoneNumber the phone number to format. + * @param defaultCountryIso the ISO 3166-1 two letters country code. + * @return the RFC3966 representation, or null if the given phone number is not valid. + */ + public static String formatNumberToRFC3966(String phoneNumber, String defaultCountryIso) { + return formatNumberInternal(phoneNumber, defaultCountryIso, PhoneNumberFormat.RFC3966); + } + + /** + * Formats the raw phone number (string) using the specified {@code formatIdentifier}. * <p> - * The given phone number must have an area code and could have a country - * code. + * The given phone number must have an area code and could have a country code. * <p> - * The defaultCountryIso is used to validate the given number and generate - * the E.164 phone number if the given number doesn't have a country code. + * The defaultCountryIso is used to validate the given number and generate the formatted number + * if the specified number doesn't have a country code. * - * @param phoneNumber - * the phone number to format - * @param defaultCountryIso - * the ISO 3166-1 two letters country code - * @return the E.164 representation, or null if the given phone number is - * not valid. + * @param rawPhoneNumber The phone number to format. + * @param defaultCountryIso The ISO 3166-1 two letters country code. + * @param formatIdentifier The (enum) identifier of the desired format. + * @return the formatted representation, or null if the specified number is not valid. */ - public static String formatNumberToE164(String phoneNumber, String defaultCountryIso) { + private static String formatNumberInternal( + String rawPhoneNumber, String defaultCountryIso, PhoneNumberFormat formatIdentifier) { + PhoneNumberUtil util = PhoneNumberUtil.getInstance(); - String result = null; try { - PhoneNumber pn = util.parse(phoneNumber, defaultCountryIso); - if (util.isValidNumber(pn)) { - result = util.format(pn, PhoneNumberFormat.E164); + PhoneNumber phoneNumber = util.parse(rawPhoneNumber, defaultCountryIso); + if (util.isValidNumber(phoneNumber)) { + return util.format(phoneNumber, formatIdentifier); } - } catch (NumberParseException e) { - } - return result; + } catch (NumberParseException ignored) { } + + return null; } /** @@ -2311,15 +2335,13 @@ public class PhoneNumberUtils * * @param phoneNumber A {@code CharSequence} the entirety of which represents a phone number. * @return A {@code CharSequence} with appropriate annotations. - * - * @hide */ - public static CharSequence ttsSpanAsPhoneNumber(CharSequence phoneNumber) { + public static CharSequence getPhoneTtsSpannable(CharSequence phoneNumber) { if (phoneNumber == null) { return null; } Spannable spannable = Spannable.Factory.getInstance().newSpannable(phoneNumber); - PhoneNumberUtils.ttsSpanAsPhoneNumber(spannable, 0, spannable.length()); + PhoneNumberUtils.addPhoneTtsSpan(spannable, 0, spannable.length()); return spannable; } @@ -2330,19 +2352,83 @@ public class PhoneNumberUtils * @param s A {@code Spannable} to annotate. * @param start The starting character position of the phone number in {@code s}. * @param end The ending character position of the phone number in {@code s}. - * - * @hide */ - public static void ttsSpanAsPhoneNumber(Spannable s, int start, int end) { - s.setSpan( - new TtsSpan.TelephoneBuilder() - .setNumberParts(splitAtNonNumerics(s.subSequence(start, end))) - .build(), + public static void addPhoneTtsSpan(Spannable s, int start, int end) { + s.setSpan(getPhoneTtsSpan(s.subSequence(start, end).toString()), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } + /** + * Wrap the supplied {@code CharSequence} with a {@code TtsSpan}, annotating it as + * containing a phone number in its entirety. + * + * @param phoneNumber A {@code CharSequence} the entirety of which represents a phone number. + * @return A {@code CharSequence} with appropriate annotations. + * @deprecated Renamed {@link #getPhoneTtsSpannable}. + * + * @hide + */ + @Deprecated + public static CharSequence ttsSpanAsPhoneNumber(CharSequence phoneNumber) { + return getPhoneTtsSpannable(phoneNumber); + } + + /** + * Attach a {@link TtsSpan} to the supplied {@code Spannable} at the indicated location, + * annotating that location as containing a phone number. + * + * @param s A {@code Spannable} to annotate. + * @param start The starting character position of the phone number in {@code s}. + * @param end The ending character position of the phone number in {@code s}. + * + * @deprecated Renamed {@link #addPhoneTtsSpan}. + * + * @hide + */ + @Deprecated + public static void ttsSpanAsPhoneNumber(Spannable s, int start, int end) { + addPhoneTtsSpan(s, start, end); + } + + /** + * Create a {@code TtsSpan} for the supplied {@code String}. + * + * @param phoneNumberString A {@code String} the entirety of which represents a phone number. + * @return A {@code TtsSpan} for {@param phoneNumberString}. + */ + public static TtsSpan getPhoneTtsSpan(String phoneNumberString) { + if (phoneNumberString == null) { + return null; + } + + // Parse the phone number + final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); + PhoneNumber phoneNumber = null; + try { + // Don't supply a defaultRegion so this fails for non-international numbers because + // we don't want to TalkBalk to read a country code (e.g. +1) if it is not already + // present + phoneNumber = phoneNumberUtil.parse(phoneNumberString, /* defaultRegion */ null); + } catch (NumberParseException ignored) { + } + + // Build a telephone tts span + final TtsSpan.TelephoneBuilder builder = new TtsSpan.TelephoneBuilder(); + if (phoneNumber == null) { + // Strip separators otherwise TalkBack will be silent + // (this behavior was observed with TalkBalk 4.0.2 from their alpha channel) + builder.setNumberParts(splitAtNonNumerics(phoneNumberString)); + } else { + if (phoneNumber.hasCountryCode()) { + builder.setCountryCode(Integer.toString(phoneNumber.getCountryCode())); + } + builder.setNumberParts(Long.toString(phoneNumber.getNationalNumber())); + } + return builder.build(); + } + // Split a phone number like "+20(123)-456#" using spaces, ignoring anything that is not // a digit, to produce a result like "20 123 456". private static String splitAtNonNumerics(CharSequence number) { @@ -2456,7 +2542,7 @@ public class PhoneNumberUtils * * @param number SIP address of the form "username@domainname" * (or the URI-escaped equivalent "username%40domainname") - * @see isUriNumber + * @see #isUriNumber * * @hide */ diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index fce4ae7..611dd7bd 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -27,13 +27,10 @@ import android.telephony.VoLteServiceState; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SignalStrength; -import android.telephony.SubscriptionManager; import android.telephony.PreciseCallState; import android.telephony.PreciseDataConnectionState; import com.android.internal.telephony.IPhoneStateListener; -import com.android.internal.telephony.PhoneConstants; - import java.util.List; /** diff --git a/telephony/java/android/telephony/PreciseCallState.java b/telephony/java/android/telephony/PreciseCallState.java index a85df15..f246416 100644 --- a/telephony/java/android/telephony/PreciseCallState.java +++ b/telephony/java/android/telephony/PreciseCallState.java @@ -16,10 +16,8 @@ package android.telephony; -import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.telephony.Rlog; import android.telephony.DisconnectCause; import android.telephony.PreciseDisconnectCause; diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java index 87529fe..31c9a9e 100644 --- a/telephony/java/android/telephony/PreciseDataConnectionState.java +++ b/telephony/java/android/telephony/PreciseDataConnectionState.java @@ -16,10 +16,8 @@ package android.telephony; -import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.telephony.Rlog; import android.telephony.TelephonyManager; import android.net.LinkProperties; diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index aca94e9..08aec08 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -32,8 +32,6 @@ import com.android.internal.telephony.ISub; import com.android.internal.telephony.IOnSubscriptionsChangedListener; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.PhoneConstants; -import com.android.internal.telephony.TelephonyProperties; - import java.util.ArrayList; import java.util.List; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 94691c0..f3b2d2e 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -29,6 +29,7 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; +import android.telecom.PhoneAccount; import android.util.Log; import com.android.internal.telecom.ITelecomService; @@ -41,9 +42,7 @@ import com.android.internal.telephony.TelephonyProperties; import java.io.FileInputStream; import java.io.IOException; -import java.util.Arrays; import java.util.List; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -3717,6 +3716,34 @@ public class TelephonyManager { } /** + * Whether the device supports configuring the DTMF tone length. + * + * @return {@code true} if the DTMF tone length can be changed, and {@code false} otherwise. + */ + public boolean canChangeDtmfToneLength() { + try { + return getITelephony().canChangeDtmfToneLength(); + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e); + } + return false; + } + + /** + * Whether the device is a world phone. + * + * @return {@code true} if the device is a world phone, and {@code false} otherwise. + */ + public boolean isWorldPhone() { + try { + return getITelephony().isWorldPhone(); + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#isWorldPhone", e); + } + return false; + } + + /** * This function retrieves value for setting "name+subId", and if that is not found * retrieves value for setting "name", and if that is not found uses def as default * @@ -3765,7 +3792,7 @@ public class TelephonyManager { /** * Returns the IMS Registration Status - *@hide + * @hide */ public boolean isImsRegistered() { try { @@ -4116,4 +4143,21 @@ public class TelephonyManager { ServiceState.rilRadioTechnologyToString(type)); } } + + /** + * Returns the subscription ID for the given phone account. + * @hide + */ + public int getSubIdForPhoneAccount(PhoneAccount phoneAccount) { + int retval = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + try { + ITelephony service = getITelephony(); + if (service != null) { + retval = service.getSubIdForPhoneAccount(phoneAccount); + } + } catch (RemoteException e) { + } + + return retval; + } } diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java index aae7617..c754068 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java @@ -34,7 +34,6 @@ import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.telephony.Rlog; import android.telephony.SubscriptionManager; -import android.util.Log; /** * Helper class to make it easier to run asynchronous caller-id lookup queries. diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index bf3ee09..3769dee 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.content.Intent; import android.os.Bundle; +import android.telecom.PhoneAccount; import android.telephony.CellInfo; import android.telephony.IccOpenLogicalChannelResponse; import android.telephony.NeighboringCellInfo; @@ -862,11 +863,25 @@ interface ITelephony { /** * Whether video calling has been enabled by the user. * - * @return {@code True} if the user has enabled video calling, {@code false} otherwise. + * @return {@code true} if the user has enabled video calling, {@code false} otherwise. */ boolean isVideoCallingEnabled(); /** + * Whether the DTMF tone length can be changed. + * + * @return {@code true} if the DTMF tone length can be changed. + */ + boolean canChangeDtmfToneLength(); + + /** + * Whether the device is a world phone. + * + * @return {@code true} if the devices is a world phone. + */ + boolean isWorldPhone(); + + /** * Get IMS Registration Status */ boolean isImsRegistered(); @@ -879,4 +894,9 @@ interface ITelephony { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ String getDeviceId(); + + /** + * Returns the subscription ID associated with the specified PhoneAccount. + */ + int getSubIdForPhoneAccount(in PhoneAccount phoneAccount); } diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java index 92cd468..85a489b 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java +++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java @@ -16,8 +16,6 @@ package com.android.internal.telephony; -import android.content.Intent; - /** * The intents that the telephony services broadcast. * diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index c89208d..0fccfa5 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -204,9 +204,4 @@ public interface TelephonyProperties * Type: string ( default = silent, enable to = prompt ) */ static final String PROPERTY_MMS_TRANSACTION = "mms.transaction"; - - /** - * Set to the sim count. - */ - static final String PROPERTY_SIM_COUNT = "ro.telephony.sim.count"; } |