SubscriptionManager: Fix NPE in getSimStateForSlotIdx

bug: 21915589
Change-Id: If703baff6408a0d7ba7c8b02bfd2427b64cda963
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index e085d89..fa1ed54 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -1124,13 +1124,14 @@
      * {@hide}
      */
     public static int getSimStateForSlotIdx(int slotIdx) {
-        int simState;
+        int simState = TelephonyManager.SIM_STATE_UNKNOWN;
 
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
-            simState = iSub.getSimStateForSlotIdx(slotIdx);
+            if (iSub != null) {
+                simState = iSub.getSimStateForSlotIdx(slotIdx);
+            }
         } catch (RemoteException ex) {
-            simState = TelephonyManager.SIM_STATE_UNKNOWN;
         }
         logd("getSimStateForSubscriber: simState=" + simState + " slotIdx=" + slotIdx);
         return simState;
@@ -1144,7 +1145,9 @@
     public boolean isActiveSubId(int subId) {
         try {
             ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
-            return iSub.isActiveSubId(subId);
+            if (iSub != null) {
+                return iSub.isActiveSubId(subId);
+            }
         } catch (RemoteException ex) {
         }
         return false;