libril: handle samsungs unsol responses

Change-Id: Ia42d9999ba0df93019a8864202f093163f8c3f41
diff --git a/ril/xmm6262/libril/ril.cpp b/ril/xmm6262/libril/ril.cpp
index 98779cc..5832d90 100644
--- a/ril/xmm6262/libril/ril.cpp
+++ b/ril/xmm6262/libril/ril.cpp
@@ -114,6 +114,9 @@
     #define appendPrintBuf(x...)
 #endif
 
+#define MAX_RIL_SOL     RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE
+#define MAX_RIL_UNSOL   RIL_UNSOL_CELL_INFO_LIST
+
 enum WakeType {DONT_WAKE, WAKE_PARTIAL};
 
 typedef struct {
@@ -336,7 +339,7 @@
 
     /* Hack to include Samsung requests */
     if (request > 10000) {
-        index = request - 10000 + RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE;
+        index = request - 10000 + MAX_RIL_SOL;
         RLOGD("SAMSUNG: request=%d, index=%d", request, index);
         pRI->pCI = &(s_commands[index]);
     } else {
@@ -379,7 +382,7 @@
     }
 
     /* Hack to include Samsung requests */
-    if (request < 1 || ((request > RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE) &&
+    if (request < 1 || ((request > MAX_RIL_SOL) &&
             (request < RIL_REQUEST_GET_CELL_BROADCAST_CONFIG)) ||
             request > RIL_REQUEST_HANGUP_VT) {
         RLOGE("unsupported request code %d token %d", request, token);
@@ -393,7 +396,7 @@
 
     /* Hack to include Samsung requests */
     if (request > 10000) {
-        index = request - 10000 + RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE;
+        index = request - 10000 + MAX_RIL_SOL;
         RLOGD("processCommandBuffer: samsung request=%d, index=%d",
                 request, index);
         pRI->pCI = &(s_commands[index]);
@@ -1442,7 +1445,7 @@
     }
     if (responselen % sizeof(int) != 0) {
         RLOGE("invalid response length %d expected multiple of %d\n",
-                (int)responselen, (int)sizeof(int));
+            (int)responselen, (int)sizeof(int));
         return RIL_ERRNO_INVALID_RESPONSE;
     }
 
@@ -3109,8 +3112,14 @@
     }
 
     for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
-        assert(i + RIL_UNSOL_RESPONSE_BASE
+        /* Hack to include Samsung responses */
+        if (i > MAX_RIL_UNSOL - RIL_UNSOL_RESPONSE_BASE) {
+            assert(i + SAMSUNG_UNSOL_RESPONSE_BASE - MAX_RIL_UNSOL
                 == s_unsolResponses[i].requestNumber);
+        } else {
+            assert(i + RIL_UNSOL_RESPONSE_BASE
+                == s_unsolResponses[i].requestNumber);
+        }
     }
 
     // New rild impl calls RIL_startEventLoop() first
@@ -3424,8 +3433,14 @@
         RLOGW("RIL_onUnsolicitedResponse called before RIL_register");
         return;
     }
-
-    unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
+    
+    /* Hack to include Samsung responses */
+    if (unsolResponse > SAMSUNG_UNSOL_RESPONSE_BASE) {
+        unsolResponseIndex = unsolResponse - SAMSUNG_UNSOL_RESPONSE_BASE + MAX_RIL_UNSOL - RIL_UNSOL_RESPONSE_BASE;
+        RLOGD("SAMSUNG: unsolResponse=%d, unsolResponseIndex=%d", unsolResponse, unsolResponseIndex);
+    } else {
+        unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
+    }
 
     if ((unsolResponseIndex < 0)
         || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
@@ -3782,6 +3797,7 @@
         case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
         case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
         case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
+        case RIL_UNSOL_STK_SEND_SMS_RESULT: return "RIL_UNSOL_STK_SEND_SMS_RESULT";
         default: return "<unknown request>";
     }
 }