diff --git a/api/current.txt b/api/current.txt index 8b583fe57a908..56d30ddff4d2f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -40772,6 +40772,8 @@ package android.telephony { method public int getSimState(); method public int getSimState(int); method public java.lang.String getSubscriberId(); + method public int getSubscriptionCarrierId(); + method public java.lang.String getSubscriptionCarrierName(); method public java.lang.String getVisualVoicemailPackageName(); method public java.lang.String getVoiceMailAlphaTag(); method public java.lang.String getVoiceMailNumber(); @@ -40816,6 +40818,7 @@ package android.telephony { field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; field public static final java.lang.String ACTION_SHOW_VOICEMAIL_NOTIFICATION = "android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION"; + field public static final java.lang.String ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED = "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED"; field public static final int APPTYPE_CSIM = 4; // 0x4 field public static final int APPTYPE_ISIM = 5; // 0x5 field public static final int APPTYPE_RUIM = 3; // 0x3 @@ -40836,6 +40839,8 @@ package android.telephony { field public static final int DATA_DISCONNECTED = 0; // 0x0 field public static final int DATA_SUSPENDED = 3; // 0x3 field public static final java.lang.String EXTRA_CALL_VOICEMAIL_INTENT = "android.telephony.extra.CALL_VOICEMAIL_INTENT"; + field public static final java.lang.String EXTRA_CARRIER_ID = "android.telephony.extra.CARRIER_ID"; + field public static final java.lang.String EXTRA_CARRIER_NAME = "android.telephony.extra.CARRIER_NAME"; field public static final java.lang.String EXTRA_HIDE_PUBLIC_SETTINGS = "android.telephony.extra.HIDE_PUBLIC_SETTINGS"; field public static final java.lang.String EXTRA_INCOMING_NUMBER = "incoming_number"; field public static final java.lang.String EXTRA_IS_REFRESH = "android.telephony.extra.IS_REFRESH"; @@ -40846,6 +40851,7 @@ package android.telephony { field public static final java.lang.String EXTRA_STATE_IDLE; field public static final java.lang.String EXTRA_STATE_OFFHOOK; field public static final java.lang.String EXTRA_STATE_RINGING; + field public static final java.lang.String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID"; field public static final java.lang.String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER"; field public static final java.lang.String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU"; field public static final int NETWORK_TYPE_1xRTT = 7; // 0x7 @@ -40881,6 +40887,7 @@ package android.telephony { field public static final int SIM_STATE_PUK_REQUIRED = 3; // 0x3 field public static final int SIM_STATE_READY = 5; // 0x5 field public static final int SIM_STATE_UNKNOWN = 0; // 0x0 + field public static final int UNKNOWN_CARRIER_ID = -1; // 0xffffffff field public static final int USSD_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff field public static final java.lang.String VVM_TYPE_CVVM = "vvm_type_cvvm"; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 4328bc08a325b..332562ec37b84 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -968,6 +968,64 @@ public class TelephonyManager { */ public static final int USSD_ERROR_SERVICE_UNAVAIL = -2; + /** + * An unknown carrier id. It could either be subscription unavailable or the subscription + * carrier cannot be recognized. Unrecognized carriers here means + * {@link #getSimOperator() MCC+MNC} cannot be identified. + */ + public static final int UNKNOWN_CARRIER_ID = -1; + + /** + * Broadcast Action: The subscription carrier identity has changed. + * This intent could be sent on the following events: + *
This is a protected intent that can only be sent by the system. + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED = + "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED"; + + /** + * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which indicates + * the updated carrier id {@link TelephonyManager#getSubscriptionCarrierId()} of the current + * subscription. + *
Will be {@link TelephonyManager#UNKNOWN_CARRIER_ID} if the subscription is unavailable or + * the carrier cannot be identified. + */ + public static final String EXTRA_CARRIER_ID = "android.telephony.extra.CARRIER_ID"; + + /** + * An string extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which + * indicates the updated carrier name of the current subscription. + * {@see TelephonyManager#getSubscriptionCarrierName()} + *
Carrier name is a user-facing name of the carrier id {@link #EXTRA_CARRIER_ID}, + * usually the brand name of the subsidiary (e.g. T-Mobile). + */ + public static final String EXTRA_CARRIER_NAME = "android.telephony.extra.CARRIER_NAME"; + + /** + * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} to indicate the + * subscription which has changed. + */ + public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID"; + + // // // Device Info @@ -6558,6 +6616,55 @@ public class TelephonyManager { } } + /** + * Returns carrier id of the current subscription. + *
To recognize a carrier (including MVNO) as a first class identity, assign each carrier + * with a canonical integer a.k.a carrier id. + * + * @return Carrier id of the current subscription. Return {@link #UNKNOWN_CARRIER_ID} if the + * subscription is unavailable or the carrier cannot be identified. + * @throws IllegalStateException if telephony service is unavailable. + */ + public int getSubscriptionCarrierId() { + try { + ITelephony service = getITelephony(); + return service.getSubscriptionCarrierId(getSubId()); + } catch (RemoteException ex) { + // This could happen if binder process crashes. + ex.rethrowAsRuntimeException(); + } catch (NullPointerException ex) { + // This could happen before phone restarts due to crashing. + throw new IllegalStateException("Telephony service unavailable"); + } + return UNKNOWN_CARRIER_ID; + } + + /** + * Returns carrier name of the current subscription. + *
Carrier name is a user-facing name of carrier id {@link #getSubscriptionCarrierId()}, + * usually the brand name of the subsidiary (e.g. T-Mobile). Each carrier could configure + * multiple {@link #getSimOperatorName() SPN} but should have a single carrier name. + * Carrier name is not a canonical identity, use {@link #getSubscriptionCarrierId()} instead. + *
The returned carrier name is unlocalized.
+ *
+ * @return Carrier name of the current subscription. Return {@code null} if the subscription is
+ * unavailable or the carrier cannot be identified.
+ * @throws IllegalStateException if telephony service is unavailable.
+ */
+ public String getSubscriptionCarrierName() {
+ try {
+ ITelephony service = getITelephony();
+ return service.getSubscriptionCarrierName(getSubId());
+ } catch (RemoteException ex) {
+ // This could happen if binder process crashes.
+ ex.rethrowAsRuntimeException();
+ } catch (NullPointerException ex) {
+ // This could happen before phone restarts due to crashing.
+ throw new IllegalStateException("Telephony service unavailable");
+ }
+ return null;
+ }
+
/**
* Return the application ID for the app type like {@link APPTYPE_CSIM}.
*
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index b0af9a84553bf..416146fcb98ec 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1317,6 +1317,34 @@ interface ITelephony {
*/
List To recognize carrier as a first class identity, assign each carrier with a canonical
+ * integer a.k.a carrier id.
+ *
+ * @param subId The subscription id
+ * @return Carrier id of given subscription id. return {@link #UNKNOWN_CARRIER_ID} if
+ * subscription is unavailable or carrier cannot be identified.
+ * @throws IllegalStateException if telephony service is unavailable.
+ * @hide
+ */
+ int getSubscriptionCarrierId(int subId);
+
+ /**
+ * Returns carrier name of the given subscription.
+ * Carrier name is a user-facing name of carrier id {@link #getSubscriptionCarrierId(int)},
+ * usually the brand name of the subsidiary (e.g. T-Mobile). Each carrier could configure
+ * multiple {@link #getSimOperatorName() SPN} but should have a single carrier name.
+ * Carrier name is not canonical identity, use {@link #getSubscriptionCarrierId(int)} instead.
+ * Returned carrier name is unlocalized.
+ *
+ * @return Carrier name of given subscription id. return {@code null} if subscription is
+ * unavailable or carrier cannot be identified.
+ * @throws IllegalStateException if telephony service is unavailable.
+ * @hide
+ */
+ String getSubscriptionCarrierName(int subId);
+
/**
* Action set from carrier signalling broadcast receivers to enable/disable metered apns
* Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required