diff options
Diffstat (limited to 'telephony/java')
19 files changed, 1084 insertions, 389 deletions
diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java index 1cbe5a26caed..c115a4bd2a10 100644 --- a/telephony/java/android/provider/Telephony.java +++ b/telephony/java/android/provider/Telephony.java @@ -2732,10 +2732,26 @@ public final class Telephony { /** * The {@code content://} style URL for this table. + * For MSIM, this will return APNs for the default subscription + * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM, + * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id. */ public static final Uri CONTENT_URI = Uri.parse("content://telephony/carriers"); /** + * The {@code content://} style URL for this table. Used for APN query based on current + * subscription. Instead of specifying carrier matching information in the selection, + * this API will return all matching APNs from current subscription carrier and queries + * will be applied on top of that. If there is no match for MVNO (Mobile Virtual Network + * Operator) APNs, return APNs from its MNO (based on mccmnc) instead. For MSIM, this will + * return APNs for the default subscription + * {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId for MSIM, + * use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id. + */ + public static final Uri SIM_APN_URI = Uri.parse( + "content://telephony/carriers/sim_apn_list"); + + /** * The {@code content://} style URL to be called from DevicePolicyManagerService, * can manage DPC-owned APNs. * @hide @@ -2745,7 +2761,9 @@ public final class Telephony { /** * The {@code content://} style URL to be called from Telephony to query APNs. * When DPC-owned APNs are enforced, only DPC-owned APNs are returned, otherwise only - * non-DPC-owned APNs are returned. + * non-DPC-owned APNs are returned. For MSIM, this will return APNs for the default + * subscription {@link SubscriptionManager#getDefaultSubscriptionId()}. To specify subId + * for MSIM, use {@link Uri#withAppendedPath(Uri, String)} to append with subscription id. * @hide */ public static final Uri FILTERED_URI = Uri.parse("content://telephony/carriers/filtered"); @@ -2759,13 +2777,6 @@ public final class Telephony { "content://telephony/carriers/enforce_managed"); /** - * The {@code content://} style URL to be called from Telephony to query current APNs. - * @hide - */ - public static final Uri SIM_APN_LIST = Uri.parse( - "content://telephony/carriers/sim_apn_list"); - - /** * The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced. * @hide */ @@ -2839,18 +2850,30 @@ public final class Telephony { /** * Mobile Country Code (MCC). * <P>Type: TEXT</P> + * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return + * matching APNs based on current subscription carrier, thus no need to specify MCC and + * other carrier matching information. In the future, Android will not support MCC for + * APN query. */ public static final String MCC = "mcc"; /** * Mobile Network Code (MNC). * <P>Type: TEXT</P> + * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return + * matching APNs based on current subscription carrier, thus no need to specify MNC and + * other carrier matching information. In the future, Android will not support MNC for + * APN query. */ public static final String MNC = "mnc"; /** * Numeric operator ID (as String). Usually {@code MCC + MNC}. * <P>Type: TEXT</P> + * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return + * matching APNs based on current subscription carrier, thus no need to specify Numeric + * and other carrier matching information. In the future, Android will not support Numeric + * for APN query. */ public static final String NUMERIC = "numeric"; @@ -2931,6 +2954,10 @@ public final class Telephony { * MVNO type: * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}. * <P>Type: TEXT</P> + * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return + * matching APNs based on current subscription carrier, thus no need to specify MVNO_TYPE + * and other carrier matching information. In the future, Android will not support MVNO_TYPE + * for APN query. */ public static final String MVNO_TYPE = "mvno_type"; @@ -2943,6 +2970,10 @@ public final class Telephony { * <li>GID: 4E, 33, ...</li> * </ul> * <P>Type: TEXT</P> + * @deprecated Use {@link #SIM_APN_URI} to query APN instead, this API will return + * matching APNs based on current subscription carrier, thus no need to specify + * MVNO_MATCH_DATA and other carrier matching information. In the future, Android will not + * support MVNO_MATCH_DATA for APN query. */ public static final String MVNO_MATCH_DATA = "mvno_match_data"; @@ -3151,7 +3182,6 @@ public final class Telephony { }) @Retention(RetentionPolicy.SOURCE) public @interface EditStatus {} - } /** diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index fd14916ecac9..f87472d9ec38 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -2400,6 +2400,34 @@ public class CarrierConfigManager { public static final String KEY_5G_ICON_CONFIGURATION_STRING = "5g_icon_configuration_string"; + /** + * Controls RSRP threshold at which AlternativeNetworkService will decide whether + * the opportunistic network is good enough for internet data. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSRP_INT = + "opportunistic_network_entry_threshold_rsrp_int"; + + /** + * Controls RSSNR threshold at which AlternativeNetworkService will decide whether + * the opportunistic network is good enough for internet data. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT = + "opportunistic_network_entry_threshold_rssnr_int"; + + /** + * Controls RSRP threshold below which AlternativeNetworkService will decide whether + * the opportunistic network available is not good enough for internet data. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSRP_INT = + "opportunistic_network_exit_threshold_rsrp_int"; + + /** + * Controls RSSNR threshold below which AlternativeNetworkService will decide whether + * the opportunistic network available is not good enough for internet data. + */ + public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT = + "opportunistic_network_exit_threshold_rssnr_int"; + /** The default value for every variable. */ private final static PersistableBundle sDefaults; @@ -2761,6 +2789,14 @@ public class CarrierConfigManager { sDefaults.putInt(KEY_CALL_WAITING_SERVICE_CLASS_INT, 1 /* SERVICE_CLASS_VOICE */); sDefaults.putString(KEY_5G_ICON_CONFIGURATION_STRING, "connected_mmwave:None,connected:5G,not_restricted:None,restricted:None"); + /* Default value is minimum RSRP level needed for SIGNAL_STRENGTH_GOOD */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSRP_INT, -108); + /* Default value is minimum RSRP level needed for SIGNAL_STRENGTH_MODERATE */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSRP_INT, -118); + /* Default value is minimum RSSNR level needed for SIGNAL_STRENGTH_GOOD */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT, 45); + /* Default value is minimum RSSNR level needed for SIGNAL_STRENGTH_MODERATE */ + sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT, 10); } /** diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index 04c28e5211c8..c8a899b339c6 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; @@ -169,6 +170,7 @@ public final class CellIdentityGsm extends CellIdentity { /** * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown. */ + @Nullable public String getMobileNetworkOperator() { return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr; } diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index 04b6a6ca7fea..8e1877d8e35f 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; @@ -197,6 +198,7 @@ public final class CellIdentityLte extends CellIdentity { /** * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown. */ + @Nullable public String getMobileNetworkOperator() { return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr; } diff --git a/telephony/java/android/telephony/CellIdentityTdscdma.java b/telephony/java/android/telephony/CellIdentityTdscdma.java index 8b1c1b9f024c..f77c468d2f5e 100644 --- a/telephony/java/android/telephony/CellIdentityTdscdma.java +++ b/telephony/java/android/telephony/CellIdentityTdscdma.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.Nullable; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; @@ -116,6 +117,7 @@ public final class CellIdentityTdscdma extends CellIdentity { /** * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown */ + @Nullable public String getMobileNetworkOperator() { return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr; } diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 3416ffe0b8f4..31f9e6d5bb90 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; @@ -173,6 +174,7 @@ public final class CellIdentityWcdma extends CellIdentity { /** * @return a 5 or 6 character string (MCC+MNC), null if any field is unknown */ + @Nullable public String getMobileNetworkOperator() { return (mMccStr == null || mMncStr == null) ? null : mMccStr + mMncStr; } diff --git a/telephony/java/android/telephony/DataFailCause.java b/telephony/java/android/telephony/DataFailCause.java index c6f7d0e458db..c53b37d8ae6a 100644 --- a/telephony/java/android/telephony/DataFailCause.java +++ b/telephony/java/android/telephony/DataFailCause.java @@ -15,151 +15,383 @@ */ package android.telephony; +import android.annotation.IntDef; +import android.annotation.NonNull; import android.content.Context; import android.os.PersistableBundle; +import com.android.internal.util.ArrayUtils; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; +import java.util.Set; /** - * Returned as the reason for a connection failure as defined - * by RIL_DataCallFailCause in ril.h and some local errors. + * Returned as the reason for a data connection failure as defined by modem and some local errors. * @hide */ -public enum DataFailCause { - NONE(0), +public final class DataFailCause { + /** There is no failure */ + public static final int NONE = 0; // This series of errors as specified by the standards // specified in ril.h - OPERATOR_BARRED(0x08), /* no retry */ - NAS_SIGNALLING(0x0E), - LLC_SNDCP(0x19), - INSUFFICIENT_RESOURCES(0x1A), - MISSING_UNKNOWN_APN(0x1B), /* no retry */ - UNKNOWN_PDP_ADDRESS_TYPE(0x1C), /* no retry */ - USER_AUTHENTICATION(0x1D), /* no retry */ - ACTIVATION_REJECT_GGSN(0x1E), /* no retry */ - ACTIVATION_REJECT_UNSPECIFIED(0x1F), - SERVICE_OPTION_NOT_SUPPORTED(0x20), /* no retry */ - SERVICE_OPTION_NOT_SUBSCRIBED(0x21), /* no retry */ - SERVICE_OPTION_OUT_OF_ORDER(0x22), - NSAPI_IN_USE(0x23), /* no retry */ - REGULAR_DEACTIVATION(0x24), /* possibly restart radio, based on config */ - QOS_NOT_ACCEPTED(0x25), - NETWORK_FAILURE(0x26), - UMTS_REACTIVATION_REQ(0x27), - FEATURE_NOT_SUPP(0x28), - TFT_SEMANTIC_ERROR(0x29), - TFT_SYTAX_ERROR(0x2A), - UNKNOWN_PDP_CONTEXT(0x2B), - FILTER_SEMANTIC_ERROR(0x2C), - FILTER_SYTAX_ERROR(0x2D), - PDP_WITHOUT_ACTIVE_TFT(0x2E), - ONLY_IPV4_ALLOWED(0x32), /* no retry */ - ONLY_IPV6_ALLOWED(0x33), /* no retry */ - ONLY_SINGLE_BEARER_ALLOWED(0x34), - ESM_INFO_NOT_RECEIVED(0x35), - PDN_CONN_DOES_NOT_EXIST(0x36), - MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED(0x37), - MAX_ACTIVE_PDP_CONTEXT_REACHED(0x41), - UNSUPPORTED_APN_IN_CURRENT_PLMN(0x42), - INVALID_TRANSACTION_ID(0x51), - MESSAGE_INCORRECT_SEMANTIC(0x5F), - INVALID_MANDATORY_INFO(0x60), - MESSAGE_TYPE_UNSUPPORTED(0x61), - MSG_TYPE_NONCOMPATIBLE_STATE(0x62), - UNKNOWN_INFO_ELEMENT(0x63), - CONDITIONAL_IE_ERROR(0x64), - MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE(0x65), - PROTOCOL_ERRORS(0x6F), /* no retry */ - APN_TYPE_CONFLICT(0x70), - INVALID_PCSCF_ADDR(0x71), - INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN(0x72), - EMM_ACCESS_BARRED(0x73), - EMERGENCY_IFACE_ONLY(0x74), - IFACE_MISMATCH(0x75), - COMPANION_IFACE_IN_USE(0x76), - IP_ADDRESS_MISMATCH(0x77), - IFACE_AND_POL_FAMILY_MISMATCH(0x78), - EMM_ACCESS_BARRED_INFINITE_RETRY(0x79), - AUTH_FAILURE_ON_EMERGENCY_CALL(0x7A), + /** Operator determined barring. */ + public static final int OPERATOR_BARRED = 0x08; + /** NAS signalling. */ + public static final int NAS_SIGNALLING = 0x0E; + /** Logical Link Control (LLC) Sub Network Dependent Convergence Protocol (SNDCP). */ + public static final int LLC_SNDCP = 0x19; + /** Insufficient resources. */ + public static final int INSUFFICIENT_RESOURCES = 0x1A; + /** Missing or unknown APN. */ + public static final int MISSING_UNKNOWN_APN = 0x1B; /* no retry */ + /** Unknown Packet Data Protocol (PDP) address type. */ + public static final int UNKNOWN_PDP_ADDRESS_TYPE = 0x1C; /* no retry */ + /** User authentication. */ + public static final int USER_AUTHENTICATION = 0x1D; /* no retry */ + /** Activation rejected by Gateway GPRS Support Node (GGSN), Serving Gateway or PDN Gateway. */ + public static final int ACTIVATION_REJECT_GGSN = 0x1E; /* no retry */ + /** Activation rejected, unspecified. */ + public static final int ACTIVATION_REJECT_UNSPECIFIED = 0x1F; + /** Service option not supported. */ + public static final int SERVICE_OPTION_NOT_SUPPORTED = 0x20; /* no retry */ + /** Requested service option not subscribed. */ + public static final int SERVICE_OPTION_NOT_SUBSCRIBED = 0x21; /* no retry */ + /** Service option temporarily out of order. */ + public static final int SERVICE_OPTION_OUT_OF_ORDER = 0x22; + /** The Network Service Access Point Identifier (NSAPI) is in use. */ + public static final int NSAPI_IN_USE = 0x23; /* no retry */ + /* possibly restart radio, based on config */ + /** Regular deactivation. */ + public static final int REGULAR_DEACTIVATION = 0x24; + /** Quality of service (QoS) is not accepted. */ + public static final int QOS_NOT_ACCEPTED = 0x25; + /** Network Failure. */ + public static final int NETWORK_FAILURE = 0x26; + /** Universal Mobile Telecommunications System (UMTS) reactivation request. */ + public static final int UMTS_REACTIVATION_REQ = 0x27; + /** Feature not supported. */ + public static final int FEATURE_NOT_SUPP = 0x28; + /** Semantic error in the Traffic flow templates (TFT) operation. */ + public static final int TFT_SEMANTIC_ERROR = 0x29; + /** Syntactical error in the Traffic flow templates (TFT) operation. */ + public static final int TFT_SYTAX_ERROR = 0x2A; + /** Unknown Packet Data Protocol (PDP) context. */ + public static final int UNKNOWN_PDP_CONTEXT = 0x2B; + /** Semantic errors in packet filter. */ + public static final int FILTER_SEMANTIC_ERROR = 0x2C; + /** Syntactical errors in packet filter(s). */ + public static final int FILTER_SYTAX_ERROR = 0x2D; + /** Packet Data Protocol (PDP) without active traffic flow template (TFT). */ + public static final int PDP_WITHOUT_ACTIVE_TFT = 0x2E; + /** Packet Data Protocol (PDP) type IPv4 only allowed. */ + public static final int ONLY_IPV4_ALLOWED = 0x32; /* no retry */ + /** Packet Data Protocol (PDP) type IPv6 only allowed. */ + public static final int ONLY_IPV6_ALLOWED = 0x33; /* no retry */ + /** Single address bearers only allowed. */ + public static final int ONLY_SINGLE_BEARER_ALLOWED = 0x34; + /** EPS Session Management (ESM) information is not received. */ + public static final int ESM_INFO_NOT_RECEIVED = 0x35; + /** PDN connection does not exist. */ + public static final int PDN_CONN_DOES_NOT_EXIST = 0x36; + /** Multiple connections to a same PDN is not allowed. */ + public static final int MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED = 0x37; + /** Packet Data Protocol (PDP) */ + public static final int MAX_ACTIVE_PDP_CONTEXT_REACHED = 0x41; + /** Unsupported APN in current public land mobile network (PLMN). */ + public static final int UNSUPPORTED_APN_IN_CURRENT_PLMN = 0x42; + /** Invalid transaction id. */ + public static final int INVALID_TRANSACTION_ID = 0x51; + /** Incorrect message semantic. */ + public static final int MESSAGE_INCORRECT_SEMANTIC = 0x5F; + /** Invalid mandatory information. */ + public static final int INVALID_MANDATORY_INFO = 0x60; + /** Unsupported message type. */ + public static final int MESSAGE_TYPE_UNSUPPORTED = 0x61; + /** Message type uncompatible. */ + public static final int MSG_TYPE_NONCOMPATIBLE_STATE = 0x62; + /** Unknown info element. */ + public static final int UNKNOWN_INFO_ELEMENT = 0x63; + /** Conditional Information Element (IE) error. */ + public static final int CONDITIONAL_IE_ERROR = 0x64; + /** Message and protocol state uncompatible. */ + public static final int MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE = 0x65; + /** Protocol errors. */ + public static final int PROTOCOL_ERRORS = 0x6F; /* no retry */ + /** APN type conflict. */ + public static final int APN_TYPE_CONFLICT = 0x70; + /** Invalid Proxy-Call Session Control Function (P-CSCF) address. */ + public static final int INVALID_PCSCF_ADDR = 0x71; + /** Internal data call preempt by high priority APN. */ + public static final int INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN = 0x72; + /** EPS (Evolved Packet System) Mobility Management (EMM) access barred. */ + public static final int EMM_ACCESS_BARRED = 0x73; + /** Emergency interface only. */ + public static final int EMERGENCY_IFACE_ONLY = 0x74; + /** Interface mismatch. */ + public static final int IFACE_MISMATCH = 0x75; + /** Companion interface in use. */ + public static final int COMPANION_IFACE_IN_USE = 0x76; + /** IP address mismatch. */ + public static final int IP_ADDRESS_MISMATCH = 0x77; + public static final int IFACE_AND_POL_FAMILY_MISMATCH = 0x78; + /** EPS (Evolved Packet System) Mobility Management (EMM) access barred infinity retry. **/ + public static final int EMM_ACCESS_BARRED_INFINITE_RETRY = 0x79; + /** Authentication failure on emergency call. */ + public static final int AUTH_FAILURE_ON_EMERGENCY_CALL = 0x7A; // OEM sepecific error codes. To be used by OEMs when they don't // want to reveal error code which would be replaced by ERROR_UNSPECIFIED - OEM_DCFAILCAUSE_1(0x1001), - OEM_DCFAILCAUSE_2(0x1002), - OEM_DCFAILCAUSE_3(0x1003), - OEM_DCFAILCAUSE_4(0x1004), - OEM_DCFAILCAUSE_5(0x1005), - OEM_DCFAILCAUSE_6(0x1006), - OEM_DCFAILCAUSE_7(0x1007), - OEM_DCFAILCAUSE_8(0x1008), - OEM_DCFAILCAUSE_9(0x1009), - OEM_DCFAILCAUSE_10(0x100A), - OEM_DCFAILCAUSE_11(0x100B), - OEM_DCFAILCAUSE_12(0x100C), - OEM_DCFAILCAUSE_13(0x100D), - OEM_DCFAILCAUSE_14(0x100E), - OEM_DCFAILCAUSE_15(0x100F), + public static final int OEM_DCFAILCAUSE_1 = 0x1001; + public static final int OEM_DCFAILCAUSE_2 = 0x1002; + public static final int OEM_DCFAILCAUSE_3 = 0x1003; + public static final int OEM_DCFAILCAUSE_4 = 0x1004; + public static final int OEM_DCFAILCAUSE_5 = 0x1005; + public static final int OEM_DCFAILCAUSE_6 = 0x1006; + public static final int OEM_DCFAILCAUSE_7 = 0x1007; + public static final int OEM_DCFAILCAUSE_8 = 0x1008; + public static final int OEM_DCFAILCAUSE_9 = 0x1009; + public static final int OEM_DCFAILCAUSE_10 = 0x100A; + public static final int OEM_DCFAILCAUSE_11 = 0x100B; + public static final int OEM_DCFAILCAUSE_12 = 0x100C; + public static final int OEM_DCFAILCAUSE_13 = 0x100D; + public static final int OEM_DCFAILCAUSE_14 = 0x100E; + public static final int OEM_DCFAILCAUSE_15 = 0x100F; // Local errors generated by Vendor RIL // specified in ril.h - REGISTRATION_FAIL(-1), - GPRS_REGISTRATION_FAIL(-2), - SIGNAL_LOST(-3), /* no retry */ - PREF_RADIO_TECH_CHANGED(-4), - RADIO_POWER_OFF(-5), /* no retry */ - TETHERED_CALL_ACTIVE(-6), /* no retry */ - ERROR_UNSPECIFIED(0xFFFF), + public static final int REGISTRATION_FAIL = -1; + public static final int GPRS_REGISTRATION_FAIL = -2; + public static final int SIGNAL_LOST = -3; /* no retry */ + public static final int PREF_RADIO_TECH_CHANGED = -4; + public static final int RADIO_POWER_OFF = -5; /* no retry */ + public static final int TETHERED_CALL_ACTIVE = -6; /* no retry */ + public static final int ERROR_UNSPECIFIED = 0xFFFF; // Errors generated by the Framework // specified here - UNKNOWN(0x10000), - RADIO_NOT_AVAILABLE(0x10001), /* no retry */ - UNACCEPTABLE_NETWORK_PARAMETER(0x10002), /* no retry */ - CONNECTION_TO_DATACONNECTIONAC_BROKEN(0x10003), - LOST_CONNECTION(0x10004), - RESET_BY_FRAMEWORK(0x10005); + public static final int UNKNOWN = 0x10000; + public static final int RADIO_NOT_AVAILABLE = 0x10001; /* no retry */ + public static final int UNACCEPTABLE_NETWORK_PARAMETER = 0x10002; /* no retry */ + public static final int CONNECTION_TO_DATACONNECTIONAC_BROKEN = 0x10003; + public static final int LOST_CONNECTION = 0x10004; + /** Data was reset by framework. */ + public static final int RESET_BY_FRAMEWORK = 0x10005; + + /** @hide */ + @IntDef(value = { + NONE, + OPERATOR_BARRED, + NAS_SIGNALLING, + LLC_SNDCP, + INSUFFICIENT_RESOURCES, + MISSING_UNKNOWN_APN, + UNKNOWN_PDP_ADDRESS_TYPE, + USER_AUTHENTICATION, + ACTIVATION_REJECT_GGSN, + ACTIVATION_REJECT_UNSPECIFIED, + SERVICE_OPTION_NOT_SUPPORTED, + SERVICE_OPTION_NOT_SUBSCRIBED, + SERVICE_OPTION_OUT_OF_ORDER, + NSAPI_IN_USE, + REGULAR_DEACTIVATION, + QOS_NOT_ACCEPTED, + NETWORK_FAILURE, + UMTS_REACTIVATION_REQ, + FEATURE_NOT_SUPP, + TFT_SEMANTIC_ERROR, + TFT_SYTAX_ERROR, + UNKNOWN_PDP_CONTEXT, + FILTER_SEMANTIC_ERROR, + FILTER_SYTAX_ERROR, + PDP_WITHOUT_ACTIVE_TFT, + ONLY_IPV4_ALLOWED, + ONLY_IPV6_ALLOWED, + ONLY_SINGLE_BEARER_ALLOWED, + ESM_INFO_NOT_RECEIVED, + PDN_CONN_DOES_NOT_EXIST, + MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED, + MAX_ACTIVE_PDP_CONTEXT_REACHED, + UNSUPPORTED_APN_IN_CURRENT_PLMN, + INVALID_TRANSACTION_ID, + MESSAGE_INCORRECT_SEMANTIC, + INVALID_MANDATORY_INFO, + MESSAGE_TYPE_UNSUPPORTED, + MSG_TYPE_NONCOMPATIBLE_STATE, + UNKNOWN_INFO_ELEMENT, + CONDITIONAL_IE_ERROR, + MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE, + PROTOCOL_ERRORS, /* no retry */ + APN_TYPE_CONFLICT, + INVALID_PCSCF_ADDR, + INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN, + EMM_ACCESS_BARRED, + EMERGENCY_IFACE_ONLY, + IFACE_MISMATCH, + COMPANION_IFACE_IN_USE, + IP_ADDRESS_MISMATCH, + IFACE_AND_POL_FAMILY_MISMATCH, + EMM_ACCESS_BARRED_INFINITE_RETRY, + AUTH_FAILURE_ON_EMERGENCY_CALL, + OEM_DCFAILCAUSE_1, + OEM_DCFAILCAUSE_2, + OEM_DCFAILCAUSE_3, + OEM_DCFAILCAUSE_4, + OEM_DCFAILCAUSE_5, + OEM_DCFAILCAUSE_6, + OEM_DCFAILCAUSE_7, + OEM_DCFAILCAUSE_8, + OEM_DCFAILCAUSE_9, + OEM_DCFAILCAUSE_10, + OEM_DCFAILCAUSE_11, + OEM_DCFAILCAUSE_12, + OEM_DCFAILCAUSE_13, + OEM_DCFAILCAUSE_14, + OEM_DCFAILCAUSE_15, + REGISTRATION_FAIL, + GPRS_REGISTRATION_FAIL, + SIGNAL_LOST, + PREF_RADIO_TECH_CHANGED, + RADIO_POWER_OFF, + TETHERED_CALL_ACTIVE, + ERROR_UNSPECIFIED, + UNKNOWN, + RADIO_NOT_AVAILABLE, + UNACCEPTABLE_NETWORK_PARAMETER, + CONNECTION_TO_DATACONNECTIONAC_BROKEN, + LOST_CONNECTION, + RESET_BY_FRAMEWORK + }) + @Retention(RetentionPolicy.SOURCE) + public @interface FailCause{} - private final int mErrorCode; - private static final HashMap<Integer, DataFailCause> sErrorCodeToFailCauseMap; + private static final Map<Integer, String> sFailCauseMap; static { - sErrorCodeToFailCauseMap = new HashMap<Integer, DataFailCause>(); - for (DataFailCause fc : values()) { - sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc); - } + sFailCauseMap = new HashMap<>(); + sFailCauseMap.put(NONE, "NONE"); + sFailCauseMap.put(OPERATOR_BARRED, "OPERATOR_BARRED"); + sFailCauseMap.put(NAS_SIGNALLING, "NAS_SIGNALLING"); + sFailCauseMap.put(LLC_SNDCP, "LLC_SNDCP"); + sFailCauseMap.put(INSUFFICIENT_RESOURCES, "INSUFFICIENT_RESOURCES"); + sFailCauseMap.put(MISSING_UNKNOWN_APN, "MISSING_UNKNOWN_APN"); + sFailCauseMap.put(UNKNOWN_PDP_ADDRESS_TYPE, "UNKNOWN_PDP_ADDRESS_TYPE"); + sFailCauseMap.put(USER_AUTHENTICATION, "USER_AUTHENTICATION"); + sFailCauseMap.put(ACTIVATION_REJECT_GGSN, "ACTIVATION_REJECT_GGSN"); + sFailCauseMap.put(ACTIVATION_REJECT_UNSPECIFIED, + "ACTIVATION_REJECT_UNSPECIFIED"); + sFailCauseMap.put(SERVICE_OPTION_NOT_SUPPORTED, + "SERVICE_OPTION_NOT_SUPPORTED"); + sFailCauseMap.put(SERVICE_OPTION_NOT_SUBSCRIBED, + "SERVICE_OPTION_NOT_SUBSCRIBED"); + sFailCauseMap.put(SERVICE_OPTION_OUT_OF_ORDER, "SERVICE_OPTION_OUT_OF_ORDER"); + sFailCauseMap.put(NSAPI_IN_USE, "NSAPI_IN_USE"); + sFailCauseMap.put(REGULAR_DEACTIVATION, "REGULAR_DEACTIVATION"); + sFailCauseMap.put(QOS_NOT_ACCEPTED, "QOS_NOT_ACCEPTED"); + sFailCauseMap.put(NETWORK_FAILURE, "NETWORK_FAILURE"); + sFailCauseMap.put(UMTS_REACTIVATION_REQ, "UMTS_REACTIVATION_REQ"); + sFailCauseMap.put(FEATURE_NOT_SUPP, "FEATURE_NOT_SUPP"); + sFailCauseMap.put(TFT_SEMANTIC_ERROR, "TFT_SEMANTIC_ERROR"); + sFailCauseMap.put(TFT_SYTAX_ERROR, "TFT_SYTAX_ERROR"); + sFailCauseMap.put(UNKNOWN_PDP_CONTEXT, "UNKNOWN_PDP_CONTEXT"); + sFailCauseMap.put(FILTER_SEMANTIC_ERROR, "FILTER_SEMANTIC_ERROR"); + sFailCauseMap.put(FILTER_SYTAX_ERROR, "FILTER_SYTAX_ERROR"); + sFailCauseMap.put(PDP_WITHOUT_ACTIVE_TFT, "PDP_WITHOUT_ACTIVE_TFT"); + sFailCauseMap.put(ONLY_IPV4_ALLOWED, "ONLY_IPV4_ALLOWED"); + sFailCauseMap.put(ONLY_IPV6_ALLOWED, "ONLY_IPV6_ALLOWED"); + sFailCauseMap.put(ONLY_SINGLE_BEARER_ALLOWED, "ONLY_SINGLE_BEARER_ALLOWED"); + sFailCauseMap.put(ESM_INFO_NOT_RECEIVED, "ESM_INFO_NOT_RECEIVED"); + sFailCauseMap.put(PDN_CONN_DOES_NOT_EXIST, "PDN_CONN_DOES_NOT_EXIST"); + sFailCauseMap.put(MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED, + "MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED"); + sFailCauseMap.put(MAX_ACTIVE_PDP_CONTEXT_REACHED, + "MAX_ACTIVE_PDP_CONTEXT_REACHED"); + sFailCauseMap.put(UNSUPPORTED_APN_IN_CURRENT_PLMN, + "UNSUPPORTED_APN_IN_CURRENT_PLMN"); + sFailCauseMap.put(INVALID_TRANSACTION_ID, "INVALID_TRANSACTION_ID"); + sFailCauseMap.put(MESSAGE_INCORRECT_SEMANTIC, "MESSAGE_INCORRECT_SEMANTIC"); + sFailCauseMap.put(INVALID_MANDATORY_INFO, "INVALID_MANDATORY_INFO"); + sFailCauseMap.put(MESSAGE_TYPE_UNSUPPORTED, "MESSAGE_TYPE_UNSUPPORTED"); + sFailCauseMap.put(MSG_TYPE_NONCOMPATIBLE_STATE, "MSG_TYPE_NONCOMPATIBLE_STATE"); + sFailCauseMap.put(UNKNOWN_INFO_ELEMENT, "UNKNOWN_INFO_ELEMENT"); + sFailCauseMap.put(CONDITIONAL_IE_ERROR, "CONDITIONAL_IE_ERROR"); + sFailCauseMap.put(MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE, + "MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE"); + sFailCauseMap.put(PROTOCOL_ERRORS, "PROTOCOL_ERRORS"); + sFailCauseMap.put(APN_TYPE_CONFLICT, "APN_TYPE_CONFLICT"); + sFailCauseMap.put(INVALID_PCSCF_ADDR, "INVALID_PCSCF_ADDR"); + sFailCauseMap.put(INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN, + "INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN"); + sFailCauseMap.put(EMM_ACCESS_BARRED, "EMM_ACCESS_BARRED"); + sFailCauseMap.put(EMERGENCY_IFACE_ONLY, "EMERGENCY_IFACE_ONLY"); + sFailCauseMap.put(IFACE_MISMATCH, "IFACE_MISMATCH"); + sFailCauseMap.put(COMPANION_IFACE_IN_USE, "COMPANION_IFACE_IN_USE"); + sFailCauseMap.put(IP_ADDRESS_MISMATCH, "IP_ADDRESS_MISMATCH"); + sFailCauseMap.put(IFACE_AND_POL_FAMILY_MISMATCH, + "IFACE_AND_POL_FAMILY_MISMATCH"); + sFailCauseMap.put(EMM_ACCESS_BARRED_INFINITE_RETRY, + "EMM_ACCESS_BARRED_INFINITE_RETRY"); + sFailCauseMap.put(AUTH_FAILURE_ON_EMERGENCY_CALL, + "AUTH_FAILURE_ON_EMERGENCY_CALL"); + sFailCauseMap.put(OEM_DCFAILCAUSE_1, "OEM_DCFAILCAUSE_1"); + sFailCauseMap.put(OEM_DCFAILCAUSE_2, "OEM_DCFAILCAUSE_2"); + sFailCauseMap.put(OEM_DCFAILCAUSE_3, "OEM_DCFAILCAUSE_3"); + sFailCauseMap.put(OEM_DCFAILCAUSE_4, "OEM_DCFAILCAUSE_4"); + sFailCauseMap.put(OEM_DCFAILCAUSE_5, "OEM_DCFAILCAUSE_5"); + sFailCauseMap.put(OEM_DCFAILCAUSE_6, "OEM_DCFAILCAUSE_6"); + sFailCauseMap.put(OEM_DCFAILCAUSE_7, "OEM_DCFAILCAUSE_7"); + sFailCauseMap.put(OEM_DCFAILCAUSE_8, "OEM_DCFAILCAUSE_8"); + sFailCauseMap.put(OEM_DCFAILCAUSE_9, "OEM_DCFAILCAUSE_9"); + sFailCauseMap.put(OEM_DCFAILCAUSE_10, "OEM_DCFAILCAUSE_10"); + sFailCauseMap.put(OEM_DCFAILCAUSE_11, "OEM_DCFAILCAUSE_11"); + sFailCauseMap.put(OEM_DCFAILCAUSE_12, "OEM_DCFAILCAUSE_12"); + sFailCauseMap.put(OEM_DCFAILCAUSE_13, "OEM_DCFAILCAUSE_13"); + sFailCauseMap.put(OEM_DCFAILCAUSE_14, "OEM_DCFAILCAUSE_14"); + sFailCauseMap.put(OEM_DCFAILCAUSE_15, "OEM_DCFAILCAUSE_15"); + sFailCauseMap.put(REGISTRATION_FAIL, "REGISTRATION_FAIL"); + sFailCauseMap.put(GPRS_REGISTRATION_FAIL, "GPRS_REGISTRATION_FAIL"); + sFailCauseMap.put(SIGNAL_LOST, "SIGNAL_LOST"); + sFailCauseMap.put(PREF_RADIO_TECH_CHANGED, "PREF_RADIO_TECH_CHANGED"); + sFailCauseMap.put(RADIO_POWER_OFF, "RADIO_POWER_OFF"); + sFailCauseMap.put(TETHERED_CALL_ACTIVE, "TETHERED_CALL_ACTIVE"); + sFailCauseMap.put(ERROR_UNSPECIFIED, "ERROR_UNSPECIFIED"); + sFailCauseMap.put(UNKNOWN, "UNKNOWN"); + sFailCauseMap.put(RADIO_NOT_AVAILABLE, "RADIO_NOT_AVAILABLE"); + sFailCauseMap.put(UNACCEPTABLE_NETWORK_PARAMETER, + "UNACCEPTABLE_NETWORK_PARAMETER"); + sFailCauseMap.put(CONNECTION_TO_DATACONNECTIONAC_BROKEN, + "CONNECTION_TO_DATACONNECTIONAC_BROKEN"); + sFailCauseMap.put(LOST_CONNECTION, "LOST_CONNECTION"); + sFailCauseMap.put(RESET_BY_FRAMEWORK, "RESET_BY_FRAMEWORK"); } /** * Map of subId -> set of data call setup permanent failure for the carrier. */ - private static final HashMap<Integer, HashSet<DataFailCause>> sPermanentFailureCache = + private static final HashMap<Integer, Set<Integer>> sPermanentFailureCache = new HashMap<>(); - DataFailCause(int errorCode) { - mErrorCode = errorCode; - } - - public int getErrorCode() { - return mErrorCode; - } - /** * Returns whether or not the fail cause is a failure that requires a modem restart * * @param context device context + * @param cause data disconnect cause * @param subId subscription index * @return true if the fail cause code needs platform to trigger a modem restart. */ - public boolean isRadioRestartFailure(Context context, int subId) { + public static boolean isRadioRestartFailure(@NonNull Context context, @FailCause int cause, + int subId) { CarrierConfigManager configManager = (CarrierConfigManager) context.getSystemService(Context.CARRIER_CONFIG_SERVICE); if (configManager != null) { PersistableBundle b = configManager.getConfigForSubId(subId); if (b != null) { - if (this == REGULAR_DEACTIVATION + if (cause == REGULAR_DEACTIVATION && b.getBoolean(CarrierConfigManager .KEY_RESTART_RADIO_ON_PDP_FAIL_REGULAR_DEACTIVATION_BOOL)) { // This is for backward compatibility support. We need to continue support this @@ -170,7 +402,7 @@ public enum DataFailCause { int[] causeCodes = b.getIntArray(CarrierConfigManager .KEY_RADIO_RESTART_FAILURE_CAUSES_INT_ARRAY); if (causeCodes != null) { - return Arrays.stream(causeCodes).anyMatch(i -> i == getErrorCode()); + return Arrays.stream(causeCodes).anyMatch(i -> i == cause); } } } @@ -178,11 +410,11 @@ public enum DataFailCause { return false; } - public boolean isPermanentFailure(Context context, int subId) { - + public static boolean isPermanentFailure(@NonNull Context context, @FailCause int failCause, + int subId) { synchronized (sPermanentFailureCache) { - HashSet<DataFailCause> permanentFailureSet = sPermanentFailureCache.get(subId); + Set<Integer> permanentFailureSet = sPermanentFailureCache.get(subId); // In case of cache miss, we need to look up the settings from carrier config. if (permanentFailureSet == null) { @@ -194,11 +426,12 @@ public enum DataFailCause { if (b != null) { String[] permanentFailureStrings = b.getStringArray(CarrierConfigManager. KEY_CARRIER_DATA_CALL_PERMANENT_FAILURE_STRINGS); - if (permanentFailureStrings != null) { permanentFailureSet = new HashSet<>(); - for (String failure : permanentFailureStrings) { - permanentFailureSet.add(DataFailCause.valueOf(failure)); + for (Map.Entry<Integer, String> e : sFailCauseMap.entrySet()) { + if (ArrayUtils.contains(permanentFailureStrings, e.getValue())) { + permanentFailureSet.add(e.getKey()); + } } } } @@ -207,7 +440,7 @@ public enum DataFailCause { // If we are not able to find the configuration from carrier config, use the default // ones. if (permanentFailureSet == null) { - permanentFailureSet = new HashSet<DataFailCause>() { + permanentFailureSet = new HashSet<Integer>() { { add(OPERATOR_BARRED); add(MISSING_UNKNOWN_APN); @@ -232,28 +465,39 @@ public enum DataFailCause { sPermanentFailureCache.put(subId, permanentFailureSet); } - return permanentFailureSet.contains(this); + return permanentFailureSet.contains(failCause); } } - public boolean isEventLoggable() { - return (this == OPERATOR_BARRED) || (this == INSUFFICIENT_RESOURCES) || - (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || - (this == ACTIVATION_REJECT_GGSN) || (this == ACTIVATION_REJECT_UNSPECIFIED) || - (this == SERVICE_OPTION_NOT_SUBSCRIBED) || - (this == SERVICE_OPTION_NOT_SUPPORTED) || - (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) || - (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || - (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) || - (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || - (this == UNACCEPTABLE_NETWORK_PARAMETER); + public static boolean isEventLoggable(@FailCause int dataFailCause) { + return (dataFailCause == OPERATOR_BARRED) || (dataFailCause == INSUFFICIENT_RESOURCES) + || (dataFailCause == UNKNOWN_PDP_ADDRESS_TYPE) + || (dataFailCause == USER_AUTHENTICATION) + || (dataFailCause == ACTIVATION_REJECT_GGSN) + || (dataFailCause == ACTIVATION_REJECT_UNSPECIFIED) + || (dataFailCause == SERVICE_OPTION_NOT_SUBSCRIBED) + || (dataFailCause == SERVICE_OPTION_NOT_SUPPORTED) + || (dataFailCause == SERVICE_OPTION_OUT_OF_ORDER) + || (dataFailCause == NSAPI_IN_USE) + || (dataFailCause == ONLY_IPV4_ALLOWED) + || (dataFailCause == ONLY_IPV6_ALLOWED) + || (dataFailCause == PROTOCOL_ERRORS) + || (dataFailCause == SIGNAL_LOST) + || (dataFailCause == RADIO_POWER_OFF) + || (dataFailCause == TETHERED_CALL_ACTIVE) + || (dataFailCause == UNACCEPTABLE_NETWORK_PARAMETER); + } + + public static String toString(@FailCause int dataFailCause) { + int cause = getFailCause(dataFailCause); + return (cause == UNKNOWN) ? "UNKNOWN(" + dataFailCause + ")" : sFailCauseMap.get(cause); } - public static DataFailCause fromInt(int errorCode) { - DataFailCause fc = sErrorCodeToFailCauseMap.get(errorCode); - if (fc == null) { - fc = UNKNOWN; + public static int getFailCause(@FailCause int failCause) { + if (sFailCauseMap.containsKey(failCause)) { + return failCause; + } else { + return UNKNOWN; } - return fc; } } diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java index c6887ab93109..f53cb8224706 100644 --- a/telephony/java/android/telephony/DisconnectCause.java +++ b/telephony/java/android/telephony/DisconnectCause.java @@ -16,12 +16,16 @@ package android.telephony; +import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; /** - * Contains disconnect call causes generated by the framework and the RIL. + * Describes the cause of a disconnected call. Those disconnect causes can be converted into a more + * generic {@link android.telecom.DisconnectCause} object. + * * @hide */ +@SystemApi public class DisconnectCause { /** The disconnect cause is not valid (Not received a disconnect cause) */ @@ -101,8 +105,8 @@ public class DisconnectCause { /** Unknown error or not specified */ public static final int ERROR_UNSPECIFIED = 36; /** - * Only emergency numbers are allowed, but we tried to dial - * a non-emergency number. + * Only emergency numbers are allowed, but we tried to dial a non-emergency number. + * @hide */ // TODO: This should be the same as NOT_EMERGENCY public static final int EMERGENCY_ONLY = 37; @@ -115,8 +119,7 @@ public class DisconnectCause { */ public static final int DIALED_MMI = 39; /** - * We tried to call a voicemail: URI but the device has no - * voicemail number configured. + * We tried to call a voicemail: URI but the device has no voicemail number configured. */ public static final int VOICEMAIL_NUMBER_MISSING = 40; /** @@ -129,6 +132,8 @@ public class DisconnectCause { * needs to be triggered by a *disconnect* event, rather than when * the InCallScreen first comes to the foreground. For now we use * the needToShowCallLostDialog field for this (see below.) + * + * @hide */ public static final int CDMA_CALL_LOST = 41; /** @@ -169,62 +174,52 @@ public class DisconnectCause { /** * Stk Call Control modified DIAL request to USSD request. - * {@hide} */ public static final int DIAL_MODIFIED_TO_USSD = 46; /** * Stk Call Control modified DIAL request to SS request. - * {@hide} */ public static final int DIAL_MODIFIED_TO_SS = 47; /** * Stk Call Control modified DIAL request to DIAL with modified data. - * {@hide} */ public static final int DIAL_MODIFIED_TO_DIAL = 48; /** * The call was terminated because CDMA phone service and roaming have already been activated. - * {@hide} */ public static final int CDMA_ALREADY_ACTIVATED = 49; /** * The call was terminated because it is not possible to place a video call while TTY is * enabled. - * {@hide} */ public static final int VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED = 50; /** * The call was terminated because it was pulled to another device. - * {@hide} */ public static final int CALL_PULLED = 51; /** * The call was terminated because it was answered on another device. - * {@hide} */ public static final int ANSWERED_ELSEWHERE = 52; /** * The call was terminated because the maximum allowable number of calls has been reached. - * {@hide} */ public static final int MAXIMUM_NUMBER_OF_CALLS_REACHED = 53; /** * The call was terminated because cellular data has been disabled. * Used when in a video call and the user disables cellular data via the settings. - * {@hide} */ public static final int DATA_DISABLED = 54; /** * The call was terminated because the data policy has disabled cellular data. * Used when in a video call and the user has exceeded the device data limit. - * {@hide} */ public static final int DATA_LIMIT_REACHED = 55; @@ -237,7 +232,6 @@ public class DisconnectCause { /** * The network does not accept the emergency call request because IMEI was used as * identification and this cability is not supported by the network. - * {@hide} */ public static final int IMEI_NOT_ACCEPTED = 58; @@ -249,7 +243,6 @@ public class DisconnectCause { /** * The call has failed because of access class barring. - * {@hide} */ public static final int IMS_ACCESS_BLOCKED = 60; @@ -265,51 +258,43 @@ public class DisconnectCause { /** * Emergency call failed with a temporary fail cause and can be redialed on this slot. - * {@hide} */ public static final int EMERGENCY_TEMP_FAILURE = 63; /** * Emergency call failed with a permanent fail cause and should not be redialed on this - * slot. - * {@hide} + * slot. */ public static final int EMERGENCY_PERM_FAILURE = 64; /** * This cause is used to report a normal event only when no other cause in the normal class * applies. - * {@hide} */ public static final int NORMAL_UNSPECIFIED = 65; /** * Stk Call Control modified DIAL request to video DIAL request. - * {@hide} */ public static final int DIAL_MODIFIED_TO_DIAL_VIDEO = 66; /** * Stk Call Control modified Video DIAL request to SS request. - * {@hide} */ public static final int DIAL_VIDEO_MODIFIED_TO_SS = 67; /** * Stk Call Control modified Video DIAL request to USSD request. - * {@hide} */ public static final int DIAL_VIDEO_MODIFIED_TO_USSD = 68; /** * Stk Call Control modified Video DIAL request to DIAL request. - * {@hide} */ public static final int DIAL_VIDEO_MODIFIED_TO_DIAL = 69; /** * Stk Call Control modified Video DIAL request to Video DIAL request. - * {@hide} */ public static final int DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO = 70; @@ -359,7 +344,10 @@ public class DisconnectCause { // Do nothing. } - /** Returns descriptive string for the specified disconnect cause. */ + /** + * Returns descriptive string for the specified disconnect cause. + * @hide + */ @UnsupportedAppUsage public static String toString(int cause) { switch (cause) { diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 0df0dafbe1dd..9317aa73ffc2 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -173,14 +173,14 @@ public class PhoneStateListener { public static final int LISTEN_CELL_INFO = 0x00000400; /** - * Listen for precise changes and fails to the device calls (cellular). + * Listen for {@link PreciseCallState.State} of ringing, background and foreground calls. * {@more} * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE * READ_PRECISE_PHONE_STATE} * * @hide */ - @UnsupportedAppUsage + @SystemApi public static final int LISTEN_PRECISE_CALL_STATE = 0x00000800; /** @@ -320,6 +320,18 @@ public class PhoneStateListener { */ public static final int LISTEN_EMERGENCY_NUMBER_LIST = 0x01000000; + /** + * Listen for call disconnect causes which contains {@link DisconnectCause} and + * {@link PreciseDisconnectCause}. + * {@more} + * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE + * READ_PRECISE_PHONE_STATE} + * + * @hide + */ + @SystemApi + public static final int LISTEN_CALL_DISCONNECT_CAUSES = 0x02000000; + /* * Subscription used to listen to the phone state changes * @hide @@ -530,15 +542,27 @@ public class PhoneStateListener { /** * Callback invoked when precise device call state changes. - * + * @param callState {@link PreciseCallState} * @hide */ - @UnsupportedAppUsage + @SystemApi public void onPreciseCallStateChanged(PreciseCallState callState) { // default implementation empty } /** + * Callback invoked when call disconnect cause changes. + * @param disconnectCause {@link DisconnectCause}. + * @param preciseDisconnectCause {@link PreciseDisconnectCause}. + * + * @hide + */ + @SystemApi + public void onCallDisconnectCauseChanged(int disconnectCause, int preciseDisconnectCause) { + // default implementation empty + } + + /** * Callback invoked when data connection state changes with precise information. * * @hide @@ -799,6 +823,15 @@ public class PhoneStateListener { () -> mExecutor.execute(() -> psl.onPreciseCallStateChanged(callState))); } + public void onCallDisconnectCauseChanged(int disconnectCause, int preciseDisconnectCause) { + PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); + if (psl == null) return; + + Binder.withCleanCallingIdentity( + () -> mExecutor.execute(() -> psl.onCallDisconnectCauseChanged( + disconnectCause, preciseDisconnectCause))); + } + public void onPreciseDataConnectionStateChanged( PreciseDataConnectionState dataConnectionState) { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); diff --git a/telephony/java/android/telephony/PreciseCallState.java b/telephony/java/android/telephony/PreciseCallState.java index ed5c26ac5cf2..59f3e1f0e7f7 100644 --- a/telephony/java/android/telephony/PreciseCallState.java +++ b/telephony/java/android/telephony/PreciseCallState.java @@ -16,29 +16,51 @@ package android.telephony; +import android.annotation.IntDef; +import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; import android.telephony.DisconnectCause; import android.telephony.PreciseDisconnectCause; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.Objects; + /** - * Contains precise call state and call fail causes generated by the - * framework and the RIL. + * Contains precise call states. * * The following call information is included in returned PreciseCallState: * * <ul> - * <li>Ringing call state. - * <li>Foreground call state. - * <li>Background call state. - * <li>Disconnect cause; generated by the framework. - * <li>Precise disconnect cause; generated by the RIL. + * <li>Precise ringing call state. + * <li>Precise foreground call state. + * <li>Precise background call state. * </ul> * + * @see android.telephony.TelephonyManager.CallState which contains generic call states. + * * @hide */ -public class PreciseCallState implements Parcelable { +@SystemApi +public final class PreciseCallState implements Parcelable { + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"PRECISE_CALL_STATE_"}, + value = { + PRECISE_CALL_STATE_NOT_VALID, + PRECISE_CALL_STATE_IDLE, + PRECISE_CALL_STATE_ACTIVE, + PRECISE_CALL_STATE_HOLDING, + PRECISE_CALL_STATE_DIALING, + PRECISE_CALL_STATE_ALERTING, + PRECISE_CALL_STATE_INCOMING, + PRECISE_CALL_STATE_WAITING, + PRECISE_CALL_STATE_DISCONNECTED, + PRECISE_CALL_STATE_DISCONNECTING}) + public @interface State {} /** Call state is not valid (Not received a call state). */ public static final int PRECISE_CALL_STATE_NOT_VALID = -1; @@ -61,9 +83,9 @@ public class PreciseCallState implements Parcelable { /** Call state: Disconnecting. */ public static final int PRECISE_CALL_STATE_DISCONNECTING = 8; - private int mRingingCallState = PRECISE_CALL_STATE_NOT_VALID; - private int mForegroundCallState = PRECISE_CALL_STATE_NOT_VALID; - private int mBackgroundCallState = PRECISE_CALL_STATE_NOT_VALID; + private @State int mRingingCallState = PRECISE_CALL_STATE_NOT_VALID; + private @State int mForegroundCallState = PRECISE_CALL_STATE_NOT_VALID; + private @State int mBackgroundCallState = PRECISE_CALL_STATE_NOT_VALID; private int mDisconnectCause = DisconnectCause.NOT_VALID; private int mPreciseDisconnectCause = PreciseDisconnectCause.NOT_VALID; @@ -73,8 +95,9 @@ public class PreciseCallState implements Parcelable { * @hide */ @UnsupportedAppUsage - public PreciseCallState(int ringingCall, int foregroundCall, int backgroundCall, - int disconnectCause, int preciseDisconnectCause) { + public PreciseCallState(@State int ringingCall, @State int foregroundCall, + @State int backgroundCall, int disconnectCause, + int preciseDisconnectCause) { mRingingCallState = ringingCall; mForegroundCallState = foregroundCall; mBackgroundCallState = backgroundCall; @@ -92,6 +115,8 @@ public class PreciseCallState implements Parcelable { /** * Construct a PreciseCallState object from the given parcel. + * + * @hide */ private PreciseCallState(Parcel in) { mRingingCallState = in.readInt(); @@ -102,59 +127,23 @@ public class PreciseCallState implements Parcelable { } /** - * Get precise ringing call state - * - * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID - * @see PreciseCallState#PRECISE_CALL_STATE_IDLE - * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE - * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING - * @see PreciseCallState#PRECISE_CALL_STATE_DIALING - * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING - * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING - * @see PreciseCallState#PRECISE_CALL_STATE_WAITING - * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED - * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING + * Returns the precise ringing call state. */ - @UnsupportedAppUsage - public int getRingingCallState() { + public @State int getRingingCallState() { return mRingingCallState; } /** - * Get precise foreground call state - * - * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID - * @see PreciseCallState#PRECISE_CALL_STATE_IDLE - * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE - * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING - * @see PreciseCallState#PRECISE_CALL_STATE_DIALING - * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING - * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING - * @see PreciseCallState#PRECISE_CALL_STATE_WAITING - * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED - * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING + * Returns the precise foreground call state. */ - @UnsupportedAppUsage - public int getForegroundCallState() { + public @State int getForegroundCallState() { return mForegroundCallState; } /** - * Get precise background call state - * - * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID - * @see PreciseCallState#PRECISE_CALL_STATE_IDLE - * @see PreciseCallState#PRECISE_CALL_STATE_ACTIVE - * @see PreciseCallState#PRECISE_CALL_STATE_HOLDING - * @see PreciseCallState#PRECISE_CALL_STATE_DIALING - * @see PreciseCallState#PRECISE_CALL_STATE_ALERTING - * @see PreciseCallState#PRECISE_CALL_STATE_INCOMING - * @see PreciseCallState#PRECISE_CALL_STATE_WAITING - * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTED - * @see PreciseCallState#PRECISE_CALL_STATE_DISCONNECTING + * Returns the precise background call state. */ - @UnsupportedAppUsage - public int getBackgroundCallState() { + public @State int getBackgroundCallState() { return mBackgroundCallState; } @@ -199,6 +188,11 @@ public class PreciseCallState implements Parcelable { * @see DisconnectCause#CDMA_NOT_EMERGENCY * @see DisconnectCause#CDMA_ACCESS_BLOCKED * @see DisconnectCause#ERROR_UNSPECIFIED + * + * TODO: remove disconnect cause from preciseCallState as there is no link between random + * connection disconnect cause with foreground, background or ringing call. + * + * @hide */ @UnsupportedAppUsage public int getDisconnectCause() { @@ -238,6 +232,11 @@ public class PreciseCallState implements Parcelable { * @see PreciseDisconnectCause#CDMA_NOT_EMERGENCY * @see PreciseDisconnectCause#CDMA_ACCESS_BLOCKED * @see PreciseDisconnectCause#ERROR_UNSPECIFIED + * + * TODO: remove precise disconnect cause from preciseCallState as there is no link between + * random connection disconnect cause with foreground, background or ringing call. + * + * @hide */ @UnsupportedAppUsage public int getPreciseDisconnectCause() { @@ -272,14 +271,8 @@ public class PreciseCallState implements Parcelable { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + mRingingCallState; - result = prime * result + mForegroundCallState; - result = prime * result + mBackgroundCallState; - result = prime * result + mDisconnectCause; - result = prime * result + mPreciseDisconnectCause; - return result; + return Objects.hash(mRingingCallState, mForegroundCallState, mForegroundCallState, + mDisconnectCause, mPreciseDisconnectCause); } @Override diff --git a/telephony/java/android/telephony/PreciseDisconnectCause.java b/telephony/java/android/telephony/PreciseDisconnectCause.java index 2acaf34dbb30..af88748af9e6 100644 --- a/telephony/java/android/telephony/PreciseDisconnectCause.java +++ b/telephony/java/android/telephony/PreciseDisconnectCause.java @@ -16,279 +16,329 @@ package android.telephony; +import android.annotation.SystemApi; + /** - * Contains precise disconnect call causes generated by the - * framework and the RIL. - * + * Contains precise disconnect call causes generated by the framework and the RIL. * @hide */ +@SystemApi public class PreciseDisconnectCause { - /** The disconnect cause is not valid (Not received a disconnect cause)*/ + /** The disconnect cause is not valid (Not received a disconnect cause).*/ public static final int NOT_VALID = -1; - /** No disconnect cause provided. Generally a local disconnect or an incoming missed call */ + /** No disconnect cause provided. Generally a local disconnect or an incoming missed call. */ public static final int NO_DISCONNECT_CAUSE_AVAILABLE = 0; /** * The destination cannot be reached because the number, although valid, - * is not currently assigned + * is not currently assigned. */ public static final int UNOBTAINABLE_NUMBER = 1; - /** The user cannot be reached because the network through which the call has been - * routed does not serve the destination desired + /** + * The user cannot be reached because the network through which the call has been routed does + * not serve the destination desired. */ public static final int NO_ROUTE_TO_DESTINATION = 3; - /** The channel most recently identified is not acceptable to the sending entity for - * use in this call + /** + * The channel most recently identified is not acceptable to the sending entity for use in this + * call. */ public static final int CHANNEL_UNACCEPTABLE = 6; - /** The MS has tried to access a service that the MS's network operator or service - * provider is not prepared to allow + /** + * The mobile station (MS) has tried to access a service that the MS's network operator or + * service provider is not prepared to allow. */ public static final int OPERATOR_DETERMINED_BARRING = 8; - /** One of the users involved in the call has requested that the call is cleared */ + /** One of the users involved in the call has requested that the call is cleared. */ public static final int NORMAL = 16; - /** The called user is unable to accept another call */ + /** The called user is unable to accept another call. */ public static final int BUSY = 17; - /** The user does not respond to a call establishment message with either an alerting - * or connect indication within the prescribed period of time allocated + /** + * The user does not respond to a call establishment message with either an alerting or connect + * indication within the prescribed period of time allocated. */ public static final int NO_USER_RESPONDING = 18; - /** The user has provided an alerting indication but has not provided a connect - * indication within a prescribed period of time + /** + * The user has provided an alerting indication but has not provided a connect indication + * within a prescribed period of time. */ public static final int NO_ANSWER_FROM_USER = 19; - /** The equipment sending this cause does not wish to accept this call */ + /** The equipment sending this cause does not wish to accept this call. */ public static final int CALL_REJECTED = 21; - /** The called number is no longer assigned */ + /** The called number is no longer assigned. */ public static final int NUMBER_CHANGED = 22; - /** This cause is returned to the network when a mobile station clears an active - * call which is being pre-empted by another call with higher precedence + /** + * This cause is returned to the network when a mobile station clears an active call which is + * being pre-empted by another call with higher precedence. */ public static final int PREEMPTION = 25; - /** The destination indicated by the mobile station cannot be reached because - * the interface to the destination is not functioning correctly + /** + * The destination indicated by the mobile station cannot be reached because the interface to + * the destination is not functioning correctly. */ public static final int DESTINATION_OUT_OF_ORDER = 27; - /** The called party number is not a valid format or is not complete */ + /** The called party number is not a valid format or is not complete. */ public static final int INVALID_NUMBER_FORMAT = 28; - /** The facility requested by user can not be provided by the network */ + /** The facility requested by user can not be provided by the network. */ public static final int FACILITY_REJECTED = 29; - /** Provided in response to a STATUS ENQUIRY message */ + /** Provided in response to a STATUS ENQUIRY message. */ public static final int STATUS_ENQUIRY = 30; - /** Reports a normal disconnect only when no other normal cause applies */ + /** Reports a normal disconnect only when no other normal cause applies. */ public static final int NORMAL_UNSPECIFIED = 31; - /** There is no channel presently available to handle the call */ + /** There is no channel presently available to handle the call. */ public static final int NO_CIRCUIT_AVAIL = 34; - /** The network is not functioning correctly and that the condition is likely - * to last a relatively long period of time + /** + * The network is not functioning correctly and that the condition is likely to last a + * relatively long period of time. */ public static final int NETWORK_OUT_OF_ORDER = 38; /** - * The network is not functioning correctly and the condition is not likely to last - * a long period of time + * The network is not functioning correctly and the condition is not likely to last a long + * period of time. */ public static final int TEMPORARY_FAILURE = 41; - /** The switching equipment is experiencing a period of high traffic */ + /** The switching equipment is experiencing a period of high traffic. */ public static final int SWITCHING_CONGESTION = 42; - /** The network could not deliver access information to the remote user as requested */ + /** The network could not deliver access information to the remote user as requested. */ public static final int ACCESS_INFORMATION_DISCARDED = 43; - /** The channel cannot be provided */ + /** The channel cannot be provided. */ public static final int CHANNEL_NOT_AVAIL = 44; - /** This cause is used to report a resource unavailable event only when no other - * cause in the resource unavailable class applies + /** + * This cause is used to report a resource unavailable event only when no other cause in the + * resource unavailable class applies. */ public static final int RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 47; - /** The requested quality of service (ITU-T X.213) cannot be provided */ + /** The requested quality of service (ITU-T X.213) cannot be provided. */ public static final int QOS_NOT_AVAIL = 49; - /** The facility could not be provided by the network because the user has no - * complete subscription + /** + * The facility could not be provided by the network because the user has no complete + * subscription. */ public static final int REQUESTED_FACILITY_NOT_SUBSCRIBED = 50; - /** Incoming calls are not allowed within this CUG */ + /** Incoming calls are not allowed within this calling user group (CUG). */ public static final int INCOMING_CALLS_BARRED_WITHIN_CUG = 55; - /** The mobile station is not authorized to use bearer capability requested */ + /** The mobile station is not authorized to use bearer capability requested. */ public static final int BEARER_CAPABILITY_NOT_AUTHORIZED = 57; - /** The requested bearer capability is not available at this time */ + /** The requested bearer capability is not available at this time. */ public static final int BEARER_NOT_AVAIL = 58; - /** The service option is not availble at this time */ + /** The service option is not availble at this time. */ public static final int SERVICE_OPTION_NOT_AVAILABLE = 63; - /** The equipment sending this cause does not support the bearer capability requested */ + /** The equipment sending this cause does not support the bearer capability requested. */ public static final int BEARER_SERVICE_NOT_IMPLEMENTED = 65; - /** The call clearing is due to ACM being greater than or equal to ACMmax */ + /** The call clearing is due to ACM being greater than or equal to ACMmax. */ public static final int ACM_LIMIT_EXCEEDED = 68; - /** The equipment sending this cause does not support the requested facility */ + /** The equipment sending this cause does not support the requested facility. */ public static final int REQUESTED_FACILITY_NOT_IMPLEMENTED = 69; - /** The equipment sending this cause only supports the restricted version of - * the requested bearer capability + /** + * The equipment sending this cause only supports the restricted version of the requested bearer + * capability. */ public static final int ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 70; - /** The service requested is not implemented at network */ + /** The service requested is not implemented at network. */ public static final int SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79; - /** The equipment sending this cause has received a message with a transaction identifier - * which is not currently in use on the MS-network interface + /** + * The equipment sending this cause has received a message with a transaction identifier + * which is not currently in use on the mobile station network interface. */ public static final int INVALID_TRANSACTION_IDENTIFIER = 81; - /** The called user for the incoming CUG call is not a member of the specified CUG */ + /** + * The called user for the incoming CUG call is not a member of the specified calling user + * group (CUG). + */ public static final int USER_NOT_MEMBER_OF_CUG = 87; - /** The equipment sending this cause has received a request which can't be accomodated */ + /** The equipment sending this cause has received a request which can't be accomodated. */ public static final int INCOMPATIBLE_DESTINATION = 88; - /** This cause is used to report receipt of a message with semantically incorrect contents */ + /** This cause is used to report receipt of a message with semantically incorrect contents. */ public static final int SEMANTICALLY_INCORRECT_MESSAGE = 95; - /** The equipment sending this cause has received a message with a non-semantical - * mandatory IE error + /** + * The equipment sending this cause has received a message with a non-semantical mandatory + * information element (IE) error. */ public static final int INVALID_MANDATORY_INFORMATION = 96; - /** This is sent in response to a message which is not defined, or defined but not - * implemented by the equipment sending this cause + /** + * This is sent in response to a message which is not defined, or defined but not implemented + * by the equipment sending this cause. */ public static final int MESSAGE_TYPE_NON_IMPLEMENTED = 97; - /** The equipment sending this cause has received a message not compatible with the - * protocol state + /** + * The equipment sending this cause has received a message not compatible with the protocol + * state. */ public static final int MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98; - /** The equipment sending this cause has received a message which includes information - * elements not recognized because its identifier is not defined or it is defined but not - * implemented by the equipment sending the cause + /** + * The equipment sending this cause has received a message which includes information + * elements not recognized because its identifier is not defined or it is defined but not + * implemented by the equipment sending the cause. */ public static final int INFORMATION_ELEMENT_NON_EXISTENT = 99; - /** The equipment sending this cause has received a message with conditional IE errors */ + /** The equipment sending this cause has received a message with conditional IE errors. */ public static final int CONDITIONAL_IE_ERROR = 100; - /** The message has been received which is incompatible with the protocol state */ + /** The message has been received which is incompatible with the protocol state. */ public static final int MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101; - /** The procedure has been initiated by the expiry of a timer in association with - * 3GPP TS 24.008 error handling procedures + /** + * The procedure has been initiated by the expiry of a timer in association with + * 3GPP TS 24.008 error handling procedures. */ public static final int RECOVERY_ON_TIMER_EXPIRED = 102; - /** This protocol error event is reported only when no other cause in the protocol - * error class applies + /** + * This protocol error event is reported only when no other cause in the protocol error class + * applies. */ public static final int PROTOCOL_ERROR_UNSPECIFIED = 111; - /** interworking with a network which does not provide causes for actions it takes - * thus, the precise cause for a message which is being sent cannot be ascertained + /** + * Interworking with a network which does not provide causes for actions it takes thus, the + * precise cause for a message which is being sent cannot be ascertained. */ public static final int INTERWORKING_UNSPECIFIED = 127; - /** The call is restricted */ + /** The call is restricted. */ public static final int CALL_BARRED = 240; - /** The call is blocked by the Fixed Dialing Number list */ + /** The call is blocked by the Fixed Dialing Number list. */ public static final int FDN_BLOCKED = 241; - /** The given IMSI is not known at the VLR */ - /** TS 24.008 cause 4 */ + /** The given IMSI is not known at the Visitor Location Register (VLR) TS 24.008 cause . */ public static final int IMSI_UNKNOWN_IN_VLR = 242; /** * The network does not accept emergency call establishment using an IMEI or not accept attach - * procedure for emergency services using an IMEI + * procedure for emergency services using an IMEI. */ public static final int IMEI_NOT_ACCEPTED = 243; - /** The call cannot be established because RADIO is OFF */ + /** The call cannot be established because RADIO is OFF. */ public static final int RADIO_OFF = 247; - /** The call cannot be established because of no cell coverage */ + /** The call cannot be established because of no cell coverage. */ public static final int OUT_OF_SRV = 248; - /** The call cannot be established because of no valid SIM */ + /** The call cannot be established because of no valid SIM. */ public static final int NO_VALID_SIM = 249; - /** The call is dropped or failed internally by modem */ + /** The call is dropped or failed internally by modem. */ public static final int RADIO_INTERNAL_ERROR = 250; - /** Call failed because of UE timer expired while waiting for a response from network */ + /** Call failed because of UE timer expired while waiting for a response from network. */ public static final int NETWORK_RESP_TIMEOUT = 251; - /** Call failed because of a network reject */ + /** Call failed because of a network reject. */ public static final int NETWORK_REJECT = 252; - /** Call failed because of radio access failure. ex. RACH failure */ + /** Call failed because of radio access failure. ex. RACH failure. */ public static final int RADIO_ACCESS_FAILURE = 253; - /** Call failed/dropped because of a RLF */ + /** Call failed/dropped because of a Radio Link Failure (RLF). */ public static final int RADIO_LINK_FAILURE = 254; - /** Call failed/dropped because of radio link lost */ + /** Call failed/dropped because of radio link lost. */ public static final int RADIO_LINK_LOST = 255; - /** Call failed because of a radio uplink issue */ + /** Call failed because of a radio uplink issue. */ public static final int RADIO_UPLINK_FAILURE = 256; - /** Call failed because of a RRC connection setup failure */ + /** Call failed because of a RRC (Radio Resource Control) connection setup failure. */ public static final int RADIO_SETUP_FAILURE = 257; - /** Call failed/dropped because of RRC connection release from NW */ + /** Call failed/dropped because of RRC (Radio Resource Control) connection release from NW. */ public static final int RADIO_RELEASE_NORMAL = 258; - /** Call failed/dropped because of RRC abnormally released by modem/network */ + /** + * Call failed/dropped because of RRC (Radio Resource Control) abnormally released by + * modem/network. + */ public static final int RADIO_RELEASE_ABNORMAL = 259; - /** Call setup failed because of access class barring */ + /** Call setup failed because of access class barring. */ public static final int ACCESS_CLASS_BLOCKED = 260; - /** Call failed/dropped because of a network detach */ + /** Call failed/dropped because of a network detach. */ public static final int NETWORK_DETACH = 261; - /** MS is locked until next power cycle */ + /** Mobile station (MS) is locked until next power cycle. */ public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000; - /** Drop call*/ + /** Drop call. */ public static final int CDMA_DROP = 1001; - /** INTERCEPT order received, MS state idle entered */ + /** INTERCEPT order received, Mobile station (MS) state idle entered. */ public static final int CDMA_INTERCEPT = 1002; - /** MS has been redirected, call is cancelled */ + /** Mobile station (MS) has been redirected, call is cancelled. */ public static final int CDMA_REORDER = 1003; - /** Service option rejection */ + /** Service option rejection. */ public static final int CDMA_SO_REJECT = 1004; - /** Requested service is rejected, retry delay is set */ + /** Requested service is rejected, retry delay is set. */ public static final int CDMA_RETRY_ORDER = 1005; - /** Unable to obtain access to the CDMA system */ + /** Unable to obtain access to the CDMA system. */ public static final int CDMA_ACCESS_FAILURE = 1006; - /** Not a preempted call */ + /** Not a preempted call. */ public static final int CDMA_PREEMPTED = 1007; - /** Not an emergency call */ + /** Not an emergency call. */ public static final int CDMA_NOT_EMERGENCY = 1008; - /** Access Blocked by CDMA network */ + /** Access Blocked by CDMA network. */ public static final int CDMA_ACCESS_BLOCKED = 1009; /** Mapped from ImsReasonInfo */ + // TODO: remove ImsReasonInfo from preciseDisconnectCause /* The passed argument is an invalid */ + /** @hide */ public static final int LOCAL_ILLEGAL_ARGUMENT = 1200; // The operation is invoked in invalid call state + /** @hide */ public static final int LOCAL_ILLEGAL_STATE = 1201; // IMS service internal error + /** @hide */ public static final int LOCAL_INTERNAL_ERROR = 1202; // IMS service goes down (service connection is lost) + /** @hide */ public static final int LOCAL_IMS_SERVICE_DOWN = 1203; // No pending incoming call exists + /** @hide */ public static final int LOCAL_NO_PENDING_CALL = 1204; // Service unavailable; by power off + /** @hide */ public static final int LOCAL_POWER_OFF = 1205; // Service unavailable; by low battery + /** @hide */ public static final int LOCAL_LOW_BATTERY = 1206; // Service unavailable; by out of service (data service state) + /** @hide */ public static final int LOCAL_NETWORK_NO_SERVICE = 1207; /* Service unavailable; by no LTE coverage * (VoLTE is not supported even though IMS is registered) */ + /** @hide */ public static final int LOCAL_NETWORK_NO_LTE_COVERAGE = 1208; /** Service unavailable; by located in roaming area */ + /** @hide */ public static final int LOCAL_NETWORK_ROAMING = 1209; /** Service unavailable; by IP changed */ + /** @hide */ public static final int LOCAL_NETWORK_IP_CHANGED = 1210; /** Service unavailable; other */ + /** @hide */ public static final int LOCAL_SERVICE_UNAVAILABLE = 1211; /* Service unavailable; IMS connection is lost (IMS is not registered) */ + /** @hide */ public static final int LOCAL_NOT_REGISTERED = 1212; /** Max call exceeded */ + /** @hide */ public static final int LOCAL_MAX_CALL_EXCEEDED = 1213; /** Call decline */ + /** @hide */ public static final int LOCAL_CALL_DECLINE = 1214; /** SRVCC is in progress */ + /** @hide */ public static final int LOCAL_CALL_VCC_ON_PROGRESSING = 1215; /** Resource reservation is failed (QoS precondition) */ + /** @hide */ public static final int LOCAL_CALL_RESOURCE_RESERVATION_FAILED = 1216; /** Retry CS call; VoLTE service can't be provided by the network or remote end * Resolve the extra code(EXTRA_CODE_CALL_RETRY_*) if the below code is set + * @hide */ public static final int LOCAL_CALL_CS_RETRY_REQUIRED = 1217; /** Retry VoLTE call; VoLTE service can't be provided by the network temporarily */ + /** @hide */ public static final int LOCAL_CALL_VOLTE_RETRY_REQUIRED = 1218; /** IMS call is already terminated (in TERMINATED state) */ + /** @hide */ public static final int LOCAL_CALL_TERMINATED = 1219; /** Handover not feasible */ + /** @hide */ public static final int LOCAL_HO_NOT_FEASIBLE = 1220; /** 1xx waiting timer is expired after sending INVITE request (MO only) */ + /** @hide */ public static final int TIMEOUT_1XX_WAITING = 1221; /** User no answer during call setup operation (MO/MT) * MO : 200 OK to INVITE request is not received, * MT : No action from user after alerting the call + * @hide */ public static final int TIMEOUT_NO_ANSWER = 1222; /** User no answer during call update operation (MO/MT) * MO : 200 OK to re-INVITE request is not received, * MT : No action from user after alerting the call + * @hide */ public static final int TIMEOUT_NO_ANSWER_CALL_UPDATE = 1223; @@ -296,102 +346,142 @@ public class PreciseDisconnectCause { * STATUSCODE (SIP response code) (IMS -> Telephony) */ /** SIP request is redirected */ + /** @hide */ public static final int SIP_REDIRECTED = 1300; /** 4xx responses */ /** 400 : Bad Request */ + /** @hide */ public static final int SIP_BAD_REQUEST = 1310; /** 403 : Forbidden */ + /** @hide */ public static final int SIP_FORBIDDEN = 1311; /** 404 : Not Found */ + /** @hide */ public static final int SIP_NOT_FOUND = 1312; /** 415 : Unsupported Media Type * 416 : Unsupported URI Scheme * 420 : Bad Extension */ + /** @hide */ public static final int SIP_NOT_SUPPORTED = 1313; /** 408 : Request Timeout */ + /** @hide */ public static final int SIP_REQUEST_TIMEOUT = 1314; /** 480 : Temporarily Unavailable */ + /** @hide */ public static final int SIP_TEMPRARILY_UNAVAILABLE = 1315; /** 484 : Address Incomplete */ + /** @hide */ public static final int SIP_BAD_ADDRESS = 1316; /** 486 : Busy Here * 600 : Busy Everywhere */ + /** @hide */ public static final int SIP_BUSY = 1317; /** 487 : Request Terminated */ + /** @hide */ public static final int SIP_REQUEST_CANCELLED = 1318; /** 406 : Not Acceptable * 488 : Not Acceptable Here * 606 : Not Acceptable */ + /** @hide */ public static final int SIP_NOT_ACCEPTABLE = 1319; /** 410 : Gone * 604 : Does Not Exist Anywhere */ + /** @hide */ public static final int SIP_NOT_REACHABLE = 1320; /** Others */ + /** @hide */ public static final int SIP_CLIENT_ERROR = 1321; /** 481 : Transaction Does Not Exist */ + /** @hide */ public static final int SIP_TRANSACTION_DOES_NOT_EXIST = 1322; /** 5xx responses * 501 : Server Internal Error */ + /** @hide */ public static final int SIP_SERVER_INTERNAL_ERROR = 1330; /** 503 : Service Unavailable */ + /** @hide */ public static final int SIP_SERVICE_UNAVAILABLE = 1331; /** 504 : Server Time-out */ + /** @hide */ public static final int SIP_SERVER_TIMEOUT = 1332; /** Others */ + /** @hide */ public static final int SIP_SERVER_ERROR = 1333; /** 6xx responses * 603 : Decline */ + /** @hide */ public static final int SIP_USER_REJECTED = 1340; /** Others */ + /** @hide */ public static final int SIP_GLOBAL_ERROR = 1341; /** Emergency failure */ + /** @hide */ public static final int EMERGENCY_TEMP_FAILURE = 1342; + /** @hide */ public static final int EMERGENCY_PERM_FAILURE = 1343; /** Media resource initialization failed */ + /** @hide */ public static final int MEDIA_INIT_FAILED = 1400; /** RTP timeout (no audio / video traffic in the session) */ + /** @hide */ public static final int MEDIA_NO_DATA = 1401; /** Media is not supported; so dropped the call */ + /** @hide */ public static final int MEDIA_NOT_ACCEPTABLE = 1402; /** Unknown media related errors */ + /** @hide */ public static final int MEDIA_UNSPECIFIED = 1403; /** User triggers the call end */ + /** @hide */ public static final int USER_TERMINATED = 1500; /** No action while an incoming call is ringing */ + /** @hide */ public static final int USER_NOANSWER = 1501; /** User ignores an incoming call */ + /** @hide */ public static final int USER_IGNORE = 1502; /** User declines an incoming call */ + /** @hide */ public static final int USER_DECLINE = 1503; /** Device declines/ends a call due to low battery */ + /** @hide */ public static final int LOW_BATTERY = 1504; /** Device declines call due to blacklisted call ID */ + /** @hide */ public static final int BLACKLISTED_CALL_ID = 1505; /** The call is terminated by the network or remote user */ + /** @hide */ public static final int USER_TERMINATED_BY_REMOTE = 1510; /** * UT */ + /** @hide */ public static final int UT_NOT_SUPPORTED = 1800; + /** @hide */ public static final int UT_SERVICE_UNAVAILABLE = 1801; + /** @hide */ public static final int UT_OPERATION_NOT_ALLOWED = 1802; + /** @hide */ public static final int UT_NETWORK_ERROR = 1803; + /** @hide */ public static final int UT_CB_PASSWORD_MISMATCH = 1804; /** * ECBM + * @hide */ public static final int ECBM_NOT_SUPPORTED = 1900; /** * Fail code used to indicate that Multi-endpoint is not supported by the Ims framework. + * @hide */ public static final int MULTIENDPOINT_NOT_SUPPORTED = 1901; @@ -405,56 +495,68 @@ public class PreciseDisconnectCause { * active wifi call and at the edge of coverage and there is no qualified LTE network available * to handover the call to. We get a handover NOT_TRIGERRED message from the modem. This error * code is received as part of the handover message. + * @hide */ public static final int CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE = 2000; /** * MT call has ended due to a release from the network * because the call was answered elsewhere + * @hide */ public static final int ANSWERED_ELSEWHERE = 2100; /** * For MultiEndpoint - Call Pull request has failed + * @hide */ public static final int CALL_PULL_OUT_OF_SYNC = 2101; /** * For MultiEndpoint - Call has been pulled from primary to secondary + * @hide */ public static final int CALL_PULLED = 2102; /** * Supplementary services (HOLD/RESUME) failure error codes. * Values for Supplemetary services failure - Failed, Cancelled and Re-Invite collision. + * @hide */ public static final int SUPP_SVC_FAILED = 2300; + /** @hide */ public static final int SUPP_SVC_CANCELLED = 2301; + /** @hide */ public static final int SUPP_SVC_REINVITE_COLLISION = 2302; /** * DPD Procedure received no response or send failed + * @hide */ public static final int IWLAN_DPD_FAILURE = 2400; /** * Establishment of the ePDG Tunnel Failed + * @hide */ public static final int EPDG_TUNNEL_ESTABLISH_FAILURE = 2500; /** * Re-keying of the ePDG Tunnel Failed; may not always result in teardown + * @hide */ public static final int EPDG_TUNNEL_REKEY_FAILURE = 2501; /** * Connection to the packet gateway is lost + * @hide */ public static final int EPDG_TUNNEL_LOST_CONNECTION = 2502; /** * The maximum number of calls allowed has been reached. Used in a multi-endpoint scenario * where the number of calls across all connected devices has reached the maximum. + * @hide */ public static final int MAXIMUM_NUMBER_OF_CALLS_REACHED = 2503; @@ -462,21 +564,25 @@ public class PreciseDisconnectCause { * Similar to {@link #CODE_LOCAL_CALL_DECLINE}, except indicates that a remote device has * declined the call. Used in a multi-endpoint scenario where a remote device declined an * incoming call. + * @hide */ public static final int REMOTE_CALL_DECLINE = 2504; /** * Indicates the call was disconnected due to the user reaching their data limit. + * @hide */ public static final int DATA_LIMIT_REACHED = 2505; /** * Indicates the call was disconnected due to the user disabling cellular data. + * @hide */ public static final int DATA_DISABLED = 2506; /** * Indicates a call was disconnected due to loss of wifi signal. + * @hide */ public static final int WIFI_LOST = 2507; @@ -499,7 +605,7 @@ public class PreciseDisconnectCause { public static final int OEM_CAUSE_14 = 0xf00e; public static final int OEM_CAUSE_15 = 0xf00f; - /** Disconnected due to unspecified reasons */ + /** Disconnected due to unspecified reasons. */ public static final int ERROR_UNSPECIFIED = 0xffff; /** Private constructor to avoid class instantiation. */ diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java index dacc5d86e9ae..a1e8b199d2a0 100644 --- a/telephony/java/android/telephony/SubscriptionInfo.java +++ b/telephony/java/android/telephony/SubscriptionInfo.java @@ -80,6 +80,12 @@ public class SubscriptionInfo implements Parcelable { private CharSequence mCarrierName; /** + * The subscription carrier id. + * @see TelephonyManager#getSimCarrierId() + */ + private int mCarrierId; + + /** * The source of the name, NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE, * NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT. */ @@ -132,10 +138,15 @@ public class SubscriptionInfo implements Parcelable { private UiccAccessRule[] mAccessRules; /** - * The ID of the SIM card. It is the ICCID of the active profile for a UICC card and the EID - * for an eUICC card. + * The string ID of the SIM card. It is the ICCID of the active profile for a UICC card and the + * EID for an eUICC card. + */ + private String mCardString; + + /** + * The card ID of the SIM card. This maps uniquely to the card string. */ - private String mCardId; + private int mCardId; /** * Whether the subscription is opportunistic. @@ -168,10 +179,10 @@ public class SubscriptionInfo implements Parcelable { public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, - @Nullable UiccAccessRule[] accessRules, String cardId) { + @Nullable UiccAccessRule[] accessRules, String cardString) { this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number, - roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardId, - false, null, true); + roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardString, + false, null, true, TelephonyManager.UNKNOWN_CARRIER_ID); } /** @@ -180,20 +191,22 @@ public class SubscriptionInfo implements Parcelable { public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, - @Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic, - @Nullable String groupUUID, boolean isMetered) { + @Nullable UiccAccessRule[] accessRules, String cardString, boolean isOpportunistic, + @Nullable String groupUUID, boolean isMetered, int carrierId) { this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number, - roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardId, - isOpportunistic, groupUUID, isMetered, false); + roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardString, -1, + isOpportunistic, groupUUID, isMetered, false, carrierId); } + /** * @hide */ public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, - @Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic, - @Nullable String groupUUID, boolean isMetered, boolean isGroupDisabled) { + @Nullable UiccAccessRule[] accessRules, String cardString, int cardId, + boolean isOpportunistic, @Nullable String groupUUID, boolean isMetered, + boolean isGroupDisabled, int carrierid) { this.mId = id; this.mIccId = iccId; this.mSimSlotIndex = simSlotIndex; @@ -209,11 +222,13 @@ public class SubscriptionInfo implements Parcelable { this.mCountryIso = countryIso; this.mIsEmbedded = isEmbedded; this.mAccessRules = accessRules; + this.mCardString = cardString; this.mCardId = cardId; this.mIsOpportunistic = isOpportunistic; this.mGroupUUID = groupUUID; this.mIsMetered = isMetered; this.mIsGroupDisabled = isGroupDisabled; + this.mCarrierId = carrierid; } @@ -239,6 +254,14 @@ public class SubscriptionInfo implements Parcelable { } /** + * @return the carrier id of this Subscription carrier. + * @see TelephonyManager#getSimCarrierId() + */ + public int getCarrierId() { + return this.mCarrierId; + } + + /** * @return the name displayed to the user that identifies this subscription */ public CharSequence getDisplayName() { @@ -508,10 +531,21 @@ public class SubscriptionInfo implements Parcelable { } /** - * @return the ID of the SIM card which contains the subscription. + * @return the card string of the SIM card which contains the subscription. The card string is + * the ICCID for UICCs or the EID for eUICCs. * @hide + * //TODO rename usages in LPA: UiccSlotUtil.java, UiccSlotsManager.java, UiccSlotInfoTest.java */ - public String getCardId() { + public String getCardString() { + return this.mCardString; + } + + /** + * @return the cardId of the SIM card which contains the subscription. + * @hide + */ + @SystemApi + public int getCardId() { return this.mCardId; } @@ -549,16 +583,18 @@ public class SubscriptionInfo implements Parcelable { Bitmap iconBitmap = Bitmap.CREATOR.createFromParcel(source); boolean isEmbedded = source.readBoolean(); UiccAccessRule[] accessRules = source.createTypedArray(UiccAccessRule.CREATOR); - String cardId = source.readString(); + String cardString = source.readString(); + int cardId = source.readInt(); boolean isOpportunistic = source.readBoolean(); String groupUUID = source.readString(); boolean isMetered = source.readBoolean(); boolean isGroupDisabled = source.readBoolean(); + int carrierid = source.readInt(); return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso, - isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered, - isGroupDisabled); + isEmbedded, accessRules, cardString, cardId, isOpportunistic, groupUUID, + isMetered, isGroupDisabled, carrierid); } @Override @@ -584,11 +620,13 @@ public class SubscriptionInfo implements Parcelable { mIconBitmap.writeToParcel(dest, flags); dest.writeBoolean(mIsEmbedded); dest.writeTypedArray(mAccessRules, flags); - dest.writeString(mCardId); + dest.writeString(mCardString); + dest.writeInt(mCardId); dest.writeBoolean(mIsOpportunistic); dest.writeString(mGroupUUID); dest.writeBoolean(mIsMetered); dest.writeBoolean(mIsGroupDisabled); + dest.writeInt(mCarrierId); } @Override @@ -614,23 +652,25 @@ public class SubscriptionInfo implements Parcelable { @Override public String toString() { String iccIdToPrint = givePrintableIccid(mIccId); - String cardIdToPrint = givePrintableIccid(mCardId); + String cardStringToPrint = givePrintableIccid(mCardString); return "{id=" + mId + ", iccId=" + iccIdToPrint + " simSlotIndex=" + mSimSlotIndex - + " displayName=" + mDisplayName + " carrierName=" + mCarrierName - + " nameSource=" + mNameSource + " iconTint=" + mIconTint + " mNumber=" + mNumber + + " carrierId=" + mCarrierId + " displayName=" + mDisplayName + + " carrierName=" + mCarrierName + " nameSource=" + mNameSource + + " iconTint=" + mIconTint + " mNumber=" + mNumber + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc + " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded + " accessRules " + Arrays.toString(mAccessRules) - + " cardId=" + cardIdToPrint + " isOpportunistic " + mIsOpportunistic - + " mGroupUUID=" + mGroupUUID + " isMetered=" + mIsMetered - + " mIsGroupDisabled=" + mIsGroupDisabled + "}"; + + " cardString=" + cardStringToPrint + " cardId=" + mCardId + + " isOpportunistic " + mIsOpportunistic + " mGroupUUID=" + mGroupUUID + + " isMetered=" + mIsMetered + " mIsGroupDisabled=" + mIsGroupDisabled + "}"; } @Override public int hashCode() { return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded, mIsOpportunistic, mGroupUUID, mIsMetered, mIccId, mNumber, mMcc, mMnc, - mCountryIso, mCardId, mDisplayName, mCarrierName, mAccessRules, mIsGroupDisabled); + mCountryIso, mCardString, mCardId, mDisplayName, mCarrierName, mAccessRules, + mIsGroupDisabled, mCarrierId); } @Override @@ -653,13 +693,15 @@ public class SubscriptionInfo implements Parcelable { && mIsEmbedded == toCompare.mIsEmbedded && mIsOpportunistic == toCompare.mIsOpportunistic && mIsGroupDisabled == toCompare.mIsGroupDisabled - && Objects.equals(mGroupUUID, toCompare.mGroupUUID) + && mCarrierId == toCompare.mCarrierId && mIsMetered == toCompare.mIsMetered + && Objects.equals(mGroupUUID, toCompare.mGroupUUID) && Objects.equals(mIccId, toCompare.mIccId) && Objects.equals(mNumber, toCompare.mNumber) && Objects.equals(mMcc, toCompare.mMcc) && Objects.equals(mMnc, toCompare.mMnc) && Objects.equals(mCountryIso, toCompare.mCountryIso) + && Objects.equals(mCardString, toCompare.mCardString) && Objects.equals(mCardId, toCompare.mCardId) && TextUtils.equals(mDisplayName, toCompare.mDisplayName) && TextUtils.equals(mCarrierName, toCompare.mCarrierName) diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 8c65eb6761b3..2c712a1c36e1 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -382,6 +382,14 @@ public class SubscriptionManager { public static final int SIM_PROVISIONED = 0; /** + * TelephonyProvider column name for subscription carrier id. + * @see TelephonyManager#getSimCarrierId() + * <p>Type: INTEGER (int) </p> + * @hide + */ + public static final String CARRIER_ID = "carrier_id"; + + /** * TelephonyProvider column name for the MCC associated with a SIM, stored as a string. * <P>Type: TEXT (String)</P> * @hide @@ -1190,7 +1198,8 @@ public class SubscriptionManager { } /** - * Request a refresh of the platform cache of profile information. + * Request a refresh of the platform cache of profile information for the eUICC which + * corresponds to the card ID returned by {@link TelephonyManager#getCardIdForDefaultEuicc()}. * * <p>Should be called by the EuiccService implementation whenever this information changes due * to an operation done outside the scope of a request initiated by the platform to the @@ -1198,17 +1207,50 @@ public class SubscriptionManager { * were made through the EuiccService. * * <p>Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * @see {@link TelephonyManager#getCardIdForDefaultEuicc()} for more information on the card ID. + * * @hide */ @SystemApi public void requestEmbeddedSubscriptionInfoListRefresh() { + int cardId = TelephonyManager.from(mContext).getCardIdForDefaultEuicc(); try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - iSub.requestEmbeddedSubscriptionInfoListRefresh(); + iSub.requestEmbeddedSubscriptionInfoListRefresh(cardId); } } catch (RemoteException ex) { - // ignore it + logd("requestEmbeddedSubscriptionInfoListFresh for card = " + cardId + " failed."); + } + } + + /** + * Request a refresh of the platform cache of profile information for the eUICC with the given + * {@code cardId}. + * + * <p>Should be called by the EuiccService implementation whenever this information changes due + * to an operation done outside the scope of a request initiated by the platform to the + * EuiccService. There is no need to refresh for downloads, deletes, or other operations that + * were made through the EuiccService. + * + * <p>Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * @param cardId the card ID of the eUICC. + * + * @see {@link TelephonyManager#getCardIdForDefaultEuicc()} for more information on the card ID. + * + * @hide + */ + @SystemApi + public void requestEmbeddedSubscriptionInfoListRefresh(int cardId) { + try { + ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); + if (iSub != null) { + iSub.requestEmbeddedSubscriptionInfoListRefresh(cardId); + } + } catch (RemoteException ex) { + logd("requestEmbeddedSubscriptionInfoListFresh for card = " + cardId + " failed."); } } @@ -2575,8 +2617,7 @@ public class SubscriptionManager { if (availableList == null) { return null; } else { - return getAvailableSubscriptionInfoList().stream() - .filter(subInfo -> !shouldHideSubscription(subInfo)) + return availableList.stream().filter(subInfo -> !shouldHideSubscription(subInfo)) .collect(Collectors.toList()); } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index e0632b1e0392..f241d45bf1e2 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -625,8 +625,6 @@ public class TelephonyManager { * The {@link #EXTRA_RINGING_CALL_STATE} extra indicates the ringing call state. * The {@link #EXTRA_FOREGROUND_CALL_STATE} extra indicates the foreground call state. * The {@link #EXTRA_BACKGROUND_CALL_STATE} extra indicates the background call state. - * The {@link #EXTRA_DISCONNECT_CAUSE} extra indicates the disconnect cause. - * The {@link #EXTRA_PRECISE_DISCONNECT_CAUSE} extra indicates the precise disconnect cause. * * <p class="note"> * Requires the READ_PRECISE_PHONE_STATE permission. @@ -634,12 +632,10 @@ public class TelephonyManager { * @see #EXTRA_RINGING_CALL_STATE * @see #EXTRA_FOREGROUND_CALL_STATE * @see #EXTRA_BACKGROUND_CALL_STATE - * @see #EXTRA_DISCONNECT_CAUSE - * @see #EXTRA_PRECISE_DISCONNECT_CAUSE * * <p class="note"> * Requires the READ_PRECISE_PHONE_STATE permission. - * + * @deprecated use {@link PhoneStateListener#LISTEN_PRECISE_CALL_STATE} instead * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @@ -647,8 +643,28 @@ public class TelephonyManager { "android.intent.action.PRECISE_CALL_STATE"; /** - * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast - * for an integer containing the state of the current ringing call. + * Broadcast intent action indicating that call disconnect cause has changed. + * + * <p> + * The {@link #EXTRA_DISCONNECT_CAUSE} extra indicates the disconnect cause. + * The {@link #EXTRA_PRECISE_DISCONNECT_CAUSE} extra indicates the precise disconnect cause. + * + * <p class="note"> + * Requires the READ_PRECISE_PHONE_STATE permission. + * + * @see #EXTRA_DISCONNECT_CAUSE + * @see #EXTRA_PRECISE_DISCONNECT_CAUSE + * + * @hide + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_CALL_DISCONNECT_CAUSE_CHANGED = + "android.intent.action.CALL_DISCONNECT_CAUSE"; + + /** + * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast and + * {@link PhoneStateListener#onPreciseCallStateChanged(PreciseCallState)} for an integer + * containing the state of the current ringing call. * * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID * @see PreciseCallState#PRECISE_CALL_STATE_IDLE @@ -670,8 +686,9 @@ public class TelephonyManager { public static final String EXTRA_RINGING_CALL_STATE = "ringing_state"; /** - * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast - * for an integer containing the state of the current foreground call. + * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast and + * {@link PhoneStateListener#onPreciseCallStateChanged(PreciseCallState)} for an integer + * containing the state of the current foreground call. * * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID * @see PreciseCallState#PRECISE_CALL_STATE_IDLE @@ -693,8 +710,9 @@ public class TelephonyManager { public static final String EXTRA_FOREGROUND_CALL_STATE = "foreground_state"; /** - * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast - * for an integer containing the state of the current background call. + * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast and + * {@link PhoneStateListener#onPreciseCallStateChanged(PreciseCallState)} for an integer + * containing the state of the current background call. * * @see PreciseCallState#PRECISE_CALL_STATE_NOT_VALID * @see PreciseCallState#PRECISE_CALL_STATE_IDLE @@ -716,8 +734,9 @@ public class TelephonyManager { public static final String EXTRA_BACKGROUND_CALL_STATE = "background_state"; /** - * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast - * for an integer containing the disconnect cause. + * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast and + * {@link PhoneStateListener#onPreciseCallStateChanged(PreciseCallState)} for an integer + * containing the disconnect cause. * * @see DisconnectCause * @@ -730,8 +749,9 @@ public class TelephonyManager { public static final String EXTRA_DISCONNECT_CAUSE = "disconnect_cause"; /** - * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast - * for an integer containing the disconnect cause provided by the RIL. + * The lookup key used with the {@link #ACTION_PRECISE_CALL_STATE_CHANGED} broadcast and + * {@link PhoneStateListener#onPreciseCallStateChanged(PreciseCallState)} for an integer + * containing the disconnect cause provided by the RIL. * * @see PreciseDisconnectCause * @@ -4888,7 +4908,7 @@ public class TelephonyManager { */ @RequiresPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) public void requestCellInfoUpdate( - @NonNull Executor executor, @NonNull CellInfoCallback callback) { + @NonNull @CallbackExecutor Executor executor, @NonNull CellInfoCallback callback) { try { ITelephony telephony = getITelephony(); if (telephony == null) return; @@ -6362,8 +6382,9 @@ public class TelephonyManager { public @PrefNetworkMode int getPreferredNetworkType(int subId) { try { ITelephony telephony = getITelephony(); - if (telephony != null) + if (telephony != null) { return telephony.getPreferredNetworkType(subId); + } } catch (RemoteException ex) { Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -6373,6 +6394,37 @@ public class TelephonyManager { } /** + * Get the preferred network type bitmap. + * + * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the + * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} + * + * <p>Requires Permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @return a 32-bit bitmap. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @SystemApi + public @NetworkTypeBitMask int getPreferredNetworkTypeBitmap() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return RadioAccessFamily.getRafFromNetworkType( + telephony.getPreferredNetworkType(getSubId())); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getPreferredNetworkTypeBitmap RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "getPreferredNetworkTypeBitmap NPE", ex); + } + return 0; + } + + /** * Sets the network selection mode to automatic. * * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the @@ -6587,6 +6639,37 @@ public class TelephonyManager { } /** + * Set the preferred network type bitmap. + * + * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the + * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @param networkTypeBitmap a 32-bit bitmap. + * @return true on success; false on any failure. + * @hide + */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + @SystemApi + public boolean setPreferredNetworkTypeBitmap(@NetworkTypeBitMask int networkTypeBitmap) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.setPreferredNetworkType( + getSubId(), RadioAccessFamily.getNetworkTypeFromRaf(networkTypeBitmap)); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "setPreferredNetworkType NPE", ex); + } + return false; + } + + /** * Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA. * * <p>Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index ebf198702bb9..6326cc688914 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -61,7 +61,6 @@ public class EuiccManager { public static final String ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS = "android.telephony.euicc.action.MANAGE_EMBEDDED_SUBSCRIPTIONS"; - /** * Broadcast Action: The eUICC OTA status is changed. * <p class="note"> @@ -87,6 +86,20 @@ public class EuiccManager { "android.telephony.euicc.action.NOTIFY_CARRIER_SETUP_INCOMPLETE"; /** + * Intent action to select a profile to enable before download a new eSIM profile. + * + * May be called during device provisioning when there are multiple slots having profiles on + * them. This Intent launches a screen for all the current existing profiles and let users to + * choose which one they want to enable. In this case, the slot contains the profile will be + * activated. + * + * @hide + */ + @SystemApi + public static final String ACTION_PROFILE_SELECTION = + "android.telephony.euicc.action.PROFILE_SELECTION"; + + /** * Intent action to provision an embedded subscription. * * <p>May be called during device provisioning to launch a screen to perform embedded SIM @@ -132,6 +145,16 @@ public class EuiccManager { public static final int EMBEDDED_SUBSCRIPTION_RESULT_ERROR = 2; /** + * Key for an extra set on the {@link #ACTION_PROVISION_EMBEDDED_SUBSCRIPTION} intent for which + * kind of activation flow will be evolved. (see {@code EUICC_ACTIVATION_}) + * + * @hide + */ + @SystemApi + public static final String EXTRA_ACTIVATION_TYPE = + "android.telephony.euicc.extra.ACTIVATION_TYPE"; + + /** * Key for an extra set on {@link PendingIntent} result callbacks providing a detailed result * code. * @@ -197,6 +220,52 @@ public class EuiccManager { public static final String META_DATA_CARRIER_ICON = "android.telephony.euicc.carriericon"; /** + * Euicc activation type which will be included in {@link #EXTRA_ACTIVATION_TYPE} and used to + * decide which kind of activation flow should be lauched. + * + * @hide + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"EUICC_ACTIVATION_"}, value = { + EUICC_ACTIVATION_TYPE_DEFAULT, + EUICC_ACTIVATION_TYPE_BACKUP, + EUICC_ACTIVATION_TYPE_TRANSFER + + }) + public @interface EuiccActivationType{} + + + /** + * The default euicc activation type which includes checking server side and downloading the + * profile based on carrier's download configuration. + * + * @hide + */ + @SystemApi + public static final int EUICC_ACTIVATION_TYPE_DEFAULT = 1; + + /** + * The euicc activation type used when the default download process failed. LPA will start the + * backup flow and try to download the profile for the carrier. + * + * @hide + */ + @SystemApi + public static final int EUICC_ACTIVATION_TYPE_BACKUP = 2; + + /** + * The activation flow of eSIM seamless transfer will be used. LPA will start normal eSIM + * activation flow and if it's failed, the name of the carrier selected will be recorded. After + * the future device pairing, LPA will contact this carrier to transfer it from the other device + * to this device. + * + * @hide + */ + @SystemApi + public static final int EUICC_ACTIVATION_TYPE_TRANSFER = 3; + + + /** * Euicc OTA update status which can be got by {@link #getOtaStatus} * @hide */ @@ -336,7 +405,7 @@ public class EuiccManager { } try { getIEuiccController().downloadSubscription(subscription, switchAfterDownload, - mContext.getOpPackageName(), callbackIntent); + mContext.getOpPackageName(), null /* resolvedBundle */, callbackIntent); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index 78fc0bc487bf..00cf9c3577ec 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -55,5 +55,6 @@ oneway interface IPhoneStateListener { void onPreferredDataSubIdChanged(in int subId); void onRadioPowerStateChanged(in int state); void onEmergencyNumberListChanged(in Map emergencyNumberList); + void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause); } diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl index 65eedb83c4cc..d169b7d04f5c 100755 --- a/telephony/java/com/android/internal/telephony/ISub.aidl +++ b/telephony/java/com/android/internal/telephony/ISub.aidl @@ -104,7 +104,7 @@ interface ISub { /** * @see android.telephony.SubscriptionManager#requestEmbeddedSubscriptionInfoListRefresh */ - oneway void requestEmbeddedSubscriptionInfoListRefresh(); + oneway void requestEmbeddedSubscriptionInfoListRefresh(int cardId); /** * Add a new SubscriptionInfo to subinfo database if needed diff --git a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java index 553e3fb9d219..0edc0026722b 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/java/com/android/internal/telephony/TelephonyPermissions.java @@ -284,8 +284,6 @@ public final class TelephonyPermissions { */ private static boolean reportAccessDeniedToReadIdentifiers(Context context, int subId, int pid, int uid, String callingPackage, String message) { - Log.wtf(LOG_TAG, - "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message); // If the device identifier check is enabled then enforce the new access requirements for // both 1P and 3P apps. boolean enableDeviceIdentifierCheck = Settings.Global.getInt(context.getContentResolver(), @@ -295,17 +293,40 @@ public final class TelephonyPermissions { boolean relax3PDeviceIdentifierCheck = Settings.Global.getInt(context.getContentResolver(), Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_3P_CHECK_RELAXED, 0) == 1; boolean is3PApp = true; + // Also check if the application is a preloaded non-privileged app; if so there is a + // separate setting to relax the check for these apps to ensure users can relax the check + // for 3P or non-priv apps as needed while continuing to test the other. + boolean relaxNonPrivDeviceIdentifierCheck = Settings.Global.getInt( + context.getContentResolver(), + Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_NON_PRIV_CHECK_RELAXED, 0) == 1; + boolean isNonPrivApp = false; ApplicationInfo callingPackageInfo = null; try { callingPackageInfo = context.getPackageManager().getApplicationInfo(callingPackage, 0); - if (callingPackageInfo.isSystemApp()) { + if (callingPackageInfo.isPrivilegedApp()) { is3PApp = false; + } else if (callingPackageInfo.isSystemApp()) { + is3PApp = false; + isNonPrivApp = true; } } catch (PackageManager.NameNotFoundException e) { // If the application info for the calling package could not be found then assume the // calling app is a 3P app to detect any issues with the check + Log.e(LOG_TAG, "Exception caught obtaining package info for package " + callingPackage, + e); } - if (enableDeviceIdentifierCheck || (is3PApp && !relax3PDeviceIdentifierCheck)) { + Log.wtf(LOG_TAG, "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message + + ":is3PApp=" + is3PApp + ":isNonPrivApp=" + isNonPrivApp); + // The new Q restrictions for device identifier access will be enforced if any of the + // following are true: + // - The PRIVILEGED_DEVICE_IDENTIFIER_CHECK_ENABLED setting has been set. + // - The app requesting a device identifier is not a preloaded app (3P), and the + // PRIVILEGED_DEVICE_IDENTIFIER_3P_CHECK_RELAXED setting has not been set. + // - The app requesting a device identifier is a preloaded app but is not a privileged app, + // and the PRIVILEGED_DEVICE_IDENTIFIER_NON_PRIV_CHECK_RELAXED setting has not been set. + if (enableDeviceIdentifierCheck + || (is3PApp && !relax3PDeviceIdentifierCheck) + || (isNonPrivApp && !relaxNonPrivDeviceIdentifierCheck)) { boolean targetQBehaviorDisabled = Settings.Global.getInt(context.getContentResolver(), Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_TARGET_Q_BEHAVIOR_ENABLED, 0) == 0; if (callingPackage != null) { diff --git a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl index 0a0ad90b5954..870a689f85b1 100644 --- a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl +++ b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl @@ -32,7 +32,7 @@ interface IEuiccController { String getEid(); int getOtaStatus(); oneway void downloadSubscription(in DownloadableSubscription subscription, - boolean switchAfterDownload, String callingPackage, in PendingIntent callbackIntent); + boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle, in PendingIntent callbackIntent); EuiccInfo getEuiccInfo(); oneway void deleteSubscription(int subscriptionId, String callingPackage, in PendingIntent callbackIntent); |