Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd44d813 authored by chen xu's avatar chen xu
Browse files

support 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. parent carrier id 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 API getSimCarrierId but will be returned as
new API getSimPreciseCarrierId.

Bug: 110559381
Change-Id: Ica273cbad16b4773edc41b79ff4bf7570de40ec1
parent 929cd083
Loading
Loading
Loading
Loading
+50 −0
Original line number Original line Diff line number Diff line
@@ -3612,6 +3612,27 @@ public final class Telephony {
                    String.valueOf(subscriptionId)).build();
                    String.valueOf(subscriptionId)).build();
        }
        }


        /**
         * 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.
         * A user facing carrier name.
         * @see TelephonyManager#getSimCarrierIdName()
         * @see TelephonyManager#getSimCarrierIdName()
@@ -3626,6 +3647,35 @@ public final class Telephony {
         */
         */
        public static final String CARRIER_ID = "carrier_id";
        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
         * 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
         * and can be solely identified by {@link All#MCCMNC} only. If there is no such mno
+105 −0
Original line number Original line Diff line number Diff line
@@ -1160,6 +1160,33 @@ public class TelephonyManager {
    public static final String ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED =
    public static final String ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED =
            "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED";
            "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
     * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which indicates
     * the updated carrier id {@link TelephonyManager#getSimCarrierId()} of
     * the updated carrier id {@link TelephonyManager#getSimCarrierId()} of
@@ -1188,6 +1215,28 @@ public class TelephonyManager {
     */
     */
    public static final String EXTRA_CARRIER_NAME = "android.telephony.extra.CARRIER_NAME";
    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
     * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} to indicate the
     * subscription which has changed.
     * subscription which has changed.
@@ -8268,6 +8317,62 @@ public class TelephonyManager {
        return null;
        return null;
    }
    }


    /**
     * 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 certs in hex string from loaded carrier privileges access rules.
     *
     *
+31 −0
Original line number Original line Diff line number Diff line
@@ -1322,6 +1322,37 @@ interface ITelephony {
     */
     */
    int getSubscriptionMNOCarrierId(int subId);
    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
     * Action set from carrier signalling broadcast receivers to enable/disable metered apns
     * Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required
     * Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required