diff options
| author | 2018-11-12 22:31:32 -0800 | |
|---|---|---|
| committer | 2018-11-12 22:31:32 -0800 | |
| commit | eb45abb8aa8c7d26806ccbf526cf123132cd59cc (patch) | |
| tree | 62e59f475a2624eef18c4c1b2c9d07c4b60b45d9 | |
| parent | b4ce0e3f2e0fe98b62df57ae41a7e4c51e20cba7 (diff) | |
| parent | 00496a118118d786686a8857c843dca71544fde2 (diff) | |
Merge "support parent carrier id"
am: 00496a1181
Change-Id: Ifdb44efdfbeecd6db8841c6de3f38e40a7e9566b
3 files changed, 186 insertions, 0 deletions
diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java index 72f0292e3820..7b798e8f185a 100644 --- a/telephony/java/android/provider/Telephony.java +++ b/telephony/java/android/provider/Telephony.java @@ -3497,6 +3497,27 @@ public final class Telephony { } /** + * Generates a content {@link Uri} used to receive updates on precise carrier identity + * change on the given subscriptionId + * {@link TelephonyManager#ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED}. + * <p> + * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the + * precise carrier identity {@link TelephonyManager#getSimPreciseCarrierId()} + * while your app is running. You can also use a {@link JobService} to ensure your app + * is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link JobService} does not guarantee timely delivery of + * updates to the {@link Uri}. + * + * @param subscriptionId the subscriptionId to receive updates on + * @return the Uri used to observe precise carrier identity changes + * @hide + */ + public static Uri getPreciseCarrierIdUriForSubscriptionId(int subscriptionId) { + return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "precise"), + String.valueOf(subscriptionId)); + } + + /** * A user facing carrier name. * @see TelephonyManager#getSimCarrierIdName() * <P>Type: TEXT </P> @@ -3511,6 +3532,35 @@ public final class Telephony { public static final String CARRIER_ID = "carrier_id"; /** + * A user facing carrier name for precise carrier id. + * @see TelephonyManager#getSimPreciseCarrierIdName() + * This is not a database column, only used to notify content observers for + * {@link #getPreciseCarrierIdUriForSubscriptionId(int)} + * @hide + */ + public static final String PRECISE_CARRIER_ID_NAME = "precise_carrier_id_name"; + + /** + * A fine-grained carrier id. + * @see TelephonyManager#getSimPreciseCarrierId() + * This is not a database column, only used to notify content observers for + * {@link #getPreciseCarrierIdUriForSubscriptionId(int)} + * @hide + */ + public static final String PRECISE_CARRIER_ID = "precise_carrier_id"; + + /** + * A unique parent carrier id. The parent-child + * relationship can be used to further differentiate a single carrier by different networks, + * by prepaid v.s. postpaid or even by 4G v.s. 3G plan. It's an optional field. + * A carrier id with a valid parent_carrier_id is considered fine-grained carrier id, will + * not be returned as {@link #CARRIER_ID} but {@link #PRECISE_CARRIER_ID}. + * <P>Type: INTEGER </P> + * @hide + */ + public static final String PARENT_CARRIER_ID = "parent_carrier_id"; + + /** * A unique mno carrier id. mno carrier shares the same {@link All#MCCMNC} as carrier id * and can be solely identified by {@link All#MCCMNC} only. If there is no such mno * carrier, then mno carrier id equals to {@link #CARRIER_ID carrier id}. diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5f69507df43c..016a77d2a741 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1212,6 +1212,33 @@ public class TelephonyManager { "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED"; /** + * Broadcast Action: The subscription precise carrier identity has changed. + * Similar like {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED}, this intent will be sent + * on the event of {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED}. However, its possible + * that precise carrier identity changes while + * {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} remains the same e.g, the same + * subscription switches to different IMSI could potentially change its precise carrier id. + * + * The intent will have the following extra values: + * <ul> + * <li>{@link #EXTRA_PRECISE_CARRIER_ID} The up-to-date precise carrier id of the + * current subscription. + * </li> + * <li>{@link #EXTRA_PRECISE_CARRIER_NAME} The up-to-date carrier name of the current + * subscription. + * </li> + * <li>{@link #EXTRA_SUBSCRIPTION_ID} The subscription id associated with the changed carrier + * identity. + * </li> + * </ul> + * <p class="note">This is a protected intent that can only be sent by the system. + * @hide + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED = + "android.telephony.action.SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED"; + + /** * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which indicates * the updated carrier id {@link TelephonyManager#getSimCarrierId()} of * the current subscription. @@ -1240,6 +1267,28 @@ public class TelephonyManager { public static final String EXTRA_CARRIER_NAME = "android.telephony.extra.CARRIER_NAME"; /** + * An int extra used with {@link #ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED} which + * indicates the updated precise carrier id {@link TelephonyManager#getSimPreciseCarrierId()} of + * the current subscription. Note, its possible precise carrier id changes while + * {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} remains the same e.g, when + * subscription switch to different IMSI. + * <p>Will be {@link TelephonyManager#UNKNOWN_CARRIER_ID} if the subscription is unavailable or + * the carrier cannot be identified. + * @hide + */ + public static final String EXTRA_PRECISE_CARRIER_ID = + "android.telephony.extra.PRECISE_CARRIER_ID"; + + /** + * An string extra used with {@link #ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED} which + * indicates the updated precise carrier name of the current subscription. + * {@see TelephonyManager#getSimPreciseCarrierIdName()} + * <p>it's a user-facing name of the precise carrier id {@link #EXTRA_PRECISE_CARRIER_ID}, + * @hide + */ + public static final String EXTRA_PRECISE_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. */ @@ -8299,6 +8348,62 @@ public class TelephonyManager { } /** + * Returns fine-grained carrier id of the current subscription. + * + * <p>The precise carrier id can be used to further differentiate a carrier by different + * networks, by prepaid v.s.postpaid or even by 4G v.s.3G plan. Each carrier has a unique + * carrier id {@link #getSimCarrierId()} but can have multiple precise carrier id. e.g, + * {@link #getSimCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM, while + * {@link #getSimPreciseCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based on the + * current subscription IMSI. + * + * <p>For carriers without any fine-grained carrier ids, return {@link #getSimCarrierId()} + * <p>Precise carrier ids are defined in the same way as carrier id + * <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a> + * except each with a "parent" id linking to its top-level carrier id. + * + * @return Returns fine-grained carrier id of the current subscription. + * Return {@link #UNKNOWN_CARRIER_ID} if the subscription is unavailable or the carrier cannot + * be identified. + * + * @hide + */ + public int getSimPreciseCarrierId() { + try { + ITelephony service = getITelephony(); + if (service != null) { + return service.getSubscriptionPreciseCarrierId(getSubId()); + } + } catch (RemoteException ex) { + // This could happen if binder process crashes. + } + return UNKNOWN_CARRIER_ID; + } + + /** + * Similar like {@link #getSimCarrierIdName()}, returns user-facing name of the + * precise carrier id {@link #getSimPreciseCarrierId()} + * + * <p>The returned name is unlocalized. + * + * @return user-facing name of the subscription precise carrier id. Return {@code null} if the + * subscription is unavailable or the carrier cannot be identified. + * + * @hide + */ + public CharSequence getSimPreciseCarrierIdName() { + try { + ITelephony service = getITelephony(); + if (service != null) { + return service.getSubscriptionPreciseCarrierName(getSubId()); + } + } catch (RemoteException ex) { + // This could happen if binder process crashes. + } + return null; + } + + /** * Return a list of certs in hex string from loaded carrier privileges access rules. * * @return a list of certificate in hex string. return {@code null} if there is no certs diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index cf66ca201785..1f3746668aa6 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1323,6 +1323,37 @@ interface ITelephony { int getSubscriptionMNOCarrierId(int subId); /** + * Returns fine-grained carrier id of the current subscription. + * + * <p>The precise carrier id can be used to further differentiate a carrier by different + * networks, by prepaid v.s.postpaid or even by 4G v.s.3G plan. Each carrier has a unique + * carrier id {@link #getSimCarrierId()} but can have multiple precise carrier id. e.g, + * {@link #getSimCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM, while + * {@link #getSimPreciseCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based on the + * current underlying network. + * + * <p>For carriers without any fine-grained carrier ids, return {@link #getSimCarrierId()} + * + * @return Returns fine-grained carrier id of the current subscription. + * Return {@link #UNKNOWN_CARRIER_ID} if the subscription is unavailable or the carrier cannot + * be identified. + * @hide + */ + int getSubscriptionPreciseCarrierId(int subId); + + /** + * Similar like {@link #getSimCarrierIdName()}, returns user-facing name of the + * precise carrier id {@link #getSimPreciseCarrierId()} + * + * <p>The returned name is unlocalized. + * + * @return user-facing name of the subscription precise carrier id. Return {@code null} if the + * subscription is unavailable or the carrier cannot be identified. + * @hide + */ + String getSubscriptionPreciseCarrierName(int subId); + + /** * Action set from carrier signalling broadcast receivers to enable/disable metered apns * Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required * @param subId the subscription ID that this action applies to. |