diff options
| author | 2019-11-08 09:56:02 -0800 | |
|---|---|---|
| committer | 2019-11-08 09:56:02 -0800 | |
| commit | 0d75aee571eb6a7048a618af894c41a24e8e5cbd (patch) | |
| tree | 962c876f0ceac373e49af4331e66606f0535f1b4 | |
| parent | 83f6768e9bc8d56b1f6c2ebaf5ce8d7222f5c06f (diff) | |
Throw illegal argument exception when slot index is invalid
Test: Manual
Bug: 144097779
Change-Id: I5c5c4eb313fd42317a2b0feed0946b8e4003ad62
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5a63eb08860b..05355db60d09 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -2584,6 +2584,8 @@ public class TelephonyManager { * * @return the lowercase 2 character ISO-3166 country code, or empty string if not available. * + * @throws IllegalArgumentException when the slotIndex is invalid. + * * {@hide} */ @SystemApi @@ -2592,6 +2594,10 @@ public class TelephonyManager { @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getNetworkCountryIso(int slotIndex) { try { + if (!SubscriptionManager.isValidSlotIndex(slotIndex)) { + throw new IllegalArgumentException("invalid slot index " + slotIndex); + } + ITelephony telephony = getITelephony(); if (telephony == null) return ""; return telephony.getNetworkCountryIsoForPhone(slotIndex, getOpPackageName()); |