Fixing few TelephonyManager calls to work when there is no SIM.

* getDeviceSoftwareVersion - Fixed to work for no SIM by not looking up subId.
* getImei - Fixed to work for no SIM by not looking up subId.
* getActivePhoneTypeForSlot - Adding a method (hidden).
* getCallState - Adding slotId version (hidden).

Bug: 27378995
Change-Id: Ia717951215a5fac591314cd6dd07af8258d89ba7
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index d9c5f0f..b697f2b 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -1398,11 +1398,13 @@
     }
 
     public int getCallState() {
-        return getCallStateForSubscriber(getDefaultSubscription());
+        return getCallStateForSlot(getSlotForDefaultSubscription());
     }
 
-    public int getCallStateForSubscriber(int subId) {
-        return DefaultPhoneNotifier.convertCallState(getPhone(subId).getState());
+    public int getCallStateForSlot(int slotId) {
+        Phone phone = PhoneFactory.getPhone(slotId);
+        return phone == null ? TelephonyManager.CALL_STATE_IDLE :
+            DefaultPhoneNotifier.convertCallState(phone.getState());
     }
 
     @Override
@@ -1563,6 +1565,24 @@
         mPhone.setCellInfoListRate(rateInMillis);
     }
 
+    @Override
+    public String getImeiForSlot(int slotId, String callingPackage) {
+      if (!canReadPhoneState(callingPackage, "getImeiForSlot")) {
+          return null;
+      }
+      Phone phone = PhoneFactory.getPhone(slotId);
+      return phone == null ? null : phone.getImei();
+    }
+
+    @Override
+    public String getDeviceSoftwareVersionForSlot(int slotId, String callingPackage) {
+      if (!canReadPhoneState(callingPackage, "getDeviceSoftwareVersionForSlot")) {
+          return null;
+      }
+      Phone phone = PhoneFactory.getPhone(slotId);
+      return phone == null ? null : phone.getDeviceSvn();
+    }
+
     //
     // Internal helper methods.
     //
@@ -1683,16 +1703,16 @@
 
     @Override
     public int getActivePhoneType() {
-        return getActivePhoneTypeForSubscriber(getDefaultSubscription());
+        return getActivePhoneTypeForSlot(getSlotForDefaultSubscription());
     }
 
     @Override
-    public int getActivePhoneTypeForSubscriber(int subId) {
-        final Phone phone = getPhone(subId);
+    public int getActivePhoneTypeForSlot(int slotId) {
+        final Phone phone = PhoneFactory.getPhone(slotId);
         if (phone == null) {
             return PhoneConstants.PHONE_TYPE_NONE;
         } else {
-            return getPhone(subId).getPhoneType();
+            return phone.getPhoneType();
         }
     }
 
@@ -1964,6 +1984,10 @@
         return mSubscriptionController.getDefaultSubId();
     }
 
+    private int getSlotForDefaultSubscription() {
+        return mSubscriptionController.getPhoneId(getDefaultSubscription());
+    }
+
     private int getPreferredVoiceSubscription() {
         return mSubscriptionController.getDefaultVoiceSubId();
     }