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

Commit f4a76599 authored by fionaxu's avatar fionaxu Committed by Chen Xu
Browse files

new carrier id APIs

1. New telephony APIs to getCurrentCarrierId
and getCurrentCarrierName
2. New broadcast intent to notify carrier id changed

Bug: 64131637
Test: Build
Change-Id: I9a240ba7df313ad701f98bb3982f29c3d5317da8
(cherry picked from commit fff6f59a)
Merged-in: I9a240ba7df313ad701f98bb3982f29c3d5317da8
parent a13201a9
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -40769,6 +40769,8 @@ package android.telephony {
    method public int getSimState();
    method public int getSimState();
    method public int getSimState(int);
    method public int getSimState(int);
    method public java.lang.String getSubscriberId();
    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 getVisualVoicemailPackageName();
    method public java.lang.String getVoiceMailAlphaTag();
    method public java.lang.String getVoiceMailAlphaTag();
    method public java.lang.String getVoiceMailNumber();
    method public java.lang.String getVoiceMailNumber();
@@ -40813,6 +40815,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_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_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_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_CSIM = 4; // 0x4
    field public static final int APPTYPE_ISIM = 5; // 0x5
    field public static final int APPTYPE_ISIM = 5; // 0x5
    field public static final int APPTYPE_RUIM = 3; // 0x3
    field public static final int APPTYPE_RUIM = 3; // 0x3
@@ -40833,6 +40836,8 @@ package android.telephony {
    field public static final int DATA_DISCONNECTED = 0; // 0x0
    field public static final int DATA_DISCONNECTED = 0; // 0x0
    field public static final int DATA_SUSPENDED = 3; // 0x3
    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_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_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_INCOMING_NUMBER = "incoming_number";
    field public static final java.lang.String EXTRA_IS_REFRESH = "android.telephony.extra.IS_REFRESH";
    field public static final java.lang.String EXTRA_IS_REFRESH = "android.telephony.extra.IS_REFRESH";
@@ -40843,6 +40848,7 @@ package android.telephony {
    field public static final java.lang.String EXTRA_STATE_IDLE;
    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_OFFHOOK;
    field public static final java.lang.String EXTRA_STATE_RINGING;
    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 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 java.lang.String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU";
    field public static final int NETWORK_TYPE_1xRTT = 7; // 0x7
    field public static final int NETWORK_TYPE_1xRTT = 7; // 0x7
@@ -40878,6 +40884,7 @@ package android.telephony {
    field public static final int SIM_STATE_PUK_REQUIRED = 3; // 0x3
    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_READY = 5; // 0x5
    field public static final int SIM_STATE_UNKNOWN = 0; // 0x0
    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_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe
    field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
    field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
    field public static final java.lang.String VVM_TYPE_CVVM = "vvm_type_cvvm";
    field public static final java.lang.String VVM_TYPE_CVVM = "vvm_type_cvvm";
+107 −0
Original line number Original line Diff line number Diff line
@@ -957,6 +957,64 @@ public class TelephonyManager {
     */
     */
    public static final int USSD_ERROR_SERVICE_UNAVAIL = -2;
    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:
     * <ul>
     *   <li>Subscription absent. Carrier identity could change from a valid id to
     *   {@link TelephonyManager#UNKNOWN_CARRIER_ID}.</li>
     *   <li>Subscription loaded. Carrier identity could change from
     *   {@link TelephonyManager#UNKNOWN_CARRIER_ID} to a valid id.</li>
     *   <li>The subscription carrier is recognized after a remote update.</li>
     * </ul>
     * The intent will have the following extra values:
     * <ul>
     *   <li>{@link #EXTRA_CARRIER_ID} The up-to-date carrier id of the current subscription id.
     *   </li>
     *   <li>{@link #EXTRA_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.
     */
    @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.
     * <p>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()}
     * <p>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
    // Device Info
@@ -6547,6 +6605,55 @@ public class TelephonyManager {
        }
        }
    }
    }


    /**
     * Returns carrier id of the current subscription.
     * <p>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.
     * <p>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.
     * <p>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}.
     * Return the application ID for the app type like {@link APPTYPE_CSIM}.
     *
     *
+28 −0
Original line number Original line Diff line number Diff line
@@ -1317,6 +1317,34 @@ interface ITelephony {
     */
     */
    List<CarrierIdentifier> getAllowedCarriers(int slotIndex);
    List<CarrierIdentifier> getAllowedCarriers(int slotIndex);


   /**
     * Returns carrier id of the given subscription.
     * <p>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.
     * <p>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.
     * <p>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
     * 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