am 9a2f5113: merge from open-source master
Merge commit '9a2f5113fd1db1e1605daad47b16b6f960045582'
* commit '9a2f5113fd1db1e1605daad47b16b6f960045582':
Add timer delete support to rild
diff --git a/include/telephony/ril.h b/include/telephony/ril.h
index 6e30d39..82d2ca3 100644
--- a/include/telephony/ril.h
+++ b/include/telephony/ril.h
@@ -1109,6 +1109,10 @@
* 8 - No Suitable Cells in this Location Area
* 9 - Network failure
* 10 - Persistent location update reject
+ * ((const char **)response)[14] is the Primary Scrambling Code of the current
+ * cell as described in TS 25.331, in hexadecimal
+ * format, or NULL if unknown or not registered
+ * to a UMTS network.
*
* Please note that registration state 4 ("unknown") is treated
* as "out of service" in the Android telephony system
@@ -2959,7 +2963,6 @@
*/
#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103
-
/***********************************************************************/
diff --git a/libril/ril.cpp b/libril/ril.cpp
index 271b666..4d0ea6f 100644
--- a/libril/ril.cpp
+++ b/libril/ril.cpp
@@ -3076,6 +3076,7 @@
case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
+ case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
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";
diff --git a/mock-ril/Android.mk b/mock-ril/Android.mk
new file mode 100644
index 0000000..9087cd1
--- /dev/null
+++ b/mock-ril/Android.mk
@@ -0,0 +1,43 @@
+# Copyright 2010 The Android Open Source Project
+
+# not currently building V8 for x86 targets
+ifeq ($(TARGET_ARCH),arm)
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ t.pb.cpp \
+ mock-ril.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils libutils libril
+
+LOCAL_STATIC_LIBRARIES := \
+ libprotobuf-cpp-2.3.0-lite libv8
+
+# for asprinf
+LOCAL_CFLAGS := -D_GNU_SOURCE -UNDEBUG -DGOOGLE_PROTOBUF_NO_RTTI
+
+LOCAL_C_INCLUDES := \
+ external/protobuf/src \
+ external/v8/include \
+ bionic \
+ $(KERNEL_HEADERS)
+
+# stlport conflicts with the host stl library
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libstlport
+LOCAL_C_INCLUDES += external/stlport/stlport
+endif
+
+# build shared library but don't require it be prelinked
+LOCAL_PRELINK_MODULE := false
+LOCAL_LDLIBS += -lpthread
+LOCAL_CFLAGS += -DMOCK_RIL -DRIL_SHLIB
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE:= libmock_ril
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif
diff --git a/mock-ril/MODULE_LICENSE_APACHE2 b/mock-ril/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mock-ril/MODULE_LICENSE_APACHE2
diff --git a/mock-ril/NOTICE b/mock-ril/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/mock-ril/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-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.
+
+ 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.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/mock-ril/README.txt b/mock-ril/README.txt
new file mode 100644
index 0000000..cd4d780
--- /dev/null
+++ b/mock-ril/README.txt
@@ -0,0 +1,28 @@
+Testing a new ril:
+
+1) On the device login in as root and remount file system so it's read/write:
+ $ adb root
+ restarting adbd as root
+
+ $ adb remount
+ remount succeeded
+
+2) Set rild.libpath to the name of the ril:
+ adb shell setprop rild.libpath /system/lib/libmock_ril.so
+
+ Using setprop makes the change temporary and the old ril will be
+ used after rebooting. (Another option is to set rild.libpath in
+ /data/local.prop, but don't forget to reboot for it to take effect).
+
+3) Compile and copy the ril to /system/lib/:
+ adb push out/target/product/passion/system/lib/libmock_ril.so /system/lib/
+
+4) To restart the ril, kill the currently running ril and the new one
+ will automatically be restarted. You can use the ps command to find
+ /system/bin/rild PID, 3212 below and kill it:
+ $ adb shell ps | grep rild
+ radio 3212 1 3224 628 ffffffff afd0e4fc S /system/bin/rild
+
+ $ adb shell kill 3212
+
+5) Make modifications, go to step 3.
diff --git a/mock-ril/mock-ril.cpp b/mock-ril/mock-ril.cpp
new file mode 100644
index 0000000..ea9897b
--- /dev/null
+++ b/mock-ril/mock-ril.cpp
@@ -0,0 +1,408 @@
+/**
+ * Copyright (C) 2010 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.
+ */
+
+// The LOG_TAG should start with "RIL" so it shows up in the radio log
+#define LOG_TAG "RIL-MOCK"
+
+#include <telephony/ril.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <alloca.h>
+#include <getopt.h>
+#include <sys/socket.h>
+#include <cutils/sockets.h>
+#include <termios.h>
+
+#include <queue>
+
+#include <utils/Log.h>
+
+#include "t.pb.h"
+#include <v8.h>
+
+#define MOCK_RIL_VER_STRING "Android Mock-ril 0.1"
+
+/**
+ * Forward declarations
+ */
+static void onRequest (int request, void *data, size_t datalen, RIL_Token t);
+static RIL_RadioState currentState();
+static int onSupports (int requestCode);
+static void onCancel (RIL_Token t);
+static const char *getVersion();
+
+extern const char * requestToString(int request);
+
+/*** Static Variables ***/
+static const RIL_RadioFunctions s_callbacks = {
+ RIL_VERSION,
+ onRequest,
+ currentState,
+ onSupports,
+ onCancel,
+ getVersion
+};
+
+static const struct RIL_Env *s_rilenv;
+
+static RIL_RadioState sState = RADIO_STATE_UNAVAILABLE;
+
+/**
+ * Call from RIL to us to make a RIL_REQUEST
+ *
+ * Must be completed with a call to RIL_onRequestComplete()
+ *
+ * RIL_onRequestComplete() may be called from any thread, before or after
+ * this function returns.
+ * * Will always be called from the same thread, so returning here implies
+ * that the radio is ready to process another command (whether or not
+ * the previous command has completed).
+ */
+static void onRequest (int request, void *data, size_t datalen, RIL_Token t)
+{
+ LOGD("onRequest: request=%d data=%p datalen=%d token=%p",
+ request, data, datalen, t);
+ s_rilenv->OnRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0);
+}
+
+/**
+ * Synchronous call from the RIL to us to return current radio state.
+ * RADIO_STATE_UNAVAILABLE should be the initial state.
+ */
+static RIL_RadioState currentState()
+{
+ LOGD("currentState: sState=%d", sState);
+ return sState;
+}
+
+/**
+ * Call from RIL to us to find out whether a specific request code
+ * is supported by this implementation.
+ *
+ * Return 1 for "supported" and 0 for "unsupported"
+ */
+
+static int
+onSupports (int requestCode)
+{
+ LOGD("onSupports: nothing supported at the moment, return 0");
+ return 0;
+}
+
+static void onCancel (RIL_Token t)
+{
+ LOGD("onCancel: ignorning");
+}
+
+static const char * getVersion(void)
+{
+ LOGD("getVersion: return '%s'", MOCK_RIL_VER_STRING);
+ return MOCK_RIL_VER_STRING;
+}
+
+
+// Extracts a C string from a V8 Utf8Value.
+const char* ToCString(const v8::String::Utf8Value& value) {
+ return *value ? *value : "<string conversion failed>";
+}
+
+// A javascript print function
+v8::Handle<v8::Value> Print(const v8::Arguments& args) {
+ bool first = true;
+ const int str_size = 1000;
+ char* str = new char[str_size];
+ int offset = 0;
+ for (int i = 0; i < args.Length(); i++) {
+ v8::HandleScope handle_scope;
+ if (first) {
+ first = false;
+ } else {
+ offset += snprintf(&str[offset], str_size, " ");
+ }
+ v8::String::Utf8Value strUtf8(args[i]);
+ const char* cstr = ToCString(strUtf8);
+ offset += snprintf(&str[offset], str_size, "%s", cstr);
+ }
+ LOGD("%s", str);
+ delete [] str;
+ return v8::Undefined();
+}
+
+// Report an exception
+void LogErrorMessage(v8::Handle<v8::Message> message,
+ const char *alternate_message) {
+ v8::HandleScope handle_scope;
+ if (message.IsEmpty()) {
+ // V8 didn't provide any extra information about this error; just
+ // print the exception.
+ LOGD("%s", alternate_message);
+ } else {
+ v8::String::Utf8Value filename(message->GetScriptResourceName());
+ const char* filename_string = ToCString(filename);
+ int linenum = message->GetLineNumber();
+ LOGD("file:%s line:%i", filename_string, linenum);
+
+ // Print line of source code.
+ v8::String::Utf8Value sourceline(message->GetSourceLine());
+ const char* sourceline_string = ToCString(sourceline);
+ LOGD("%s", sourceline_string);
+
+ // Print location information under source line
+ int start = message->GetStartColumn();
+ int end = message->GetEndColumn();
+ char *error_string = new char[end+1];
+ memset(error_string, ' ', start);
+ memset(&error_string[start], '^', end - start);
+ error_string[end] = 0;
+ LOGD("%s", error_string);
+ delete [] error_string;
+ }
+}
+
+void ErrorCallback(v8::Handle<v8::Message> message,
+ v8::Handle<v8::Value> data) {
+ LogErrorMessage(message, "");
+}
+
+// Report an exception
+void ReportException(v8::TryCatch* try_catch) {
+ v8::HandleScope handle_scope;
+
+ v8::String::Utf8Value exception(try_catch->Exception());
+ v8::Handle<v8::Message> msg = try_catch->Message();
+ if (msg.IsEmpty()) {
+ // Why is try_catch->Message empty?
+ // is always empty on compile errors
+ }
+ LogErrorMessage(msg, ToCString(exception));
+}
+
+v8::Handle<v8::Value> GetScreenState(v8::Local<v8::String> property,
+ const v8::AccessorInfo &info) {
+ v8::Local<v8::Object> self = info.Holder();
+ v8::Local<v8::External> wrap =
+ v8::Local<v8::External>::Cast(self->GetInternalField(0));
+ void *p = wrap->Value();
+ int state = static_cast<int *>(p)[0];
+ LOGD("GetScreenState state=%d", state);
+ return v8::Integer::New(state);
+}
+
+bool callOnRequest(v8::Handle<v8::Context> context, int request,
+ void *data, size_t datalen, RIL_Token t) {
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ // Get the onRequestFunction, making sure its a function
+ v8::Handle<v8::String> name = v8::String::New("onRequest");
+ v8::Handle<v8::Value> onRequestFunctionValue = context->Global()->Get(name);
+ if(!onRequestFunctionValue->IsFunction()) {
+ // Wasn't a function
+ LOGD("callOnRequest X wasn't a function");
+ return false;
+ }
+ v8::Handle<v8::Function> onRequestFunction =
+ v8::Handle<v8::Function>::Cast(onRequestFunctionValue);
+
+ // Create the request
+ v8::Handle<v8::Value> v8RequestValue = v8::Number::New(request);
+
+ // Create the parameter for the request
+ v8::Handle<v8::Object> params_obj =
+ v8::ObjectTemplate::New()->NewInstance();
+ switch(request) {
+ case(RIL_REQUEST_SCREEN_STATE): {
+ LOGD("callOnRequest RIL_REQUEST_SCREEN_STATE");
+ if (datalen < sizeof(int)) {
+ LOGD("callOnRequest err size < sizeof int");
+ } else {
+ v8::Handle<v8::ObjectTemplate> params_obj_template =
+ v8::ObjectTemplate::New();
+ params_obj_template->SetInternalFieldCount(1);
+ params_obj_template->SetAccessor(v8::String::New("ScreenState"),
+ GetScreenState, NULL);
+ // How to not leak this pointer!!!
+ int *p = new int;
+ *p = ((int *)data)[0];
+ params_obj = params_obj_template->NewInstance();
+ params_obj->SetInternalField(0, v8::External::New(p));
+ }
+ break;
+ }
+ default: {
+ LOGD("callOnRequest X unknown request");
+ break;
+ }
+ }
+
+ // Invoke onRequest
+ bool retValue;
+ const int argc = 2;
+ v8::Handle<v8::Value> argv[argc] = { v8RequestValue, params_obj };
+ v8::Handle<v8::Value> result =
+ onRequestFunction->Call(context->Global(), argc, argv);
+ if (try_catch.HasCaught()) {
+ ReportException(&try_catch);
+ retValue = false;
+ } else {
+ v8::String::Utf8Value result_string(result);
+ LOGD("callOnRequest result=%s", ToCString(result_string));
+ retValue = true;
+ }
+ return retValue;
+}
+
+// There appears to be a bug which causes TryCatch.HasCaught()
+// to return true after creating a String Value.
+void v8Bug1() {
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ LOGD("v8Bug1: start, HasCaught()=%d", try_catch.HasCaught());
+
+ v8::Handle<v8::Value> mydata(v8::String::New("hello"));
+ LOGD("v8Bug1 after creating mydata, HasCaught()=%d", try_catch.HasCaught());
+ if (try_catch.HasCaught()) {
+ LOGD("v8Bug1: Why is HasCaught true");
+ }
+}
+
+void testV8() {
+ LOGD("testV8 E:");
+ v8::HandleScope handle_scope;
+
+ // Add a Message listner to Catch errors as they occur
+ v8::Handle<v8::Value> mydata(v8::String::New("hello"));
+ v8::V8::AddMessageListener(ErrorCallback, mydata);
+
+ v8::TryCatch try_catch;
+
+ // Create a template for the global object and
+ // add the function template for print to it.
+ v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
+ global->Set(v8::String::New("print"), v8::FunctionTemplate::New(Print));
+
+ // Create context with our globals and make it the current scope
+ v8::Handle<v8::Context> context = v8::Context::New(NULL, global);
+ v8::Context::Scope context_scope(context);
+
+ // Compile the source
+ v8::Handle<v8::String> source = v8::String::New(
+ "function onRequest(reqNum, params) {\n"
+ " print(\"reqNum=\" + reqNum);\n"
+ " if (reqNum == 61) {\n"
+ " print(\"params.ScreenState=\" + params.ScreenState);\n"
+ " }\n"
+ " return \"Hello World\";\n"
+ "}\n");
+ v8::Handle<v8::Script> script = v8::Script::Compile(source);
+ if (script.IsEmpty()) {
+ LOGD("testV8 compile source failed");
+ ReportException(&try_catch);
+ } else {
+ // Run the resulting script
+ v8::Handle<v8::Value> result = script->Run();
+ if (try_catch.HasCaught()) {
+ LOGD("testV8 run script failed");
+ ReportException(&try_catch);
+ } else {
+ // Call the onRequest function
+ int data[1] = { 0 };
+ callOnRequest(context, RIL_REQUEST_SCREEN_STATE, data,
+ sizeof(data), NULL);
+ }
+ }
+ LOGD("testV8 X:");
+}
+
+pthread_t s_tid_mainloop;
+static void * mainLoop(void *param)
+{
+ // Test using STLport
+ std::queue<void *> q;
+
+ LOGD("before push q.size=%d", q.size());
+ q.push(param);
+ LOGD("after push q.size=%d", q.size());
+ void *p = q.front();
+ if (p == param) {
+ LOGD("q.push succeeded");
+ } else {
+ LOGD("q.push failed");
+ }
+ q.pop();
+ LOGD("after pop q.size=%d", q.size());
+
+ // Test a simple protobuf
+ LOGD("create T a simple protobuf");
+ T* t = new T();
+ LOGD("set_id(1)");
+ t->set_id(1);
+ int id = t->id();
+ LOGD("id=%d", id);
+ delete t;
+
+ LOGD("mainLoop E");
+
+ for (int i=0;;i++) {
+ sleep(10);
+ LOGD("mainLoop: looping %d", i);
+ }
+
+ LOGD("mainLoop X");
+
+ return NULL;
+}
+
+const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc,
+ char **argv) {
+ int ret;
+ pthread_attr_t attr;
+
+ LOGD("RIL_Init E");
+
+ v8Bug1();
+ testV8();
+
+ s_rilenv = env;
+
+ ret = pthread_attr_init (&attr);
+ if (ret != 0) {
+ LOGE("RIL_Init X: pthread_attr_init failed err=%s", strerror(ret));
+ return NULL;
+ }
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (ret != 0) {
+ LOGE("RIL_Init X: pthread_attr_setdetachstate failed err=%s",
+ strerror(ret));
+ return NULL;
+ }
+ ret = pthread_create(&s_tid_mainloop, &attr, mainLoop, NULL);
+ if (ret != 0) {
+ LOGE("RIL_Init X: pthread_create failed err=%s", strerror(ret));
+ return NULL;
+ }
+
+ LOGD("RIL_Init X");
+ return &s_callbacks;
+}
diff --git a/mock-ril/t.pb.cpp b/mock-ril/t.pb.cpp
new file mode 100644
index 0000000..ba573e3
--- /dev/null
+++ b/mock-ril/t.pb.cpp
@@ -0,0 +1,236 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "t.pb.h"
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+// @@protoc_insertion_point(includes)
+
+void protobuf_ShutdownFile_t_2eproto() {
+ delete T::default_instance_;
+}
+
+void protobuf_AddDesc_t_2eproto() {
+ static bool already_here = false;
+ if (already_here) return;
+ already_here = true;
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ T::default_instance_ = new T();
+ T::default_instance_->InitAsDefaultInstance();
+ ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_t_2eproto);
+}
+
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_t_2eproto {
+ StaticDescriptorInitializer_t_2eproto() {
+ protobuf_AddDesc_t_2eproto();
+ }
+} static_descriptor_initializer_t_2eproto_;
+
+
+// ===================================================================
+
+const ::std::string T::_default_os_;
+#ifndef _MSC_VER
+const int T::kIdFieldNumber;
+const int T::kOsFieldNumber;
+#endif // !_MSC_VER
+
+T::T()
+ : ::google::protobuf::MessageLite() {
+ SharedCtor();
+}
+
+void T::InitAsDefaultInstance() {
+}
+
+T::T(const T& from)
+ : ::google::protobuf::MessageLite() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void T::SharedCtor() {
+ _cached_size_ = 0;
+ id_ = 0;
+ os_ = const_cast< ::std::string*>(&_default_os_);
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+T::~T() {
+ SharedDtor();
+}
+
+void T::SharedDtor() {
+ if (os_ != &_default_os_) {
+ delete os_;
+ }
+ if (this != default_instance_) {
+ }
+}
+
+void T::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const T& T::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_t_2eproto(); return *default_instance_;
+}
+
+T* T::default_instance_ = NULL;
+
+T* T::New() const {
+ return new T;
+}
+
+void T::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ id_ = 0;
+ if (_has_bit(1)) {
+ if (os_ != &_default_os_) {
+ os_->clear();
+ }
+ }
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+bool T::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
+ ::google::protobuf::uint32 tag;
+ while ((tag = input->ReadTag()) != 0) {
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // required int32 id = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &id_)));
+ _set_bit(0);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(18)) goto parse_os;
+ break;
+ }
+
+ // optional string os = 2;
+ case 2: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ parse_os:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_os()));
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectAtEnd()) return true;
+ break;
+ }
+
+ default: {
+ handle_uninterpreted:
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ return true;
+ }
+ DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void T::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required int32 id = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->id(), output);
+ }
+
+ // optional string os = 2;
+ if (_has_bit(1)) {
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 2, this->os(), output);
+ }
+
+}
+
+int T::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required int32 id = 1;
+ if (has_id()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->id());
+ }
+
+ // optional string os = 2;
+ if (has_os()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->os());
+ }
+
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void T::CheckTypeAndMergeFrom(
+ const ::google::protobuf::MessageLite& from) {
+ MergeFrom(*::google::protobuf::down_cast<const T*>(&from));
+}
+
+void T::MergeFrom(const T& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_id(from.id());
+ }
+ if (from._has_bit(1)) {
+ set_os(from.os());
+ }
+ }
+}
+
+void T::CopyFrom(const T& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool T::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void T::Swap(T* other) {
+ if (other != this) {
+ std::swap(id_, other->id_);
+ std::swap(os_, other->os_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::std::string T::GetTypeName() const {
+ return "T";
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+// @@protoc_insertion_point(global_scope)
diff --git a/mock-ril/t.pb.h b/mock-ril/t.pb.h
new file mode 100644
index 0000000..19fc07d
--- /dev/null
+++ b/mock-ril/t.pb.h
@@ -0,0 +1,193 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: t.proto
+
+#ifndef PROTOBUF_t_2eproto__INCLUDED
+#define PROTOBUF_t_2eproto__INCLUDED
+
+#include <string>
+
+#include <google/protobuf/stubs/common.h>
+
+#if GOOGLE_PROTOBUF_VERSION < 2003000
+#error This file was generated by a newer version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please update
+#error your headers.
+#endif
+#if 2003000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#error This file was generated by an older version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please
+#error regenerate this file with a newer version of protoc.
+#endif
+
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/extension_set.h>
+// @@protoc_insertion_point(includes)
+
+// Internal implementation detail -- do not call these.
+void protobuf_AddDesc_t_2eproto();
+void protobuf_AssignDesc_t_2eproto();
+void protobuf_ShutdownFile_t_2eproto();
+
+class T;
+
+// ===================================================================
+
+class T : public ::google::protobuf::MessageLite {
+ public:
+ T();
+ virtual ~T();
+
+ T(const T& from);
+
+ inline T& operator=(const T& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ static const T& default_instance();
+
+ void Swap(T* other);
+
+ // implements Message ----------------------------------------------
+
+ T* New() const;
+ void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
+ void CopyFrom(const T& from);
+ void MergeFrom(const T& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::std::string GetTypeName() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required int32 id = 1;
+ inline bool has_id() const;
+ inline void clear_id();
+ static const int kIdFieldNumber = 1;
+ inline ::google::protobuf::int32 id() const;
+ inline void set_id(::google::protobuf::int32 value);
+
+ // optional string os = 2;
+ inline bool has_os() const;
+ inline void clear_os();
+ static const int kOsFieldNumber = 2;
+ inline const ::std::string& os() const;
+ inline void set_os(const ::std::string& value);
+ inline void set_os(const char* value);
+ inline void set_os(const char* value, size_t size);
+ inline ::std::string* mutable_os();
+
+ // @@protoc_insertion_point(class_scope:T)
+ private:
+ mutable int _cached_size_;
+
+ ::google::protobuf::int32 id_;
+ ::std::string* os_;
+ static const ::std::string _default_os_;
+ friend void protobuf_AddDesc_t_2eproto();
+ friend void protobuf_AssignDesc_t_2eproto();
+ friend void protobuf_ShutdownFile_t_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
+
+ // WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
+ inline bool _has_bit(int index) const {
+ return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
+ }
+ inline void _set_bit(int index) {
+ _has_bits_[index / 32] |= (1u << (index % 32));
+ }
+ inline void _clear_bit(int index) {
+ _has_bits_[index / 32] &= ~(1u << (index % 32));
+ }
+
+ void InitAsDefaultInstance();
+ static T* default_instance_;
+};
+// ===================================================================
+
+
+// ===================================================================
+
+// T
+
+// required int32 id = 1;
+inline bool T::has_id() const {
+ return _has_bit(0);
+}
+inline void T::clear_id() {
+ id_ = 0;
+ _clear_bit(0);
+}
+inline ::google::protobuf::int32 T::id() const {
+ return id_;
+}
+inline void T::set_id(::google::protobuf::int32 value) {
+ _set_bit(0);
+ id_ = value;
+}
+
+// optional string os = 2;
+inline bool T::has_os() const {
+ return _has_bit(1);
+}
+inline void T::clear_os() {
+ if (os_ != &_default_os_) {
+ os_->clear();
+ }
+ _clear_bit(1);
+}
+inline const ::std::string& T::os() const {
+ return *os_;
+}
+inline void T::set_os(const ::std::string& value) {
+ _set_bit(1);
+ if (os_ == &_default_os_) {
+ os_ = new ::std::string;
+ }
+ os_->assign(value);
+}
+inline void T::set_os(const char* value) {
+ _set_bit(1);
+ if (os_ == &_default_os_) {
+ os_ = new ::std::string;
+ }
+ os_->assign(value);
+}
+inline void T::set_os(const char* value, size_t size) {
+ _set_bit(1);
+ if (os_ == &_default_os_) {
+ os_ = new ::std::string;
+ }
+ os_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* T::mutable_os() {
+ _set_bit(1);
+ if (os_ == &_default_os_) {
+ os_ = new ::std::string;
+ }
+ return os_;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+// @@protoc_insertion_point(global_scope)
+
+#endif // PROTOBUF_t_2eproto__INCLUDED
diff --git a/mock-ril/t.proto b/mock-ril/t.proto
new file mode 100644
index 0000000..2b33444
--- /dev/null
+++ b/mock-ril/t.proto
@@ -0,0 +1,9 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+// Author: wink@google.com (Wink Saville)
+
+option optimize_for=LITE_RUNTIME;
+
+message T {
+ required int32 id = 1;
+ optional string os = 2;
+}
diff --git a/reference-cdma-sms/Android.mk b/reference-cdma-sms/Android.mk
deleted file mode 100644
index a179d8c..0000000
--- a/reference-cdma-sms/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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
-include $(BUILD_SHARED_LIBRARY)
diff --git a/reference-cdma-sms/reference-cdma-sms.c b/reference-cdma-sms/reference-cdma-sms.c
deleted file mode 100644
index 89b2774..0000000
--- a/reference-cdma-sms/reference-cdma-sms.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 443ddf5..0000000
--- a/reference-cdma-sms/reference-cdma-sms.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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*/
-