AI 144185: Integrate cdma into the main code base.

Automated import of CL 144185
diff --git a/include/telephony/ril.h b/include/telephony/ril.h
index 7e725d7..7b35417 100644
--- a/include/telephony/ril.h
+++ b/include/telephony/ril.h
@@ -33,7 +33,9 @@
 #define ANDROID_RIL_H 1
 
 #include <stdlib.h>
+#ifndef FEATURE_UNIT_TEST
 #include <sys/time.h>
+#endif /* !FEATURE_UNIT_TEST */
 
 #ifdef __cplusplus
 extern "C" {
@@ -56,7 +58,15 @@
                                                    call on a Class C GPRS device */
     RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9,  /* data ops are not allowed before device
                                                    registers in network */
-    RIL_E_SMS_SEND_FAIL_RETRY = 10		/* fail to send sms and need retry */	
+    RIL_E_SMS_SEND_FAIL_RETRY = 10,             /* fail to send sms and need retry */    
+    RIL_E_SIM_ABSENT = 11,                      /* fail to set the location where CDMA subscription 
+                                                   shall be retrieved because of SIM or RUIM 
+                                                   card absent */
+#ifdef FEATURE_MULTIMODE_ANDROID 
+    RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12,      /* fail to find CDMA subscription from specified 
+                                                   location */
+    RIL_E_MODE_NOT_SUPPORTED = 13               /* HW does not support preferred network type */
+#endif 
 } RIL_Errno;
 
 typedef enum {
@@ -69,23 +79,30 @@
 } RIL_CallState;
 
 typedef enum {
-    RADIO_STATE_OFF = 0,          /* Radio explictly powered off (eg CFUN=0) */
-    RADIO_STATE_UNAVAILABLE = 1,  /* Radio unavailable (eg, resetting or not booted) */
-    RADIO_STATE_SIM_NOT_READY = 2,      /* Radio is on, but the SIM interface is not ready */
-    RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3, /* SIM PIN locked, PUK required, network 
-                               personalization locked, or SIM absent */
-    RADIO_STATE_SIM_READY = 4           /* Radio is on and SIM interface is available */
+    RADIO_STATE_OFF = 0,                   /* Radio explictly powered off (eg CFUN=0) */
+    RADIO_STATE_UNAVAILABLE = 1,           /* Radio unavailable (eg, resetting or not booted) */
+    RADIO_STATE_SIM_NOT_READY = 2,         /* Radio is on, but the SIM interface is not ready */
+    RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3,  /* SIM PIN locked, PUK required, network 
+                                              personalization locked, or SIM absent */
+    RADIO_STATE_SIM_READY = 4,             /* Radio is on and SIM interface is available */
+    RADIO_STATE_RUIM_NOT_READY = 5,        /* Radio is on, but the RUIM interface is not ready */
+    RADIO_STATE_RUIM_READY = 6,            /* Radio is on and the RUIM interface is available */
+    RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7, /* RUIM PIN locked, PUK required, network 
+                                              personalization locked, or RUIM absent */
+    RADIO_STATE_NV_NOT_READY = 8,          /* Radio is on, but the NV interface is not available */
+    RADIO_STATE_NV_READY = 9               /* Radio is on and the NV interface is available */
 } RIL_RadioState;
 
 typedef struct {
     RIL_CallState   state;
-    int             index;      /* GSM Index for use with, eg, AT+CHLD */
+    int             index;      /* Connection Index for use with, eg, AT+CHLD */
     int             toa;        /* type of address, eg 145 = intl */
     char            isMpty;     /* nonzero if is mpty call */
     char            isMT;       /* nonzero if call is mobile terminated */
     char            als;        /* ALS line indicator if available 
                                    (0 = line 1) */
-    char            isVoice;    /* nonzero if this is is a voice call */
+    char            isVoice;    /* nonzero if this is is a voice call 
+                                   "p" if the CDMA voice privacy mode is active */
 
     char *          number;     /* phone number */
     char            numberPresentation; /* 0 = Allowed, 
@@ -100,7 +117,7 @@
     char *          type;       /* X.25, IP, IPV6, etc. */
     char *          apn;
     char *          address;
-} RIL_PDP_Context_Response;
+} RIL_Data_Call_Response;
 
 typedef struct {
     int messageRef;   /*TP-Message-Reference*/
@@ -166,14 +183,14 @@
                                  * 4 = erasure
                                  */
 
-    int             reason;     /* from TS 27.007 7.11 "reason" */
-    int             serviceClass;/* From 27.007 +CCFC/+CLCK "class"
-                                    See table for Android mapping from
-                                    MMI service code 
-				    0 means user doesn't input class */
-    int             toa;        /* "type" from TS 27.007 7.11 */
-    char *          number;     /* "number" from TS 27.007 7.11. May be NULL */
-    int             timeSeconds; /* for CF no reply only */
+    int             reason;       /* from TS 27.007 7.11 "reason" */
+    int             serviceClass; /* From 27.007 +CCFC/+CLCK "class"
+                                     See table for Android mapping from
+                                     MMI service code 
+                                     0 means user doesn't input class */
+    int             toa;          /* "type" from TS 27.007 7.11 */
+    char *          number;       /* "number" from TS 27.007 7.11. May be NULL */
+    int             timeSeconds;  /* for CF no reply only */
 }RIL_CallForwardInfo;
 
 typedef struct {
@@ -198,7 +215,7 @@
     CALL_FAIL_ERROR_UNSPECIFIED = 0xffff
 } RIL_LastCallFailCause;
 
-/* See RIL_REQUEST_LAST_PDP_FAIL_CAUSE */
+/* See RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE */
 typedef enum {
     PDP_FAIL_BARRED = 8,         /* no retry; prompt user */
     PDP_FAIL_BAD_APN = 27,       /* no retry; prompt user */
@@ -206,7 +223,7 @@
     PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 32,  /*no retry; prompt user */
     PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 33, /*no retry; prompt user */
     PDP_FAIL_ERROR_UNSPECIFIED = 0xffff  /* This and all other cases: retry silently */
-} RIL_LastPDPActivateFailCause;
+} RIL_LastDataCallActivateFailCause;
 
 /* Used by RIL_UNSOL_SUPP_SVC_NOTIFICATION */
 typedef struct {
@@ -223,18 +240,108 @@
                                    (MT only, may be NULL). */
 } RIL_SuppSvcNotification;
 
-/* see RIL_REQUEST_GET_SIM_STATUS */
-#define RIL_SIM_ABSENT      		0
-#define RIL_SIM_NOT_READY   		1
+#define RIL_SIM_ABSENT              0
+#define RIL_SIM_NOT_READY           1
 /* RIL_SIM_READY means that the radio state is RADIO_STATE_SIM_READY. 
  * This is more
  * than "+CPIN: READY". It also means the radio is ready for SIM I/O
  */
-#define RIL_SIM_READY       		2
-#define RIL_SIM_PIN         		3
-#define RIL_SIM_PUK         		4
+#define RIL_SIM_READY               2
+#define RIL_SIM_PIN                 3
+#define RIL_SIM_PUK                 4
 #define RIL_SIM_NETWORK_PERSONALIZATION 5
 
+/* see RIL_REQUEST_GET_SIM_STATUS */
+
+#define RIL_CARD_MAX_APPS     8
+
+typedef enum {
+    RIL_CARDSTATE_ABSENT   = 0,
+    RIL_CARDSTATE_PRESENT  = 1,
+    RIL_CARDSTATE_ERROR    = 2
+} RIL_CardState;
+
+typedef enum {
+    RIL_PERSOSUBSTATE_UNKNOWN                   = 0, /* initial state */
+    RIL_PERSOSUBSTATE_IN_PROGRESS               = 1, /* in between each lock transition */
+    RIL_PERSOSUBSTATE_READY                     = 2, /* when either SIM or RUIM Perso is finished 
+                                                        since each app can only have 1 active perso 
+                                                        involved */
+    RIL_PERSOSUBSTATE_SIM_NETWORK               = 3,
+    RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET        = 4,
+    RIL_PERSOSUBSTATE_SIM_CORPORATE             = 5,
+    RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER      = 6,
+    RIL_PERSOSUBSTATE_SIM_SIM                   = 7,
+    RIL_PERSOSUBSTATE_SIM_NETWORK_PUK           = 8, /* The corresponding perso lock is blocked */
+    RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK    = 9,
+    RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK         = 10,
+    RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK  = 11,
+    RIL_PERSOSUBSTATE_SIM_SIM_PUK               = 12,
+    RIL_PERSOSUBSTATE_RUIM_NETWORK1             = 13,
+    RIL_PERSOSUBSTATE_RUIM_NETWORK2             = 14,
+    RIL_PERSOSUBSTATE_RUIM_HRPD                 = 15,
+    RIL_PERSOSUBSTATE_RUIM_CORPORATE            = 16,
+    RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER     = 17,
+    RIL_PERSOSUBSTATE_RUIM_RUIM                 = 18,
+    RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK         = 19, /* The corresponding perso lock is blocked */
+    RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK         = 20,
+    RIL_PERSOSUBSTATE_RUIM_HRPD_PUK             = 21,
+    RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK        = 22,
+    RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,
+    RIL_PERSOSUBSTATE_RUIM_RUIM_PUK             = 24
+} RIL_PersoSubstate;
+
+typedef enum {
+    RIL_APPSTATE_UNKNOWN               = 0,
+    RIL_APPSTATE_DETECTED              = 1,
+    RIL_APPSTATE_PIN                   = 2, /* If PIN1 or UPin is required */
+    RIL_APPSTATE_PUK                   = 3, /* If PUK1 or Puk for UPin is required */
+    RIL_APPSTATE_SUBSCRIPTION_PERSO    = 4, /* perso_substate should be look at 
+                                               when app_state is assigned to this value */
+    RIL_APPSTATE_READY                 = 5
+} RIL_AppState;
+
+typedef enum {
+    RIL_PINSTATE_UNKNOWN              = 0,
+    RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1,
+    RIL_PINSTATE_ENABLED_VERIFIED     = 2,
+    RIL_PINSTATE_DISABLED             = 3,
+    RIL_PINSTATE_ENABLED_BLOCKED      = 4,
+    RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5
+} RIL_PinState;
+
+typedef enum {
+  RIL_APPTYPE_UNKNOWN = 0,
+  RIL_APPTYPE_SIM     = 1,
+  RIL_APPTYPE_USIM    = 2,
+  RIL_APPTYPE_RUIM    = 3,
+  RIL_APPTYPE_CSIM    = 4
+} RIL_AppType;
+
+typedef struct
+{
+  RIL_AppType      app_type;    
+  RIL_AppState     app_state;     
+  RIL_PersoSubstate perso_substate; /* applicable only if app_state == 
+                                       RIL_APPSTATE_SUBSCRIPTION_PERSO */
+  char             *aid_ptr;        /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41, 
+                                       0x30, 0x30, 0x30 */
+  char             *app_label_ptr;  /* null terminated string */
+  int              pin1_replaced;   /* applicable to USIM and CSIM */
+  RIL_PinState     pin1;           
+  RIL_PinState     pin2;          
+} RIL_AppStatus;
+
+typedef struct
+{
+  RIL_CardState card_state;                      
+  RIL_PinState  universal_pin_state;             /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */
+  int           gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS */
+  int           cdma_subscription_app_index;     /* value < RIL_CARD_MAX_APPS */
+  int           num_applications;                /* value <= RIL_CARD_MAX_APPS */
+  RIL_AppStatus applications[RIL_CARD_MAX_APPS];
+} RIL_CardStatus;
+
 /* The result of a SIM refresh, returned in data[0] of RIL_UNSOL_SIM_REFRESH */
 typedef enum {
     /* A file on SIM has been updated.  data[1] contains the EFID. */
@@ -245,6 +352,20 @@
     SIM_RESET = 2
 } RIL_SimRefreshResult;
 
+/* Used by RIL_REQUEST_GET_BROADCAST_CONFIG and RIL_REQUEST_SET_BROADCAST_CONFIG */
+
+typedef struct {
+  int uFromServiceID;
+  int uToserviceID;
+  unsigned char bSelected;
+} RIL_BroadcastServiceInfo;
+
+typedef struct {
+  int size;
+  RIL_BroadcastServiceInfo *entries;
+} RIL_BroadcastSMSConfig;
+
+
 /* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */
 #define RIL_RESTRICTED_STATE_NONE           0x00
 /* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */
@@ -263,8 +384,8 @@
  * 
  * "data" is NULL
  *
- * "response" must be an int * pointing to RIL_SIM_* constant 
- * This should always succeed (RIL_SUCCESS)
+ * "response" is const RIL_CardStatus *
+
  *
  * If the radio is off or unavailable, return RIL_SIM_NOT_READY 
  *
@@ -492,7 +613,7 @@
  * Hang up a specific line (like AT+CHLD=1x)
  *
  * "data" is an int * 
- * (int *)data)[0] contains GSM call index (value of 'x' in CHLD above)
+ * (int *)data)[0] contains Connection index (value of 'x' in CHLD above)
  *
  * "response" is NULL
  *
@@ -619,7 +740,7 @@
  *  RADIO_NOT_AVAILABLE
  *  GENERIC_FAILURE
  *
- * See also: RIL_REQUEST_LAST_PDP_FAIL_CAUSE
+ * See also: RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE
  */
 #define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
 
@@ -650,15 +771,34 @@
  *
  * "data" is NULL
  * "response" is a "char **"
- * ((const char **)response)[0] is registration state 0-5 from TS 27.007 7.2
- * ((const char **)response)[1] is LAC if registered or NULL if not
- * ((const char **)response)[2] is CID if registered or NULL if not
- *
- * LAC and CID are in hexadecimal format.
- * valid LAC are 0x0000 - 0xffff
- * valid CID are 0x00000000 - 0x0fffffff
- *     In GSM, CID is Cell ID (as described in TS 27.007) in 16 bits
- *     In UMTS, CID is UMTS Cell Identity (as described in TS 25.331) in 28 bits
+ * ((const char **)response)[0] is registration state 0-6,
+ *              0 - Not registered, MT is not currently searching a new operator to register
+ *              1 - Registered, home network
+ *              2 - Not registered, but MT is currently searching a new operator to register
+ *              3 - Registration denied
+ *              4 - Unknown
+ *              5 - Registered, roaming
+ *              6 - Registered, roaming affiliates
+ * ((const char **)response)[1] is LAC if registered on a GSM/WCDMA system or NULL if not. 
+ *                                  Valid LAC are 0x0000 - 0xffff
+ * ((const char **)response)[2] is CID if registered on a * GSM/WCDMA or NULL if not. 
+ *                                  Valid CID are 0x00000000 - 0xffffffff
+ * ((const char **)response)[3] indicates the available radio technology 0-7,
+ *                                  0 - Unknown, 1 - GPRS, 2 - EDGE, 3 - UMTS, 4 - IS95A, 
+ *                                  5 - IS95B, 6 - 1xRTT, 7 - EvDo Rev. 0, 8 - EvDo Rev. A
+ * ((const char **)response)[4] is Base Station ID if registered on a CDMA system or NULL if not.
+ *                                  Base Station ID in hexadecimal format
+ * ((const char **)response)[5] is Base Station latitude if registered on a CDMA system or NULL
+ *                                  if not. Base Station latitude in hexadecimal format
+ * ((const char **)response)[6] is Base Station longitude if registered on a CDMA system or NULL
+ *                                  if not. Base Station longitude in hexadecimal format
+ * ((const char **)response)[7] is concurrent services support indicator if registered on a CDMA 
+ *                                  system 0-1, 0 - Concurrent services not supported, 
+ *                                              1 - Concurrent services supported
+ * ((const char **)response)[8] is System ID if registered on a CDMA system or NULL if not.
+ *                                  Valid System ID are 0 - 32767
+ * ((const char **)response)[9] is Network ID if registered on a CDMA system or NULL if not.
+ *                                  Valid System ID are 0 - 65535
  * 
  * Please note that registration state 4 ("unknown") is treated 
  * as "out of service" in the Android telephony system
@@ -714,6 +854,11 @@
  *                                  or NULL if unregistered
  * ((const char **)response)[2] is 5 or 6 digit numeric code (MCC + MNC)
  *                                  or NULL if unregistered
+ * ((const char **)response)[3] is system type, range from 0 to 3 or NULL if unregistered,
+ *                                  0 - WCDMA system,
+ *                                  1 - GSM system, 
+ *                                  2 - 1x system,
+ *                                  3 - EVDO system
  *                                  
  * Valid errors:
  *  SUCCESS
