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

Commit d8104ecf authored by Jack Yu's avatar Jack Yu
Browse files

Added slot index version of getNetworkCountryIso

Added this API to get network country ISO so in SIM
absent case, we can get the information from the 2nd
phone.

Bug: 141128426
Test: CTS
Merged-In: Ib02e4d145cb39683bcb13d39715003095ad93eef
Change-Id: Ib02e4d145cb39683bcb13d39715003095ad93eef
(cherry picked from commit a5fedc5c)
parent 4ed6876d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44898,6 +44898,7 @@ package android.telephony {
    field public static final int DATA_ROAMING_DISABLE = 0; // 0x0
    field public static final int DATA_ROAMING_ENABLE = 1; // 0x1
    field public static final int DEFAULT_SUBSCRIPTION_ID = 2147483647; // 0x7fffffff
    field public static final String EXTRA_SLOT_INDEX = "android.telephony.extra.SLOT_INDEX";
    field public static final String EXTRA_SUBSCRIPTION_INDEX = "android.telephony.extra.SUBSCRIPTION_INDEX";
    field public static final int INVALID_SIM_SLOT_INDEX = -1; // 0xffffffff
    field public static final int INVALID_SUBSCRIPTION_ID = -1; // 0xffffffff
+1 −0
Original line number Diff line number Diff line
@@ -8126,6 +8126,7 @@ package android.telephony {
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst();
    method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Map<java.lang.Integer,java.lang.Integer> getLogicalToPhysicalSlotMapping();
    method public static long getMaxNumberVerificationTimeoutMillis();
    method @NonNull public String getNetworkCountryIso(int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmask();
    method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState();
    method public int getSimApplicationState();
+1 −0
Original line number Diff line number Diff line
@@ -2876,6 +2876,7 @@ package android.telephony {
    method public int checkCarrierPrivilegesForPackage(String);
    method public int getCarrierIdListVersion();
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag();
    method @NonNull public String getNetworkCountryIso(int);
    method public android.util.Pair<java.lang.Integer,java.lang.Integer> getRadioHalVersion();
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile();
    method @Deprecated public void setCarrierTestOverride(String, String, String, String, String, String, String);
+6 −0
Original line number Diff line number Diff line
@@ -885,6 +885,11 @@ public class SubscriptionManager {
     */
    public static final String EXTRA_SUBSCRIPTION_INDEX = "android.telephony.extra.SUBSCRIPTION_INDEX";

    /**
     * Integer extra to specify SIM slot index.
     */
    public static final String EXTRA_SLOT_INDEX = "android.telephony.extra.SLOT_INDEX";

    private final Context mContext;
    private volatile INetworkPolicyManager mNetworkPolicy;

@@ -2112,6 +2117,7 @@ public class SubscriptionManager {
        if (VDBG) logd("putPhoneIdAndSubIdExtra: phoneId=" + phoneId + " subId=" + subId);
        intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
        intent.putExtra(EXTRA_SUBSCRIPTION_INDEX, subId);
        intent.putExtra(EXTRA_SLOT_INDEX, phoneId);
        intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
    }

+18 −22
Original line number Diff line number Diff line
@@ -2428,41 +2428,37 @@ public class TelephonyManager {
     * @return the lowercase 2 character ISO-3166 country code, or empty string if not available.
     */
    public String getNetworkCountryIso() {
        return getNetworkCountryIsoForPhone(getPhoneId());
        return getNetworkCountryIso(getPhoneId());
    }

    /**
     * Returns the ISO country code equivalent of the MCC (Mobile Country Code) of the current
     * Returns the ISO-3166 country code equivalent of the MCC (Mobile Country Code) of the current
     * registered operator or the cell nearby, if available.
     * <p>
     * The ISO-3166 country code is provided in lowercase 2 character format.
     * <p>
     * Note: In multi-sim, this returns a shared emergency network country iso from other
     * subscription if the subscription used to create the TelephonyManager doesn't camp on
     * a network due to some reason (e.g. pin/puk locked), or sim is absent in the corresponding
     * slot.
     * Note: Result may be unreliable on CDMA networks (use {@link #getPhoneType()} to determine
     * if on a CDMA network).
     *
     * @param subId for which Network CountryIso is returned
     * @hide
     */
    @UnsupportedAppUsage
    public String getNetworkCountryIso(int subId) {
        return getNetworkCountryIsoForPhone(getPhoneId(subId));
    }

    /**
     * Returns the ISO country code equivalent of the current registered
     * operator's MCC (Mobile Country Code) of a subscription.
     * <p>
     * Availability: Only when user is registered to a network. Result may be
     * unreliable on CDMA networks (use {@link #getPhoneType()} to determine if
     * on a CDMA network).
     *
     * @param phoneId for which Network CountryIso is returned
     * @param slotIndex the SIM slot index to get network country ISO.
     *
     * @return the lowercase 2 character ISO-3166 country code, or empty string if not available.
     *
     * {@hide}
     */
    /** {@hide} */
    @UnsupportedAppUsage
    public String getNetworkCountryIsoForPhone(int phoneId) {
    @SystemApi
    @TestApi
    @NonNull
    public String getNetworkCountryIso(int slotIndex) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony == null) return "";
            return telephony.getNetworkCountryIsoForPhone(phoneId);
            return telephony.getNetworkCountryIsoForPhone(slotIndex);
        } catch (RemoteException ex) {
            return "";
        }