Change tests against INVALID_SUBSCRIPTION_ID to use isValidSubscriptionId.

Rename isValidSubId to isValidSubscriptionId.

Bug: 18668873
Change-Id: Ie709a62bbb74e0a767daeb9e3fb3aecd4c45df44
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
index 5350e5a..1e2a233 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
@@ -81,11 +81,11 @@
     SecurityMode getSecurityMode() {
         KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
         SecurityMode mode = SecurityMode.None;
-        if (monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED)
-                != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+        if (SubscriptionManager.isValidSubscriptionId(
+                monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED))) {
             mode = SecurityMode.SimPin;
-        } else if (monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED)
-                != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+        } else if (SubscriptionManager.isValidSubscriptionId(
+                    monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED))
                 && mLockPatternUtils.isPukUnlockScreenEnable()) {
             mode = SecurityMode.SimPuk;
         } else {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
index f1c4cd4..f4acff8 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
@@ -75,7 +75,7 @@
         if (DEBUG) Log.v(TAG, "Resetting state");
         KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
         mSubId = monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED);
-        if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+        if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
             int count = TelephonyManager.getDefault().getSimCount();
             Resources rez = getResources();
             final String msg;
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
index c9670bb..b85d966 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
@@ -118,7 +118,7 @@
             state = ENTER_PUK;
             KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
             mSubId = monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED);
-            if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
                 int count = TelephonyManager.getDefault().getSimCount();
                 Resources rez = getResources();
                 final String msg;
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 8458ae0..c8cfe31b 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -938,7 +938,7 @@
                     + slotId + ", state=" + state +")");
         }
 
-        if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
             Log.w(TAG, "invalid subId in handleSimStateChange()");
             return;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 7ac0daf..e66934e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -964,11 +964,10 @@
 
         // if the setup wizard hasn't run yet, don't show
         final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", false);
