OSDN Git Service

Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)
[android-x86/hardware-ril.git] / mock-ril / src / cpp / mock_ril.cpp
index e856b5e..646c322 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <telephony/ril.h>
 #include <stdio.h>
 #include <assert.h>
 #include <string.h>
@@ -31,8 +30,9 @@
 #include <termios.h>
 
 #include <v8.h>
+#include "ril.h"
 
-#include "ril.pb.h"
+#include "hardware/ril/mock-ril/src/proto/ril.pb.h"
 
 #include "ctrl_server.h"
 #include "logging.h"
@@ -59,7 +59,7 @@ extern void RIL_register(const RIL_RadioFunctions *callbacks);
 //#define MOCK_RIL_DEBUG
 #ifdef  MOCK_RIL_DEBUG
 
-#define DBG(...) LOGD(__VA_ARGS__)
+#define DBG(...) ALOGD(__VA_ARGS__)
 
 #else
 
@@ -243,7 +243,7 @@ class UnsolicitedThread : public WorkerThread {
 
     void * Worker(void *param)
     {
-        LOGD("UnsolicitedThread::Worker E param=%p", param);
+        ALOGD("UnsolicitedThread::Worker E param=%p", param);
 
         v8::Locker locker;
 
@@ -261,7 +261,7 @@ class UnsolicitedThread : public WorkerThread {
             v8::Locker locker;
         }
 
-        LOGD("UnsolicitedThread::Worker X param=%p", param);
+        ALOGD("UnsolicitedThread::Worker X param=%p", param);
 
         return NULL;
     }
@@ -270,6 +270,7 @@ class UnsolicitedThread : public WorkerThread {
 
 void startMockRil(v8::Handle<v8::Context> context) {
     v8::HandleScope handle_scope;
+    v8::TryCatch try_catch;
 
     // Get handle to startMockRil and call it.
     v8::Handle<v8::String> name = v8::String::New("startMockRil");
@@ -277,7 +278,16 @@ void startMockRil(v8::Handle<v8::Context> context) {
     v8::Handle<v8::Function> start =
             v8::Handle<v8::Function>::Cast(functionValue);
 
-    start->Call(context->Global(), 0, NULL);
+    v8::Handle<v8::Value> result = start->Call(context->Global(), 0, NULL);
+    if (try_catch.HasCaught()) {
+        LOGE("startMockRil error");
+        ReportException(&try_catch);
+        LOGE("FATAL ERROR: Unsable to startMockRil.");
+    } else {
+        v8::String::Utf8Value result_string(result);
+        LOGE("startMockRil result=%s", ToCString(result_string));
+    }
+
 }
 
 
@@ -286,7 +296,7 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc,
     int ret;
     pthread_attr_t attr;
 
-    LOGD("RIL_Init E: ----------------");
+    ALOGD("RIL_Init E: ----------------");
 
     // Initialize V8
     v8::V8::Initialize();
@@ -309,17 +319,6 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc,
 
     s_rilenv = &testEnv;
 
-#if 0
-    LOGD("RIL_Init run tests #####################");
-    testJsSupport(context);
-    testRequests(context);
-    experiments(context);
-    testWorker();
-    testWorkerV8(context);
-    testJs(context);
-    LOGD("RIL_Init tests completed ###############");
-#endif
-
     // load/run mock_ril.js
     char *buffer;
     int status = ReadFile("/sdcard/data/mock_ril.js", &buffer);
@@ -335,6 +334,16 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc,
     requestsInit(context, &s_requestWorkerQueue);
     responsesInit(context);
 
+#if 0
+    ALOGD("RIL_Init run tests #####################");
+    testJsSupport(context);
+    testRequests(context);
+    experiments(context);
+    testWorker();
+    testWorkerV8(context);
+    ALOGD("RIL_Init tests completed ###############");
+#endif
+
     // Register our call backs so when we startMockRil
     // and it wants to send unsolicited messages the
     // mock ril is registered
@@ -348,6 +357,6 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc,
     ut->Run(NULL);
 #endif
 
-    LOGD("RIL_Init X: ----------------");
+    ALOGD("RIL_Init X: ----------------");
     return &s_callbacks;
 }