diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 2b2f2023bef61..ef8ae7095d651 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -13485,7 +13485,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isNrDualConnectivityEnabled(); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isOffhook(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isOpportunisticNetworkEnabled(); - method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isPotentialEmergencyNumber(@NonNull String); + method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isPotentialEmergencyNumber(@NonNull String); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRadioOn(); method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean isTetheringApnRequired(); diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 1273aa3abbc9b..dfa4fc0c8984e 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1782,266 +1782,21 @@ public class PhoneNumberUtils { public static boolean isEmergencyNumber(int subId, String number) { // Return true only if the specified number *exactly* matches // one of the emergency numbers listed by the RIL / SIM. - return isEmergencyNumberInternal(subId, number, true /* useExactMatch */); + return isEmergencyNumberInternal(subId, number); } /** - * Checks if given number might *potentially* result in - * a call to an emergency service on the current network. - * - * Specifically, this method will return true if the specified number - * is an emergency number according to the list managed by the RIL or - * SIM, *or* if the specified number simply starts with the same - * digits as any of the emergency numbers listed in the RIL / SIM. - * - * This method is intended for internal use by the phone app when - * deciding whether to allow ACTION_CALL intents from 3rd party apps - * (where we're required to *not* allow emergency calls to be placed.) - * - * @param number the number to look up. - * @return true if the number is in the list of emergency numbers - * listed in the RIL / SIM, *or* if the number starts with the - * same digits as any of those emergency numbers. - * - * @deprecated Please use {@link TelephonyManager#isPotentialEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - public static boolean isPotentialEmergencyNumber(String number) { - return isPotentialEmergencyNumber(getDefaultVoiceSubId(), number); - } - - /** - * Checks if given number might *potentially* result in - * a call to an emergency service on the current network. - * - * Specifically, this method will return true if the specified number - * is an emergency number according to the list managed by the RIL or - * SIM, *or* if the specified number simply starts with the same - * digits as any of the emergency numbers listed in the RIL / SIM. - * - * This method is intended for internal use by the phone app when - * deciding whether to allow ACTION_CALL intents from 3rd party apps - * (where we're required to *not* allow emergency calls to be placed.) + * Helper function for isEmergencyNumber(String, String) and. * * @param subId the subscription id of the SIM. * @param number the number to look up. - * @return true if the number is in the list of emergency numbers - * listed in the RIL / SIM, *or* if the number starts with the - * same digits as any of those emergency numbers. - * - * @deprecated Please use {@link TelephonyManager#isPotentialEmergencyNumber(String)} - * instead. - * - * @hide - */ - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - @Deprecated - public static boolean isPotentialEmergencyNumber(int subId, String number) { - // Check against the emergency numbers listed by the RIL / SIM, - // and *don't* require an exact match. - return isEmergencyNumberInternal(subId, number, false /* useExactMatch */); - } - - /** - * Helper function for isEmergencyNumber(String) and - * isPotentialEmergencyNumber(String). - * - * @param number the number to look up. - * - * @param useExactMatch if true, consider a number to be an emergency - * number only if it *exactly* matches a number listed in - * the RIL / SIM. If false, a number is considered to be an - * emergency number if it simply starts with the same digits - * as any of the emergency numbers listed in the RIL / SIM. - * (Setting useExactMatch to false allows you to identify - * number that could *potentially* result in emergency calls - * since many networks will actually ignore trailing digits - * after a valid emergency number.) - * - * @return true if the number is in the list of emergency numbers - * listed in the RIL / sim, otherwise return false. - */ - private static boolean isEmergencyNumberInternal(String number, boolean useExactMatch) { - return isEmergencyNumberInternal(getDefaultVoiceSubId(), number, useExactMatch); - } - - /** - * Helper function for isEmergencyNumber(String) and - * isPotentialEmergencyNumber(String). - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * - * @param useExactMatch if true, consider a number to be an emergency - * number only if it *exactly* matches a number listed in - * the RIL / SIM. If false, a number is considered to be an - * emergency number if it simply starts with the same digits - * as any of the emergency numbers listed in the RIL / SIM. - * (Setting useExactMatch to false allows you to identify - * number that could *potentially* result in emergency calls - * since many networks will actually ignore trailing digits - * after a valid emergency number.) - * - * @return true if the number is in the list of emergency numbers - * listed in the RIL / sim, otherwise return false. - */ - private static boolean isEmergencyNumberInternal(int subId, String number, - boolean useExactMatch) { - return isEmergencyNumberInternal(subId, number, null, useExactMatch); - } - - /** - * Checks if a given number is an emergency number for a specific country. - * - * @param number the number to look up. - * @param defaultCountryIso the specific country which the number should be checked against - * @return if the number is an emergency number for the specific country, then return true, - * otherwise false - * - * @deprecated Please use {@link TelephonyManager#isEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - @UnsupportedAppUsage - public static boolean isEmergencyNumber(String number, String defaultCountryIso) { - return isEmergencyNumber(getDefaultVoiceSubId(), number, defaultCountryIso); - } - - /** - * Checks if a given number is an emergency number for a specific country. - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * @param defaultCountryIso the specific country which the number should be checked against - * @return if the number is an emergency number for the specific country, then return true, - * otherwise false - * - * @deprecated Please use {@link TelephonyManager#isEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - public static boolean isEmergencyNumber(int subId, String number, String defaultCountryIso) { - return isEmergencyNumberInternal(subId, number, - defaultCountryIso, - true /* useExactMatch */); - } - - /** - * Checks if a given number might *potentially* result in a call to an - * emergency service, for a specific country. - * - * Specifically, this method will return true if the specified number - * is an emergency number in the specified country, *or* if the number - * simply starts with the same digits as any emergency number for that - * country. - * - * This method is intended for internal use by the phone app when - * deciding whether to allow ACTION_CALL intents from 3rd party apps - * (where we're required to *not* allow emergency calls to be placed.) - * - * @param number the number to look up. - * @param defaultCountryIso the specific country which the number should be checked against - * @return true if the number is an emergency number for the specific - * country, *or* if the number starts with the same digits as - * any of those emergency numbers. - * - * @deprecated Please use {@link TelephonyManager#isPotentialEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - public static boolean isPotentialEmergencyNumber(String number, String defaultCountryIso) { - return isPotentialEmergencyNumber(getDefaultVoiceSubId(), number, defaultCountryIso); - } - - /** - * Checks if a given number might *potentially* result in a call to an - * emergency service, for a specific country. - * - * Specifically, this method will return true if the specified number - * is an emergency number in the specified country, *or* if the number - * simply starts with the same digits as any emergency number for that - * country. - * - * This method is intended for internal use by the phone app when - * deciding whether to allow ACTION_CALL intents from 3rd party apps - * (where we're required to *not* allow emergency calls to be placed.) - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * @param defaultCountryIso the specific country which the number should be checked against - * @return true if the number is an emergency number for the specific - * country, *or* if the number starts with the same digits as - * any of those emergency numbers. - * - * @deprecated Please use {@link TelephonyManager#isPotentialEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - public static boolean isPotentialEmergencyNumber(int subId, String number, - String defaultCountryIso) { - return isEmergencyNumberInternal(subId, number, - defaultCountryIso, - false /* useExactMatch */); - } - - /** - * Helper function for isEmergencyNumber(String, String) and - * isPotentialEmergencyNumber(String, String). - * - * @param number the number to look up. - * @param defaultCountryIso the specific country which the number should be checked against - * @param useExactMatch if true, consider a number to be an emergency - * number only if it *exactly* matches a number listed in - * the RIL / SIM. If false, a number is considered to be an - * emergency number if it simply starts with the same digits - * as any of the emergency numbers listed in the RIL / SIM. - * - * @return true if the number is an emergency number for the specified country. - */ - private static boolean isEmergencyNumberInternal(String number, - String defaultCountryIso, - boolean useExactMatch) { - return isEmergencyNumberInternal(getDefaultVoiceSubId(), number, defaultCountryIso, - useExactMatch); - } - - /** - * Helper function for isEmergencyNumber(String, String) and - * isPotentialEmergencyNumber(String, String). - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * @param defaultCountryIso the specific country which the number should be checked against - * @param useExactMatch if true, consider a number to be an emergency - * number only if it *exactly* matches a number listed in - * the RIL / SIM. If false, a number is considered to be an - * emergency number if it simply starts with the same digits - * as any of the emergency numbers listed in the RIL / SIM. - * * @return true if the number is an emergency number for the specified country. * @hide */ - private static boolean isEmergencyNumberInternal(int subId, String number, - String defaultCountryIso, - boolean useExactMatch) { - // TODO: clean up all the callers that pass in a defaultCountryIso, since it's ignored now. + private static boolean isEmergencyNumberInternal(int subId, String number) { + //TODO: remove subid later. Keep it for now in case we need it later. try { - if (useExactMatch) { return TelephonyManager.getDefault().isEmergencyNumber(number); - } else { - return TelephonyManager.getDefault().isPotentialEmergencyNumber(number); - } } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "isEmergencyNumberInternal: RuntimeException: " + ex); } @@ -2061,143 +1816,7 @@ public class PhoneNumberUtils { */ @Deprecated public static boolean isLocalEmergencyNumber(Context context, String number) { - return isLocalEmergencyNumber(context, getDefaultVoiceSubId(), number); - } - - /** - * Checks if a given number is an emergency number for the country that the user is in. - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * @param context the specific context which the number should be checked against - * @return true if the specified number is an emergency number for the country the user - * is currently in. - * - * @deprecated Please use {@link TelephonyManager#isEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - @UnsupportedAppUsage - public static boolean isLocalEmergencyNumber(Context context, int subId, String number) { - return isLocalEmergencyNumberInternal(subId, number, - context, - true /* useExactMatch */); - } - - /** - * Checks if a given number might *potentially* result in a call to an - * emergency service, for the country that the user is in. The current - * country is determined using the CountryDetector. - * - * Specifically, this method will return true if the specified number - * is an emergency number in the current country, *or* if the number - * simply starts with the same digits as any emergency number for the - * current country. - * - * This method is intended for internal use by the phone app when - * deciding whether to allow ACTION_CALL intents from 3rd party apps - * (where we're required to *not* allow emergency calls to be placed.) - * - * @param number the number to look up. - * @param context the specific context which the number should be checked against - * @return true if the specified number is an emergency number for a local country, based on the - * CountryDetector. - * - * @see android.location.CountryDetector - * - * @deprecated Please use {@link TelephonyManager#isPotentialEmergencyNumber(String)} - * instead. - * - * @hide - */ - @Deprecated - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static boolean isPotentialLocalEmergencyNumber(Context context, String number) { - return isPotentialLocalEmergencyNumber(context, getDefaultVoiceSubId(), number); - } - - /** - * Checks if a given number might *potentially* result in a call to an - * emergency service, for the country that the user is in. The current - * country is determined using the CountryDetector. - * - * Specifically, this method will return true if the specified number - * is an emergency number in the current country, *or* if the number - * simply starts with the same digits as any emergency number for the - * current country. - * - * This method is intended for internal use by the phone app when - * deciding whether to allow ACTION_CALL intents from 3rd party apps - * (where we're required to *not* allow emergency calls to be placed.) - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * @param context the specific context which the number should be checked against - * @return true if the specified number is an emergency number for a local country, based on the - * CountryDetector. - * - * @deprecated Please use {@link TelephonyManager#isPotentialEmergencyNumber(String)} - * instead. - * - * @hide - */ - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - @Deprecated - public static boolean isPotentialLocalEmergencyNumber(Context context, int subId, - String number) { - return isLocalEmergencyNumberInternal(subId, number, - context, - false /* useExactMatch */); - } - - /** - * Helper function for isLocalEmergencyNumber() and - * isPotentialLocalEmergencyNumber(). - * - * @param number the number to look up. - * @param context the specific context which the number should be checked against - * @param useExactMatch if true, consider a number to be an emergency - * number only if it *exactly* matches a number listed in - * the RIL / SIM. If false, a number is considered to be an - * emergency number if it simply starts with the same digits - * as any of the emergency numbers listed in the RIL / SIM. - * - * @return true if the specified number is an emergency number for a - * local country, based on the CountryDetector. - * - * @see android.location.CountryDetector - * @hide - */ - private static boolean isLocalEmergencyNumberInternal(String number, - Context context, - boolean useExactMatch) { - return isLocalEmergencyNumberInternal(getDefaultVoiceSubId(), number, context, - useExactMatch); - } - - /** - * Helper function for isLocalEmergencyNumber() and - * isPotentialLocalEmergencyNumber(). - * - * @param subId the subscription id of the SIM. - * @param number the number to look up. - * @param context the specific context which the number should be checked against - * @param useExactMatch if true, consider a number to be an emergency - * number only if it *exactly* matches a number listed in - * the RIL / SIM. If false, a number is considered to be an - * emergency number if it simply starts with the same digits - * as any of the emergency numbers listed in the RIL / SIM. - * - * @return true if the specified number is an emergency number for a - * local country, based on the CountryDetector. - * @hide - */ - private static boolean isLocalEmergencyNumberInternal(int subId, String number, - Context context, - boolean useExactMatch) { - return isEmergencyNumberInternal(subId, number, null /* unused */, useExactMatch); + return isEmergencyNumberInternal(getDefaultVoiceSubId(), number); } /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index c9a63c654a40c..aa8011bb899d0 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -14367,8 +14367,11 @@ public class TelephonyManager { * network; {@code false} if it is not; or throw an SecurityException if the caller does not * have the required permission/privileges * @throws IllegalStateException if the Telephony process is not currently available. + * + * @deprecated Please use {@link TelephonyManager#isEmergencyNumber(String)} instead. * @hide */ + @Deprecated @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @RequiresFeature(PackageManager.FEATURE_TELEPHONY_CALLING)