Merge "Fix crash associated with invalid sub id in PhoneInterfaceManager" into mm-wireless-dev
am: 903b71ea25

* commit '903b71ea259d8f535bd51e602a3094334c1e2f88':
  Fix crash associated with invalid sub id in PhoneInterfaceManager
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 63256b6..454a2e7 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -195,8 +195,9 @@
         public Object argument;
         /** The result of the request that is run on the main thread */
         public Object result;
-        /** The subscriber id that this request applies to. Null if default. */
-        public Integer subId;
+        // The subscriber id that this request applies to. Defaults to
+        // SubscriptionManager.INVALID_SUBSCRIPTION_ID
+        public Integer subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
 
         public MainThreadRequest(Object argument) {
             this.argument = argument;
@@ -204,7 +205,9 @@
 
         public MainThreadRequest(Object argument, Integer subId) {
             this.argument = argument;
-            this.subId = subId;
+            if (subId != null) {
+                this.subId = subId;
+            }
         }
     }
 
@@ -780,7 +783,7 @@
      * @see #sendRequestAsync
      */
     private Object sendRequest(int command, Object argument) {
-        return sendRequest(command, argument, null);
+        return sendRequest(command, argument, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
     }
 
     /**
@@ -867,7 +870,8 @@
     }
 
     private Phone getPhoneFromRequest(MainThreadRequest request) {
-        return (request.subId == null) ? mPhone : getPhone(request.subId);
+        return (request.subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID)
+                ? mPhone : getPhone(request.subId);
     }
 
     // returns phone associated with the subId.
@@ -1500,7 +1504,8 @@
 
             try {
                 cells = (ArrayList<NeighboringCellInfo>) sendRequest(
-                        CMD_HANDLE_NEIGHBORING_CELL, null, null);
+                        CMD_HANDLE_NEIGHBORING_CELL, null,
+                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
             } catch (RuntimeException e) {
                 Log.e(LOG_TAG, "getNeighboringCellInfo " + e);
             }