@@ -831,34 +976,39 @@
 
 
 /**
- * RIL_REQUEST_SETUP_DEFAULT_PDP
+ * RIL_REQUEST_SETUP_DATA_CALL
  *
- * Configure and activate PDP context (CID 1) for default IP connection 
- *
- * Android Telephony layer will start up pppd process on specified
- * tty when this request responded to.
+ * Setup a packet data connection
  *
  * "data" is a const char **
- * ((const char **)data)[0] is the APN to connect to
- * ((const char **)data)[1] is the username, or NULL
- * ((const char **)data)[2] is the password, or NULL
+ * ((const char **)data)[0] indicates whether to setup connection on radio technology CDMA 
+ *                              or GSM/UMTS, 0-1. 0 - CDMA, 1-GSM/UMTS
+ * 
+ * ((const char **)data)[1] Profile Number or NULL to indicate default profile
+ * ((const char **)data)[2] is the APN to connect to if radio technology is GSM/UMTS. This APN will 
+ *                          override the one in the profile. NULL indicates no APN overrride.
+ * ((const char **)data)[3] is the username for APN, or NULL
+ * ((const char **)data)[4] is the password for APN, or NULL
  *
  * "response" is a char **
- * ((char **)response)[0] indicating PDP CID, which is generated by RIL
- * ((char **)response)[1] indicating the network interface name
- * ((char **)response)[2] indicating the IP address for this interface
+ * ((char **)response)[0] indicating PDP CID, which is generated by RIL. This Connection ID is 
+ *                          used in GSM/UMTS and CDMA
+ * ((char **)response)[1] indicating the network interface name for GSM/UMTS or CDMA
+ * ((char **)response)[2] indicating the IP address for this interface for GSM/UMTS 
+ *                          and NULL for CDMA
  *
  * FIXME may need way to configure QoS settings
+ * 
+ * replaces  RIL_REQUEST_SETUP_DEFAULT_PDP
  *
  * Valid errors:
  *  SUCCESS
  *  RADIO_NOT_AVAILABLE
  *  GENERIC_FAILURE
  *
- * See also: RIL_REQUEST_DEACTIVATE_DEFAULT_PDP
+ * See also: RIL_REQUEST_DEACTIVATE_DATA_CALL
  */
-
-#define RIL_REQUEST_SETUP_DEFAULT_PDP 27
+#define RIL_REQUEST_SETUP_DATA_CALL 27
 
 
 
@@ -1073,10 +1223,11 @@
 #define RIL_REQUEST_SMS_ACKNOWLEDGE  37
 
 /**
- * RIL_REQUEST_GET_IMEI
+ * RIL_REQUEST_GET_IMEI - DEPRECATED
  *
  * Get the device IMEI, including check digit
  *
+ * The request is DECRECATED, use RIL_REQUEST_DEVICE_IDENTITY
  * Valid when RadioState is not RADIO_STATE_UNAVAILABLE
  *
  * "data" is NULL
@@ -1091,10 +1242,11 @@
 #define RIL_REQUEST_GET_IMEI 38
 
 /**
- * RIL_REQUEST_GET_IMEISV
+ * RIL_REQUEST_GET_IMEISV - DEPRECATED
  *
  * Get the device IMEISV, which should be two decimal digits
  *
+ * The request is DECRECATED, use RIL_REQUEST_DEVICE_IDENTITY
  * Valid when RadioState is not RADIO_STATE_UNAVAILABLE
  *
  * "data" is NULL
@@ -1130,12 +1282,14 @@
 #define RIL_REQUEST_ANSWER 40
 
 /**
- * RIL_REQUEST_DEACTIVATE_DEFAULT_PDP
+ * RIL_REQUEST_DEACTIVATE_DATA_CALL
  *
- * Deactivate PDP context created by RIL_REQUEST_SETUP_DEFAULT_PDP
+ * Deactivate packet data connection
+ * replaces RIL_REQUEST_DEACTIVATE_DEFAULT_PDP
  *
  * "data" is const char **
- * ((char**)data)[0] indicating PDP CID
+ * ((char**)data)[0] indicating CID
+ * 
  * "response" is NULL
  *
  * Valid errors:
@@ -1143,10 +1297,9 @@
  *  RADIO_NOT_AVAILABLE
  *  GENERIC_FAILURE
  *
- * See also: RIL_REQUEST_SETUP_DEFAULT_PDP
+ * See also: RIL_REQUEST_SETUP_DATA_CALL
  */
-
-#define RIL_REQUEST_DEACTIVATE_DEFAULT_PDP 41
+#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
 
 /**
  * RIL_REQUEST_QUERY_FACILITY_LOCK
@@ -1383,7 +1536,8 @@
  * TS 27.007 "AT+CHLD=2x"
  * 
  * "data" is an int * 
- * (int *)data)[0] contains GSM call index (value of 'x' in CHLD above)
+ * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) "response" is NULL
+ *
  * "response" is NULL
  *
  * Valid errors:
@@ -1454,10 +1608,11 @@
 #define RIL_REQUEST_QUERY_CLIP 55
 
 /**
- * RIL_REQUEST_LAST_PDP_FAIL_CAUSE
+ * RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE
  * 
  * Requests the failure cause code for the most recently failed PDP 
- * context activate
+ * context or CDMA data connection active
+ * replaces RIL_REQUEST_LAST_PDP_FAIL_CAUSE
  *
  * "data" is NULL
  *
@@ -1467,7 +1622,7 @@
  *
  * If the implementation does not have access to the exact cause codes,
  * then it should return one of the values listed in 
- * RIL_LastPDPActivateFailCause, as the UI layer needs to distinguish these 
+ * RIL_LastDataCallActivateFailCause, as the UI layer needs to distinguish these 
  * cases for error notification
  * and potential retries.
  *
@@ -1480,17 +1635,18 @@
  *  
  */ 
 
-#define RIL_REQUEST_LAST_PDP_FAIL_CAUSE 56
+#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56
 
 /**
- * RIL_REQUEST_PDP_CONTEXT_LIST
+ * RIL_REQUEST_DATA_CALL_LIST
  *
  * Queries the status of PDP contexts, returning for each
  * its CID, whether or not it is active, and its PDP type,
  * APN, and PDP adddress.
+ * replaces RIL_REQUEST_PDP_CONTEXT_LIST
  *
  * "data" is NULL
- * "response" is an array of RIL_PDP_Context_Response
+ * "response" is an array of RIL_Data_Call_Response
  *
  * Valid errors:
  *  SUCCESS 
@@ -1498,7 +1654,7 @@
  *  GENERIC_FAILURE
  */
 
-#define RIL_REQUEST_PDP_CONTEXT_LIST 57
+#define RIL_REQUEST_DATA_CALL_LIST 57
 
 /**
  * RIL_REQUEST_RESET_RADIO
@@ -1665,6 +1821,19 @@
  * ((int *)data)[0] is == 3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000)
  * ((int *)data)[0] is == 4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)
  * ((int *)data)[0] is == 5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850)
+ * ((int *)data)[0] is == 6 for "Cellular (800-MHz Band)"
+ * ((int *)data)[0] is == 7 for "PCS (1900-MHz Band)"
+ * ((int *)data)[0] is == 8 for "Band Class 3 (JTACS Band)"
+ * ((int *)data)[0] is == 9 for "Band Class 4 (Korean PCS Band)"
+ * ((int *)data)[0] is == 10 for "Band Class 5 (450-MHz Band)"
+ * ((int *)data)[0] is == 11 for "Band Class 6 (2-GMHz IMT2000 Band)"
+ * ((int *)data)[0] is == 12 for "Band Class 7 (Upper 700-MHz Band)"
+ * ((int *)data)[0] is == 13 for "Band Class 8 (1800-MHz Band)"
+ * ((int *)data)[0] is == 14 for "Band Class 9 (900-MHz Band)"
+ * ((int *)data)[0] is == 15 for "Band Class 10 (Secondary 800-MHz Band)"
+ * ((int *)data)[0] is == 16 for "Band Class 11 (400-MHz European PAMR Band)"
+ * ((int *)data)[0] is == 17 for "Band Class 15 (AWS Band)"
+ * ((int *)data)[0] is == 18 for "Band Class 16 (US 2.5-GHz Band)"
  *
  * "response" is NULL
  *
@@ -1692,6 +1861,19 @@
  *  3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000)
  *  4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)
  *  5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850)
+ *  6 for "Cellular (800-MHz Band)"
+ *  7 for "PCS (1900-MHz Band)"
+ *  8 for "Band Class 3 (JTACS Band)"
+ *  9 for "Band Class 4 (Korean PCS Band)"
+ *  10 for "Band Class 5 (450-MHz Band)"
+ *  11 for "Band Class 6 (2-GMHz IMT2000 Band)"
+ *  12 for "Band Class 7 (Upper 700-MHz Band)"
+ *  13 for "Band Class 8 (1800-MHz Band)"
+ *  14 for "Band Class 9 (900-MHz Band)"
+ *  15 for "Band Class 10 (Secondary 800-MHz Band)"
+ *  16 for "Band Class 11 (400-MHz European PAMR Band)"
+ *  17 for "Band Class 15 (AWS Band)"
+ *  18 for "Band Class 16 (US 2.5-GHz Band)"
  *
  * Valid errors:
  *  SUCCESS
@@ -1820,16 +2002,23 @@
  * (CS/PS domain, RAT, and operation mode)
  *
  * "data" is int *
- * ((int *)data)[0] is == 0 for WCDMA preferred (auto mode)
+ * 
+ * ((int *)data)[0] is == 0 for GSM/WCDMA (WCDMA preferred)
  * ((int *)data)[0] is == 1 for GSM only
  * ((int *)data)[0] is == 2 for WCDMA only
+ * ((int *)data)[0] is == 3 for GSM/WCDMA (auto mode)
+ * ((int *)data)[0] is == 4 for CDMA and EvDo (auto mode, according to PRL)
+ * ((int *)data)[0] is == 5 for CDMA only
+ * ((int *)data)[0] is == 6 for EvDo only
+ * ((int *)data)[0] is == 7 for GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL)
  *
  * "response" is NULL
  *
  * Valid errors:
- *  RIL_E_SUCCESS
- *  RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
- *  RIL_E_GENERIC_FAILURE
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE (radio resetting)
+ *  GENERIC_FAILURE
+ *  MODE_NOT_SUPPORTED
  */
 #define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73
 
@@ -1842,9 +2031,14 @@
  * "data" is NULL
  *
  * "response" is int *
- * ((int *)response)[0] is == 0 for WCDMA preferred (auto mode)
+ * ((int *)response)[0] is == 0 for GSM/WCDMA (WCDMA preferred)
  * ((int *)response)[0] is == 1 for GSM only
  * ((int *)response)[0] is == 2 for WCDMA only
+ * ((int *)response)[0] is == 3 for GSM/WCDMA (auto mode, according to PRL)
+ * ((int *)response)[0] is == 4 for CDMA and EvDo (auto mode, according to PRL)
+ * ((int *)response)[0] is == 5 for CDMA only
+ * ((int *)response)[0] is == 6 for EvDo only
+ * ((int *)response)[0] is == 7 for GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL)
  *
  * Valid errors:
  *  SUCCESS
@@ -1872,7 +2066,7 @@
 
 /**
  * RIL_REQUEST_SET_LOCATION_UPDATES
- *
+ * 
  * Enables/disables network state change notifications due to changes in
  * LAC and/or CID (basically, +CREG=2 vs. +CREG=1).  
  *
@@ -1884,7 +2078,7 @@
  * ((int *)data)[0] is == 0 for updates disabled (+CREG=1)
  *
  * "response" is NULL
- *
+ * 
  * Valid errors:
  *  SUCCESS
  *  RADIO_NOT_AVAILABLE
@@ -1894,8 +2088,434 @@
  */
 #define RIL_REQUEST_SET_LOCATION_UPDATES 76
 
+/**
+ * RIL_REQUEST_CDMA_SET_SUBSCRIPTION
+ * 
+ * Request to set the location where the CDMA subscription shall
+ * be retrieved
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 from RUIM/SIM (default)
+ * ((int *)data)[0] is == 1 from NV
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *  SIM_ABSENT
+ *  SUBSCRIPTION_NOT_AVAILABLE
+ */
+#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION 77
+
+/**
+ * RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE
+ * 
+ * Request to set the roaming preferences in CDMA
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for Home Networks only, as defined in PRL
+ * ((int *)data)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL
+ * ((int *)data)[0] is == 2 for Roaming on Any Network, as defined in the PRL
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78
+
+/**
+ * RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE
+ * 
+ * Request the actual setting of the roaming preferences in CDMA in the modem
+ *
+ * "data" is NULL
+ * 
+ * "response" is int *
+ * ((int *)response)[0] is == 0 for Home Networks only, as defined in PRL
+ * ((int *)response)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL
+ * ((int *)response)[0] is == 2 for Roaming on Any Network, as defined in the PRL
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79
+
+/**
+ * RIL_REQUEST_SET_TTY_MODE
+ * 
+ * Request to set the TTY mode
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for TTY off
+ * ((int *)data)[0] is == 1 for TTY on
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_SET_TTY_MODE 80
+
+/**
+ * RIL_REQUEST_QUERY_TTY_MODE
+ * 
+ * Request the setting of TTY mode
+ *
+ * "data" is NULL
+ * 
+ * "response" is int *
+ * ((int *)response)[0] is == 0 for TTY off
+ * ((int *)response)[0] is == 1 for TTY on
+ *
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_QUERY_TTY_MODE 81
+
+/**
+ * RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE
+ *
+ * Request to set the preferred voice privacy mode used in voice
+ * scrambling
+ *
+ * "data" is int *
+ * ((int *)data)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)
+ * ((int *)data)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82
+
+/**
+ * RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE
+ * 
+ * Request the setting of preferred voice privacy mode
+ *
+ * "data" is NULL
+ * 
+ * "response" is int *
+ * ((int *)response)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)
+ * ((int *)response)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83
+
+/**
+ * RIL_REQUEST_CDMA_FLASH
+ *
+ * Send FLASH
+ *
+ * "data" is const char *
+ * ((const char *)data)[0] is a FLASH string
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_FLASH 84
+
+/**
+ * RIL_REQUEST_CDMA_BURST_DTMF
+ *
+ * Send DTMF string
+ *
+ * "data" is const char *
+ * ((const char *)data)[0] is a DTMF string
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_BURST_DTMF 85
+
+/**
+ * RIL_REQUEST_CDMA_VALIDATE_AKEY
+ *
+ * Validate AKey.
+ *
+ * "data" is const char *
+ * ((const char *)data)[0] is a AKey string
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_VALIDATE_AKEY 86
+
+/**
+ * RIL_REQUEST_CDMA_SEND_SMS
+ *
+ * Send a CDMA SMS message
+ *
+ * "data" is const RIL_CDMA_SMS_Message *
+ * 
+ * "response" is a const RIL_SMS_Response *
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SEND_SMS 87
+
+/**
+ * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE
+ *
+ * Acknowledge the success or failure in the receipt of SMS
+ * previously indicated via RIL_UNSOL_RESPONSE_CDMA_NEW_SMS
+ *
+ * "data" is const RIL_CDMA_SMS_Ack *
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88
+
+/**
+ * RIL_REQUEST_GET_BROADCAST_CONFIG
+ *
+ * Request the setting of GSM/WCDMA Cell Broadcast SMS config
+ * 
+ * "data" is NULL
+ * 
+ * "response" is const RIL_BroadcastSMSConfig *
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_GET_BROADCAST_CONFIG 89
+
+/**
+ * RIL_REQUEST_SET_BROADCAST_CONFIG
+ *
+ * Set GSM/WCDMA Cell Broadcast SMS config
+ *
+ * "data" is const RIL_BroadcastSMSConfig *
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_SET_BROADCAST_CONFIG 90
+
+/**
+ * RIL_REQUEST_BROADCAST_ACTIVATION
+ *
+ * Enable or disable the reception of GSM/WCDMA Cell Broadcast SMS
+ *
+ * "data" is const int *
+ * (const int *)data[0] indicates to activate or turn off the
+ * reception of GSM/WCDMA Cell Broadcast SMS, 0-1,
+ *                       0 - Activate, 1 - Turn off
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_BROADCAST_ACTIVATION 91
+
+/**
+ * RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG
+ *
+ * Request the setting of CDMA Broadcast SMS config
+ *
+ * "data" is NULL
+ * 
+ * "response" is const RIL_CDMA_BroadcastSMSConfig *
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG 92
+
+/**
+ * RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG
+ *
+ * Set CDMA Broadcast SMS config
+ *
+ * "data" is const RIL_CDMA_BroadcastSMSConfig *
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG 93
+
+/**
+ * RIL_REQUEST_CDMA_BROADCAST_ACTIVATION
+ *
+ * Enable or disable the reception of CDMA Broadcast SMS
+ *
+ * "data" is const int *
+ * (const int *)data[0] indicates to activate or turn off the
+ * reception of CDMA Broadcast SMS, 0-1,
+ *                       0 - Activate, 1 - Turn off
+ * 
+ * "response" is NULL
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_BROADCAST_ACTIVATION 94
+
+/**
+ * RIL_REQUEST_CDMA_SUBSCRIPTION
+ *
+ * Request the device MDN / H_SID / H_NID.
+ *
+ * The request is only allowed when CDMA subscription is available.  When CDMA
+ * subscription is changed, application layer should re-issue the request to
+ * update the subscription information.
+ *
+ * If a NULL value is returned for any of the device id, it means that error
+ * accessing the device.
+ *
+ * "response" is const char **
+ * ((const char **)response)[0] is MDN if CDMA subscription is available
+ * ((const char **)response)[1] is H_SID (Home SID) if CDMA subscription is available
+ * ((const char **)response)[2] is H_NID (Home SID) if CDMA subscription is available
+ *
+ * Valid errors:
+ *  SUCCESS
+ *  RIL_E_SUBSCRIPTION_NOT_AVAILABLE
+ */
+
+#define RIL_REQUEST_CDMA_SUBSCRIPTION 99
+
+/**
+ * RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM
+ *
+ * Stores a CDMA SMS message to RUIM memory.
+ *
+ * "data" is RIL_CDMA_SMS_WriteArgs *
+ *
+ * "response" is int *
+ * ((const int *)response)[0] is the record index where the message is stored.
+ *
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 100
+
+/**
+ * RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM
+ *
+ * Deletes a CDMA SMS message from RUIM memory.
+ *
+ * "data" is int  *
+ * ((int *)data)[0] is the record index of the message to delete.
+ *
+ * "response" is NULL
+ *
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ *
+ */
+#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 101
+
+/**
+ * RIL_REQUEST_DEVICE_IDENTITY
+ * 
+ * Request the device ESN / MEID / IMEI / IMEISV. 
+ * 
+ * The request is always allowed and contains GSM and CDMA device identity;
+ * it substitutes the deprecated requests RIL_REQUEST_GET_IMEI and 
+ * RIL_REQUEST_GET_IMEISV.
+ * 
+ * If a NULL value is returned for any of the device id, it means that error 
+ * accessing the device.
+ * 
+ * When CDMA subscription is changed the ESN/MEID may change.  The application 
+ * layer should re-issue the request to update the device identity in this case.
+ * 
+ * "response" is const char **
+ * ((const char **)response)[0] is IMEI if GSM subscription is available 
+ * ((const char **)response)[1] is IMEISV if GSM subscription is available 
+ * ((const char **)response)[2] is ESN if CDMA subscription is available 
+ * ((const char **)response)[3] is MEID if CDMA subscription is available 
+ * 
+ * Valid errors:
+ *  SUCCESS
+ *  RADIO_NOT_AVAILABLE
+ *  GENERIC_FAILURE
+ */
+#define RIL_REQUEST_DEVICE_IDENTITY 102
+
+
+
 /***********************************************************************/
 
