diff options
author | Anthony Lee <anthonylee@google.com> | 2014-09-11 09:21:38 -0700 |
---|---|---|
committer | Anthony Lee <anthonylee@google.com> | 2014-09-11 12:37:29 -0700 |
commit | b78890c159f9f06617712261e6c9f284841f2357 (patch) | |
tree | 1a06a15aa7a4a6a7b82eefcdba3875cdf91a399d | |
parent | 2f67e237383ae6e76c44333ab79c6f0d1e3e568d (diff) | |
download | frameworks_base-b78890c159f9f06617712261e6c9f284841f2357.zip frameworks_base-b78890c159f9f06617712261e6c9f284841f2357.tar.gz frameworks_base-b78890c159f9f06617712261e6c9f284841f2357.tar.bz2 |
isValidSlotId() and isValidPhoneId() updated to handle negatives.
The old version of the code wanted to just check to make sure
that the slot/phone id is greater than INVALID_SLOT_ID or
INVALID_PHONE_ID that are both currently defined to be -1000. The
changes are made for 2 reasons. First, INVALID_SLOT_ID and/or
INVALID_PHONE_ID might not always be defined to be a negative value
so there is a big assumption. Secondly, anything greater than
-1000 allows other negative values to be considered valid ids.
Bug: 17243556
Change-Id: I2bbfcc2cfd2d7c4772dfb9c50af2dc88c0f315e2
-rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index d0f355e..fe68263 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -930,13 +930,20 @@ public class SubscriptionManager implements BaseColumns { /** @hide */ public static boolean isValidSlotId(int slotId) { - return slotId > INVALID_SLOT_ID && slotId < TelephonyManager.getDefault().getSimCount(); + // We are testing INVALID_SLOT_ID and slotId >= 0 independently because we should + // not assume that INVALID_SLOT_ID will always be a negative value. Any negative + // value is invalid. + return slotId != INVALID_SLOT_ID && slotId >= 0 && + slotId < TelephonyManager.getDefault().getSimCount(); } /** @hide */ public static boolean isValidPhoneId(int phoneId) { - return phoneId > INVALID_PHONE_ID - && phoneId < TelephonyManager.getDefault().getPhoneCount(); + // We are testing INVALID_PHONE_ID and phoneId >= 0 independently because we should + // not assume that INVALID_PHONE_ID will always be a negative value. Any negative + // value is invalid. + return phoneId != INVALID_PHONE_ID && phoneId >= 0 && + phoneId < TelephonyManager.getDefault().getPhoneCount(); } /** @hide */ |