diff --git a/api/system-current.txt b/api/system-current.txt index c9f96e079f337..a4e20cc5c5009 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8245,7 +8245,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 getLogicalToPhysicalSlotMapping(); method public static long getMaxNumberVerificationTimeoutMillis(); - method @NonNull public String getNetworkCountryIso(int); + method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) 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(); diff --git a/api/test-current.txt b/api/test-current.txt index 0cf2f1bb33ae4..a40cb923065fa 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2928,7 +2928,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 @NonNull @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getNetworkCountryIso(int); method public android.util.Pair getRadioHalVersion(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile(); method @Deprecated public void setCarrierTestOverride(String, String, String, String, String, String, String); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 1ff85b14c8bbe..f3215d4d0e8b1 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -2444,7 +2444,14 @@ public class TelephonyManager { * @return the lowercase 2 character ISO-3166 country code, or empty string if not available. */ public String getNetworkCountryIso() { - return getNetworkCountryIso(getPhoneId()); + try { + ITelephony telephony = getITelephony(); + if (telephony == null) return ""; + return telephony.getNetworkCountryIsoForPhone(getPhoneId(), + null /* no permission check */); + } catch (RemoteException ex) { + return ""; + } } /** @@ -2470,11 +2477,12 @@ public class TelephonyManager { @SystemApi @TestApi @NonNull + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getNetworkCountryIso(int slotIndex) { try { ITelephony telephony = getITelephony(); if (telephony == null) return ""; - return telephony.getNetworkCountryIsoForPhone(slotIndex); + return telephony.getNetworkCountryIsoForPhone(slotIndex, getOpPackageName()); } catch (RemoteException ex) { return ""; } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 866e936a1211e..4d90579757272 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -302,7 +302,7 @@ interface ITelephony { * operator's MCC (Mobile Country Code). * @see android.telephony.TelephonyManager#getNetworkCountryIso */ - String getNetworkCountryIsoForPhone(int phoneId); + String getNetworkCountryIsoForPhone(int phoneId, String callingPkg); /** * Returns the neighboring cell information of the device.