OSDN Git Service

Code drop from //branches/cupcake/...@124589
authorThe Android Open Source Project <initial-contribution@android.com>
Thu, 18 Dec 2008 02:05:51 +0000 (18:05 -0800)
committerThe Android Open Source Project <initial-contribution@android.com>
Thu, 18 Dec 2008 02:05:51 +0000 (18:05 -0800)
include/telephony/ril.h
libril/ril.cpp
libril/ril_commands.h
libril/ril_event.cpp
reference-ril/Android.mk

index c86f487..fa1948f 100644 (file)
@@ -172,6 +172,16 @@ typedef struct {
     int             timeSeconds; /* for CF no reply only */
 }RIL_CallForwardInfo;
 
+typedef struct {
+   char * cid;         /* cell id in 2G,  Primary Scrambling Code in 3G
+                        * hexadecimal format.
+                        * Valid values are 0x00000000 - 0xffffffff.
+                        */
+   int    rssi;        /* Received RSSI in 2G,
+                        * Level index of CPICH Received Signal Code Power in 3G
+                        */
+} RIL_NeighboringCell;
+
 /* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
 typedef enum {
     CALL_FAIL_NORMAL = 16,
@@ -1830,17 +1840,7 @@ typedef enum {
  * Request neighboring cell id in GSM network
  *
  * "data" is NULL
- * "response" is a char **
- * ((char *)response)[0] is the number of available cell ids, range from 0 to 6
- * ((char *)response)[1] is CID[0] if available or NULL if not
- * ((char *)response)[2] is CID[1] if available or NULL if not
- * ((char *)response)[3] is CID[2] if available or NULL if not
- * ((char *)response)[4] is CID[3] if available or NULL if not
- * ((char *)response)[5] is CID[4] if available or NULL if not
- * ((char *)response)[6] is CID[5] if available or NULL if not
- *
- * CIDs are in hexadecimal format.  Valid values are 0x00000000 - 0xffffffff.
- *
+ * "response" must be a " const RIL_NeighboringCell** "
  *
  * Valid errors:
  *  SUCCESS
index f9c03b3..7a8c4a9 100644 (file)
@@ -22,6 +22,7 @@
 #include <cutils/jstring.h>
 #include <cutils/record_stream.h>
 #include <utils/Log.h>
+#include <utils/SystemClock.h>
 #include <pthread.h>
 #include <utils/Parcel.h>
 #include <cutils/jstring.h>
@@ -211,6 +212,7 @@ static int responseCallForwards(Parcel &p, void *response, size_t responselen);
 static int responseContexts(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 responseCellList(Parcel &p, void *response, size_t responselen);
 
 extern "C" const char * requestToString(int request);
 extern "C" const char * failCauseToString(RIL_Errno);
@@ -1182,6 +1184,42 @@ static int responseSsn(Parcel &p, void *response, size_t responselen)
     return 0;
 }
 
+static int responseCellList(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_NeighboringCell *) != 0) {
+        LOGE("invalid response length %d expected multiple of %d\n",
+            (int)responselen, (int)sizeof (RIL_NeighboringCell *));
+        return RIL_ERRNO_INVALID_RESPONSE;
+    }
+
+    startResponse;
+    /* number of cell info's */
+    num = responselen / sizeof(RIL_NeighboringCell *);
+    p.writeInt32(num);
+
+    for (int i = 0 ; i < num ; i++) {
+        RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i];
+
+        /* each cell info */
+        p.writeInt32(p_cur->rssi);
+        writeStringToParcel (p, p_cur->cid);
+
+        appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf,
+            p_cur->cid, p_cur->rssi);
+    }
+    removeLastChar;
+    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
@@ -1903,10 +1941,9 @@ void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
 
 
         case RIL_UNSOL_NITZ_TIME_RECEIVED: 
-            // FIXME use monotonic system time instead
-            time_t timeReceived = time(NULL);
+            int64_t timeReceived = elapsedRealtime();
             // Store the time this was received in case it is delayed
-            p.writeInt32(timeReceived);            
+            p.writeInt64(timeReceived);
         break;
     }    
     
index 85831fa..a097da0 100644 (file)
@@ -89,5 +89,5 @@
     {RIL_REQUEST_EXPLICIT_CALL_TRANSFER, dispatchVoid, responseVoid},
     {RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, dispatchInts, responseVoid},
     {RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, dispatchVoid, responseInts},
-    {RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, dispatchVoid, responseStrings},
+    {RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, dispatchVoid, responseCellList},
     {RIL_REQUEST_SET_LOCATION_UPDATES, dispatchInts, responseVoid}
index ed99a12..46e2cc9 100644 (file)
@@ -34,6 +34,7 @@ static pthread_mutex_t listMutex;
 #define MUTEX_INIT() pthread_mutex_init(&listMutex, NULL)
 #define MUTEX_DESTROY() pthread_mutex_destroy(&listMutex)
 
+#ifndef timeradd
 #define timeradd(tvp, uvp, vvp)                                                \
        do {                                                            \
                (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
@@ -43,6 +44,7 @@ static pthread_mutex_t listMutex;
                        (vvp)->tv_usec -= 1000000;                      \
                }                                                       \
        } while (0)
+#endif
 
 #ifndef timercmp
 #define timercmp(a, b, op)               \
index cb01d51..7ec1f97 100644 (file)
@@ -19,15 +19,15 @@ LOCAL_CFLAGS := -D_GNU_SOURCE
 
 LOCAL_C_INCLUDES := $(KERNEL_HEADERS)
 
-ifeq ($(TARGET_PRODUCT),sooner)
+ifeq ($(TARGET_DEVICE),sooner)
   LOCAL_CFLAGS += -DOMAP_CSMI_POWER_CONTROL -DUSE_TI_COMMANDS 
 endif
 
-ifeq ($(TARGET_PRODUCT),surf)
+ifeq ($(TARGET_DEVICE),surf)
   LOCAL_CFLAGS += -DPOLL_CALL_STATE -DUSE_QMI
 endif
 
-ifeq ($(TARGET_PRODUCT),dream)
+ifeq ($(TARGET_DEVICE),dream)
   LOCAL_CFLAGS += -DPOLL_CALL_STATE -DUSE_QMI
 endif