Also catch IllegalArgumentException in TelecomAccountRegistry

There look to be some race conditions where Phone#getSubId()
returns a value and SubscriptionManager#getSlotIndex(subId)
can not find that Phone mapping.

Log this condition as a warning, as it should happen rarely.

Bug: 122853430
Bug: 123883627
Test: Manual
Change-Id: Ic168a881b09b87b701ee037cbbbe36cff26e314e
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 3078220..6fb9be5 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2819,6 +2819,9 @@
         } catch (ImsException e) {
             Log.w(LOG_TAG, "IMS isCapable - service unavailable: " + e.getMessage());
             return false;
+        } catch (IllegalArgumentException e) {
+            Log.i(LOG_TAG, "isCapable: " + subId + " is inactive, returning false.");
+            return false;
         } finally {
             Binder.restoreCallingIdentity(token);
         }
@@ -3403,7 +3406,7 @@
     private int getSlotIndexOrException(int subId) throws IllegalArgumentException {
         int slotId = SubscriptionManager.getSlotIndex(subId);
         if (!SubscriptionManager.isValidSlotIndex(slotId)) {
-            throw new IllegalArgumentException("Invalid Subscription Id.");
+            throw new IllegalArgumentException("Invalid Subscription Id, subId=" + subId);
         }
         return slotId;
     }
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index bfd8e27..f925dd6 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -156,6 +156,10 @@
                 Log.w(this, "registerMmTelCapabilityCallback: registration failed, no ImsService"
                         + " available. Exception: " + e.getMessage());
                 return;
+            } catch (IllegalArgumentException e) {
+                Log.w(this, "registerMmTelCapabilityCallback: registration failed, invalid"
+                        + " subscription, Exception" + e.getMessage());
+                return;
             }
         }