-        final boolean absent = mUpdateMonitor.getNextSubIdForState(
-                IccCardConstants.State.ABSENT) != SubscriptionManager.INVALID_SUBSCRIPTION_ID;
-        final boolean disabled = mUpdateMonitor.getNextSubIdForState(
-                IccCardConstants.State.PERM_DISABLED)
-                != SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+        final boolean absent = SubscriptionManager.isValidSubscriptionId(
+                mUpdateMonitor.getNextSubIdForState(IccCardConstants.State.ABSENT));
+        final boolean disabled = SubscriptionManager.isValidSubscriptionId(
+                mUpdateMonitor.getNextSubIdForState(IccCardConstants.State.PERM_DISABLED));
         final boolean lockedOrMissing = mUpdateMonitor.isSimPinSecure()
                 || ((absent || disabled) && requireSim);
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 3397a38..833ccd5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -265,7 +265,7 @@
 
     private MobileSignalController getDataController() {
         int dataSubId = SubscriptionManager.getDefaultDataSubId();
-        if (dataSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+        if (!SubscriptionManager.isValidSubscriptionId(dataSubId)) {
             if (DEBUG) Log.e(TAG, "No data sim selected");
             return mDefaultSignalController;
         }
@@ -283,8 +283,9 @@
 
     public boolean isEmergencyOnly() {
         int voiceSubId = SubscriptionManager.getDefaultVoiceSubId();
-        if (voiceSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
-            for (MobileSignalController mobileSignalController : mMobileSignalControllers.values()) {
+        if (!SubscriptionManager.isValidSubscriptionId(voiceSubId)) {
+            for (MobileSignalController mobileSignalController :
+                                            mMobileSignalControllers.values()) {
                 if (!mobileSignalController.isEmergencyOnly()) {
                     return false;
                 }
@@ -397,7 +398,7 @@
         } else {
             int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                     SubscriptionManager.INVALID_SUBSCRIPTION_ID);
-            if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            if (SubscriptionManager.isValidSubscriptionId(subId)) {
                 if (mMobileSignalControllers.containsKey(subId)) {
                     mMobileSignalControllers.get(subId).handleBroadcast(intent);
                 } else {
@@ -1265,7 +1266,7 @@
 
         private void updateDataSim() {
             int defaultDataSub = SubscriptionManager.getDefaultDataSubId();
-            if (SubscriptionManager.isValidSubId(defaultDataSub)) {
+            if (SubscriptionManager.isValidSubscriptionId(defaultDataSub)) {
                 mCurrentState.dataSim = defaultDataSub == mSubscriptionInfo.getSubscriptionId();
             } else {
                 // There doesn't seem to be a data sim selected, however if
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 34da901..776f836 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -480,7 +480,7 @@
                 r.callerUid = callerUid;
                 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
                 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
-                if (!SubscriptionManager.isValidSubId(subId)) {
+                if (!SubscriptionManager.isValidSubscriptionId(subId)) {
                     r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
                  } else {//APP specify subID
                     r.subId = subId;
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 39cce69..d174f47 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -392,7 +392,7 @@
      */
     public SubscriptionInfo getActiveSubscriptionInfo(int subId) {
         if (VDBG) logd("[getActiveSubscriptionInfo]+ subId=" + subId);
-        if (!isValidSubId(subId)) {
+        if (!isValidSubscriptionId(subId)) {
             logd("[getActiveSubscriptionInfo]- invalid subId");
             return null;
         }
@@ -626,7 +626,7 @@
      */
     public int setIconTint(int tint, int subId) {
         if (VDBG) logd("[setIconTint]+ tint:" + tint + " subId:" + subId);
-        if (!isValidSubId(subId)) {
+        if (!isValidSubscriptionId(subId)) {
             logd("[setIconTint]- fail");
             return -1;
         }
@@ -671,7 +671,7 @@
             logd("[setDisplayName]+  displayName:" + displayName + " subId:" + subId
                     + " nameSource:" + nameSource);
         }
-        if (!isValidSubId(subId)) {
+        if (!isValidSubscriptionId(subId)) {
             logd("[setDisplayName]- fail");
             return -1;
         }
@@ -699,7 +699,7 @@
      * @hide
      */
     public int setDisplayNumber(String number, int subId) {
-        if (number == null || !isValidSubId(subId)) {
+        if (number == null || !isValidSubscriptionId(subId)) {
             logd("[setDisplayNumber]- fail");
             return -1;
         }
@@ -728,7 +728,7 @@
      */
     public int setDataRoaming(int roaming, int subId) {
         if (VDBG) logd("[setDataRoaming]+ roaming:" + roaming + " subId:" + subId);
-        if (roaming < 0 || !isValidSubId(subId)) {
+        if (roaming < 0 || !isValidSubscriptionId(subId)) {
             logd("[setDataRoaming]- fail");
             return -1;
         }
@@ -754,7 +754,7 @@
      * @hide
      */
     public static int getSlotId(int subId) {
-        if (!isValidSubId(subId)) {
+        if (!isValidSubscriptionId(subId)) {
             logd("[getSlotId]- fail");
         }
 
@@ -796,7 +796,7 @@
 
     /** @hide */
     public static int getPhoneId(int subId) {
-        if (!isValidSubId(subId)) {
+        if (!isValidSubscriptionId(subId)) {
             logd("[getPhoneId]- fail");
             return INVALID_PHONE_INDEX;
         }
@@ -985,13 +985,13 @@
     //FIXME this is vulnerable to race conditions
     /** @hide */
     public boolean allDefaultsSelected() {
-        if (getDefaultDataSubId() == INVALID_SUBSCRIPTION_ID) {
+        if (!isValidSubscriptionId(getDefaultDataSubId())) {
             return false;
         }
-        if (getDefaultSmsSubId() == INVALID_SUBSCRIPTION_ID) {
+        if (!isValidSubscriptionId(getDefaultSmsSubId())) {
             return false;
         }
-        if (getDefaultVoiceSubId() == INVALID_SUBSCRIPTION_ID) {
+        if (!isValidSubscriptionId(getDefaultVoiceSubId())) {
             return false;
         }
         return true;
@@ -1018,7 +1018,7 @@
      * @return true if a valid subId else false
      * @hide
      */
-    public static boolean isValidSubId(int subId) {
+    public static boolean isValidSubscriptionId(int subId) {
         return subId > INVALID_SUBSCRIPTION_ID ;
     }