+
 #define RIL_UNSOL_RESPONSE_BASE 1000
 
 /**
@@ -2057,18 +2677,19 @@
 
 
 /**
- * RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED
+ * RIL_UNSOL_DATA_CALL_LIST_CHANGED
  *
  * Indicate a PDP context state has changed, or a new context
  * has been activated or deactivated
+ * replaces RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED
  *
- * "data" is an array of RIL_PDP_Context_Response identical to that
- * returned by RIL_REQUEST_PDP_CONTEXT_LIST
+ * "data" is an array of RIL_Data_Call_Response identical to that
+ * returned by RIL_REQUEST_DATA_CALL_LIST
  *
- * See also: RIL_REQUEST_PDP_CONTEXT_LIST
+ * See also: RIL_REQUEST_DATA_CALL_LIST
  */
 
-#define RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED 1010
+#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010
 
 /**
  * RIL_UNSOL_SUPP_SVC_NOTIFICATION
@@ -2164,17 +2785,13 @@
  */
 #define RIL_UNSOL_CALL_RING 1018
 
-
-/*
- * Import four CDMA notifications 1019 - 1022. Need fix when do real CDMA merge.
- */
-
 /**
  * RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED
  *
  * Indicates that SIM state changes.
- *
+ * 
  * Callee will invoke RIL_REQUEST_GET_SIM_STATUS on main thread
+
  * "data" is null
  */
 #define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019
@@ -2183,14 +2800,15 @@
  * RIL_UNSOL_RESPONSE_CDMA_NEW_SMS
  *
  * Called when new CDMA SMS is received
- *
+ * 
  * "data" is const RIL_CDMA_SMS_Message *
- *
+ * 
  * Callee will subsequently confirm the receipt of the SMS with
  * a RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE
- *
+ * 
  * No new RIL_UNSOL_RESPONSE_CDMA_NEW_SMS should be sent until
  * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE has been received
+ * 
  */
 #define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020
 
@@ -2198,13 +2816,14 @@
  * RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS
  *
  * Called when new Broadcast SMS is received
- *
+ * 
  * "data" is const char * of 88 bytes which indicates each page
  * of a CBS Message sent to the MS by the BTS as coded in 3GPP
  * 23.041 Section 9.4.1.1
+ *
  */
 #define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021
-	
+
 /**
  * RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL
  *
@@ -2212,9 +2831,10 @@
  * cannot be saved on the RUIM until space is freed.
  *
  * "data" is null
+ *
  */
-#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022	
-	
+#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022
+
 /**
  * RIL_UNSOL_RESTRICTED_STATE_CHANGED
  *
@@ -2363,7 +2983,7 @@
  * RIL_onRequestComplete will return as soon as possible
  *
  * @param t is parameter passed in on previous call to RIL_Notification
- *          routine.
+ * routine.
  * @param e error code
  *          if "e" != SUCCESS, then response can be null/is ignored
  * @param response is owned by caller, and should not be modified or
@@ -2408,3 +3028,5 @@
 
 #endif /*ANDROID_RIL_H*/
 
