diff options
Diffstat (limited to 'telephony/java')
7 files changed, 109 insertions, 3 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java b/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java index 438b572..f7dee99 100644 --- a/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java +++ b/telephony/java/android/telephony/PhoneNumberFormattingTextWatcher.java @@ -117,6 +117,7 @@ public class PhoneNumberFormattingTextWatcher implements TextWatcher { } mSelfChange = false; } + PhoneNumberUtils.ttsSpanAsPhoneNumber(s, 0, s.length()); } /** diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 897702d..0844232 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -31,9 +31,11 @@ import android.os.SystemProperties; import android.provider.Contacts; import android.provider.ContactsContract; 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; @@ -2307,6 +2309,59 @@ public class PhoneNumberUtils return retStr; } + /** + * 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. + * + * @hide + */ + public static CharSequence ttsSpanAsPhoneNumber(CharSequence phoneNumber) { + if (phoneNumber == null) { + return null; + } + Spannable spannable = Spannable.Factory.getInstance().newSpannable(phoneNumber); + PhoneNumberUtils.ttsSpanAsPhoneNumber(spannable, 0, spannable.length()); + return spannable; + } + + /** + * 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}. + * + * @hide + */ + public static void ttsSpanAsPhoneNumber(Spannable s, int start, int end) { + s.setSpan( + new TtsSpan.TelephoneBuilder() + .setNumberParts(splitAtNonNumerics(s.subSequence(start, end))) + .build(), + start, + end, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + } + + // 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) { + StringBuilder sb = new StringBuilder(number.length()); + for (int i = 0; i < number.length(); i++) { + sb.append(PhoneNumberUtils.isISODigit(number.charAt(i)) + ? number.charAt(i) + : " "); + } + // It is very important to remove extra spaces. At time of writing, any leading or trailing + // spaces, or any sequence of more than one space, will confuse TalkBack and cause the TTS + // span to be non-functional! + return sb.toString().replaceAll(" +", " ").trim(); + } + private static String getCurrentIdp(boolean useNanp) { // in case, there is no IDD is found, we shouldn't convert it. String ps = SystemProperties.get( diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java index dd4c45d..734fc68 100644 --- a/telephony/java/android/telephony/RadioAccessFamily.java +++ b/telephony/java/android/telephony/RadioAccessFamily.java @@ -19,6 +19,8 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; +import com.android.internal.telephony.RILConstants; + /** * Object to indicate the phone radio type and access technology. * @@ -107,6 +109,7 @@ public class RadioAccessFamily implements Parcelable { * @param outParcel The Parcel in which the object should be written. * @param flags Additional flags about how the object should be written. */ + @Override public void writeToParcel(Parcel outParcel, int flags) { outParcel.writeInt(mPhoneId); outParcel.writeInt(mRadioAccessFamily); @@ -131,5 +134,18 @@ public class RadioAccessFamily implements Parcelable { return new RadioAccessFamily[size]; } }; + + public static int getRafFromNetworkType(int type) { + // TODO map from RILConstants.NETWORK_TYPE_* to RAF_* + switch (type) { + case RILConstants.NETWORK_MODE_WCDMA_PREF: + case RILConstants.NETWORK_MODE_GSM_UMTS: + return RAF_UMTS | RAF_GSM; + case RILConstants.NETWORK_MODE_GSM_ONLY: + return RAF_GSM; + default: + return RAF_UNKNOWN; + } + } } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index abf1ead..20cd037 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.NonNull; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; @@ -1064,7 +1065,7 @@ public class SubscriptionManager { * is never null but the length maybe 0. * @hide */ - public int[] getActiveSubscriptionIdList() { + public @NonNull int[] getActiveSubscriptionIdList() { int[] subId = null; try { diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index e015469..73e3213 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; @@ -40,6 +41,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.regex.Matcher; import java.util.regex.Pattern; @@ -1879,6 +1881,23 @@ public class TelephonyManager { } /** + * Return the set of subscriber IDs that should be considered as "merged + * together" for data usage purposes. This is commonly {@code null} to + * indicate no merging is required. Any returned subscribers are sorted in a + * deterministic order. + * + * @hide + */ + public @Nullable String[] getMergedSubscriberIds() { + try { + return getITelephony().getMergedSubscriberIds(); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return null; + } + + /** * Returns the MSISDN string. * for a GSM phone. Return null if it is unavailable. * <p> @@ -3609,5 +3628,3 @@ public class TelephonyManager { } } } - - diff --git a/telephony/java/com/android/ims/internal/IImsCallSession.aidl b/telephony/java/com/android/ims/internal/IImsCallSession.aidl index d1946e3..b1f2d32 100644 --- a/telephony/java/com/android/ims/internal/IImsCallSession.aidl +++ b/telephony/java/com/android/ims/internal/IImsCallSession.aidl @@ -223,6 +223,20 @@ interface IImsCallSession { void sendDtmf(char c, in Message result); /** + * Start a DTMF code. According to <a href="http://tools.ietf.org/html/rfc2833">RFC 2833</a>, + * event 0 ~ 9 maps to decimal value 0 ~ 9, '*' to 10, '#' to 11, event 'A' ~ 'D' to 12 ~ 15, + * and event flash to 16. Currently, event flash is not supported. + * + * @param c the DTMF to send. '0' ~ '9', 'A' ~ 'D', '*', '#' are valid inputs. + */ + void startDtmf(char c); + + /** + * Stop a DTMF code. + */ + void stopDtmf(); + + /** * Sends an USSD message. * * @param ussdMessage USSD message to send diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a9e9f5e..4affad8 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -772,6 +772,8 @@ interface ITelephony { */ String getLine1AlphaTagForDisplay(int subId); + String[] getMergedSubscriberIds(); + /** * Override the operator branding for the current ICCID. * |