diff options
| author | 2019-01-29 17:25:17 +0000 | |
|---|---|---|
| committer | 2019-01-29 17:25:17 +0000 | |
| commit | d8148b6c8c259d3088a6d1aa9703ff208c76c36e (patch) | |
| tree | 1507a1ba1f4f4bf0f398620cfe56e85f6a72513a | |
| parent | 34b11c92b34c8244c47fc2c1f9d8eb733b884004 (diff) | |
| parent | 3590fa4d72e251a35ea493fed1bb1ede14bc2a6e (diff) | |
Merge "Add check for slot index value"
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 2461aad80246..217772d0a5c9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -8949,6 +8949,9 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) { + if (carriers == null || !SubscriptionManager.isValidPhoneId(slotIndex)) { + return -1; + } // Execute the method setCarrierRestrictionRules with an empty excluded list and // indicating priority for the allowed list. CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder() @@ -8959,7 +8962,7 @@ public class TelephonyManager { int result = setCarrierRestrictionRules(carrierRestrictionRules); - // Convert boolean result into int, as required by this method. + // Convert result into int, as required by this method. if (result == SET_CARRIER_RESTRICTION_SUCCESS) { return carriers.size(); } else { @@ -9052,9 +9055,11 @@ public class TelephonyManager { @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) { - CarrierRestrictionRules carrierRestrictionRule = getCarrierRestrictionRules(); - if (carrierRestrictionRule != null) { - return carrierRestrictionRule.getAllowedCarriers(); + if (SubscriptionManager.isValidPhoneId(slotIndex)) { + CarrierRestrictionRules carrierRestrictionRule = getCarrierRestrictionRules(); + if (carrierRestrictionRule != null) { + return carrierRestrictionRule.getAllowedCarriers(); + } } return new ArrayList<CarrierIdentifier>(0); } |