+
+
diff --git a/include/telephony/ril_cdma_sms.h b/include/telephony/ril_cdma_sms.h
new file mode 100644
index 0000000..5c8fd81
--- /dev/null
+++ b/include/telephony/ril_cdma_sms.h
@@ -0,0 +1,809 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * ISSUES:
+ *
+ */
+
+/**
+ * TODO
+ *
+ *  
+ */
+
+
+#ifndef ANDROID_RIL_CDMA_SMS_H 
+#define ANDROID_RIL_CDMA_SMS_H 1
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Used by RIL_REQUEST_CDMA_SEND_SMS and RIL_UNSOL_RESPONSE_CDMA_NEW_SMS */
+
+#define RIL_CDMA_SMS_ADDRESS_MAX     36
+#define RIL_CDMA_SMS_SUBADDRESS_MAX  36
+#define RIL_CDMA_SMS_BEARER_DATA_MAX 255
+
+typedef enum {
+    RIL_CDMA_SMS_DIGIT_MODE_4_BIT = 0,     /* DTMF digits */
+    RIL_CDMA_SMS_DIGIT_MODE_8_BIT = 1,
+    RIL_CDMA_SMS_DIGIT_MODE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_DigitMode;
+
+typedef enum {
+    RIL_CDMA_SMS_NUMBER_MODE_NOT_DATA_NETWORK = 0,
+    RIL_CDMA_SMS_NUMBER_MODE_DATA_NETWORK     = 1,
+    RIL_CDMA_SMS_NUMBER_MODE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_NumberMode;
+
+typedef enum {
+    RIL_CDMA_SMS_NUMBER_TYPE_UNKNOWN                   = 0,
+    RIL_CDMA_SMS_NUMBER_TYPE_INTERNATIONAL_OR_DATA_IP  = 1,
+      /* INTERNATIONAL is used when number mode is not data network address.
+       * DATA_IP is used when the number mode is data network address 
+       */
+    RIL_CDMA_SMS_NUMBER_TYPE_NATIONAL_OR_INTERNET_MAIL = 2,
+      /* NATIONAL is used when the number mode is not data network address.
+       * INTERNET_MAIL is used when the number mode is data network address. 
+       * For INTERNET_MAIL, in the address data "digits", each byte contains 
+       * an ASCII character. Examples are "x@y.com,a@b.com - ref TIA/EIA-637A 3.4.3.3 
+       */
+    RIL_CDMA_SMS_NUMBER_TYPE_NETWORK                   = 3,
+    RIL_CDMA_SMS_NUMBER_TYPE_SUBSCRIBER                = 4,
+    RIL_CDMA_SMS_NUMBER_TYPE_ALPHANUMERIC              = 5,
+      /* GSM SMS: address value is GSM 7-bit chars */
+    RIL_CDMA_SMS_NUMBER_TYPE_ABBREVIATED               = 6,
+    RIL_CDMA_SMS_NUMBER_TYPE_RESERVED_7                = 7,
+    RIL_CDMA_SMS_NUMBER_TYPE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_NumberType;
+
+typedef enum {
+    RIL_CDMA_SMS_NUMBER_PLAN_UNKNOWN     = 0,
+    RIL_CDMA_SMS_NUMBER_PLAN_TELEPHONY   = 1,      /* CCITT E.164 and E.163, including ISDN plan */
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_2  = 2,      
+    RIL_CDMA_SMS_NUMBER_PLAN_DATA        = 3,      /* CCITT X.121 */
+    RIL_CDMA_SMS_NUMBER_PLAN_TELEX       = 4,      /* CCITT F.69 */
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_5  = 5,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_6  = 6,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_7  = 7,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_8  = 8,      
+    RIL_CDMA_SMS_NUMBER_PLAN_PRIVATE     = 9,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_10 = 10,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_11 = 11,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_12 = 12,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_13 = 13,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_14 = 14,      
+    RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_15 = 15,      
+    RIL_CDMA_SMS_NUMBER_PLAN_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_NumberPlan;
+
+typedef struct {
+    RIL_CDMA_SMS_DigitMode digit_mode;
+      /* Indicates 4-bit or 8-bit */
+    RIL_CDMA_SMS_NumberMode number_mode;
+      /* Used only when digitMode is 8-bit */
+    RIL_CDMA_SMS_NumberType number_type;
+      /* Used only when digitMode is 8-bit.
+       * To specify an international address, use the following: 
+       * digitMode = RIL_CDMA_SMS_DIGIT_MODE_8_BIT
+       * numberMode = RIL_CDMA_SMS_NOT_DATA_NETWORK
+       * numberType = RIL_CDMA_SMS_NUMBER_TYPE_INTERNATIONAL_OR_DATA_IP
+       * numberPlan = RIL_CDMA_SMS_NUMBER_PLAN_TELEPHONY
+       * numberOfDigits = number of digits
+       * digits = ASCII digits, e.g. '1', '2', '3'3, '4', and '5'
+       */
+    RIL_CDMA_SMS_NumberPlan number_plan;
+      /* Used only when digitMode is 8-bit */
+    unsigned char number_of_digits;
+    unsigned char digits[ RIL_CDMA_SMS_ADDRESS_MAX ];
+      /* Each byte in this array represnts a 40bit or 8-bit digit of address data */ 
+} RIL_CDMA_SMS_Address;
+
+typedef enum {
+    RIL_CDMA_SMS_SUBADDRESS_TYPE_NSAP           = 0,    /* CCITT X.213 or ISO 8348 AD2 */
+    RIL_CDMA_SMS_SUBADDRESS_TYPE_USER_SPECIFIED = 1,    /* e.g. X.25 */
+    RIL_CDMA_SMS_SUBADDRESS_TYPE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_SubaddressType;
+
+typedef struct {
+    RIL_CDMA_SMS_SubaddressType subaddressType;
+    /* 1 means the last byte's lower 4 bits should be ignored */
+    unsigned char odd;
+    unsigned char number_of_digits;
+    /* Each byte respresents a 8-bit digit of subaddress data */
+    unsigned char digits[ RIL_CDMA_SMS_SUBADDRESS_MAX ];
+} RIL_CDMA_SMS_Subaddress;
+
+typedef struct {
+    int uTeleserviceID;
+    unsigned char bIsServicePresent;
+    int uServicecategory;
+    RIL_CDMA_SMS_Address sAddress;
+    RIL_CDMA_SMS_Subaddress sSubAddress;
+    int uBearerDataLen;
+    unsigned char aBearerData[ RIL_CDMA_SMS_BEARER_DATA_MAX ];
+} RIL_CDMA_SMS_Message;
+
+/* Used by RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE */
+
+typedef enum {
+    RIL_CDMA_SMS_NO_ERROR       = 0,
+    RIL_CDMA_SMS_ERROR          = 1,
+    RIL_CDMA_SMS_ERROR_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_ErrorClass;
+
+typedef struct {
+    RIL_CDMA_SMS_ErrorClass uErrorClass;
+    int uSMSCauseCode;
+} RIL_CDMA_SMS_Ack;
+
+/* Used by RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG and RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG */
+
+typedef struct {
+    int uServiceCategory;
+    int uLanguage;
+    unsigned char bSelected;
+} RIL_CDMA_BroadcastServiceInfo;
+
+typedef struct {
+    int size;
+    RIL_CDMA_BroadcastServiceInfo *entries;
+} RIL_CDMA_BroadcastSMSConfig;
+
+/* Used by RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM */
+
+typedef struct {
+    int status;     /* Status of message.  See TS 27.005 3.1, "<stat>": */
+                  /*      0 = "REC UNREAD"    */
+                  /*      1 = "REC READ"      */
+                  /*      2 = "STO UNSENT"    */
+                  /*      3 = "STO SENT"      */
+
+    RIL_CDMA_SMS_Message message;
+} RIL_CDMA_SMS_WriteArgs;
+
+
+/* Used by RIL_REQUEST_ENCODE_CDMA_SMS and RIL_REQUEST_DECODE_CDMA_SMS*/
+
+#define RIL_CDMA_SMS_UDH_MAX_SND_SIZE           128 
+#define RIL_CDMA_SMS_UDH_EO_DATA_SEGMENT_MAX    131 /* 140 - 3 - 6 */
+#define RIL_CDMA_SMS_MAX_UD_HEADERS         7
+#define RIL_CDMA_SMS_USER_DATA_MAX     229
+#define RIL_CDMA_SMS_ADDRESS_MAX            36
+#define RIL_CDMA_SMS_UDH_LARGE_PIC_SIZE     128
+#define RIL_CDMA_SMS_UDH_SMALL_PIC_SIZE     32
+#define RIL_CDMA_SMS_UDH_VAR_PIC_SIZE       134
+#define RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS   4
+#define RIL_CDMA_SMS_UDH_LARGE_BITMAP_SIZE  32
+#define RIL_CDMA_SMS_UDH_SMALL_BITMAP_SIZE  8
+#define RIL_CDMA_SMS_UDH_OTHER_SIZE         226
+#define RIL_CDMA_SMS_IP_ADDRESS_SIZE        4
+
+/* ------------------- */
+/* ---- User Data ---- */
+/* ------------------- */
+typedef enum {
+    RIL_CDMA_SMS_UDH_CONCAT_8         = 0x00,
+    RIL_CDMA_SMS_UDH_SPECIAL_SM,
+    /* 02 - 03    Reserved */
+    RIL_CDMA_SMS_UDH_PORT_8           = 0x04,
+    RIL_CDMA_SMS_UDH_PORT_16,
+    RIL_CDMA_SMS_UDH_SMSC_CONTROL,
+    RIL_CDMA_SMS_UDH_SOURCE,
+    RIL_CDMA_SMS_UDH_CONCAT_16,
+    RIL_CDMA_SMS_UDH_WCMP,
+    RIL_CDMA_SMS_UDH_TEXT_FORMATING,
+    RIL_CDMA_SMS_UDH_PRE_DEF_SOUND,
+    RIL_CDMA_SMS_UDH_USER_DEF_SOUND,
+    RIL_CDMA_SMS_UDH_PRE_DEF_ANIM,
+    RIL_CDMA_SMS_UDH_LARGE_ANIM,
+    RIL_CDMA_SMS_UDH_SMALL_ANIM,
+    RIL_CDMA_SMS_UDH_LARGE_PICTURE,
+    RIL_CDMA_SMS_UDH_SMALL_PICTURE,
+    RIL_CDMA_SMS_UDH_VAR_PICTURE,
+
+    RIL_CDMA_SMS_UDH_USER_PROMPT      = 0x13,
+    RIL_CDMA_SMS_UDH_EXTENDED_OBJECT  = 0x14,
+
+    /* 15 - 1F    Reserved for future EMS */
+
+    RIL_CDMA_SMS_UDH_RFC822           = 0x20,
+
+    /*  21 - 6F    Reserved for future use */
+    /*  70 - 7f    Reserved for (U)SIM Toolkit Security Headers */
+    /*  80 - 9F    SME to SME specific use */
+    /*  A0 - BF    Reserved for future use */
+    /*  C0 - DF    SC specific use */
+    /*  E0 - FF    Reserved for future use */
+
+    RIL_CDMA_SMS_UDH_OTHER            = 0xFFFF, /* For unsupported or proprietary headers */
+    RIL_CDMA_SMS_UDH_ID_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
+
+} RIL_CDMA_SMS_UdhId;
+
+typedef struct {
+    /*indicates the reference number for a particular concatenated short message. */
+    /*it is constant for every short message which makes up a particular concatenated short message*/
+    unsigned char       msg_ref;
+
+    /*indicates the total number of short messages within the concatenated short message.
+     The value shall start at 1 and remain constant for every 
+     short message which makes up the concatenated short message.
+     if it is 0 then the receiving entity shall ignore the whole Information Element*/
+    unsigned char       total_sm;
+
+    /* 
+     * it indicates the sequence number of a particular short message within the concatenated short 
+     * message. The value shall start at 1 and increment by one for every short message sent 
+     * within the concatenated short message. If the value is zero or the value is 
+     * greater than the value in octet 2 then the receiving 
+     * entity shall ignore the whole Information Element.
+     */
+    unsigned char      seq_num;
+} RIL_CDMA_SMS_UdhConcat8;
+
+/* GW message waiting actions
+*/
+typedef enum {
+    RIL_CDMA_SMS_GW_MSG_WAITING_NONE,
+    RIL_CDMA_SMS_GW_MSG_WAITING_DISCARD,
+    RIL_CDMA_SMS_GW_MSG_WAITING_STORE,
+    RIL_CDMA_SMS_GW_MSG_WAITING_NONE_1111,
+    RIL_CDMA_SMS_GW_MSG_WAITING_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_GWMsgWaiting;
+
+/* GW message waiting types
+*/
+typedef enum {
+    RIL_CDMA_SMS_GW_MSG_WAITING_VOICEMAIL,
+    RIL_CDMA_SMS_GW_MSG_WAITING_FAX,
+    RIL_CDMA_SMS_GW_MSG_WAITING_EMAIL,
+    RIL_CDMA_SMS_GW_MSG_WAITING_OTHER,
+    RIL_CDMA_SMS_GW_MSG_WAITING_KIND_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_GWMsgWaitingKind;
+
+typedef struct {
+    RIL_CDMA_SMS_GWMsgWaiting                 msg_waiting;
+    RIL_CDMA_SMS_GWMsgWaitingKind             msg_waiting_kind;
+
+    /*it indicates the number of messages of the type specified in Octet 1 waiting.*/
+    unsigned char                             message_count;
+} RIL_CDMA_SMS_UdhSpecialSM;
+
+typedef struct {
+    unsigned char  dest_port;
+    unsigned char  orig_port;
+} RIL_CDMA_SMS_UdhWap8;
+
+typedef struct {
+    unsigned short  dest_port;
+    unsigned short  orig_port;
+} RIL_CDMA_SMS_UdhWap16;
+
+typedef struct {
+    unsigned short      msg_ref;
+    unsigned char       total_sm;
+    unsigned char       seq_num;
+
+} RIL_CDMA_SMS_UdhConcat16;
+
+typedef enum {
+    RIL_CDMA_SMS_UDH_LEFT_ALIGNMENT = 0,
+    RIL_CDMA_SMS_UDH_CENTER_ALIGNMENT,
+    RIL_CDMA_SMS_UDH_RIGHT_ALIGNMENT,
+    RIL_CDMA_SMS_UDH_DEFAULT_ALIGNMENT,
+    RIL_CDMA_SMS_UDH_MAX_ALIGNMENT,
+    RIL_CDMA_SMS_UDH_ALIGNMENT_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_UdhAlignment;
+
+typedef enum {
+    RIL_CDMA_SMS_UDH_FONT_NORMAL = 0,
+    RIL_CDMA_SMS_UDH_FONT_LARGE,
+    RIL_CDMA_SMS_UDH_FONT_SMALL,
+    RIL_CDMA_SMS_UDH_FONT_RESERVED,
+    RIL_CDMA_SMS_UDH_FONT_MAX,
+    RIL_CDMA_SMS_UDH_FONT_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_UdhFontSize;
+
+typedef enum {
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BLACK          = 0x0,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_GREY      = 0x1,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_RED       = 0x2,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_YELLOW    = 0x3,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_GREEN     = 0x4,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_CYAN      = 0x5,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_BLUE      = 0x6,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_MAGENTA   = 0x7,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_GREY           = 0x8,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_WHITE          = 0x9,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_RED     = 0xA,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_YELLOW  = 0xB,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_GREEN   = 0xC,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_CYAN    = 0xD,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_BLUE    = 0xE,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_MAGENTA = 0xF,
+    RIL_CDMA_SMS_UDH_TEXT_COLOR_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_UdhTextColor;
+
+typedef struct {
+    unsigned char              start_position;
+    unsigned char              text_formatting_length;
+    RIL_CDMA_SMS_UdhAlignment  alignment_type ;       /*bit 0 and  bit 1*/
+    RIL_CDMA_SMS_UdhFontSize   font_size ;            /*bit 3 and  bit 2*/
+    unsigned char              style_bold;            /*bit 4 */
+    unsigned char              style_italic;          /*bit 5  */
+    unsigned char              style_underlined;      /*bit 6 */
+    unsigned char              style_strikethrough;   /*bit 7 */
+
+    /* if FALSE, ignore the following color information */
+    unsigned char              is_color_present;
+    RIL_CDMA_SMS_UdhTextColor  text_color_foreground;
+    RIL_CDMA_SMS_UdhTextColor  text_color_background;
+
+} RIL_CDMA_SMS_UdhTextFormating;
+
+/* Predefined sound
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       snd_number;
+} RIL_CDMA_SMS_UdhPreDefSound;
+
+/* User Defined sound
+*/
+typedef struct {
+    unsigned char       data_length;
+    unsigned char       position;
+    unsigned char       user_def_sound[RIL_CDMA_SMS_UDH_MAX_SND_SIZE];
+} RIL_CDMA_SMS_UdhUserDefSound;
+
+/* Large picture
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       data[RIL_CDMA_SMS_UDH_LARGE_PIC_SIZE];
+} RIL_CDMA_SMS_UdhLargePictureData;
+
+/* Small picture
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       data[RIL_CDMA_SMS_UDH_SMALL_PIC_SIZE];
+} RIL_CDMA_SMS_UdhSmallPictureData;
+
+/* Variable length picture
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       width;    /* Number of pixels - Should be a mutliple of 8 */
+    unsigned char       height;
+    unsigned char       data[RIL_CDMA_SMS_UDH_VAR_PIC_SIZE];
+} RIL_CDMA_SMS_UdhVarPicture;
+
+/* Predefined animation
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       animation_number;
+} RIL_CDMA_SMS_UdhPreDefAnim;
+
+/* Large animation
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       data[RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS][RIL_CDMA_SMS_UDH_LARGE_BITMAP_SIZE];
+} RIL_CDMA_SMS_UdhLargeAnim;
+
+/* Small animation
+*/
+typedef struct {
+    unsigned char       position;
+    unsigned char       data[RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS][RIL_CDMA_SMS_UDH_SMALL_BITMAP_SIZE];
+} RIL_CDMA_SMS_UdhSmallAnim;
+
+/* User Prompt Indicator UDH
+*/
+typedef struct {
+    unsigned char       number_of_objects;
+    /* Number of objects of the same kind that follow this header which will
+    ** be stitched together by the applications. For example, 5 small pictures
+    ** are to be stitched together horizontally, or 6 iMelody tones are to be
+    ** connected together with intermediate iMelody header and footer ignored.
+    ** Allowed objects to be stitched:
+    **   - Images (small, large, variable)
+    **   - User defined sounds
+    */
+} RIL_CDMA_SMS_UdhUserPrompt;
+
+typedef struct {
+    unsigned char         length;
+
+    unsigned char         data[RIL_CDMA_SMS_UDH_EO_DATA_SEGMENT_MAX];
+    /* RIL_CDMA_SMS_UDH_EO_VCARD: See http://www.imc.org/pdi/vcard-21.doc for payload */
+    /* RIL_CDMA_SMS_UDH_EO_VCALENDAR: See http://www.imc.org/pdi/vcal-10.doc */
+    /* Or: Unsupported/proprietary extended objects */
+
+} RIL_CDMA_SMS_UdhEoContent;
+
+/* Extended Object UDH
+*/
+/* Extended Object IDs/types
+*/
+typedef enum {
+    RIL_CDMA_SMS_UDH_EO_VCARD                   = 0x09,
+    RIL_CDMA_SMS_UDH_EO_VCALENDAR               = 0x0A,
+    RIL_CDMA_SMS_UDH_EO_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
+} RIL_CDMA_SMS_UdhEoId;
+
+typedef struct {
+    /* Extended objects are to be used together with 16-bit concatenation
+    ** UDH. The max number of segments supported for E.O. is 8 at least.
+    */
+    RIL_CDMA_SMS_UdhEoContent    content;
+
+    unsigned char                                 first_segment;
+    /* The following fields are only present in the first segment of a
+    ** concatenated SMS message.
+    */
+   unsigned char                                   reference;
+    /* Identify those extended object segments which should be linked together
+    */
+   unsigned short                                  length;
+    /* Length of the whole extended object data
+    */
+    unsigned char                                   control;
+    RIL_CDMA_SMS_UdhEoId                    type;
+    unsigned short                                  position;
+    /* Absolute position of the E.O. in the whole text after concatenation,
+    ** starting from 1.
+    */
+} RIL_CDMA_SMS_UdhEo;
+
+typedef struct {
+    RIL_CDMA_SMS_UdhId  header_id;
+    unsigned char               header_length;
+    unsigned char              data[RIL_CDMA_SMS_UDH_OTHER_SIZE];
+} RIL_CDMA_SMS_UdhOther;
+
+typedef struct {
+    unsigned char        header_length;
+} RIL_CDMA_SMS_UdhRfc822;
+
+typedef struct {
+    RIL_CDMA_SMS_UdhId                header_id;
+
+    union {
+        RIL_CDMA_SMS_UdhConcat8             concat_8;       // 00
+    
+        RIL_CDMA_SMS_UdhSpecialSM           special_sm;     // 01
+        RIL_CDMA_SMS_UdhWap8                wap_8;          // 04
+        RIL_CDMA_SMS_UdhWap16               wap_16;         // 05
+        RIL_CDMA_SMS_UdhConcat16            concat_16;      // 08
+        RIL_CDMA_SMS_UdhTextFormating       text_formating; // 0a
+        RIL_CDMA_SMS_UdhPreDefSound         pre_def_sound;  // 0b
+        RIL_CDMA_SMS_UdhUserDefSound        user_def_sound; // 0c
+        RIL_CDMA_SMS_UdhPreDefAnim          pre_def_anim;   // 0d
+        RIL_CDMA_SMS_UdhLargeAnim           large_anim;     // 0e
+        RIL_CDMA_SMS_UdhSmallAnim           small_anim;     // 0f
+        RIL_CDMA_SMS_UdhLargePictureData    large_picture;  // 10
+        RIL_CDMA_SMS_UdhSmallPictureData    small_picture;  // 11
+        RIL_CDMA_SMS_UdhVarPicture          var_picture;    // 12
+    
+        RIL_CDMA_SMS_UdhUserPrompt          user_prompt;    // 13
+        RIL_CDMA_SMS_UdhEo                  eo;             // 14
+    
+        RIL_CDMA_SMS_UdhRfc822              rfc822;         // 20
+        RIL_CDMA_SMS_UdhOther               other;
+
+    }u;   
+} RIL_CDMA_SMS_Udh;
+
+/* ----------------------------- */
+/* -- User data encoding type -- */
+/* ----------------------------- */
+typedef enum {
+    RIL_CDMA_SMS_ENCODING_OCTET        = 0,    /* 8-bit */
+    RIL_CDMA_SMS_ENCODING_IS91EP,              /* varies */
+    RIL_CDMA_SMS_ENCODING_ASCII,               /* 7-bit */
+    RIL_CDMA_SMS_ENCODING_IA5,                 /* 7-bit */
+    RIL_CDMA_SMS_ENCODING_UNICODE,             /* 16-bit */
+    RIL_CDMA_SMS_ENCODING_SHIFT_JIS,           /* 8 or 16-bit */
+    RIL_CDMA_SMS_ENCODING_KOREAN,              /* 8 or 16-bit */
+    RIL_CDMA_SMS_ENCODING_LATIN_HEBREW,        /* 8-bit */
+    RIL_CDMA_SMS_ENCODING_LATIN,               /* 8-bit */
+    RIL_CDMA_SMS_ENCODING_GSM_7_BIT_DEFAULT,   /* 7-bit */
+    RIL_CDMA_SMS_ENCODING_MAX32        = 0x10000000
+
+} RIL_CDMA_SMS_UserDataEncoding;
+
+/* ------------------------ */
+/* -- IS-91 EP data type -- */
+/* ------------------------ */
+typedef enum {
+    RIL_CDMA_SMS_IS91EP_VOICE_MAIL         = 0x82,
+    RIL_CDMA_SMS_IS91EP_SHORT_MESSAGE_FULL = 0x83,
+    RIL_CDMA_SMS_IS91EP_CLI_ORDER          = 0x84,
+    RIL_CDMA_SMS_IS91EP_SHORT_MESSAGE      = 0x85,
+    RIL_CDMA_SMS_IS91EP_MAX32              = 0x10000000
+
+} RIL_CDMA_SMS_IS91EPType;
+
+typedef struct {
+    /* NOTE: If message_id.udh_present == TRUE:
+    **       'num_headers' is the number of User Data Headers (UDHs),
+    **       and 'headers' include all those headers.
+    */
+    unsigned char                              num_headers;
+    RIL_CDMA_SMS_Udh                     headers[RIL_CDMA_SMS_MAX_UD_HEADERS];
+
+    RIL_CDMA_SMS_UserDataEncoding      encoding;
+    RIL_CDMA_SMS_IS91EPType             is91ep_type;
+
+    /*----------------------------------------------------------------------
+     'data_len' indicates the valid number of bytes in the 'data' array.
+
+     'padding_bits' (0-7) indicates how many bits in the last byte of 'data'
+     are invalid bits. This parameter is only used for Mobile-Originated
+     messages. There is no way for the API to tell how many padding bits
+     exist in the received message. Instead, the application can find out how
+     many padding bits exist in the user data when decoding the user data.
+
+     'data' has the raw bits of the user data field of the SMS message.
+     The client software should decode the raw user data according to its
+     supported encoding types and languages.
+
+     EXCEPTION 1: CMT-91 user data raw bits are first translated into BD fields
+     (e.g. num_messages, callback, etc.) The translated user data field in
+     VMN and Short Message is in the form of ASCII characters, each occupying
+     a byte in the resulted 'data'.
+
+     EXCEPTION 2: GSM 7-bit Default characters are decoded so that each byte
+     has one 7-bit GSM character.
+
+     'number_of_digits' is the number of digits/characters (7, 8, 16, or
+     whatever bits) in the raw user data, which can be used by the client
+     when decoding the user data according to the encoding type and language.
+    -------------------------------------------------------------------------*/
+    unsigned char                                data_len;
+    unsigned char                                padding_bits;
+    unsigned char                                data[ RIL_CDMA_SMS_USER_DATA_MAX ];
+    unsigned char                                number_of_digits;
+
+} RIL_CDMA_SMS_CdmaUserData;
+
+/* -------------------- */
+/* ---- Message Id ---- */
+/* -------------------- */
+typedef enum {
+    RIL_CDMA_SMS_BD_TYPE_RESERVED_0     = 0,
+    RIL_CDMA_SMS_BD_TYPE_DELIVER,       /* MT only */
+    RIL_CDMA_SMS_BD_TYPE_SUBMIT,        /* MO only */
+    RIL_CDMA_SMS_BD_TYPE_CANCELLATION,  /* MO only */
+    RIL_CDMA_SMS_BD_TYPE_DELIVERY_ACK,  /* MT only */
+    RIL_CDMA_SMS_BD_TYPE_USER_ACK,      /* MT & MO */
+    RIL_CDMA_SMS_BD_TYPE_READ_ACK,      /* MT & MO */
+    RIL_CDMA_SMS_BD_TYPE_MAX32          = 0x10000000
+
+} RIL_CDMA_SMS_BdMessageType;
+
+typedef unsigned int  RIL_CDMA_SMS_MessageNumber;
+
+typedef struct {
+    RIL_CDMA_SMS_BdMessageType   type;
+    RIL_CDMA_SMS_MessageNumber      id_number;
+    unsigned char                      udh_present;
+    /* NOTE: if FEATURE_SMS_UDH is not defined,
+    ** udh_present should be ignored.
+    */
+} RIL_CDMA_SMS_MessageId;
+
+typedef unsigned char           RIL_CDMA_SMS_UserResponse;
+
+/* ------------------- */
+/* ---- Timestamp ---- */
+/* ------------------- */
+typedef struct {
+    /* If 'year' is between 96 and 99, the actual year is 1900 + 'year';
+       if 'year' is between 00 and 95, the actual year is 2000 + 'year'.
+       NOTE: Each field has two BCD digits and byte arrangement is <MSB, ... ,LSB>
+    */
+    unsigned char      year;        /* 0x00-0x99 */
+    unsigned char      month;       /* 0x01-0x12 */
+    unsigned char      day;         /* 0x01-0x31 */
+    unsigned char      hour;        /* 0x00-0x23 */
+    unsigned char      minute;      /* 0x00-0x59 */
+    unsigned char      second;      /* 0x00-0x59 */
+    signed char      timezone;    /* +/-, [-48,+48] number of 15 minutes - GW only */
+} RIL_CDMA_SMS_Timestamp;
+
+/* ------------------ */
+/* ---- Priority ---- */
+/* ------------------ */
+typedef enum {
+    RIL_CDMA_SMS_PRIORITY_NORMAL      = 0,
+    RIL_CDMA_SMS_PRIORITY_INTERACTIVE,
+    RIL_CDMA_SMS_PRIORITY_URGENT,
+    RIL_CDMA_SMS_PRIORITY_EMERGENCY,
+    RIL_CDMA_SMS_PRIORITY_MAX32       = 0x10000000
+
+} RIL_CDMA_SMS_Priority;
+
+/* ----------------- */
+/* ---- Privacy ---- */
+/* ----------------- */
+typedef enum {
+    RIL_CDMA_SMS_PRIVACY_NORMAL      = 0,
+    RIL_CDMA_SMS_PRIVACY_RESTRICTED,
+    RIL_CDMA_SMS_PRIVACY_CONFIDENTIAL,
+    RIL_CDMA_SMS_PRIVACY_SECRET,
+    RIL_CDMA_SMS_PRIVACY_MAX32       = 0x10000000
+
+} RIL_CDMA_SMS_Privacy;
+
+/* ---------------------- */
+/* ---- Reply option ---- */
+/* ---------------------- */
+typedef struct {
+    /* whether user ack is requested
+    */
+    unsigned char          user_ack_requested;
+
+    /* whether delivery ack is requested.
+       Should be FALSE for incoming messages.
+    */
+    unsigned char          delivery_ack_requested;
+
+    /* Message originator requests the receiving phone to send back a READ_ACK
+    ** message automatically when the user reads the received message.
+    */
+    unsigned char          read_ack_requested;
+
+} RIL_CDMA_SMS_ReplyOption;
+
+typedef enum {
+    RIL_CDMA_SMS_ALERT_MODE_DEFAULT         = 0,
+    RIL_CDMA_SMS_ALERT_MODE_LOW_PRIORITY    = 1,
+    RIL_CDMA_SMS_ALERT_MODE_MEDIUM_PRIORITY = 2,
+    RIL_CDMA_SMS_ALERT_MODE_HIGH_PRIORITY   = 3,
+
+    /* For pre-IS637A implementations, alert_mode only has values of True/False:
+    */
+    RIL_CDMA_SMS_ALERT_MODE_OFF   = 0,
+    RIL_CDMA_SMS_ALERT_MODE_ON    = 1
+
+} RIL_CDMA_SMS_AlertMode;
+
+/* ------------------ */
+/* ---- Language ---- */
+/* ------------------ */
+typedef enum {
+    RIL_CDMA_SMS_LANGUAGE_UNSPECIFIED = 0,
+    RIL_CDMA_SMS_LANGUAGE_ENGLISH,
+    RIL_CDMA_SMS_LANGUAGE_FRENCH,
+    RIL_CDMA_SMS_LANGUAGE_SPANISH,
+    RIL_CDMA_SMS_LANGUAGE_JAPANESE,
+    RIL_CDMA_SMS_LANGUAGE_KOREAN,
+    RIL_CDMA_SMS_LANGUAGE_CHINESE,
+    RIL_CDMA_SMS_LANGUAGE_HEBREW,
+    RIL_CDMA_SMS_LANGUAGE_MAX32       = 0x10000000
+
+} RIL_CDMA_SMS_Language;
+
+/* ---------------------------------- */
+/* ---------- Display Mode ---------- */
+/* ---------------------------------- */
+typedef enum {
+    RIL_CDMA_SMS_DISPLAY_MODE_IMMEDIATE   = 0,
+    RIL_CDMA_SMS_DISPLAY_MODE_DEFAULT     = 1,
+    RIL_CDMA_SMS_DISPLAY_MODE_USER_INVOKE = 2,
+    RIL_CDMA_SMS_DISPLAY_MODE_RESERVED    = 3
+} RIL_CDMA_SMS_DisplayMode;
+
+/* IS-637B parameters/fields
+*/
+
+/* ---------------------------------- */
+/* ---------- Delivery Status ------- */
+/* ---------------------------------- */
+typedef enum {
+    RIL_CDMA_SMS_DELIVERY_STATUS_ACCEPTED              = 0,    /* ERROR_CLASS_NONE */
+    RIL_CDMA_SMS_DELIVERY_STATUS_DEPOSITED_TO_INTERNET = 1,    /* ERROR_CLASS_NONE */
+    RIL_CDMA_SMS_DELIVERY_STATUS_DELIVERED             = 2,    /* ERROR_CLASS_NONE */
+    RIL_CDMA_SMS_DELIVERY_STATUS_CANCELLED             = 3,    /* ERROR_CLASS_NONE */
+
+    RIL_CDMA_SMS_DELIVERY_STATUS_NETWORK_CONGESTION  = 4,    /* ERROR_CLASS_TEMP & PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_NETWORK_ERROR       = 5,    /* ERROR_CLASS_TEMP & PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_CANCEL_FAILED       = 6,    /* ERROR_CLASS_PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_BLOCKED_DESTINATION = 7,    /* ERROR_CLASS_PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_TEXT_TOO_LONG       = 8,    /* ERROR_CLASS_PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_DUPLICATE_MESSAGE   = 9,    /* ERROR_CLASS_PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_INVALID_DESTINATION = 10,   /* ERROR_CLASS_PERM */
+    RIL_CDMA_SMS_DELIVERY_STATUS_MESSAGE_EXPIRED     = 13,   /* ERROR_CLASS_PERM */
+
+    RIL_CDMA_SMS_DELIVERY_STATUS_UNKNOWN_ERROR       = 0x1F  /* ERROR_CLASS_PERM */
+
+    /* All the other values are reserved */
+
+} RIL_CDMA_SMS_DeliveryStatusE;
+
+typedef struct {
+    RIL_CDMA_SMS_ErrorClass       error_class;
+    RIL_CDMA_SMS_DeliveryStatusE   status;
+} RIL_CDMA_SMS_DeliveryStatus;
+
+typedef struct {
+    unsigned char               address[RIL_CDMA_SMS_IP_ADDRESS_SIZE];
+    unsigned char             is_valid;
+} RIL_CDMA_SMS_IpAddress;
+
+/* This special parameter captures any unrecognized/proprietary parameters
+*/
+typedef struct {
+    unsigned char                         input_other_len;
+    unsigned char                         desired_other_len; /* used during decoding */
+    unsigned char                         * other_data;
+} RIL_CDMA_SMS_OtherParm;
+
+typedef struct {
+    /* the mask indicates which fields are present in this message */
+    unsigned int                        mask;
+
+    RIL_CDMA_SMS_MessageId         message_id;
+    RIL_CDMA_SMS_CdmaUserData     user_data;
+    RIL_CDMA_SMS_UserResponse        user_response;
+    RIL_CDMA_SMS_Timestamp          mc_time;
+    RIL_CDMA_SMS_Timestamp          validity_absolute;
+    RIL_CDMA_SMS_Timestamp          validity_relative;
+    RIL_CDMA_SMS_Timestamp          deferred_absolute;
+    RIL_CDMA_SMS_Timestamp          deferred_relative;
+    RIL_CDMA_SMS_Priority           priority;
+    RIL_CDMA_SMS_Privacy            privacy;
+    RIL_CDMA_SMS_ReplyOption       reply_option;
+    unsigned char                         num_messages;  /* the actual value; not BCDs */
+    RIL_CDMA_SMS_AlertMode         alert_mode;
+     /* For pre-IS-637A implementations, alert_mode is either Off or On. */
+    RIL_CDMA_SMS_Language           language;
+    RIL_CDMA_SMS_Address            callback;
+    RIL_CDMA_SMS_DisplayMode       display_mode;
+
+    RIL_CDMA_SMS_DeliveryStatus    delivery_status;
+    unsigned int                        deposit_index;
+
+    RIL_CDMA_SMS_IpAddress         ip_address;
+    unsigned char                         rsn_no_notify;
+
+    /* See function comments of wms_ts_decode() and
+    ** wms_ts_decode_cdma_bd_with_other() for details regarding 'other' parameters
+    */
+    RIL_CDMA_SMS_OtherParm         other;
+
+} RIL_CDMA_SMS_ClientBd;
+
+typedef struct {
+    unsigned char length;   /* length, in bytes, of the encoded SMS message */
+    unsigned char * data;   /* the encoded SMS message (max 255 bytes) */
+} RIL_CDMA_Encoded_SMS;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*ANDROID_RIL_CDMA_SMS_H*/
+
diff --git a/libril/ril.cpp b/libril/ril.cpp
index d112e1b..38225aa 100644
--- a/libril/ril.cpp
+++ b/libril/ril.cpp
@@ -20,6 +20,7 @@
 #include <hardware_legacy/power.h>
 
 #include <telephony/ril.h>
+#include <telephony/ril_cdma_sms.h>
 #include <cutils/sockets.h>
 #include <cutils/jstring.h>
 #include <cutils/record_stream.h>
@@ -72,6 +73,8 @@
 
 #define NUM_ELEMS(a)     (sizeof (a) / sizeof (a)[0])
 
+#define MIN(a,b) ((a)<(b) ? (a) : (b))
+
 /* Constants for response types */
 #define RESPONSE_SOLICITED 0
 #define RESPONSE_UNSOLICITED 1
@@ -199,6 +202,11 @@
 static void dispatchRaw(Parcel& p, RequestInfo *pRI);
 static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
 
+static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
+static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
+static void dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI);
+static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI);
+static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI);
 static int responseInts(Parcel &p, void *response, size_t responselen);
 static int responseStrings(Parcel &p, void *response, size_t responselen);
 static int responseString(Parcel &p, void *response, size_t responselen);
@@ -207,9 +215,13 @@
 static int responseSMS(Parcel &p, void *response, size_t responselen);
 static int responseSIM_IO(Parcel &p, void *response, size_t responselen);
 static int responseCallForwards(Parcel &p, void *response, size_t responselen);
-static int responseContexts(Parcel &p, void *response, size_t responselen);
+static int responseDataCallList(Parcel &p, void *response, size_t responselen);
 static int responseRaw(Parcel &p, void *response, size_t responselen);
 static int responseSsn(Parcel &p, void *response, size_t responselen);
+static int responseSimStatus(Parcel &p, void *response, size_t responselen);
+static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen);
+static int responseCdmaBrCnf(Parcel &p, void *response, size_t responselen);
+static int responseCdmaSms(Parcel &p, void *response, size_t responselen);
 static int responseCellList(Parcel &p, void *response, size_t responselen);
 
 extern "C" const char * requestToString(int request);
@@ -237,8 +249,7 @@
 
 
 static char *
-strdupReadString(Parcel &p)
-{
+strdupReadString(Parcel &p) {
     size_t stringlen;
     const char16_t *s16;
             
@@ -247,8 +258,7 @@
     return strndup16to8(s16, stringlen);
 }
 
-static void writeStringToParcel(Parcel &p, const char *s)
-{
+static void writeStringToParcel(Parcel &p, const char *s) {
     char16_t *s16;
     size_t s16_len;
     s16 = strdup8to16(s, &s16_len);
@@ -258,8 +268,7 @@
 
 
 static void
-memsetString (char *s)
-{
+memsetString (char *s) {
     if (s != NULL) {
         memset (s, 0, strlen(s));
     }
@@ -267,8 +276,7 @@
 
 void   nullParcelReleaseFunction (const uint8_t* data, size_t dataSize,
                                     const size_t* objects, size_t objectsSize,
-                                        void* cookie)
-{
+                                        void* cookie) {
     // do nothing -- the data reference lives longer than the Parcel object
 }
 
@@ -278,8 +286,7 @@
  * is not sent back up to the command process 
  */
 static void
-issueLocalRequest(int request, void *data, int len)
-{
+issueLocalRequest(int request, void *data, int len) {
     RequestInfo *pRI;
     int ret;
 
@@ -306,8 +313,7 @@
 
 
 static int
-processCommandBuffer(void *buffer, size_t buflen)
-{
+processCommandBuffer(void *buffer, size_t buflen) {
     Parcel p;
     status_t status;
     int32_t request;
@@ -355,16 +361,14 @@
 }
 
 static void
-invalidCommandBlock (RequestInfo *pRI)
-{
+invalidCommandBlock (RequestInfo *pRI) {
     LOGE("invalid command block for token %d request %s", 
                 pRI->token, requestToString(pRI->pCI->requestNumber));
 }
 
 /** Callee expects NULL */
 static void 
-dispatchVoid (Parcel& p, RequestInfo *pRI)
-{
+dispatchVoid (Parcel& p, RequestInfo *pRI) {
     clearPrintBuf;
     printRequest(pRI->token, pRI->pCI->requestNumber);
     s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI);
@@ -372,8 +376,7 @@
 
 /** Callee expects const char * */
 static void
-dispatchString (Parcel& p, RequestInfo *pRI)
-{
+dispatchString (Parcel& p, RequestInfo *pRI) {
     status_t status;
     size_t datalen;
     size_t stringlen;
@@ -402,8 +405,7 @@
 
 /** Callee expects const char ** */
 static void
-dispatchStrings (Parcel &p, RequestInfo *pRI)
-{
+dispatchStrings (Parcel &p, RequestInfo *pRI) {
     int32_t countStrings;
     status_t status;
     size_t datalen;
@@ -460,8 +462,7 @@
 
 /** Callee expects const int * */
 static void
-dispatchInts (Parcel &p, RequestInfo *pRI)
-{
+dispatchInts (Parcel &p, RequestInfo *pRI) {
     int32_t count;
     status_t status;
     size_t datalen;
@@ -513,8 +514,7 @@
  *   String pdu
  */
 static void
-dispatchSmsWrite (Parcel &p, RequestInfo *pRI)
-{
+dispatchSmsWrite (Parcel &p, RequestInfo *pRI) {
     RIL_SMS_WriteArgs args;
     int32_t t;
     status_t status;
@@ -563,8 +563,7 @@
  *   int32_t clir
  */
 static void
-dispatchDial (Parcel &p, RequestInfo *pRI)
-{
+dispatchDial (Parcel &p, RequestInfo *pRI) {
     RIL_Dial dial;
     int32_t t;
     status_t status;
@@ -614,8 +613,7 @@
  *   String pin2 
  */
 static void
-dispatchSIM_IO (Parcel &p, RequestInfo *pRI)
-{
+dispatchSIM_IO (Parcel &p, RequestInfo *pRI) {
     RIL_SIM_IO simIO;
     int32_t t;
     status_t status;
@@ -689,8 +687,7 @@
  *  int32_t timeSeconds
  */
 static void 
-dispatchCallForward(Parcel &p, RequestInfo *pRI)
-{
+dispatchCallForward(Parcel &p, RequestInfo *pRI) {
     RIL_CallForwardInfo cff;
     int32_t t;
     status_t status;
@@ -753,8 +750,7 @@
 
 
 static void 
-dispatchRaw(Parcel &p, RequestInfo *pRI)
-{
+dispatchRaw(Parcel &p, RequestInfo *pRI) {
     int32_t len;
     status_t status;
     const void *data;
@@ -786,9 +782,331 @@
     return;
 }
 
+static void 
+dispatchCdmaSms(Parcel &p, RequestInfo *pRI) {
+    RIL_CDMA_SMS_Message rcsm;
+    int32_t  t;
+    uint8_t ut;
+    status_t status;
+    int32_t digitCount;
+    int digitLimit;
+    
+    memset(&rcsm, 0, sizeof(rcsm));
+
+    status = p.readInt32(&t);
+    rcsm.uTeleserviceID = (int) t;
+
+    status = p.read(&ut,sizeof(ut));
+    rcsm.bIsServicePresent = (uint8_t) ut;
+
+    status = p.readInt32(&t);
+    rcsm.uServicecategory = (int) t;
+
+    status = p.readInt32(&t);
+    rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
+
+    status = p.readInt32(&t);
+    rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
+
+    status = p.readInt32(&t);
+    rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
+
+    status = p.readInt32(&t);
+    rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
+
+    status = p.read(&ut,sizeof(ut));
+    rcsm.sAddress.number_of_digits= (uint8_t) ut;
+
+    digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
+    for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
+        status = p.read(&ut,sizeof(ut));
+        rcsm.sAddress.digits[digitCount] = (uint8_t) ut;
+    }
+
+    status = p.readInt32(&t); 
+    rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
+
+    status = p.read(&ut,sizeof(ut)); 
+    rcsm.sSubAddress.odd = (uint8_t) ut;
+
+    status = p.read(&ut,sizeof(ut));
+    rcsm.sSubAddress.number_of_digits = (uint8_t) ut;
+
+    digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
+    for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {   
+        status = p.read(&ut,sizeof(ut)); 
+        rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut;
+    }
+
+    status = p.readInt32(&t); 
+    rcsm.uBearerDataLen = (int) t;
+
+    digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
+    for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {     
+        status = p.read(&ut, sizeof(ut)); 
+        rcsm.aBearerData[digitCount] = (uint8_t) ut;
+    }
+
+    if (status != NO_ERROR) {
+        goto invalid;
+    }
+
+    startRequest;
+    appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
+            sAddress.digitmode=%d, sAddress.NumberMode=%d, sAddress.numberType=%d, ", 
+            printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory,
+            rcsm.sAddress.digitMode, rcsm.sAddress.numberMode,rcsm.sAddress.numberType);
+    closeRequest;
+   
+    printRequest(pRI->token, pRI->pCI->requestNumber);
+
+    s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI);
+
+#ifdef MEMSET_FREED
+    memset(&rcsm, 0, sizeof(rcsm));
+#endif
+
+    return;
+
+invalid:
+    invalidCommandBlock(pRI);
+    return;
+}
+
+static void 
+dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) {
+    RIL_CDMA_SMS_Ack rcsa;
+    int32_t  t;
+    status_t status;
+    int32_t digitCount;
+
+    memset(&rcsa, 0, sizeof(rcsa));
+
+    status = p.readInt32(&t);
+    rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t;
+
+    status = p.readInt32(&t);
+    rcsa.uSMSCauseCode = (int) t;
+
+    if (status != NO_ERROR) {
+        goto invalid;
+    }
+
+    startRequest;
+    appendPrintBuf("%suBearerReplySeq=%d, uErrorClass=%d, uTLStatus=%d, ",
+            printBuf, rcsa.uBearerReplySeq,rcsa.uErrorClass,rcsa.uSMSCauseCode);
+    closeRequest;
+
+    printRequest(pRI->token, pRI->pCI->requestNumber);
+
+    s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI);
+
+#ifdef MEMSET_FREED
+    memset(&rcsa, 0, sizeof(rcsa));
+#endif
+
+    return;
+
+invalid:
+    invalidCommandBlock(pRI);
+    return;
+}
+
+static void 
+dispatchBrSmsCnf(Parcel &p, RequestInfo *pRI) {
+    RIL_BroadcastSMSConfig rbsc;
+    int32_t  t;
+    uint8_t ut;
+    status_t status;
+    int32_t digitCount;
+
+    memset(&rbsc, 0, sizeof(rbsc));
+
+    status = p.readInt32(&t);
+    rbsc.size = (int) t;
+
+    status = p.readInt32(&t);
+    rbsc.entries->uFromServiceID = (int) t;
+
+    status = p.readInt32(&t);
+    rbsc.entries->uToserviceID = (int) t;
+
+    //usage of read function on assumption that it reads any length given as 2nd argument
+    status = p.read(&ut,sizeof(ut));
+    rbsc.entries->bSelected = (uint8_t) ut;
+
+    if (status != NO_ERROR) {
+        goto invalid;
+    }
+
+    startRequest;
+    appendPrintBuf("%ssize=%d, uServicecategory=%d, entries.uFromServiceID=%d, \
+            entries.uToserviceID=%d, entries.bSelected =%d, ", printBuf,
+            rbsc.size,rbsc.entries->uFromServiceID, rbsc.entries->uToserviceID,
+            rbsc.entries->bSelected);
+    closeRequest;
+
+    printRequest(pRI->token, pRI->pCI->requestNumber);
+
+    s_callbacks.onRequest(pRI->pCI->requestNumber, &rbsc, sizeof(rbsc),pRI);
+
+#ifdef MEMSET_FREED
+    memset(&rbsc, 0, sizeof(rbsc));
+#endif
+
+    return;
+
+invalid:
+    invalidCommandBlock(pRI);
+    return;
+
+}
+
+static void 
+dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) {
+    RIL_CDMA_BroadcastSMSConfig rcbsc;
+    int32_t  t;
+    uint8_t ut;
+    status_t status;
+    int32_t digitCount;
+
+    memset(&rcbsc, 0, sizeof(rcbsc));
+
+    status = p.readInt32(&t);
+    rcbsc.size = (int) t;
+
+    status = p.readInt32(&t);
+    rcbsc.entries->uServiceCategory = (int) t;
+
+    status = p.readInt32(&t);
+    rcbsc.entries->uLanguage = (int) t;
+
+    status = p.read(&ut, sizeof(ut));
+    rcbsc.entries->bSelected = (uint8_t) ut;
+
+    if (status != NO_ERROR) {
+        goto invalid;
+    }
+
+    startRequest;
+    appendPrintBuf("%sbIsEnabled=%d, size=%d, entries.uServicecategory=%d, \
+            entries.uLanguage =%d, entries.bSelected =%d, ", printBuf, rcbsc.bIsEnabled,rcbsc.size,
+            rcbsc.entries->uServiceCategory,rcbsc.entries->uLanguage, rcbsc.entries->bSelected);
+    closeRequest;
+
+    printRequest(pRI->token, pRI->pCI->requestNumber);
+
+    s_callbacks.onRequest(pRI->pCI->requestNumber, &rcbsc, sizeof(rcbsc),pRI);
+
+#ifdef MEMSET_FREED
+    memset(&rcbsc, 0, sizeof(rcbsc));
+#endif
+
+    return;
+
+invalid:
+    invalidCommandBlock(pRI);
+    return;
+
+}
+
+static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) {
+    RIL_CDMA_SMS_WriteArgs rcsw;
+    int32_t  t;
+    uint32_t ut;
+    uint8_t  uct;
+    status_t status;
+    int32_t  digitCount;
+
+    memset(&rcsw, 0, sizeof(rcsw));
+
+    status = p.readInt32(&t);
+    rcsw.status = t;
+    
+    status = p.readInt32(&t);
+    rcsw.message.uTeleserviceID = (int) t;
+
+    status = p.read(&uct,sizeof(uct));
+    rcsw.message.bIsServicePresent = (uint8_t) uct;
+
+    status = p.readInt32(&t);
+    rcsw.message.uServicecategory = (int) t;
+
+    status = p.readInt32(&t);
+    rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t;
+
+    status = p.readInt32(&t);
+    rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t;
+
+    status = p.readInt32(&t);
+    rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t;
+
+    status = p.readInt32(&t);
+    rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t;
+
+    status = p.read(&uct,sizeof(uct));
+    rcsw.message.sAddress.number_of_digits = (uint8_t) uct;
+
+    for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) {
+        status = p.read(&uct,sizeof(uct));
+        rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct;
+    }
+
+    status = p.readInt32(&t); 
+    rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t;
+
+    status = p.read(&uct,sizeof(uct)); 
+    rcsw.message.sSubAddress.odd = (uint8_t) uct;
+
+    status = p.read(&uct,sizeof(uct));
+    rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct;
+
+    for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) {
+        status = p.read(&uct,sizeof(uct)); 
+        rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct;
+    }
+
+    status = p.readInt32(&t); 
+    rcsw.message.uBearerDataLen = (int) t;
+
+    for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) {
+        status = p.read(&uct, sizeof(uct)); 
+        rcsw.message.aBearerData[digitCount] = (uint8_t) uct;
+    }
+
+    if (status != NO_ERROR) {
+        goto invalid;
+    }
+
+    startRequest;
+    appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, 
+            message.uServicecategory=%d, message.sAddress.digitmode=%d,
+            message.sAddress.NumberMode=%d,
+            message.sAddress.numberType=%d, ",
+            printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent,
+            rcsw.message.uServicecategory, rcsw.message.sAddress.digitMode,
+            rcsw.message.sAddress.numberMode,
+            rcsw.message.sAddress.numberType);
+    closeRequest;
+
+    printRequest(pRI->token, pRI->pCI->requestNumber);
+
+    s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI);
+
+#ifdef MEMSET_FREED
+    memset(&rcsw, 0, sizeof(rcsw));
+#endif
+
+    return;
+
+invalid:
+    invalidCommandBlock(pRI);
+    return;
+
+}
+
 static int
-blockingWrite(int fd, const void *buffer, size_t len)
-{
+blockingWrite(int fd, const void *buffer, size_t len) {
     size_t writeOffset = 0; 
     const uint8_t *toWrite;
 
@@ -814,8 +1132,7 @@
 }
 
 static int
-sendResponseRaw (const void *data, size_t dataSize)
-{
+sendResponseRaw (const void *data, size_t dataSize) {
     int fd = s_fdCommand;
     int ret;
     uint32_t header;
@@ -856,8 +1173,7 @@
 }
 
 static int
-sendResponse (Parcel &p)
-{
+sendResponse (Parcel &p) {
     printResponse;
     return sendResponseRaw(p.data(), p.dataSize());
 }
@@ -865,8 +1181,7 @@
 /** response is an int* pointing to an array of ints*/
  
 static int 
-responseInts(Parcel &p, void *response, size_t responselen)
-{
+responseInts(Parcel &p, void *response, size_t responselen) {
     int numInts;
 
     if (response == NULL && responselen != 0) {
@@ -897,8 +1212,7 @@
 }
 
 /** response is a char **, pointing to an array of char *'s */
-static int responseStrings(Parcel &p, void *response, size_t responselen)
-{
+static int responseStrings(Parcel &p, void *response, size_t responselen) {
     int numStrings;
     
     if (response == NULL && responselen != 0) {
@@ -936,8 +1250,7 @@
  * NULL strings are accepted 
  * FIXME currently ignores responselen
  */
-static int responseString(Parcel &p, void *response, size_t responselen)
-{
+static int responseString(Parcel &p, void *response, size_t responselen) {
     /* one string only */
     startResponse;
     appendPrintBuf("%s%s", printBuf, (char*)response);
@@ -948,15 +1261,13 @@
     return 0;
 }
 
-static int responseVoid(Parcel &p, void *response, size_t responselen)
-{
+static int responseVoid(Parcel &p, void *response, size_t responselen) {
     startResponse;
     removeLastChar;
     return 0;
 }
 
-static int responseCallList(Parcel &p, void *response, size_t responselen)
-{    
+static int responseCallList(Parcel &p, void *response, size_t responselen) {
     int num;
 
     if (response == NULL && responselen != 0) {
@@ -987,7 +1298,7 @@
         p.writeInt32(p_cur->isVoice);
         writeStringToParcel (p, p_cur->number);
         p.writeInt32(p_cur->numberPresentation);
-        appendPrintBuf("%s[%s,id=%d,toa=%d,%s,%s,als=%d,%s,%s,cli=%d],", 
+        appendPrintBuf("%s[%s,id=%d,toa=%d,%s,%s,als=%d,%s,%s,cli=%d],",
             printBuf,
             callStateToString(p_cur->state),
             p_cur->index, p_cur->toa,
@@ -1004,8 +1315,7 @@
     return 0;
 }
 
-static int responseSMS(Parcel &p, void *response, size_t responselen)
-{
+static int responseSMS(Parcel &p, void *response, size_t responselen) {
     if (response == NULL) {
         LOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -1030,23 +1340,23 @@
     return 0;
 }
 
-static int responseContexts(Parcel &p, void *response, size_t responselen)
+static int responseDataCallList(Parcel &p, void *response, size_t responselen)
 {
     if (response == NULL && responselen != 0) {
         LOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
     }
 
-    if (responselen % sizeof(RIL_PDP_Context_Response) != 0) {
+    if (responselen % sizeof(RIL_Data_Call_Response) != 0) {
         LOGE("invalid response length %d expected multiple of %d", 
-                (int)responselen, (int)sizeof(RIL_PDP_Context_Response));
+                (int)responselen, (int)sizeof(RIL_Data_Call_Response));
         return RIL_ERRNO_INVALID_RESPONSE;
     }
 
-    int num = responselen / sizeof(RIL_PDP_Context_Response);
+    int num = responselen / sizeof(RIL_Data_Call_Response);
     p.writeInt32(num);
 
-    RIL_PDP_Context_Response *p_cur = (RIL_PDP_Context_Response *) response;
+    RIL_Data_Call_Response *p_cur = (RIL_Data_Call_Response *) response;
     startResponse;
     int i;
     for (i = 0; i < num; i++) {
@@ -1068,8 +1378,7 @@
     return 0;
 }
 
-static int responseRaw(Parcel &p, void *response, size_t responselen)
-{
+static int responseRaw(Parcel &p, void *response, size_t responselen) {
     if (response == NULL && responselen != 0) {
         LOGE("invalid response: NULL with responselen != 0");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -1087,8 +1396,7 @@
 }
 
 
-static int responseSIM_IO(Parcel &p, void *response, size_t responselen)
-{
+static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
     if (response == NULL) {
         LOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -1114,8 +1422,7 @@
     return 0;
 }
 
-static int responseCallForwards(Parcel &p, void *response, size_t responselen)
-{
+static int responseCallForwards(Parcel &p, void *response, size_t responselen) {
     int num;
     
     if (response == NULL && responselen != 0) {
@@ -1155,8 +1462,7 @@
     return 0;
 }
 
-static int responseSsn(Parcel &p, void *response, size_t responselen)
-{
+static int responseSsn(Parcel &p, void *response, size_t responselen) {
     if (response == NULL) {
         LOGE("invalid response: NULL");
         return RIL_ERRNO_INVALID_RESPONSE;
@@ -1239,13 +1545,184 @@
     triggerEvLoop();
 }
 
+static int responseSimStatus(Parcel &p, void *response, size_t responselen) {
+    int i;
+
+    if (response == NULL && responselen != 0) {
+        LOGE("invalid response: NULL");
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    if (responselen % sizeof (RIL_CardStatus *) != 0) {
+        LOGE("invalid response length %d expected multiple of %d\n", 
+            (int)responselen, (int)sizeof (RIL_CardStatus *));
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    RIL_CardStatus *p_cur = ((RIL_CardStatus *) response);
+
+    p.writeInt32(p_cur->card_state);
+    p.writeInt32(p_cur->universal_pin_state);
+    p.writeInt32(p_cur->gsm_umts_subscription_app_index);
+    p.writeInt32(p_cur->cdma_subscription_app_index);
+    p.writeInt32(p_cur->num_applications);
+
+    startResponse;
+    for (i = 0; i < p_cur->num_applications; i++) {
+        p.writeInt32(p_cur->applications[i].app_type);
+        p.writeInt32(p_cur->applications[i].app_state);
+        p.writeInt32(p_cur->applications[i].perso_substate);
+        writeStringToParcel (p, (const char*)(p_cur->applications[i].aid_ptr));
+        writeStringToParcel (p, (const char*)(p_cur->applications[i].app_label_ptr));
+        p.writeInt32(p_cur->applications[i].pin1_replaced);
+        p.writeInt32(p_cur->applications[i].pin1);
+        p.writeInt32(p_cur->applications[i].pin2);
+        appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,aid_ptr=%s,\
+                app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],",
+                printBuf,
+                p_cur->applications[i].app_type,
+                p_cur->applications[i].app_state,
+                p_cur->applications[i].perso_substate,
+                p_cur->applications[i].aid_ptr,
+                p_cur->applications[i].app_label_ptr,
+                p_cur->applications[i].pin1_replaced,
+                p_cur->applications[i].pin1,
+                p_cur->applications[i].pin2);
+    }
+    closeResponse;
+
+    return 0;
+} 
+
+static int responseBrSmsCnf(Parcel &p, void *response, size_t responselen) {
+    int num;
+
+    if (response == NULL && responselen != 0) {
+        LOGE("invalid response: NULL");
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    if (responselen % sizeof(RIL_BroadcastSMSConfig *) != 0) {
+        LOGE("invalid response length %d expected multiple of %d", 
+                (int)responselen, (int)sizeof(RIL_BroadcastSMSConfig *));
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    /* number of call info's */
+    num = responselen / sizeof(RIL_BroadcastSMSConfig *);
+    p.writeInt32(num);
+
+    RIL_BroadcastSMSConfig *p_cur = (RIL_BroadcastSMSConfig *) response;
+    p.writeInt32(p_cur->size);
+    p.writeInt32(p_cur->entries->uFromServiceID);
+    p.writeInt32(p_cur->entries->uToserviceID);
+    p.write(&(p_cur->entries->bSelected),sizeof(p_cur->entries->bSelected));
+    
+    startResponse;
+    appendPrintBuf("%s size=%d, uServicecategory=%d, entries.uFromServiceID=%d, \
+            entries.uToserviceID=%d, entries.bSelected =%d, ",
+            printBuf, p_cur->size,p_cur->entries->uFromServiceID,
+            p_cur->.entries->uToserviceID,p_cur->entries->bSelected);
+    closeResponse;
+
+    return 0;
+}
+
+static int responseCdmaBrCnf(Parcel &p, void *response, size_t responselen) {
+    int num;
+
+    if (response == NULL && responselen != 0) {
+        LOGE("invalid response: NULL");
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    if (responselen % sizeof(RIL_CDMA_BroadcastSMSConfig*) != 0) {
+        LOGE("invalid response length %d expected multiple of %d", 
+                (int)responselen, (int)sizeof(RIL_CDMA_BroadcastSMSConfig *));
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    /* number of call info's */
+    num = responselen / sizeof(RIL_CDMA_BroadcastSMSConfig *);
+    p.writeInt32(num);
+
+    RIL_CDMA_BroadcastSMSConfig *p_cur = (RIL_CDMA_BroadcastSMSConfig * ) response;
+    p.writeInt32(p_cur->size);
+    p.writeInt32(p_cur->entries->uServiceCategory);
+    p.writeInt32(p_cur->entries->uLanguage);
+    p.write(&(p_cur->entries->bSelected),sizeof(p_cur->entries->bSelected));
+
+    startResponse;
+    appendPrintBuf("%ssize=%d, entries.uServicecategory=%d, entries.uLanguage =%d, \
+            entries.bSelected =%d, ", printBuf,p_cur->size, p_cur->entries->uServiceCategory,
+            p_cur->entries->uLanguage, p_cur->entries->bSelected);
+    closeResponse;
+
+    return 0;
+}
+
+static int responseCdmaSms(Parcel &p, void *response, size_t responselen) {
+    int num;
+    int digitCount;
+    int digitLimit;
+    uint8_t uct;
+    void* dest;
+
+    if (response == NULL && responselen != 0) {
+        LOGE("invalid response: NULL");
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    if (responselen != sizeof(RIL_CDMA_SMS_Message*)) {
+        LOGE("invalid response length was %d expected %d",
+                (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message *));
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response;
+    p.writeInt32(p_cur->uTeleserviceID);
+    p.write(&(p_cur->bIsServicePresent),sizeof(uct));
+    p.writeInt32(p_cur->uServicecategory);
+    p.writeInt32(p_cur->sAddress.digit_mode);
+    p.writeInt32(p_cur->sAddress.number_mode);
+    p.writeInt32(p_cur->sAddress.number_type);
+    p.writeInt32(p_cur->sAddress.number_plan);
+    p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct));
+    digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
+    for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
+        p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct));
+    }
+
+    p.writeInt32(p_cur->sSubAddress.subaddressType);
+    p.write(&(p_cur->sSubAddress.odd),sizeof(uct));
+    p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct));
+    digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
+    for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
+        p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct));
+    }
+
+    digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
+    p.writeInt32(p_cur->uBearerDataLen);
+    for(digitCount =0 ; digitCount < digitLimit; digitCount ++) {
+       p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct));
+    }
+
+    startResponse;
+    appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \
+            sAddress.digitmode=%d, sAddress.NumberMode=%d, sAddress.numberType=%d, ", 
+            printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory,
+            p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type);
+    closeResponse;
+
+    return 0;
+}
+
 /**
  * A write on the wakeup fd is done just to pop us out of select()
  * We empty the buffer here and then ril_event will reset the timers on the
  * way back down
  */
-static void processWakeupCallback(int fd, short flags, void *param)
-{
+static void processWakeupCallback(int fd, short flags, void *param) {
     char buff[16];
     int ret;
 
@@ -1257,8 +1734,7 @@
     } while (ret > 0 || (ret < 0 && errno == EINTR)); 
 }
 
-static void onCommandsSocketClosed()
-{
+static void onCommandsSocketClosed() {
     int ret;
     RequestInfo *p_cur;
 
@@ -1280,8 +1756,7 @@
     assert (ret == 0);
 }
 
-static void processCommandsCallback(int fd, short flags, void *param)
-{
+static void processCommandsCallback(int fd, short flags, void *param) {
     RecordStream *p_rs;
     void *p_record;
     size_t recordlen;
@@ -1328,8 +1803,7 @@
 }
 
 
-static void onNewCommandConnect()
-{
+static void onNewCommandConnect() {
     // implicit radio state changed
     RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
                                     NULL, 0);
@@ -1356,8 +1830,7 @@
 
 }
 
-static void listenCallback (int fd, short flags, void *param)
-{
+static void listenCallback (int fd, short flags, void *param) {
     int ret;
     int err;
     int is_phone_socket;
@@ -1380,7 +1853,7 @@
         LOGE("Error on accept() errno:%d", errno);
         /* start listening for new connections again */
         rilEventAddWakeup(&s_listen_event);
-	return;
+	      return;
     }
 
     /* check the credential of the other side and only accept socket from
@@ -1388,23 +1861,23 @@
      */ 
     errno = 0;
     is_phone_socket = 0;
-    
+
     err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds);
-    
+
     if (err == 0 && szCreds > 0) {
-      errno = 0;
-      pwd = getpwuid(creds.uid);
-      if (pwd != NULL) {
-	if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) {
-	  is_phone_socket = 1;
-	} else {
-	  LOGE("RILD can't accept socket from process %s", pwd->pw_name);
-	}
-      } else {
-	LOGE("Error on getpwuid() errno: %d", errno);
-      }
+        errno = 0;
+        pwd = getpwuid(creds.uid);
+        if (pwd != NULL) {
+            if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) {
+                is_phone_socket = 1;
+            } else {
+                LOGE("RILD can't accept socket from process %s", pwd->pw_name);
+            }
+        } else {
+            LOGE("Error on getpwuid() errno: %d", errno);
+        }
     } else {
-      LOGD("Error on getsockopt() errno: %d", errno);
+        LOGD("Error on getsockopt() errno: %d", errno);
     }
 
     if ( !is_phone_socket ) {
@@ -1448,8 +1921,7 @@
     free(args);
 }
 
-static void debugCallback (int fd, short flags, void *param)
-{
+static void debugCallback (int fd, short flags, void *param) {
     int acceptFD, option;
     struct sockaddr_un peeraddr;
     socklen_t socklen = sizeof (peeraddr);
@@ -1543,14 +2015,14 @@
             issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0);
             break;
         case 6:
-            LOGI("Debug port: Setup PDP, Apn :%s\n", args[1]);
+            LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
             actData[0] = args[1];
-            issueLocalRequest(RIL_REQUEST_SETUP_DEFAULT_PDP, &actData, 
+            issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, 
                               sizeof(actData));
             break;
         case 7:
-            LOGI("Debug port: Deactivate PDP");
-            issueLocalRequest(RIL_REQUEST_DEACTIVATE_DEFAULT_PDP, &deactData, 
+            LOGI("Debug port: Deactivate Data Call");
+            issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, 
                               sizeof(deactData));
             break;
         case 8:
@@ -1577,8 +2049,7 @@
 }
 
 
-static void userTimerCallback (int fd, short flags, void *param)
-{
+static void userTimerCallback (int fd, short flags, void *param) {
     UserCallbackInfo *p_info;
 
     p_info = (UserCallbackInfo *)param;
@@ -1596,8 +2067,7 @@
 
 
 static void *
-eventLoop(void *param)
-{
+eventLoop(void *param) {
     int ret;
     int filedes[2];
 
@@ -1635,8 +2105,7 @@
 }
 
 extern "C" void 
-RIL_startEventLoop(void)
-{
+RIL_startEventLoop(void) {
     int ret;
     pthread_attr_t attr;
     
@@ -1666,8 +2135,7 @@
 }
 
 extern "C" void 
-RIL_register (const RIL_RadioFunctions *callbacks)
-{
+RIL_register (const RIL_RadioFunctions *callbacks) {
     int ret;
     int flags;
 
@@ -1692,11 +2160,11 @@
 
     // Little self-check
 
-    for (int i = 0; i < (int)NUM_ELEMS(s_commands) ; i++) {
+    for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) {
         assert(i == s_commands[i].requestNumber);
     }
 
-    for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses) ; i++) {
+    for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
         assert(i + RIL_UNSOL_RESPONSE_BASE 
                 == s_unsolResponses[i].requestNumber);
     }
@@ -1769,8 +2237,7 @@
 }
 
 static int
-checkAndDequeueRequestInfo(struct RequestInfo *pRI)
-{
+checkAndDequeueRequestInfo(struct RequestInfo *pRI) {
     int ret = 0;
     
     if (pRI == NULL) {
@@ -1798,8 +2265,7 @@
 
 
 extern "C" void
-RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen)
-{
+RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
     RequestInfo *pRI;
     int ret;
     size_t errorOffset;
@@ -1856,14 +2322,12 @@
 
 
 static void
-grabPartialWakeLock()
-{
+grabPartialWakeLock() {
     acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME);
 }
 
 static void
-releaseWakeLock()
-{
+releaseWakeLock() {
     release_wake_lock(ANDROID_WAKE_LOCK_NAME);
 }
 
@@ -1871,8 +2335,7 @@
  * Timer callback to put us back to sleep before the default timeout
  */
 static void
-wakeTimeoutCallback (void *param)
-{
+wakeTimeoutCallback (void *param) {
     // We're using "param != NULL" as a cancellation mechanism
     if (param == NULL) {
         //LOGD("wakeTimeout: releasing wake lock");
@@ -2011,7 +2474,6 @@
 static UserCallbackInfo *
 internalRequestTimedCallback (RIL_TimedCallback callback, void *param, 
                                 const struct timeval *relativeTime)
-
 {
     struct timeval myRelativeTime;
     UserCallbackInfo *p_info;
@@ -2040,14 +2502,12 @@
 
 extern "C" void
 RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, 
-                                const struct timeval *relativeTime)
-{
+                                const struct timeval *relativeTime) {
     internalRequestTimedCallback (callback, param, relativeTime);
 }
 
 const char *
-failCauseToString(RIL_Errno e)
-{
+failCauseToString(RIL_Errno e) {
     switch(e) {
         case RIL_E_SUCCESS: return "E_SUCCESS";
         case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE";
@@ -2060,26 +2520,34 @@
         case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL";
         case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
         case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY";
+        case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT";
+#ifdef FEATURE_MULTIMODE_ANDROID 
+        case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE";
+        case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED";
+#endif
         default: return "<unknown error>";
     }
 }
 
 const char *
-radioStateToString(RIL_RadioState s)
-{
+radioStateToString(RIL_RadioState s) {
     switch(s) {
         case RADIO_STATE_OFF: return "RADIO_OFF";
         case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE";
         case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY";
         case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT";
         case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY";
+        case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY";
+        case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY";
+        case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
+        case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
+        case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
         default: return "<unknown state>";
     }
 }
 
 const char *
-callStateToString(RIL_CallState s)
-{
+callStateToString(RIL_CallState s) {
     switch(s) {
         case RIL_CALL_ACTIVE : return "ACTIVE";
         case RIL_CALL_HOLDING: return "HOLDING";
@@ -2092,8 +2560,7 @@
 }
 
 const char *
-requestToString(int request) 
-{
+requestToString(int request) {
 /*
  cat libs/telephony/ril_commands.h \
  | egrep "^ *{RIL_" \
@@ -2132,7 +2599,7 @@
         case RIL_REQUEST_DTMF: return "DTMF";
         case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
         case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
-        case RIL_REQUEST_SETUP_DEFAULT_PDP: return "SETUP_DEFAULT_PDP";
+        case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
         case RIL_REQUEST_SIM_IO: return "SIM_IO";
         case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
         case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
@@ -2146,7 +2613,7 @@
         case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
         case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
         case RIL_REQUEST_ANSWER: return "ANSWER";
-        case RIL_REQUEST_DEACTIVATE_DEFAULT_PDP: return "DEACTIVATE_DEFAULT_PDP";
+        case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
         case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
         case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
         case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
@@ -2164,13 +2631,13 @@
         case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
         case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
         case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
-        case RIL_REQUEST_LAST_PDP_FAIL_CAUSE: return "LAST_PDP_FAIL_CAUSE";
-        case RIL_REQUEST_PDP_CONTEXT_LIST: return "PDP_CONTEXT_LIST";
+        case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
+        case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
         case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
         case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
         case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
-	    case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
-	    case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
+        case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
+        case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
         case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
         case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
         case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
@@ -2179,7 +2646,27 @@
         case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
         case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
         case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
-
+        case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION";
+        case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
+        case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
+        case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
+        case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
+        case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
+        case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
+        case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
+        case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
+        case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
+        case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
+        case RIL_REQUEST_GET_BROADCAST_CONFIG:return"GET_BROADCAST_CONFIG";
+        case RIL_REQUEST_SET_BROADCAST_CONFIG:return"SET_BROADCAST_CONFIG";
+        case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG:return "CDMA_GET_BROADCAST_CONFIG";
+        case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG:return "SET_CDMA_BROADCAST_CONFIG";
+        case RIL_REQUEST_BROADCAST_ACTIVATION:return "BROADCAST_ACTIVATION"; 
+        case RIL_REQUEST_CDMA_VALIDATE_AKEY: return"CDMA_VALIDATE_AKEY";
+        case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
+        case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
+        case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
+        case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
         case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
         case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
         case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED";
@@ -2196,9 +2683,13 @@
         case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
         case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
         case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
-        case RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED: return "UNSOL_PDP_CONTEXT_LIST_CHANGED";
+        case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
         case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
         case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
+        case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
+        case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
+        case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
+        case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
         default: return "<unknown request>";
     }
 }
diff --git a/libril/ril_commands.h b/libril/ril_commands.h
index a097da0..7ba209f 100644
--- a/libril/ril_commands.h
+++ b/libril/ril_commands.h
@@ -15,7 +15,7 @@
 ** limitations under the License.
 */
     {0, NULL, NULL},                   //none
-    {RIL_REQUEST_GET_SIM_STATUS,dispatchVoid, responseInts},
+    {RIL_REQUEST_GET_SIM_STATUS, dispatchVoid, responseSimStatus},
     {RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseVoid},
     {RIL_REQUEST_ENTER_SIM_PUK, dispatchStrings, responseVoid},
     {RIL_REQUEST_ENTER_SIM_PIN2, dispatchStrings, responseVoid},
@@ -41,7 +41,7 @@
     {RIL_REQUEST_DTMF, dispatchString, responseVoid},
     {RIL_REQUEST_SEND_SMS, dispatchStrings, responseSMS},
     {RIL_REQUEST_SEND_SMS_EXPECT_MORE, dispatchStrings, responseSMS},
-    {RIL_REQUEST_SETUP_DEFAULT_PDP, dispatchStrings, responseStrings},
+    {RIL_REQUEST_SETUP_DATA_CALL, dispatchStrings, responseStrings},
     {RIL_REQUEST_SIM_IO, dispatchSIM_IO, responseSIM_IO},
     {RIL_REQUEST_SEND_USSD, dispatchString, responseVoid},
     {RIL_REQUEST_CANCEL_USSD, dispatchVoid, responseVoid},
@@ -55,7 +55,7 @@
     {RIL_REQUEST_GET_IMEI, dispatchVoid, responseString},
     {RIL_REQUEST_GET_IMEISV, dispatchVoid, responseString},
     {RIL_REQUEST_ANSWER,dispatchVoid, responseVoid},
-    {RIL_REQUEST_DEACTIVATE_DEFAULT_PDP, dispatchStrings, responseVoid},
+    {RIL_REQUEST_DEACTIVATE_DATA_CALL, dispatchStrings, responseVoid},
     {RIL_REQUEST_QUERY_FACILITY_LOCK, dispatchStrings, responseInts},    
     {RIL_REQUEST_SET_FACILITY_LOCK, dispatchStrings, responseVoid},
     {RIL_REQUEST_CHANGE_BARRING_PASSWORD, dispatchStrings, responseVoid},
@@ -70,8 +70,8 @@
     {RIL_REQUEST_SET_MUTE, dispatchInts, responseVoid},
     {RIL_REQUEST_GET_MUTE, dispatchVoid, responseInts},
     {RIL_REQUEST_QUERY_CLIP, dispatchVoid, responseInts},
-    {RIL_REQUEST_LAST_PDP_FAIL_CAUSE, dispatchVoid, responseInts},
-    {RIL_REQUEST_PDP_CONTEXT_LIST, dispatchVoid, responseContexts},
+    {RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, dispatchVoid, responseInts},
+    {RIL_REQUEST_DATA_CALL_LIST, dispatchVoid, responseDataCallList}, 
     {RIL_REQUEST_RESET_RADIO, dispatchVoid, responseVoid},
     {RIL_REQUEST_OEM_HOOK_RAW, dispatchRaw, responseRaw},
     {RIL_REQUEST_OEM_HOOK_STRINGS, dispatchStrings, responseStrings},
@@ -90,4 +90,26 @@
     {RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, dispatchInts, responseVoid},
     {RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, dispatchVoid, responseInts},
     {RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, dispatchVoid, responseCellList},
-    {RIL_REQUEST_SET_LOCATION_UPDATES, dispatchInts, responseVoid}
+    {RIL_REQUEST_SET_LOCATION_UPDATES, dispatchInts, responseVoid},
+    {RIL_REQUEST_CDMA_SET_SUBSCRIPTION, dispatchInts, responseVoid},
+    {RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, dispatchInts, responseVoid},
+    {RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, dispatchVoid, responseInts},
+    {RIL_REQUEST_SET_TTY_MODE, dispatchInts, responseVoid},
+    {RIL_REQUEST_QUERY_TTY_MODE, dispatchVoid, responseInts},
+    {RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, dispatchInts, responseVoid},
+    {RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, dispatchVoid, responseInts},
+    {RIL_REQUEST_CDMA_FLASH, dispatchString, responseVoid},
+    {RIL_REQUEST_CDMA_BURST_DTMF, dispatchString, responseVoid},
+    {RIL_REQUEST_CDMA_SEND_SMS, dispatchCdmaSms, responseVoid}, //new DISPATCH function
+    {RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, dispatchCdmaSmsAck, responseVoid}, //new DISPATCH function
+    {RIL_REQUEST_GET_BROADCAST_CONFIG, dispatchVoid, responseBrSmsCnf}, //new RESPONSE function
+    {RIL_REQUEST_SET_BROADCAST_CONFIG, dispatchBrSmsCnf, responseVoid}, //new DISPATCH function
+    {RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG, dispatchVoid, responseCdmaBrCnf}, //new RESPONSE function
+    {RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, dispatchCdmaBrSmsCnf, responseVoid}, //new DISPATCH unction
+    {RIL_REQUEST_BROADCAST_ACTIVATION, dispatchInts, responseVoid},
+    {RIL_REQUEST_CDMA_VALIDATE_AKEY, dispatchString, responseVoid},
+    {RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, dispatchInts, responseVoid},
+    {RIL_REQUEST_CDMA_SUBSCRIPTION, dispatchVoid, responseStrings},//Assumption Made here to use DispatchVoid!
+    {RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM, dispatchRilCdmaSmsWriteArgs, responseInts}, //new DISPATCH function
+    {RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, dispatchInts, responseVoid},
+    {RIL_REQUEST_DEVICE_IDENTITY, dispatchVoid, responseStrings}
diff --git a/libril/ril_event.cpp b/libril/ril_event.cpp
index 46e2cc9..e40e72b 100644
--- a/libril/ril_event.cpp
+++ b/libril/ril_event.cpp
@@ -2,16 +2,16 @@
 **
 ** Copyright 2008, The Android Open Source Project
 **
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 
@@ -89,8 +89,8 @@
     dlog("~~~~~~~~~~~~~~~~~~");
 }
 #else
-#define dlog(x...)
-#define dump_event(x)
+#define dlog(x...) do {} while(0)
+#define dump_event(x) do {} while(0)
 #endif
 
 static void getNow(struct timeval * tv)
@@ -151,7 +151,7 @@
                 n = rev->fd;
             }
         }
-        nfds = n + 1; 
+        nfds = n + 1;
         dlog("~~~~ nfds = %d ~~~~", nfds);
     }
 }
@@ -207,7 +207,7 @@
     while (ev != &pending_list) {
         struct ril_event * next = ev->next;
         removeFromList(ev);
-        ev->func(ev->fd, 0, ev->param); 
+        ev->func(ev->fd, 0, ev->param);
         ev = next;
     }
     dlog("~~~~ -firePending ~~~~");
@@ -277,7 +277,7 @@
             if (ev->fd >= nfds) nfds = ev->fd+1;
             dlog("~~~~ nfds = %d ~~~~", nfds);
             break;
-        } 
+        }
     }
     MUTEX_RELEASE();
     dlog("~~~~ -ril_event_add ~~~~");
@@ -306,7 +306,7 @@
         }
         // list now points to the first event older than ev
         addToList(ev, list);
-    } 
+    }
 
     MUTEX_RELEASE();
     dlog("~~~~ -ril_timer_add ~~~~");
@@ -328,6 +328,20 @@
     dlog("~~~~ -ril_event_del ~~~~");
 }
 
+#if DEBUG
+static void printReadies(fd_set * rfds)
+{
+    for (int i = 0; (i < MAX_FD_EVENTS); i++) {
+        struct ril_event * rev = watch_table[i];
+        if (rev != NULL && FD_ISSET(rev->fd, rfds)) {
+          dlog("DON: fd=%d is ready", rev->fd);
+        }
+    }
+}
+#else
+#define printReadies(rfds) do {} while(0)
+#endif
+
 void ril_event_loop()
 {
     int n;
@@ -348,7 +362,9 @@
             dlog("~~~~ blocking for %ds + %dus ~~~~", (int)tv.tv_sec, (int)tv.tv_usec);
             ptv = &tv;
         }
+        printReadies(&rfds);
         n = select(nfds, &rfds, NULL, NULL, ptv);
+        printReadies(&rfds);
         dlog("~~~~ %d events fired ~~~~", n);
         if (n < 0) {
             if (errno == EINTR) continue;
diff --git a/libril/ril_unsol_commands.h b/libril/ril_unsol_commands.h
index 39a344f..f89082b 100644
--- a/libril/ril_unsol_commands.h
+++ b/libril/ril_unsol_commands.h
@@ -24,7 +24,7 @@
     {RIL_UNSOL_ON_USSD_REQUEST, responseVoid, DONT_WAKE},
     {RIL_UNSOL_NITZ_TIME_RECEIVED, responseString, WAKE_PARTIAL},
     {RIL_UNSOL_SIGNAL_STRENGTH, responseInts, DONT_WAKE},
-    {RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED, responseContexts, WAKE_PARTIAL},
+    {RIL_UNSOL_DATA_CALL_LIST_CHANGED, responseDataCallList, WAKE_PARTIAL},
     {RIL_UNSOL_SUPP_SVC_NOTIFICATION, responseSsn, WAKE_PARTIAL},
     {RIL_UNSOL_STK_SESSION_END, responseVoid, WAKE_PARTIAL},
     {RIL_UNSOL_STK_PROACTIVE_COMMAND, responseString, WAKE_PARTIAL},
@@ -33,6 +33,7 @@
     {RIL_UNSOL_SIM_SMS_STORAGE_FULL, responseVoid, WAKE_PARTIAL},
     {RIL_UNSOL_SIM_REFRESH, responseInts, WAKE_PARTIAL},
     {RIL_UNSOL_CALL_RING, responseVoid, WAKE_PARTIAL},
+
     /* import unsolicited CDMA notifications, need change response type
      * of CDMA_NEW_SMS when do real CDMA merge
      */
diff --git a/reference-cdma-sms/Android.mk b/reference-cdma-sms/Android.mk
new file mode 100644
index 0000000..d0fd586
--- /dev/null
+++ b/reference-cdma-sms/Android.mk
@@ -0,0 +1,23 @@
+# Copyright 2008 The Android Open Source Project

+

+LOCAL_PATH:= $(call my-dir)

+include $(CLEAR_VARS)

+

+LOCAL_SRC_FILES:= \

+    reference-cdma-sms.c

+

+LOCAL_SHARED_LIBRARIES := \

+	libcutils libutils libril

+

+	# for asprinf

+LOCAL_CFLAGS := -D_GNU_SOURCE

+

+LOCAL_C_INCLUDES := $(KERNEL_HEADERS)

+

+LOCAL_SHARED_LIBRARIES += \

+  libcutils libutils

+LOCAL_LDLIBS += -lpthread

+LOCAL_MODULE:= libreference-cdma-sms

+LOCAL_PRELINK_MODULE := false

+include $(BUILD_SHARED_LIBRARY)

+

diff --git a/reference-cdma-sms/reference-cdma-sms.c b/reference-cdma-sms/reference-cdma-sms.c
new file mode 100644
index 0000000..8777ded
--- /dev/null
+++ b/reference-cdma-sms/reference-cdma-sms.c
@@ -0,0 +1,35 @@
+/* 
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "reference-cdma-sms.h"
+
+#undef LOG_TAG
+#define LOG_TAG "CDMA"
+#include <utils/Log.h>
+
+RIL_Errno wmsts_ril_cdma_decode_sms( RIL_CDMA_Encoded_SMS *  encoded_sms,
+        RIL_CDMA_SMS_ClientBd * client_bd) {
+    LOGE("ril_cdma_decode_sms function not implemented\n");
+    return RIL_E_GENERIC_FAILURE;
+  }
+
+RIL_Errno wmsts_ril_cdma_encode_sms(RIL_CDMA_SMS_ClientBd * client_bd, 
+        RIL_CDMA_Encoded_SMS *  encoded_sms) {
+
+    LOGE("ril_cdma_encode_sms function not implemented\n");
+    return RIL_E_GENERIC_FAILURE;
+  }
diff --git a/reference-cdma-sms/reference-cdma-sms.h b/reference-cdma-sms/reference-cdma-sms.h
new file mode 100644
index 0000000..a82f6eb
--- /dev/null
+++ b/reference-cdma-sms/reference-cdma-sms.h
@@ -0,0 +1,70 @@
+/* 
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef REFERENCE_CDMA_SMS_H 
+#define REFERENCE_CDMA_SMS_H 1
+
+#include <telephony/ril.h>
+#include <telephony/ril_cdma_sms.h>
+
+/**
+ * TODO T:
+ * check if Bearer data subparameter mask values (CDMS_SMA_MASK_*) have to be moved to ril_cdma_sms.h
+ * vendor implementation needs to use ril_cdma_decode_sms and ril_cdma_encode_sms as function names
+ */
+
+/** Bearer data subparameter mask values: */
+// TODO T: use enum from vendor .h
+#define WMS_MASK_BD_NULL                 0x00000000
+#define WMS_MASK_BD_MSG_ID               0x00000001
+#define WMS_MASK_BD_USER_DATA            0x00000002
+#define WMS_MASK_BD_USER_RESP            0x00000004
+#define WMS_MASK_BD_MC_TIME              0x00000008
+#define WMS_MASK_BD_VALID_ABS            0x00000010
+#define WMS_MASK_BD_VALID_REL            0x00000020
+#define WMS_MASK_BD_DEFER_ABS            0x00000040
+#define WMS_MASK_BD_DEFER_REL            0x00000080
+#define WMS_MASK_BD_PRIORITY             0x00000100
+#define WMS_MASK_BD_PRIVACY              0x00000200
+#define WMS_MASK_BD_REPLY_OPTION         0x00000400
+#define WMS_MASK_BD_NUM_OF_MSGS          0x00000800
+#define WMS_MASK_BD_ALERT                0x00001000
+#define WMS_MASK_BD_LANGUAGE             0x00002000
+#define WMS_MASK_BD_CALLBACK             0x00004000
+#define WMS_MASK_BD_DISPLAY_MODE         0x00008000
+#define WMS_MASK_BD_SCPT_DATA            0x00010000
+#define WMS_MASK_BD_SCPT_RESULT          0x00020000
+#define WMS_MASK_BD_DEPOSIT_INDEX        0x00040000
+#define WMS_MASK_BD_DELIVERY_STATUS      0x00080000
+#define WMS_MASK_BD_IP_ADDRESS           0x10000000
+#define WMS_MASK_BD_RSN_NO_NOTIFY        0x20000000
+#define WMS_MASK_BD_OTHER                0x40000000
+
+
+/** Decode a CDMA SMS Message. */
+RIL_Errno wmsts_ril_cdma_decode_sms (
+    RIL_CDMA_Encoded_SMS *  encoded_sms,   /* Input */
+    RIL_CDMA_SMS_ClientBd * client_bd      /* Output */
+);
+
+/** Encode a CDMA SMS Message. */
+RIL_Errno wmsts_ril_cdma_encode_sms (
+    RIL_CDMA_SMS_ClientBd * client_bd,     /* Input */
+    RIL_CDMA_Encoded_SMS *  encoded_sms    /* Output */
+);
+
+#endif /*REFERENCE_CDMA_SMS_H*/
+
diff --git a/reference-ril/reference-ril.c b/reference-ril/reference-ril.c
index e2c9829..f7faf8e 100644
--- a/reference-ril/reference-ril.c
+++ b/reference-ril/reference-ril.c
@@ -39,7 +39,7 @@
 
 #define MAX_AT_RESPONSE 0x1000
 
-/* pathname returned from RIL_REQUEST_SETUP_DEFAULT_PDP */
+/* pathname returned from RIL_REQUEST_SETUP_DATA_CALL / RIL_REQUEST_SETUP_DEFAULT_PDP */
 #define PPP_TTY_PATH "/dev/omap_csmi_tty1"
 
 #ifdef USE_TI_COMMANDS
@@ -63,7 +63,7 @@
 static const char *getVersion();
 static int isRadioOn();
 static int getSIMStatus();
-static void onPDPContextListChanged(void *param);
+static void onDataCallListChanged(void *param);
 
 extern const char * requestToString(int request);
 
@@ -268,19 +268,19 @@
     RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
 }
 
-static void requestOrSendPDPContextList(RIL_Token *t);
+static void requestOrSendDataCallList(RIL_Token *t);
 
-static void onPDPContextListChanged(void *param)
+static void onDataCallListChanged(void *param)
 {
-    requestOrSendPDPContextList(NULL);
+    requestOrSendDataCallList(NULL);
 }
 
-static void requestPDPContextList(void *data, size_t datalen, RIL_Token t)
+static void requestDataCallList(void *data, size_t datalen, RIL_Token t)
 {
-    requestOrSendPDPContextList(&t);
+    requestOrSendDataCallList(&t);
 }
 
-static void requestOrSendPDPContextList(RIL_Token *t)
+static void requestOrSendDataCallList(RIL_Token *t)
 {
     ATResponse *p_response;
     ATLine *p_cur;
@@ -293,7 +293,7 @@
         if (t != NULL)
             RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0);
         else
-            RIL_onUnsolicitedResponse(RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED,
+            RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED,
                                       NULL, 0);
         return;
     }
@@ -302,8 +302,8 @@
          p_cur = p_cur->p_next)
         n++;
 
-    RIL_PDP_Context_Response *responses =
-        alloca(n * sizeof(RIL_PDP_Context_Response));
+    RIL_Data_Call_Response *responses =
+        alloca(n * sizeof(RIL_Data_Call_Response));
 
     int i;
     for (i = 0; i < n; i++) {
@@ -314,7 +314,7 @@
         responses[i].address = "";
     }
 
-    RIL_PDP_Context_Response *response = responses;
+    RIL_Data_Call_Response *response = responses;
     for (p_cur = p_response->p_intermediates; p_cur != NULL;
          p_cur = p_cur->p_next) {
         char *line = p_cur->line;
@@ -341,7 +341,7 @@
         if (t != NULL)
             RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0);
         else
-            RIL_onUnsolicitedResponse(RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED,
+            RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED,
                                       NULL, 0);
         return;
     }
@@ -399,11 +399,11 @@
 
     if (t != NULL)
         RIL_onRequestComplete(*t, RIL_E_SUCCESS, responses,
-                              n * sizeof(RIL_PDP_Context_Response));
+                              n * sizeof(RIL_Data_Call_Response));
     else
-        RIL_onUnsolicitedResponse(RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED,
+        RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED,
                                   responses,
-                                  n * sizeof(RIL_PDP_Context_Response));
+                                  n * sizeof(RIL_Data_Call_Response));
 
     return;
 
@@ -411,7 +411,7 @@
     if (t != NULL)
         RIL_onRequestComplete(*t, RIL_E_GENERIC_FAILURE, NULL, 0);
     else
-        RIL_onUnsolicitedResponse(RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED,
+        RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED,
                                   NULL, 0);
 
     at_response_free(p_response);
@@ -941,7 +941,7 @@
     at_response_free(p_response);
 }
 
-static void requestSetupDefaultPDP(void *data, size_t datalen, RIL_Token t)
+static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t)
 {
     const char *apn;
     char *cmd;
@@ -949,7 +949,7 @@
     ATResponse *p_response = NULL;
     char *response[2] = { "1", PPP_TTY_PATH };
 
-    apn = ((const char **)data)[0];
+    apn = ((const char **)data)[2];
 
 #ifdef USE_TI_COMMANDS
     // Config for multislot class 10 (probably default anyway eh?)
@@ -1347,8 +1347,8 @@
         case RIL_REQUEST_SEND_SMS:
             requestSendSMS(data, datalen, t);
             break;
-        case RIL_REQUEST_SETUP_DEFAULT_PDP:
-            requestSetupDefaultPDP(data, datalen, t);
+        case RIL_REQUEST_SETUP_DATA_CALL:
+            requestSetupDataCall(data, datalen, t);
             break;
         case RIL_REQUEST_SMS_ACKNOWLEDGE:
             requestSMSAcknowledge(data, datalen, t);
@@ -1405,8 +1405,8 @@
             at_send_command("AT+COPS=0", NULL);
             break;
 
-        case RIL_REQUEST_PDP_CONTEXT_LIST:
-            requestPDPContextList(data, datalen, t);
+        case RIL_REQUEST_DATA_CALL_LIST:
+            requestDataCallList(data, datalen, t);
             break;
 
         case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE:
@@ -1831,7 +1831,7 @@
             RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED,
             NULL, 0);
 #ifdef WORKAROUND_FAKE_CGEV
-        RIL_requestTimedCallback (onPDPContextListChanged, NULL, NULL);
+        RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); //TODO use new function
 #endif /* WORKAROUND_FAKE_CGEV */
     } else if (strStartsWith(s,"+CREG:")
                 || strStartsWith(s,"+CGREG:")
@@ -1840,7 +1840,7 @@
             RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED,
             NULL, 0);
 #ifdef WORKAROUND_FAKE_CGEV
-        RIL_requestTimedCallback (onPDPContextListChanged, NULL, NULL);
+        RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL); 
 #endif /* WORKAROUND_FAKE_CGEV */
     } else if (strStartsWith(s, "+CMT:")) {
         RIL_onUnsolicitedResponse (
@@ -1853,13 +1853,13 @@
     } else if (strStartsWith(s, "+CGEV:")) {
         /* Really, we can ignore NW CLASS and ME CLASS events here,
          * but right now we don't since extranous
-         * RIL_UNSOL_PDP_CONTEXT_LIST_CHANGED calls are tolerated
+         * RIL_UNSOL_DATA_CALL_LIST_CHANGED calls are tolerated
          */
         /* can't issue AT commands here -- call on main thread */
-        RIL_requestTimedCallback (onPDPContextListChanged, NULL, NULL);
+        RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL);
 #ifdef WORKAROUND_FAKE_CGEV
     } else if (strStartsWith(s, "+CME ERROR: 150")) {
-        RIL_requestTimedCallback (onPDPContextListChanged, NULL, NULL);
+        RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL);
 #endif /* WORKAROUND_FAKE_CGEV */
     }
 }
@@ -2068,3 +2068,4 @@
 }
 
 #endif /* RIL_SHLIB */
+