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

Commit 5e6e52a0 authored by Anthony Lee's avatar Anthony Lee Committed by Android (Google) Code Review
Browse files

Merge "isValidSlotId() and isValidPhoneId() updated to handle negatives." into lmp-dev

parents 24a95a10 b78890c1
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -930,13 +930,20 @@ public class SubscriptionManager implements BaseColumns {


    /** @hide */
    /** @hide */
    public static boolean isValidSlotId(int slotId) {
    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 */
    /** @hide */
    public static boolean isValidPhoneId(int phoneId) {
    public static boolean isValidPhoneId(int phoneId) {
        return phoneId > INVALID_PHONE_ID
        // We are testing INVALID_PHONE_ID and phoneId >= 0 independently because we should
                && phoneId < TelephonyManager.getDefault().getPhoneCount();
        // 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 */
    /** @hide */