Create a very initial mock_ril.js and supporting code.
Change-Id: I742c413f33d99e8fe8e5a320dab067174b560e98
diff --git a/mock-ril/.gitignore b/mock-ril/.gitignore
new file mode 100644
index 0000000..0d20b64
--- /dev/null
+++ b/mock-ril/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/mock-ril/Android.mk b/mock-ril/Android.mk
index 9087cd1..a3c0b2a 100644
--- a/mock-ril/Android.mk
+++ b/mock-ril/Android.mk
@@ -1,20 +1,36 @@
# Copyright 2010 The Android Open Source Project
-
+#
# not currently building V8 for x86 targets
ifeq ($(TARGET_ARCH),arm)
LOCAL_PATH:= $(call my-dir)
+
+# Mock-ril only buid for debug variants
+ifneq ($(filter userdebug eng tests, $(TARGET_BUILD_VARIANT)),)
+
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- t.pb.cpp \
- mock-ril.cpp
+ ctrl_server.cpp \
+ experiments.cpp \
+ js_support.cpp \
+ mock_ril.cpp \
+ node_buffer.cpp \
+ node_util.cpp \
+ protobuf_v8.cpp \
+ responses.cpp \
+ requests.cpp \
+ ril.pb.cpp \
+ util.cpp \
+ worker.cpp \
+ worker_v8.cpp
+
LOCAL_SHARED_LIBRARIES := \
- libcutils libutils libril
+ libz libcutils libutils libril
LOCAL_STATIC_LIBRARIES := \
- libprotobuf-cpp-2.3.0-lite libv8
+ libprotobuf-cpp-2.3.0-full libv8
# for asprinf
LOCAL_CFLAGS := -D_GNU_SOURCE -UNDEBUG -DGOOGLE_PROTOBUF_NO_RTTI
@@ -32,12 +48,16 @@
endif
# build shared library but don't require it be prelinked
+# __BSD_VISIBLE for htolexx macros.
+LOCAL_STRIP_MODULE := true
LOCAL_PRELINK_MODULE := false
LOCAL_LDLIBS += -lpthread
-LOCAL_CFLAGS += -DMOCK_RIL -DRIL_SHLIB
+LOCAL_CFLAGS += -DMOCK_RIL -DRIL_SHLIB -D__BSD_VISIBLE
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:= libmock_ril
include $(BUILD_SHARED_LIBRARY)
endif
+
+endif
diff --git a/mock-ril/Makefile b/mock-ril/Makefile
new file mode 100644
index 0000000..792850d
--- /dev/null
+++ b/mock-ril/Makefile
@@ -0,0 +1,76 @@
+# A Makefile to run protoc and also allow testing.
+.PHONY : all
+all : ril.pb.cpp ril.pb.h ril.desc ril_pb2.py ctrl.pb.cpp ctrl.pb.h ctrl.desc ctrl_pb2.py
+
+# Run protoc to create the c++ files for ril
+ril.pb.cpp ril.pb.h : ril.proto
+ protoc --cpp_out=. $<
+ mv ril.pb.cc ril.pb.cpp
+
+# Run protoc to create the pyhton files for ril
+ril_pb2.py : ril.proto
+ protoc --python_out=. $<
+
+# Run protoc to create the ril descriptor file for ril
+ril.desc : ril.proto
+ protoc --descriptor_set_out=$@ --include_imports $<
+
+# Run protoc to create the c++ files for control
+ctrl.pb.cpp ctrl.pb.h : ctrl.proto
+ protoc --cpp_out=. $<
+ mv ctrl.pb.cc ctrl.pb.cpp
+
+# Run protoc to create the pyhton files for control
+ctrl_pb2.py : ctrl.proto
+ protoc --python_out=. $<
+
+# Run protoc to create the ctrl descriptor file for control
+ctrl.desc : ctrl.proto
+ protoc --descriptor_set_out=$@ --include_imports $<
+
+# After starting phone do this first to get lastest ril.desc/proto and setup rild
+.PHONY : first
+first :
+ adb root ; sleep 3 ; adb remount ; adb shell setprop rild.libpath /data/lib/libmock_ril.so
+ adb push mock_ril.js /sdcard/data/
+ adb push ril_vars.js /sdcard/data/
+ adb push ril.desc /sdcard/data/
+ adb push ctrl.desc /sdcard/data/
+ adb forward tcp:11111 tcp:54312
+
+.PHONY : js
+js :
+ adb push mock_ril.js /sdcard/data/
+ adb push ril_vars.js /sdcard/data/
+ adb push ril.desc /sdcard/data/
+ adb push ctrl.desc /sdcard/data/
+ adb shell ps | awk '/rild/ { print $$2 }' | xargs adb shell kill
+
+.PHONY : tcs
+tcs :
+ ./tcs.py 127.0.0.1 11111
+
+# Push a new libmock_ril.so and kill rild to run a test
+.PHONY : test
+test :
+ adb push mock_ril.js /sdcard/data/
+ adb push ril_vars.js /sdcard/data/
+ adb push ril.desc /sdcard/data/
+ adb push ctrl.desc /sdcard/data/
+ adb push ../../../out/target/product/passion/system/lib/libmock_ril.so /data/lib/
+ adb shell ps | awk '/rild/ { print $$2 }' | xargs adb shell kill
+
+# Push a new libmock_ril.so and kill rild to run a test
+.PHONY : mockriltest
+mockriltest :
+ adb push mock_ril.js /sdcard/data/
+ adb push ril_vars.js /sdcard/data/
+ adb push ril.desc /sdcard/data/
+ adb push ctrl.desc /sdcard/data/
+ adb shell ps | awk '/rild/ { print $$2 }' | xargs adb shell kill
+
+# Remove generated files
+.PHONY : clean
+clean :
+ rm -rf ril.pb.cpp ril.pb.h ril.desc ril_pb2.py
+ rm -rf ctrl.pb.cpp ctrl.pb.h ctrl.desc ctrl_pb2.py
diff --git a/mock-ril/NOTICE b/mock-ril/NOTICE
index c5b1efa..15930fa 100644
--- a/mock-ril/NOTICE
+++ b/mock-ril/NOTICE
@@ -187,4 +187,35 @@
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
+-------------------------------------------------------------------------
+The following files are copied from http://www.nodejs.obj and modified:
+ node_buffer.h
+ node_buffer.cc (renamed to node_buffer.cpp)
+ node_object_wrap.h
+The following files are snippets from http://www.nodejs.obj node.cc/node.h
+ node_util.h
+ node_util.cpp
+
+
+Node's license follows:
+
+Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
+-------------------------------------------------------------------------
diff --git a/mock-ril/README.txt b/mock-ril/README.txt
index cd4d780..32abdd8 100644
--- a/mock-ril/README.txt
+++ b/mock-ril/README.txt
@@ -1,5 +1,110 @@
+Mock-ril:
+
+Install:
+
+Install protoc see the external/protobuf/INSTALL.txt and
+external/protobuf/python/README.txt. The short answer is:
+
+ $ cd external/protobuf
+ $ ./configure
+ $ make
+ $ make check
+ $ make install
+ $ cd python
+ $ python setup.py install
+
+If you get "from google.protobuf import xxxx" statements
+that google.protobuf is not found you didn't install the
+python support for protobuf. Also on Mac OSX I got an
+error running the protoc tests but installing was fine.
+
+Running/testing:
+
+See "Testing a new ril:" below for general instructions but
+for the mock-ril I've added some targets to the Makefile to
+ease testing.
+
+Execute the "first" target first to setup appropriate
+environment:
+ $ cd hardware/ril/mock-ril
+ $ make first
+
+If changes made to ".proto" files run make with the default
+"all" target:
+ $ make
+
+If changes are made to "c++" file create a new library and
+run the "test" target:
+ $ mm
+ $ make test
+
+If changes to only the execute "js" target:
+ $ make js
+
+To run the test control server:
+ $ make tcs
+
+Implementation:
+
+The mock-ril is a library where the ril is implemented primarily
+in javascript, mock-ril.js. In addition it can be controlled by
+sending messages from another computer to port 54312 (TODO make
+programmable) to the ctrlServer, a Worker in In mock-ril.js.
+
+See mock_ril.js for additional documentation.
+
+files:
+ ctrl.proto Protobuf messages for the control server
+ ctrl.* Protobuf generated files.
+ ctrl_pb2.py Python files generated from ctrl.proto
+ ctrl_server.* Cpp interface routines between ctrlServer
+ in javascript and the controller.
+ experiments.* Early experiments
+ js_support.* Java script support methods. Exposes various
+ routines to javascript, such as print, readFile
+ and include.
+ logging.h LOG_TAG and include utils/log.h
+ mock_ril.[cpp|h] Main module inteface code.
+ mock_ril.js The mock ril
+ node_buffer.* A Buffer for communicating between c++ and js.
+ This was ported from nodejs.org.
+ node_object.* An object wrapper to make it easier to expose
+ c++ code to js. Ported from nodejs.org.
+ node_util.* Some utilities ported from nodejs.org.
+ protobuf_v8.* Protobuf code for javascript ported from
+ http://code.google.com/p/protobuf-for-node/.
+ requests.* Interface code for handling framework requests.
+ responses* Interface code for handling framework responses.
+ ril.proto The protobuf version of ril.h
+ ril_vars.js Some additional variables defined for enums in
+ ril.h.
+ ril_pb2.py Python files generated from ril.proto.
+ status.h STATUS constants.
+ tcs.py Test the ctrlServer.
+ util.* Utility routines
+ worker.* Define WorkerThread and WorkerQueue.
+ worker_v8.* Expose WorkerQueue to js.
+
+
+TODO: more documentation.
+
+
Testing a new ril:
+The Makefile is used to generate files and make testing easier.
+I has several targets:
+
+all runs protoc and generates files, ril.desc ril.pb.*
+
+clean target removes generated files.
+
+first changes to root, remounts r/w and copies some files.
+
+test copies the latest libmock_ril.so and kills rild
+ to run the new mockril
+
+General instructions for testing ril's:
+
1) On the device login in as root and remount file system so it's read/write:
$ adb root
restarting adbd as root
diff --git a/mock-ril/ctrl.desc b/mock-ril/ctrl.desc
new file mode 100644
index 0000000..b38de52
--- /dev/null
+++ b/mock-ril/ctrl.desc
Binary files differ
diff --git a/mock-ril/ctrl.pb.cpp b/mock-ril/ctrl.pb.cpp
new file mode 100644
index 0000000..49bc5f6
--- /dev/null
+++ b/mock-ril/ctrl.pb.cpp
@@ -0,0 +1,347 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "ctrl.pb.h"
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+// @@protoc_insertion_point(includes)
+
+namespace ctrl_proto {
+
+namespace {
+
+const ::google::protobuf::Descriptor* CtrlRspRadioState_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ CtrlRspRadioState_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* CtrlCmd_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* CtrlStatus_descriptor_ = NULL;
+
+} // namespace
+
+
+void protobuf_AssignDesc_ctrl_2eproto() {
+ protobuf_AddDesc_ctrl_2eproto();
+ const ::google::protobuf::FileDescriptor* file =
+ ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
+ "ctrl.proto");
+ GOOGLE_CHECK(file != NULL);
+ CtrlRspRadioState_descriptor_ = file->message_type(0);
+ static const int CtrlRspRadioState_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CtrlRspRadioState, state_),
+ };
+ CtrlRspRadioState_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ CtrlRspRadioState_descriptor_,
+ CtrlRspRadioState::default_instance_,
+ CtrlRspRadioState_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CtrlRspRadioState, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CtrlRspRadioState, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(CtrlRspRadioState));
+ CtrlCmd_descriptor_ = file->enum_type(0);
+ CtrlStatus_descriptor_ = file->enum_type(1);
+}
+
+namespace {
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+inline void protobuf_AssignDescriptorsOnce() {
+ ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
+ &protobuf_AssignDesc_ctrl_2eproto);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ CtrlRspRadioState_descriptor_, &CtrlRspRadioState::default_instance());
+}
+
+} // namespace
+
+void protobuf_ShutdownFile_ctrl_2eproto() {
+ delete CtrlRspRadioState::default_instance_;
+ delete CtrlRspRadioState_reflection_;
+}
+
+void protobuf_AddDesc_ctrl_2eproto() {
+ static bool already_here = false;
+ if (already_here) return;
+ already_here = true;
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ ::ril_proto::protobuf_AddDesc_ril_2eproto();
+ ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+ "\n\nctrl.proto\022\nctrl_proto\032\tril.proto\"9\n\021C"
+ "trlRspRadioState\022$\n\005state\030\001 \002(\0162\025.ril_pr"
+ "oto.RadioState*:\n\007CtrlCmd\022\021\n\rCTRL_CMD_EC"
+ "HO\020\000\022\034\n\030CTRL_CMD_GET_RADIO_STATE\020\001*5\n\nCt"
+ "rlStatus\022\022\n\016CTRL_STATUS_OK\020\000\022\023\n\017CTRL_STA"
+ "TUS_ERR\020\001", 209);
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+ "ctrl.proto", &protobuf_RegisterTypes);
+ CtrlRspRadioState::default_instance_ = new CtrlRspRadioState();
+ CtrlRspRadioState::default_instance_->InitAsDefaultInstance();
+ ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_ctrl_2eproto);
+}
+
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_ctrl_2eproto {
+ StaticDescriptorInitializer_ctrl_2eproto() {
+ protobuf_AddDesc_ctrl_2eproto();
+ }
+} static_descriptor_initializer_ctrl_2eproto_;
+
+const ::google::protobuf::EnumDescriptor* CtrlCmd_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return CtrlCmd_descriptor_;
+}
+bool CtrlCmd_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* CtrlStatus_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return CtrlStatus_descriptor_;
+}
+bool CtrlStatus_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int CtrlRspRadioState::kStateFieldNumber;
+#endif // !_MSC_VER
+
+CtrlRspRadioState::CtrlRspRadioState()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void CtrlRspRadioState::InitAsDefaultInstance() {
+}
+
+CtrlRspRadioState::CtrlRspRadioState(const CtrlRspRadioState& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void CtrlRspRadioState::SharedCtor() {
+ _cached_size_ = 0;
+ state_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+CtrlRspRadioState::~CtrlRspRadioState() {
+ SharedDtor();
+}
+
+void CtrlRspRadioState::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+void CtrlRspRadioState::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* CtrlRspRadioState::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return CtrlRspRadioState_descriptor_;
+}
+
+const CtrlRspRadioState& CtrlRspRadioState::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ctrl_2eproto(); return *default_instance_;
+}
+
+CtrlRspRadioState* CtrlRspRadioState::default_instance_ = NULL;
+
+CtrlRspRadioState* CtrlRspRadioState::New() const {
+ return new CtrlRspRadioState;
+}
+
+void CtrlRspRadioState::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ state_ = 0;
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool CtrlRspRadioState::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 .ril_proto.RadioState state = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RadioState_IsValid(value)) {
+ set_state(static_cast< ril_proto::RadioState >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void CtrlRspRadioState::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required .ril_proto.RadioState state = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->state(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* CtrlRspRadioState::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required .ril_proto.RadioState state = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->state(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int CtrlRspRadioState::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required .ril_proto.RadioState state = 1;
+ if (has_state()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->state());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void CtrlRspRadioState::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const CtrlRspRadioState* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const CtrlRspRadioState*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void CtrlRspRadioState::MergeFrom(const CtrlRspRadioState& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_state(from.state());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void CtrlRspRadioState::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void CtrlRspRadioState::CopyFrom(const CtrlRspRadioState& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool CtrlRspRadioState::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void CtrlRspRadioState::Swap(CtrlRspRadioState* other) {
+ if (other != this) {
+ std::swap(state_, other->state_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata CtrlRspRadioState::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = CtrlRspRadioState_descriptor_;
+ metadata.reflection = CtrlRspRadioState_reflection_;
+ return metadata;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace ctrl_proto
+
+// @@protoc_insertion_point(global_scope)
diff --git a/mock-ril/ctrl.pb.h b/mock-ril/ctrl.pb.h
new file mode 100644
index 0000000..1bfaed5
--- /dev/null
+++ b/mock-ril/ctrl.pb.h
@@ -0,0 +1,213 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: ctrl.proto
+
+#ifndef PROTOBUF_ctrl_2eproto__INCLUDED
+#define PROTOBUF_ctrl_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>
+#include <google/protobuf/generated_message_reflection.h>
+#include "ril.pb.h"
+// @@protoc_insertion_point(includes)
+
+namespace ctrl_proto {
+
+// Internal implementation detail -- do not call these.
+void protobuf_AddDesc_ctrl_2eproto();
+void protobuf_AssignDesc_ctrl_2eproto();
+void protobuf_ShutdownFile_ctrl_2eproto();
+
+class CtrlRspRadioState;
+
+enum CtrlCmd {
+ CTRL_CMD_ECHO = 0,
+ CTRL_CMD_GET_RADIO_STATE = 1
+};
+bool CtrlCmd_IsValid(int value);
+const CtrlCmd CtrlCmd_MIN = CTRL_CMD_ECHO;
+const CtrlCmd CtrlCmd_MAX = CTRL_CMD_GET_RADIO_STATE;
+const int CtrlCmd_ARRAYSIZE = CtrlCmd_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* CtrlCmd_descriptor();
+inline const ::std::string& CtrlCmd_Name(CtrlCmd value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ CtrlCmd_descriptor(), value);
+}
+inline bool CtrlCmd_Parse(
+ const ::std::string& name, CtrlCmd* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<CtrlCmd>(
+ CtrlCmd_descriptor(), name, value);
+}
+enum CtrlStatus {
+ CTRL_STATUS_OK = 0,
+ CTRL_STATUS_ERR = 1
+};
+bool CtrlStatus_IsValid(int value);
+const CtrlStatus CtrlStatus_MIN = CTRL_STATUS_OK;
+const CtrlStatus CtrlStatus_MAX = CTRL_STATUS_ERR;
+const int CtrlStatus_ARRAYSIZE = CtrlStatus_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* CtrlStatus_descriptor();
+inline const ::std::string& CtrlStatus_Name(CtrlStatus value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ CtrlStatus_descriptor(), value);
+}
+inline bool CtrlStatus_Parse(
+ const ::std::string& name, CtrlStatus* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<CtrlStatus>(
+ CtrlStatus_descriptor(), name, value);
+}
+// ===================================================================
+
+class CtrlRspRadioState : public ::google::protobuf::Message {
+ public:
+ CtrlRspRadioState();
+ virtual ~CtrlRspRadioState();
+
+ CtrlRspRadioState(const CtrlRspRadioState& from);
+
+ inline CtrlRspRadioState& operator=(const CtrlRspRadioState& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const CtrlRspRadioState& default_instance();
+
+ void Swap(CtrlRspRadioState* other);
+
+ // implements Message ----------------------------------------------
+
+ CtrlRspRadioState* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const CtrlRspRadioState& from);
+ void MergeFrom(const CtrlRspRadioState& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required .ril_proto.RadioState state = 1;
+ inline bool has_state() const;
+ inline void clear_state();
+ static const int kStateFieldNumber = 1;
+ inline ril_proto::RadioState state() const;
+ inline void set_state(ril_proto::RadioState value);
+
+ // @@protoc_insertion_point(class_scope:ctrl_proto.CtrlRspRadioState)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ int state_;
+ friend void protobuf_AddDesc_ctrl_2eproto();
+ friend void protobuf_AssignDesc_ctrl_2eproto();
+ friend void protobuf_ShutdownFile_ctrl_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 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 CtrlRspRadioState* default_instance_;
+};
+// ===================================================================
+
+
+// ===================================================================
+
+// CtrlRspRadioState
+
+// required .ril_proto.RadioState state = 1;
+inline bool CtrlRspRadioState::has_state() const {
+ return _has_bit(0);
+}
+inline void CtrlRspRadioState::clear_state() {
+ state_ = 0;
+ _clear_bit(0);
+}
+inline ril_proto::RadioState CtrlRspRadioState::state() const {
+ return static_cast< ril_proto::RadioState >(state_);
+}
+inline void CtrlRspRadioState::set_state(ril_proto::RadioState value) {
+ GOOGLE_DCHECK(ril_proto::RadioState_IsValid(value));
+ _set_bit(0);
+ state_ = value;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace ctrl_proto
+
+#ifndef SWIG
+namespace google {
+namespace protobuf {
+
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ctrl_proto::CtrlCmd>() {
+ return ctrl_proto::CtrlCmd_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ctrl_proto::CtrlStatus>() {
+ return ctrl_proto::CtrlStatus_descriptor();
+}
+
+} // namespace google
+} // namespace protobuf
+#endif // SWIG
+
+// @@protoc_insertion_point(global_scope)
+
+#endif // PROTOBUF_ctrl_2eproto__INCLUDED
diff --git a/mock-ril/ctrl.proto b/mock-ril/ctrl.proto
new file mode 100644
index 0000000..da0069c
--- /dev/null
+++ b/mock-ril/ctrl.proto
@@ -0,0 +1,20 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+// Author: wink@google.com (Wink Saville)
+
+package ctrl_proto;
+
+import "ril.proto";
+
+enum CtrlCmd {
+ CTRL_CMD_ECHO = 0;
+ CTRL_CMD_GET_RADIO_STATE = 1;
+}
+
+enum CtrlStatus {
+ CTRL_STATUS_OK = 0;
+ CTRL_STATUS_ERR = 1;
+}
+
+message CtrlRspRadioState {
+ required ril_proto.RadioState state = 1;
+}
diff --git a/mock-ril/ctrl_pb2.py b/mock-ril/ctrl_pb2.py
new file mode 100644
index 0000000..a56589a
--- /dev/null
+++ b/mock-ril/ctrl_pb2.py
@@ -0,0 +1,103 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+
+from google.protobuf import descriptor
+from google.protobuf import message
+from google.protobuf import reflection
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+
+DESCRIPTOR = descriptor.FileDescriptor(
+ name='ctrl.proto',
+ package='ctrl_proto',
+ serialized_pb='\n\nctrl.proto\x12\nctrl_proto\x1a\tril.proto\"9\n\x11\x43trlRspRadioState\x12$\n\x05state\x18\x01 \x02(\x0e\x32\x15.ril_proto.RadioState*:\n\x07\x43trlCmd\x12\x11\n\rCTRL_CMD_ECHO\x10\x00\x12\x1c\n\x18\x43TRL_CMD_GET_RADIO_STATE\x10\x01*5\n\nCtrlStatus\x12\x12\n\x0e\x43TRL_STATUS_OK\x10\x00\x12\x13\n\x0f\x43TRL_STATUS_ERR\x10\x01')
+
+_CTRLCMD = descriptor.EnumDescriptor(
+ name='CtrlCmd',
+ full_name='ctrl_proto.CtrlCmd',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='CTRL_CMD_ECHO', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CTRL_CMD_GET_RADIO_STATE', index=1, number=1,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=96,
+ serialized_end=154,
+)
+
+
+_CTRLSTATUS = descriptor.EnumDescriptor(
+ name='CtrlStatus',
+ full_name='ctrl_proto.CtrlStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='CTRL_STATUS_OK', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CTRL_STATUS_ERR', index=1, number=1,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=156,
+ serialized_end=209,
+)
+
+
+CTRL_CMD_ECHO = 0
+CTRL_CMD_GET_RADIO_STATE = 1
+CTRL_STATUS_OK = 0
+CTRL_STATUS_ERR = 1
+
+
+
+_CTRLRSPRADIOSTATE = descriptor.Descriptor(
+ name='CtrlRspRadioState',
+ full_name='ctrl_proto.CtrlRspRadioState',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='state', full_name='ctrl_proto.CtrlRspRadioState.state', index=0,
+ number=1, type=14, cpp_type=8, label=2,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=37,
+ serialized_end=94,
+)
+
+import ril_pb2
+
+_CTRLRSPRADIOSTATE.fields_by_name['state'].enum_type = ril_pb2._RADIOSTATE
+
+class CtrlRspRadioState(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _CTRLRSPRADIOSTATE
+
+ # @@protoc_insertion_point(class_scope:ctrl_proto.CtrlRspRadioState)
+
+# @@protoc_insertion_point(module_scope)
diff --git a/mock-ril/ctrl_server.cpp b/mock-ril/ctrl_server.cpp
new file mode 100644
index 0000000..65338ca
--- /dev/null
+++ b/mock-ril/ctrl_server.cpp
@@ -0,0 +1,482 @@
+/**
+ * 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.
+ */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <cutils/sockets.h>
+
+#include "logging.h"
+#include "node_buffer.h"
+#include "status.h"
+#include "util.h"
+#include "worker.h"
+
+#include "ctrl.pb.h"
+#include "ctrl_server.h"
+
+//#define CONTROL_SERVER_DEBUG
+#ifdef CONTROL_SERVER_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+#define MOCK_RIL_CONTROL_SERVER_STOPPING_SOCKET 54311
+#define MOCK_RIL_CONTROL_SERVER_SOCKET 54312
+
+class CtrlServerThread;
+static CtrlServerThread *g_ctrl_server;
+
+class CtrlServerThread : public WorkerThread {
+ private:
+ #define SOCKET_NAME_MOCK_RIL_CST_STOPPER "mock-ril-cst-stopper"
+ v8::Handle<v8::Context> context_;
+ int server_accept_socket_;
+ int server_to_client_socket_;
+ int stop_server_fd_;
+ int stop_client_fd_;
+ int stopper_fd_;
+ fd_set rd_fds_;
+ fd_set wr_fds_;
+ bool done_;
+
+ Buffer *ObtainBuffer(int length) {
+ Buffer *b = Buffer::New(length);
+ return b;
+ }
+
+ int WriteAll(int s, void *data, int length) {
+ int ret_value;
+ uint8_t *bytes = (uint8_t *)data;
+ int count = length;
+
+ while (length > 0) {
+ ret_value = send(s, bytes, length, 0);
+ if (ret_value < 0) {
+ return STATUS_ERR;
+ }
+ if (ret_value == 0) {
+ return STATUS_CLIENT_CLOSED_CONNECTION;
+ }
+ bytes += ret_value;
+ length -= ret_value;
+ }
+
+ return STATUS_OK;
+ }
+
+ int ReadAll(int s, void *data, int length) {
+ int ret_value;
+ uint8_t *bytes = (uint8_t *)data;
+ int count = length;
+
+ while (length != 0) {
+ ret_value = recv(s, bytes, length, 0);
+ if (ret_value < 0) {
+ return STATUS_ERR;
+ }
+ if (ret_value == 0) {
+ return STATUS_CLIENT_CLOSED_CONNECTION;
+ }
+ bytes += ret_value;
+ length -= ret_value;
+ }
+
+ return STATUS_OK;
+ }
+
+ int ReadMessage(MsgHeader *mh, Buffer **pBuffer) {
+ int status;
+
+ status = ReadAll(server_to_client_socket_, &mh->cmd, 4);
+ mh->cmd = letoh32(mh->cmd);
+ DBG("rm: mh->cmd=%d status=%d", mh->cmd, status);
+ if (status != STATUS_OK) return status;
+
+ status = ReadAll(server_to_client_socket_, &mh->token, 8);
+ mh->token = letoh64(mh->token);
+ DBG("rm: mh->token=%lld status=%d", mh->token, status);
+ if (status != STATUS_OK) return status;
+
+ status = ReadAll(server_to_client_socket_, &mh->status, 4);
+ mh->status = letoh32(mh->status);
+ DBG("rm: mh->status=%d status=%d", mh->status, status);
+ if (status != STATUS_OK) return status;
+
+ status = ReadAll(server_to_client_socket_, &mh->length_protobuf, 4);
+ mh->length_protobuf = letoh32(mh->length_protobuf);
+ DBG("rm: mh->length_protobuf=%d status=%d", mh->length_protobuf, status);
+ if (status != STATUS_OK) return status;
+
+ Buffer *buffer;
+ if (mh->length_protobuf > 0) {
+ buffer = ObtainBuffer(mh->length_protobuf);
+ status = ReadAll(server_to_client_socket_, buffer->data(), buffer->length());
+ DBG("rm: read protobuf status=%d", status);
+ if (status != STATUS_OK) return status;
+ } else {
+ DBG("rm: NO protobuf");
+ mh->length_protobuf = 0;
+ buffer = NULL;
+ }
+
+ *pBuffer = buffer;
+ return STATUS_OK;
+ }
+
+ public:
+ int WriteMessage(MsgHeader *mh, Buffer *buffer) {
+ int status;
+ uint32_t i;
+ uint64_t l;
+
+ i = htole32(mh->cmd);
+ status = WriteAll(server_to_client_socket_, &i, 4);
+ DBG("wm: mh->cmd=%d status=%d", mh->cmd, status);
+ if (status != 0) return status;
+
+ l = htole64(mh->token);
+ status = WriteAll(server_to_client_socket_, &l, 8);
+ DBG("wm: mh->token=%lld status=%d", mh->token, status);
+ if (status != 0) return status;
+
+ i = htole32(mh->status);
+ status = WriteAll(server_to_client_socket_, &i, 4);
+ DBG("wm: mh->status=%d status=%d", mh->status, status);
+ if (status != 0) return status;
+
+ if (buffer == NULL) {
+ mh->length_protobuf = 0;
+ } else {
+ mh->length_protobuf = buffer->length();
+ }
+ if (mh->length_protobuf < 0) {
+ LOGE("wm: length_protobuf=zero");
+ mh->length_protobuf = 0;
+ }
+ i = htole32(mh->length_protobuf);
+ status = WriteAll(server_to_client_socket_, &i, 4);
+ DBG("wm: mh->length_protobuf=%d status=%d",
+ mh->length_protobuf, status);
+ if (status != 0) return status;
+
+ if (mh->length_protobuf > 0) {
+ status = WriteAll(server_to_client_socket_, buffer->data(), buffer->length());
+ DBG("wm: protobuf data=%p len=%d status=%d",
+ buffer->data(), buffer->length(), status);
+ if (status != 0) return status;
+ }
+
+ return STATUS_OK;
+ }
+
+ CtrlServerThread(v8::Handle<v8::Context> context) :
+ context_(context),
+ server_accept_socket_(-1),
+ server_to_client_socket_(-1),
+ done_(false) {
+ }
+
+ virtual int Run() {
+ DBG("CtrlServerThread::Run E");
+
+ // Create a server socket.
+ server_accept_socket_ = socket_inaddr_any_server(
+ MOCK_RIL_CONTROL_SERVER_SOCKET, SOCK_STREAM);
+ if (server_accept_socket_ < 0) {
+ LOGE("CtrlServerThread::Run error creating server_accept_socket_ '%s'",
+ strerror(errno));
+ return STATUS_ERR;
+ }
+
+ // Create a server socket that will be used for stopping
+ stop_server_fd_ = socket_loopback_server(
+ MOCK_RIL_CONTROL_SERVER_STOPPING_SOCKET, SOCK_STREAM);
+ if (stop_server_fd_ < 0) {
+ LOGE("CtrlServerThread::Run error creating stop_server_fd_ '%s'",
+ strerror(errno));
+ return STATUS_ERR;
+ }
+
+ // Create a client socket that will be used for sending a stop
+ stop_client_fd_ = socket_loopback_client(
+ MOCK_RIL_CONTROL_SERVER_STOPPING_SOCKET, SOCK_STREAM);
+ if (stop_client_fd_ < 0) {
+ LOGE("CtrlServerThread::Run error creating stop_client_fd_ '%s'",
+ strerror(errno));
+ return STATUS_ERR;
+ }
+
+ // Accept the connection of the stop_client_fd_
+ stopper_fd_ = accept(stop_server_fd_, NULL, NULL);
+ if (stopper_fd_ < 0) {
+ LOGE("CtrlServerThread::Run error accepting stop_client_fd '%s'",
+ strerror(errno));
+ return STATUS_ERR;
+ }
+
+ // Run the new thread
+ int ret_value = WorkerThread::Run(NULL);
+ DBG("CtrlServerThread::Run X");
+ return ret_value;
+ }
+
+ virtual void Stop() {
+ DBG("CtrlServerThread::Stop E");
+ if (BeginStopping()) {
+ done_ = true;
+ int rv = send(stop_client_fd_, &done_, sizeof(done_), 0);
+ if (rv <= 0) {
+ LOGE("CtrlServerThread::Stop could not send stop"
+ "WE WILL PROBABLY HANG");
+ }
+ WaitUntilStopped();
+ }
+ DBG("CtrlServerThread::Stop X");
+ }
+
+ virtual bool isRunning() {
+ bool rv = done_ || WorkerThread::isRunning();
+ return rv;
+ }
+
+ int WaitOnSocketOrStopping(fd_set *rfds, int s) {
+ DBG("WaitOnSocketOrStopping E s=%d stopper_fd_=%d", s, stopper_fd_);
+ FD_ZERO(rfds);
+ FD_SET(s, rfds);
+ FD_SET(stopper_fd_, rfds);
+ int fd_number = s > stopper_fd_ ? s + 1 : stopper_fd_ + 1;
+ v8::Unlocker unlocker;
+ int rv = select(fd_number, rfds, NULL, NULL, NULL);
+ v8::Locker locker;
+ DBG("WaitOnSocketOrStopping X rv=%d s=%d stopper_fd_=%d", rv, s, stopper_fd_);
+ return rv;
+ }
+
+ int sendToCtrlServer(MsgHeader *mh, Buffer *buffer) {
+ DBG("sendToCtrlServer E: cmd=%d token=%lld", mh->cmd, mh->token);
+
+ int status = STATUS_OK;
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ // Get the onRilRequest Function
+ v8::Handle<v8::String> name = v8::String::New("onCtrlServerCmd");
+ v8::Handle<v8::Value> onCtrlServerCmdFunctionValue =
+ context_->Global()->Get(name);
+ v8::Handle<v8::Function> onCtrlServerCmdFunction =
+ v8::Handle<v8::Function>::Cast(onCtrlServerCmdFunctionValue);
+
+ // Create the CmdValue and TokenValue
+ v8::Handle<v8::Value> v8CmdValue = v8::Number::New(mh->cmd);
+ v8::Handle<v8::Value> v8TokenValue = v8::Number::New(mh->token);
+
+ // Invoke onRilRequest
+ const int argc = 3;
+ v8::Handle<v8::Value> buf;
+ if (mh->length_protobuf == 0) {
+ buf = v8::Undefined();
+ } else {
+ buf = buffer->handle_;
+ }
+ v8::Handle<v8::Value> argv[argc] = {
+ v8CmdValue, v8TokenValue, buf };
+ v8::Handle<v8::Value> result =
+ onCtrlServerCmdFunction->Call(context_->Global(), argc, argv);
+ if (try_catch.HasCaught()) {
+ ReportException(&try_catch);
+ status = STATUS_ERR;
+ } else {
+ v8::String::Utf8Value result_string(result);
+ DBG("sendToCtrlServer result=%s", ToCString(result_string));
+ status = STATUS_OK;
+ }
+
+ if (status != STATUS_OK) {
+ LOGE("sendToCtrlServer Error: status=%d", status);
+ // An error report complete now
+ mh->length_protobuf = 0;
+ mh->status = ctrl_proto::CTRL_STATUS_ERR;
+ g_ctrl_server->WriteMessage(mh, NULL);
+ }
+
+ DBG("sendToCtrlServer X: status=%d", status);
+ return status;
+ }
+
+ virtual void * Worker(void *param) {
+ DBG("CtrlServerThread::Worker E param=%p stopper_fd_=%d",
+ param, stopper_fd_);
+
+ v8::Locker locker;
+ v8::HandleScope handle_scope;
+ v8::Context::Scope context_scope(context_);
+
+ while (isRunning()) {
+ int ret_value;
+
+ // Wait on either server_accept_socket_ or stopping
+ DBG("CtrlServerThread::Worker wait on server for a client");
+ WaitOnSocketOrStopping(&rd_fds_, server_accept_socket_);
+ if (isRunning() != true) {
+ break;
+ }
+
+ if (FD_ISSET(server_accept_socket_, &rd_fds_)) {
+ server_to_client_socket_ = accept(server_accept_socket_, NULL, NULL);
+ DBG("CtrlServerThread::Worker accepted server_to_client_socket_=%d isRunning()=%d",
+ server_to_client_socket_, isRunning());
+
+ int status;
+ Buffer *buffer;
+ MsgHeader mh;
+ while ((server_to_client_socket_ > 0) && isRunning()) {
+ DBG("CtrlServerThread::Worker wait on client for message");
+ WaitOnSocketOrStopping(&rd_fds_, server_to_client_socket_);
+ if (isRunning() != true) {
+ break;
+ }
+
+ status = ReadMessage(&mh, &buffer);
+ if (status != STATUS_OK) break;
+
+ if (mh.cmd == ctrl_proto::CTRL_CMD_ECHO) {
+ LOGD("CtrlServerThread::Worker echo");
+ status = WriteMessage(&mh, buffer);
+ if (status != STATUS_OK) break;
+ } else {
+ DBG("CtrlServerThread::Worker sendToCtrlServer");
+ status = sendToCtrlServer(&mh, buffer);
+ if (status != STATUS_OK) break;
+ }
+ }
+ close(server_to_client_socket_);
+ server_to_client_socket_ = -1;
+ }
+ }
+ close(stop_server_fd_);
+ stop_server_fd_ = -1;
+
+ close(stop_client_fd_);
+ stop_client_fd_ = -1;
+
+ close(stopper_fd_);
+ stopper_fd_ = -1;
+
+ close(server_accept_socket_);
+ server_accept_socket_ = -1;
+
+ DBG("CtrlServerThread::Worker X param=%p", param);
+ return NULL;
+ }
+};
+
+/**
+ * Send a control request complete response.
+ */
+v8::Handle<v8::Value> SendCtrlRequestComplete(const v8::Arguments& args) {
+ DBG("SendCtrlRequestComplete E:");
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> retValue;
+
+ void *data;
+ size_t datalen;
+
+ Buffer* buffer;
+ MsgHeader mh;
+
+ /**
+ * Get the arguments. There should be at least 3, reqNum,
+ * ril error code and token. Optionally a Buffer containing
+ * the protobuf representation of the data to return.
+ */
+ if (args.Length() < 3) {
+ // Expecting a reqNum, ERROR and token
+ LOGE("SendCtrlRequestComplete X %d parameters"
+ " expecting at least 3: status, reqNum, and token",
+ args.Length());
+ return v8::Undefined();
+ }
+ v8::Handle<v8::Value> v8CtrlStatus(args[0]->ToObject());
+ mh.status = ctrl_proto::CtrlStatus(v8CtrlStatus->NumberValue());
+ DBG("SendCtrlRequestComplete: status=%d", mh.status);
+
+ v8::Handle<v8::Value> v8ReqNum(args[1]->ToObject());
+ mh.cmd = int(v8ReqNum->NumberValue());
+ DBG("SendCtrlRequestComplete: cmd=%d", mh.cmd);
+
+ v8::Handle<v8::Value> v8Token(args[2]->ToObject());
+ mh.token = int64_t(v8Token->NumberValue());
+ DBG("SendCtrlRequestComplete: token=%lld", mh.token);
+
+ if (args.Length() >= 4) {
+ buffer = ObjectWrap::Unwrap<Buffer>(args[3]->ToObject());
+ mh.length_protobuf = buffer->length();
+ DBG("SendCtrlRequestComplete: mh.length_protobuf=%d",
+ mh.length_protobuf);
+ } else {
+ mh.length_protobuf = 0;
+ buffer = NULL;
+ DBG("SendCtrlRequestComplete: NO PROTOBUF");
+ }
+
+ DBG("SendCtrlRequestComplete: WriteMessage");
+ int status = g_ctrl_server->WriteMessage(&mh, buffer);
+
+ DBG("SendCtrlRequestComplete E:");
+ return v8::Undefined();
+}
+
+void ctrlServerInit(v8::Handle<v8::Context> context) {
+ int status;
+
+ g_ctrl_server = new CtrlServerThread(context);
+ status = g_ctrl_server->Run();
+ if (status != STATUS_OK) {
+ LOGE("mock_ril control server could not start");
+ } else {
+ LOGD("CtrlServer started");
+ }
+
+#if 0
+ LOGD("Test CtrlServerThread stop sleeping 10 seconds...");
+ v8::Unlocker unlocker;
+ sleep(10);
+ LOGD("Test CtrlServerThread call Stop");
+ g_ctrl_server->Stop();
+ v8::Locker locker;
+
+ // Restart
+ g_ctrl_server = new CtrlServerThread(context);
+ status = g_ctrl_server->Run();
+ if (status != STATUS_OK) {
+ LOGE("mock_ril control server could not start");
+ } else {
+ DBG("mock_ril control server started");
+ }
+#endif
+}
diff --git a/mock-ril/ctrl_server.h b/mock-ril/ctrl_server.h
new file mode 100644
index 0000000..c964597
--- /dev/null
+++ b/mock-ril/ctrl_server.h
@@ -0,0 +1,38 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_CONTROL_SERVER_H_
+#define MOCK_RIL_CONTROL_SERVER_H_
+
+#include <v8.h>
+
+/**
+ * All Control messages start with a header followed
+ * by an optional protobuf. If length_protobuf is 0
+ * there is no protobuf following the header.
+ */
+struct MsgHeader {
+ int32_t cmd;
+ int64_t token;
+ int32_t status;
+ int32_t length_protobuf;
+};
+
+extern v8::Handle<v8::Value> SendCtrlRequestComplete(const v8::Arguments& args);
+
+extern void ctrlServerInit(v8::Handle<v8::Context> context);
+
+#endif // MOCK_RIL_CONTROL_SERVER_H_
diff --git a/mock-ril/experiments.cpp b/mock-ril/experiments.cpp
new file mode 100644
index 0000000..317fd9d
--- /dev/null
+++ b/mock-ril/experiments.cpp
@@ -0,0 +1,281 @@
+/**
+ * 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.
+ */
+
+#include <v8.h>
+#include <telephony/ril.h>
+
+#include "logging.h"
+#include "status.h"
+#include "worker.h"
+#include "util.h"
+
+#include "ril.pb.h"
+
+#include "logging.h"
+#include "js_support.h"
+#include "node_buffer.h"
+#include "node_util.h"
+#include "protobuf_v8.h"
+#include "requests.h"
+
+#include "experiments.h"
+
+void testStlPort() {
+ // Test using STLport
+ std::queue<int *> q;
+ int data[] = {1, 2, 3};
+
+ int *param = data;
+ 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());
+}
+
+v8::Handle<v8::Value> GetReqScreenState(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("GetReqScreenState state=%d", state);
+ return v8::Integer::New(state);
+}
+
+bool callOnRilRequest(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 onRilRequestFunction, making sure its a function
+ v8::Handle<v8::String> name = v8::String::New("onRilRequest");
+ v8::Handle<v8::Value> onRilRequestFunctionValue = context->Global()->Get(name);
+ if(!onRilRequestFunctionValue->IsFunction()) {
+ // Wasn't a function
+ LOGD("callOnRilRequest X wasn't a function");
+ return false;
+ }
+ v8::Handle<v8::Function> onRilRequestFunction =
+ v8::Handle<v8::Function>::Cast(onRilRequestFunctionValue);
+
+ // 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("callOnRilRequest RIL_REQUEST_SCREEN_STATE");
+ if (datalen < sizeof(int)) {
+ LOGD("callOnRilRequest 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(
+ "ReqScreenState"), GetReqScreenState, 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("callOnRilRequest X unknown request");
+ break;
+ }
+ }
+
+ // Invoke onRilRequest
+ bool retValue;
+ const int argc = 2;
+ v8::Handle<v8::Value> argv[argc] = { v8RequestValue, params_obj };
+ v8::Handle<v8::Value> result =
+ onRilRequestFunction->Call(context->Global(), argc, argv);
+ if (try_catch.HasCaught()) {
+ LOGD("callOnRilRequest error");
+ ReportException(&try_catch);
+ retValue = false;
+ } else {
+ v8::String::Utf8Value result_string(result);
+ LOGD("callOnRilRequest result=%s", ToCString(result_string));
+ retValue = true;
+ }
+ return retValue;
+}
+
+void testOnRilRequestUsingCppRequestObjs(v8::Handle<v8::Context> context) {
+ LOGD("testOnRilRequestUsingCppRequestObjs E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ runJs(context, &try_catch, "local-string",
+ "function onRilRequest(reqNum, params) {\n"
+ " print(\"reqNum=\" + reqNum);\n"
+ " if (reqNum == 61) {\n"
+ " print(\"params.ReqScreenState=\" + params.ReqScreenState);\n"
+ " }\n"
+ " return \"Hello World\";\n"
+ "}\n");
+ if (!try_catch.HasCaught()) {
+ // Call the onRilRequest function
+ int data[1] = { 0 };
+ callOnRilRequest(context, RIL_REQUEST_SCREEN_STATE, data,
+ sizeof(data), NULL);
+ }
+ LOGD("testOnRilRequestUsingCppRequestObjs X:");
+}
+
+void testReqScreenStateProtobuf() {
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ LOGD("testReqScreenStateProtobuf E");
+
+ LOGD("create ReqScreenState");
+ ril_proto::ReqScreenState* ss = new ril_proto::ReqScreenState();
+ ss->set_state(true);
+ bool state = ss->state();
+ LOGD("state=%d", state);
+ ss->set_state(false);
+ state = ss->state();
+ LOGD("state=%d", state);
+ int len = ss->ByteSize();
+ LOGD("create buffer len=%d", len);
+ char *buffer = new char[len];
+ LOGD("serialize");
+ bool ok = ss->SerializeToArray(buffer, len);
+ if (!ok) {
+ LOGD("testReqScreenStateProtobuf X: Could not serialize ss");
+ return;
+ }
+ LOGD("ReqScreenState serialized ok");
+ ril_proto::ReqScreenState *newSs = new ril_proto::ReqScreenState();
+ ok = newSs->ParseFromArray(buffer, len);
+ if (!ok) {
+ LOGD("testReqScreenStateProtobuf X: Could not deserialize ss");
+ return;
+ }
+ LOGD("newSs->state=%d", newSs->state());
+
+ delete [] buffer;
+ delete ss;
+ delete newSs;
+ LOGD("testReqScreenStateProtobuf X");
+}
+
+void testReqHangUpProtobuf() {
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ LOGD("testReqHangUpProtobuf E");
+
+ LOGD("create ReqHangUp");
+ ril_proto::ReqHangUp* hu = new ril_proto::ReqHangUp();
+ hu->set_connection_index(3);
+ bool connection_index = hu->connection_index();
+ LOGD("connection_index=%d", connection_index);
+ hu->set_connection_index(2);
+ connection_index = hu->connection_index();
+ LOGD("connection_index=%d", connection_index);
+ LOGD("create buffer");
+ int len = hu->ByteSize();
+ char *buffer = new char[len];
+ LOGD("serialize");
+ bool ok = hu->SerializeToArray(buffer, len);
+ if (!ok) {
+ LOGD("testReqHangUpProtobuf X: Could not serialize hu");
+ return;
+ }
+ LOGD("ReqHangUp serialized ok");
+ ril_proto::ReqHangUp *newHu = new ril_proto::ReqHangUp();
+ ok = newHu->ParseFromArray(buffer, len);
+ if (!ok) {
+ LOGD("testReqHangUpProtobuf X: Could not deserialize hu");
+ return;
+ }
+ LOGD("newHu->connection_index=%d", newHu->connection_index());
+
+ delete [] buffer;
+ delete hu;
+ delete newHu;
+ LOGD("testReqHangUpProtobuf X");
+}
+
+void testProtobufV8(v8::Handle<v8::Context> context) {
+ LOGD("testProtobufV8 E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ if (try_catch.HasCaught()) {
+ LOGD("TryCatch.hasCaught is true after protobuf_v8::init");
+ ReportException(&try_catch);
+ }
+ runJs(context, &try_catch, "local-string",
+ "fileContents = readFileToString('mock_ril.js');\n"
+ "print('fileContents:\\n' + fileContents);\n"
+ "\n"
+ "buffer = readFileToBuffer('ril.desc');\n"
+ "var schema = new Schema(buffer);\n"
+ "\n"
+ "var originalReqEnterSimPin = { pin : 'hello-the-pin' };\n"
+ "print('originalReqEnterSimPin: pin=' + originalReqEnterSimPin.pin);\n"
+ "var ReqEnterSimPinSchema = schema['ril_proto.ReqEnterSimPin'];\n"
+ "serializedOriginalReqEnterSimPin = ReqEnterSimPinSchema.serialize(originalReqEnterSimPin);\n"
+ "print('serializedOriginalReqEnterSimPin.length=' + serializedOriginalReqEnterSimPin.length);\n"
+ "newReqEnterSimPin = ReqEnterSimPinSchema.parse(serializedOriginalReqEnterSimPin);\n"
+ "print('newReqEnterSimPin: pin=' + newReqEnterSimPin.pin);\n"
+ "\n"
+ "var originalReqScreenState = { state : true };\n"
+ "print('originalReqScreenState: state=' + originalReqScreenState.state);\n"
+ "var ReqScreenStateSchema = schema['ril_proto.ReqScreenState'];\n"
+ "var serializedOriginalReqScreenState = ReqScreenStateSchema.serialize(originalReqScreenState);\n"
+ "print('serializedOriginalReqScreenState.length=' + serializedOriginalReqScreenState.length);\n"
+ "var newReqScreenState = ReqScreenStateSchema.parse(serializedOriginalReqScreenState);\n"
+ "print('newReqScreenState: state=' + newReqScreenState.state);\n"
+ "\n"
+ "originalReqScreenState.state = false;\n"
+ "print('originalReqScreenState: state=' + originalReqScreenState.state);\n"
+ "serializedOriginalReqScreenState = ReqScreenStateSchema.serialize(originalReqScreenState);\n"
+ "print('serializedOriginalReqScreenState.length=' + serializedOriginalReqScreenState.length);\n"
+ "newReqScreenState = ReqScreenStateSchema.parse(serializedOriginalReqScreenState);\n"
+ "print('newReqScreenState: state=' + newReqScreenState.state);\n");
+ LOGD("testProtobufV8 X");
+}
+
+void experiments(v8::Handle<v8::Context> context) {
+ LOGD("experiments E: ********");
+ testStlPort();
+ testReqScreenStateProtobuf();
+ testOnRilRequestUsingCppRequestObjs(context);
+ testProtobufV8(context);
+ LOGD("experiments X: ********\n");
+}
diff --git a/mock-ril/experiments.h b/mock-ril/experiments.h
new file mode 100644
index 0000000..54044ab
--- /dev/null
+++ b/mock-ril/experiments.h
@@ -0,0 +1,24 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_INITIAL_TESTS_H_
+#define MOCK_RIL_INITIAL_TESTS_H_
+
+#include <v8.h>
+
+void experiments(v8::Handle<v8::Context> context);
+
+#endif // MOCK_RIL_INITIAL_TESTS_H_
diff --git a/mock-ril/js_support.cpp b/mock-ril/js_support.cpp
new file mode 100644
index 0000000..83955e3
--- /dev/null
+++ b/mock-ril/js_support.cpp
@@ -0,0 +1,415 @@
+/**
+ * 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.
+ */
+
+#include <v8.h>
+#include <telephony/ril.h>
+
+#include "ctrl_server.h"
+#include "logging.h"
+#include "node_buffer.h"
+#include "node_object_wrap.h"
+#include "node_util.h"
+#include "protobuf_v8.h"
+#include "responses.h"
+#include "status.h"
+#include "util.h"
+#include "worker.h"
+#include "worker_v8.h"
+
+#include "js_support.h"
+
+//#define JS_SUPPORT_DEBUG
+#ifdef JS_SUPPORT_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+/**
+ * Current Radio state
+ */
+RIL_RadioState RadioState = RADIO_STATE_UNAVAILABLE;
+
+v8::Handle<v8::Value> RadioStateGetter(v8::Local<v8::String> property,
+ const v8::AccessorInfo& info) {
+ return v8::Integer::New((int)RadioState);
+}
+
+void RadioStateSetter(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
+ RadioState = RIL_RadioState(value->Int32Value());
+}
+
+// A javascript sleep for a number of milli-seconds
+v8::Handle<v8::Value> MsSleep(const v8::Arguments& args) {
+ if (args.Length() != 1) {
+ DBG("MsSleep: expecting milli-seconds to sleep");
+ } else {
+ v8::Handle<v8::Value> v8MsValue(args[0]->ToObject());
+ int ms = int(v8MsValue->NumberValue());
+ v8::Unlocker unlocker;
+ usleep(ms * 1000);
+ v8::Locker locker;
+ }
+ return v8::Undefined();
+}
+
+// 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();
+}
+
+int ReadFile(const char *fileName, char** data, size_t *length) {
+ int status;
+ char* buffer = NULL;
+ size_t fileLength = 0;
+ FILE *f;
+
+ DBG("ReadFile E fileName=%s", fileName);
+
+ f = fopen(fileName, "rb");
+ if (f == NULL) {
+ DBG("Could not fopen '%s'", fileName);
+ status = STATUS_COULD_NOT_OPEN_FILE;
+ } else {
+ // Determine the length of the file
+ fseek(f, 0, SEEK_END);
+ fileLength = ftell(f);
+ DBG("fileLength=%d", fileLength);
+ rewind(f);
+
+ // Read file into a buffer
+ buffer = new char[fileLength+1];
+ size_t readLength = fread(buffer, 1, fileLength, f);
+ if (readLength != fileLength) {
+ DBG("Couldn't read entire file");
+ delete [] buffer;
+ buffer = NULL;
+ status = STATUS_COULD_NOT_READ_FILE;
+ } else {
+ DBG("File read");
+ buffer[fileLength] = 0;
+ status = STATUS_OK;
+ }
+ fclose(f);
+ }
+
+ if (length != NULL) {
+ *length = fileLength;
+ }
+ *data = buffer;
+ DBG("ReadFile X status=%d", status);
+ return status;
+}
+
+char *CreateFileName(const v8::Arguments& args) {
+ v8::String::Utf8Value fileNameUtf8Value(args[0]);
+ const char* fileName = ToCString(fileNameUtf8Value);
+ const char* directory = "/sdcard/data/";
+
+ int fullPathLength = strlen(directory) + strlen(fileName) + 1;
+ char * fullPath = new char[fullPathLength];
+ strncpy(fullPath, directory, fullPathLength);
+ strncat(fullPath, fileName, fullPathLength);
+ return fullPath;
+}
+
+// A javascript read file function arg[0] = filename
+v8::Handle<v8::Value> ReadFileToString(const v8::Arguments& args) {
+ DBG("ReadFileToString E");
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> retValue;
+
+ if (args.Length() < 1) {
+ // No file name return Undefined
+ DBG("ReadFile X no argumens");
+ return v8::Undefined();
+ } else {
+ char *fileName = CreateFileName(args);
+
+ char *buffer;
+ int status = ReadFile(fileName, &buffer);
+ if (status == 0) {
+ retValue = v8::String::New(buffer);
+ } else {
+ retValue = v8::Undefined();
+ }
+ }
+ DBG("ReadFileToString X");
+ return retValue;
+}
+
+// A javascript read file function arg[0] = filename
+v8::Handle<v8::Value> ReadFileToBuffer(const v8::Arguments& args) {
+ DBG("ReadFileToBuffer E");
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> retValue;
+
+ if (args.Length() < 1) {
+ // No file name return Undefined
+ DBG("ReadFileToBuffer X no argumens");
+ return v8::Undefined();
+ } else {
+ char *fileName = CreateFileName(args);
+
+ char *buffer;
+ size_t length;
+ int status = ReadFile(fileName, &buffer, &length);
+ if (status == 0) {
+ Buffer *buf = Buffer::New(length);
+ memmove(buf->data(), buffer, length);
+ retValue = buf->handle_;
+ } else {
+ retValue = v8::Undefined();
+ }
+ }
+ DBG("ReadFileToBuffer X");
+ return retValue;
+}
+
+void ErrorCallback(v8::Handle<v8::Message> message,
+ v8::Handle<v8::Value> data) {
+ LogErrorMessage(message, "");
+}
+
+// Read, compile and run a javascript file
+v8::Handle<v8::Value> Include(const v8::Arguments& args) {
+ DBG("Include E");
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> retValue;
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ if (args.Length() < 1) {
+ // No file name return Undefined
+ DBG("Include X no argumens");
+ return v8::Undefined();
+ } else {
+ char *fileName = CreateFileName(args);
+
+ char *buffer;
+ int status = ReadFile(fileName, &buffer);
+ if (status == 0) {
+ runJs(v8::Context::GetCurrent(), &try_catch, fileName, buffer);
+ } else {
+ retValue = v8::Undefined();
+ }
+ }
+ DBG("Include X");
+ return retValue;
+}
+
+
+/**
+ * Create a JsContext, must be called within a HandleScope?
+ */
+v8::Persistent<v8::Context> makeJsContext() {
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ // Add a Message listner to Catch errors as they occur
+ v8::V8::AddMessageListener(ErrorCallback);
+
+ // 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->SetAccessor(v8::String::New("radioState"),
+ RadioStateGetter, RadioStateSetter);
+ global->Set(v8::String::New("msSleep"), v8::FunctionTemplate::New(MsSleep));
+ global->Set(v8::String::New("print"), v8::FunctionTemplate::New(Print));
+ global->Set(v8::String::New("readFileToBuffer"),
+ v8::FunctionTemplate::New(ReadFileToBuffer));
+ global->Set(v8::String::New("readFileToString"),
+ v8::FunctionTemplate::New(ReadFileToString));
+ global->Set(v8::String::New("sendRilRequestComplete"),
+ v8::FunctionTemplate::New(SendRilRequestComplete));
+ global->Set(v8::String::New("sendRilUnsolicitedResponse"),
+ v8::FunctionTemplate::New(SendRilUnsolicitedResponse));
+ global->Set(v8::String::New("sendCtrlRequestComplete"),
+ v8::FunctionTemplate::New(SendCtrlRequestComplete));
+ global->Set(v8::String::New("include"), v8::FunctionTemplate::New(Include));
+ WorkerV8ObjectTemplateInit(global);
+ SchemaObjectTemplateInit(global);
+ Buffer::InitializeObjectTemplate(global);
+
+ // Create context with our globals and make it the current scope
+ v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
+
+
+ if (try_catch.HasCaught()) {
+ DBG("makeJsContext: Exception making the context");
+ ReportException(&try_catch);
+ try_catch.ReThrow();
+ }
+
+ return context;
+}
+
+/**
+ * Run some javascript code.
+ */
+void runJs(v8::Handle<v8::Context> context, v8::TryCatch *try_catch,
+ const char *fileName, const char *code) {
+ v8::HandleScope handle_scope;
+
+ // Compile the source
+ v8::Handle<v8::Script> script = v8::Script::Compile(
+ v8::String::New(code), v8::String::New(fileName));
+ if (try_catch->HasCaught()) {
+ LOGE("-- Compiling the source failed");
+ } else {
+ // Run the resulting script
+ v8::Handle<v8::Value> result = script->Run();
+ if (try_catch->HasCaught()) {
+ LOGE("-- Running the script failed");
+ }
+ }
+}
+
+void testRadioState(v8::Handle<v8::Context> context) {
+ LOGD("testRadioState E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ runJs(context, &try_catch, "local-string",
+ "for(i = 0; i < 10; i++) {\n"
+ " radioState = i;\n"
+ " print('radioState=' + radioState);\n"
+ "}\n"
+ "radioState = 1;\n"
+ "print('last radioState=' + radioState);\n");
+ LOGD("testRadioState X:");
+}
+
+void testMsSleep(v8::Handle<v8::Context> context) {
+ LOGD("testMsSleep E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ runJs(context, &try_catch, "local-string",
+ "for(i = 0; i < 10; i++) {\n"
+ " sleeptime = i * 200\n"
+ " print('msSleep ' + sleeptime);\n"
+ " msSleep(sleeptime);\n"
+ "}\n");
+ LOGD("testMsSleep X:");
+}
+
+void testPrint(v8::Handle<v8::Context> context) {
+ LOGD("testPrint E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ runJs(context, &try_catch, "local-string", "print(\"Hello\")");
+ LOGD("testPrint X:");
+}
+
+void testCompileError(v8::Handle<v8::Context> context) {
+ LOGD("testCompileError E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ // +++ generate a compile time error
+ runJs(context, &try_catch, "local-string", "+++");
+ LOGD("testCompileError X:");
+}
+
+void testRuntimeError(v8::Handle<v8::Context> context) {
+ LOGD("testRuntimeError E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ // Runtime error
+ runJs(context, &try_catch, "local-string",
+ "function hello() {\n"
+ " print(\"Hi there\");\n"
+ "}\n"
+ "helloo()");
+ LOGD("testRuntimeError X:");
+}
+
+void testReadFile() {
+ char *buffer;
+ size_t length;
+ int status;
+
+ LOGD("testReadFile E:");
+
+ status = ReadFile("/sdcard/data/no-file", &buffer, &length);
+ LOGD("testReadFile expect status != 0, status=%d, buffer=%p, length=%d",
+ status, buffer, length);
+
+ LOGD("testReadFile X:");
+}
+
+
+void testReadFileToStringBuffer(v8::Handle<v8::Context> context) {
+ LOGD("testReadFileToStringBuffer E:");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ runJs(context, &try_catch, "local-string",
+ "fileContents = readFileToString(\"mock_ril.js\");\n"
+ "print(\"fileContents:\\n\" + fileContents);\n"
+ "buffer = readFileToBuffer(\"ril.desc\");\n"
+ "print(\"buffer.length=\" + buffer.length);\n");
+ LOGD("testReadFileToStringBuffer X:");
+}
+
+void testJsSupport(v8::Handle<v8::Context> context) {
+ LOGD("testJsSupport E: ********");
+ testRadioState(context);
+ testMsSleep(context);
+ testPrint(context);
+ testCompileError(context);
+ testRuntimeError(context);
+ testReadFile();
+ testReadFileToStringBuffer(context);
+ LOGD("testJsSupport X: ********\n");
+}
diff --git a/mock-ril/js_support.h b/mock-ril/js_support.h
new file mode 100644
index 0000000..9827b24
--- /dev/null
+++ b/mock-ril/js_support.h
@@ -0,0 +1,47 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_JS_SUPPORT_H_
+#define MOCK_RIL_JS_SUPPORT_H_
+
+#include <v8.h>
+#include <telephony/ril.h>
+
+extern RIL_RadioState RadioState;
+
+// A javascript print function
+extern v8::Handle<v8::Value> Print(const v8::Arguments& args);
+
+// Read a file into a array returning the buffer and the
+extern int ReadFile(const char *fileName, char** data, size_t *length = NULL);
+
+// A javascript read file function arg[0] = filename
+extern v8::Handle<v8::Value> ReadFileToString(const v8::Arguments& args);
+
+// A javascript read file function arg[0] = filename
+extern v8::Handle<v8::Value> ReadFileToBuffer(const v8::Arguments& args);
+
+// make the Java
+extern v8::Persistent<v8::Context> makeJsContext();
+
+// Run a javascript
+extern void runJs(v8::Handle<v8::Context> context, v8::TryCatch *try_catch,
+ const char *fileName, const char *code);
+
+// Test this module
+extern void testJsSupport(v8::Handle<v8::Context> context);
+
+#endif // MOCK_RIL_JS_SUPPORT_H_
diff --git a/mock-ril/logging.h b/mock-ril/logging.h
new file mode 100644
index 0000000..602fbf2
--- /dev/null
+++ b/mock-ril/logging.h
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+
+#ifndef _LOGGING_H
+#define _LOGGING_H
+
+// The LOG_TAG should start with "RIL" so it shows up in the radio log
+#define LOG_TAG "RIL-MOCK"
+
+#include <utils/Log.h>
+
+#endif
diff --git a/mock-ril/mock-ril.cpp b/mock-ril/mock-ril.cpp
deleted file mode 100644
index ea9897b..0000000
--- a/mock-ril/mock-ril.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/**
- * 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/mock_ril.cpp b/mock-ril/mock_ril.cpp
new file mode 100644
index 0000000..8c9ea42
--- /dev/null
+++ b/mock-ril/mock_ril.cpp
@@ -0,0 +1,327 @@
+/**
+ * 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.
+ */
+
+#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 <v8.h>
+
+#include "ril.pb.h"
+
+#include "ctrl_server.h"
+#include "logging.h"
+#include "experiments.h"
+#include "js_support.h"
+#include "node_buffer.h"
+#include "node_object_wrap.h"
+#include "node_util.h"
+#include "protobuf_v8.h"
+#include "requests.h"
+#include "responses.h"
+#include "status.h"
+#include "util.h"
+#include "worker.h"
+#include "worker_v8.h"
+
+#include "mock_ril.h"
+
+//#define MOCK_RIL_DEBUG
+#ifdef MOCK_RIL_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+
+#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();
+
+static void testOnRequestComplete(RIL_Token t, RIL_Errno e,
+ void *response, size_t responselen);
+static void testRequestTimedCallback(RIL_TimedCallback callback,
+ void *param, const struct timeval *relativeTime);
+static void testOnUnsolicitedResponse(int unsolResponse, const void *data,
+ size_t datalen);
+
+/**
+ * The environment from rild with the completion routine
+ */
+const struct RIL_Env *s_rilenv;
+
+/**
+ * Expose our routines to rild
+ */
+static const RIL_RadioFunctions s_callbacks = {
+ RIL_VERSION,
+ onRequest,
+ currentState,
+ onSupports,
+ onCancel,
+ getVersion
+};
+
+/**
+ * A test environment
+ */
+static const RIL_Env testEnv = {
+ testOnRequestComplete,
+ testOnUnsolicitedResponse,
+ testRequestTimedCallback
+};
+
+/**
+ * The request worker queue to handle requests
+ */
+static RilRequestWorkerQueue *s_requestWorkerQueue;
+
+/**
+ * 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 c1mpleted).
+ */
+static void onRequest (int request, void *data, size_t datalen, RIL_Token t)
+{
+ DBG("onRequest: request=%d data=%p datalen=%d token=%p",
+ request, data, datalen, t);
+ s_requestWorkerQueue->AddRequest(request, data, datalen, t);
+}
+
+/**
+ * Synchronous call from the RIL to us to return current radio state.
+ * RADIO_STATE_UNAVAILABLE should be the initial state.
+ */
+static RIL_RadioState currentState()
+{
+ DBG("currentState: RadioState=%d", RadioState);
+ return RadioState;
+}
+
+/**
+ * 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)
+{
+ DBG("onSupports: nothing supported at the moment, return 0");
+ return 0;
+}
+
+static void onCancel (RIL_Token t)
+{
+ DBG("onCancel: ignorning");
+}
+
+static const char * getVersion(void)
+{
+ DBG("getVersion: return '%s'", MOCK_RIL_VER_STRING);
+ return MOCK_RIL_VER_STRING;
+}
+
+/**
+ * "t" is parameter passed in on previous call to RIL_Notification
+ * routine.
+ *
+ * If "e" != SUCCESS, then response can be null/is ignored
+ *
+ * "response" is owned by caller, and should not be modified or
+ * freed by callee
+ *
+ * RIL_onRequestComplete will return as soon as possible
+ */
+void testOnRequestComplete(RIL_Token t, RIL_Errno e,
+ void *response, size_t responselen) {
+ DBG("testOnRequestComplete E: token=%p rilErrCode=%d data=%p datalen=%d",
+ t, e, response, responselen);
+ DBG("testOnRequestComplete X:");
+}
+
+/**
+ * "unsolResponse" is one of RIL_UNSOL_RESPONSE_*
+ * "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_*
+ *
+ * "data" is owned by caller, and should not be modified or freed by callee
+ */
+void testOnUnsolicitedResponse(int unsolResponse, const void *data,
+ size_t datalen) {
+ DBG("testOnUnsolicitedResponse ignoring");
+}
+
+/**
+ * Call user-specifed "callback" function on on the same thread that
+ * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies
+ * a relative time value at which the callback is invoked. If relativeTime is
+ * NULL or points to a 0-filled structure, the callback will be invoked as
+ * soon as possible
+ */
+void testRequestTimedCallback(RIL_TimedCallback callback,
+ void *param, const struct timeval *relativeTime) {
+ DBG("testRequestTimedCallback ignoring");
+}
+
+#if 0
+class UnsolicitedThread : public WorkerThread {
+ private:
+ v8::Handle<v8::Context> context_;
+
+ public:
+ UnsolicitedThread(v8::Handle<v8::Context> context) :
+ context_(context) {
+ }
+
+ int OnUnsolicitedTick(int tick) {
+ v8::HandleScope handle_scope;
+
+ // Get handle to onUnslicitedTick.
+ v8::Handle<v8::String> name = v8::String::New("onUnsolicitedTick");
+ v8::Handle<v8::Value> functionValue = context_->Global()->Get(name);
+ v8::Handle<v8::Function> onUnsolicitedTick =
+ v8::Handle<v8::Function>::Cast(functionValue);
+
+ // Create the argument array
+ v8::Handle<v8::Value> v8TickValue = v8::Number::New(tick);
+ v8::Handle<v8::Value> argv[1] = { v8TickValue };
+
+ v8::Handle<v8::Value> resultValue =
+ onUnsolicitedTick->Call(context_->Global(), 1, argv);
+ int result = int(resultValue->NumberValue());
+ return result;
+ }
+
+ void * Worker(void *param)
+ {
+ LOGD("UnsolicitedThread::Worker E param=%p", param);
+
+ v8::Locker locker;
+
+ for (int i=0;!Stopping();i++) {
+ // Get access and setup scope
+ v8::HandleScope handle_scope;
+ v8::Context::Scope context_scope(context_);
+
+ // Do it
+ int sleepTime = OnUnsolicitedTick(i);
+
+ // Wait
+ v8::Unlocker unlocker;
+ sleep(sleepTime);
+ v8::Locker locker;
+ }
+
+ LOGD("UnsolicitedThread::Worker X param=%p", param);
+
+ return NULL;
+ }
+};
+#endif
+
+const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc,
+ char **argv) {
+ int ret;
+ pthread_attr_t attr;
+
+ LOGD("RIL_Init E: ----------------");
+
+ // Initialize V8
+ v8::V8::Initialize();
+
+ // We're going to use multiple threads need to start locked
+ v8::Locker locker;
+
+ // Initialize modules
+ protobuf_v8::Init();
+ WorkerV8Init();
+
+ // Make a context and setup a scope
+ v8::Persistent<v8::Context> context = makeJsContext();
+ v8::Context::Scope context_scope(context);
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ // Initialize modules needing context
+ ctrlServerInit(context);
+
+ 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);
+ if (status == 0) {
+ runJs(context, &try_catch, "mock_ril.js", buffer);
+ if (try_catch.HasCaught()) {
+ // TODO: Change to event this is fatal
+ LOGE("FATAL ERROR: Unable to run mock_ril.js");
+ }
+ }
+
+ s_rilenv = env;
+ requestsInit(context, &s_requestWorkerQueue);
+ responsesInit(context);
+
+#if 0
+ UnsolicitedThread *ut = new UnsolicitedThread(context);
+ ut->Run(NULL);
+#endif
+
+ LOGD("RIL_Init X: ----------------");
+ return &s_callbacks;
+}
diff --git a/mock-ril/mock_ril.h b/mock-ril/mock_ril.h
new file mode 100644
index 0000000..c29b5ed
--- /dev/null
+++ b/mock-ril/mock_ril.h
@@ -0,0 +1,24 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_MOCK_RIL_H_
+#define MOCK_RIL_MOCK_RIL_H_
+
+#include <telephony/ril.h>
+
+extern const struct RIL_Env *s_rilenv;
+
+#endif // MOCK_RIL_MOCK_RIL_H_
diff --git a/mock-ril/mock_ril.js b/mock-ril/mock_ril.js
new file mode 100644
index 0000000..ac29b7f
--- /dev/null
+++ b/mock-ril/mock_ril.js
@@ -0,0 +1,352 @@
+/**
+ * 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.
+ */
+
+/**
+ * @fileoverview Mock Radio Interface Layer (RIL) used for testing
+ *
+ * The following routines are defined in c++:
+ *
+ * Print a string to android log
+ * print(string)
+ *
+ * Read a file to a string.
+ * String readFileToString(String fileName)
+ *
+ * Read a file to a Buffer.
+ * Buffer readFileToBuffer(String fileName)
+ *
+ * Send an response unsolicited response to the framework.
+ * sendRilUnsolicitedResponse(Number responseNum, Buffer responseProtobuf)
+ *
+ * Send a completion request to the framework.
+ * sendRilRequestComplete(Number rilErrCode, Number reqNum,
+ * String token, Buffer responseProtobuf)
+ *
+ * Send a complete request to the controller.
+ * sendCtrlRequestComplete(Number ctrlStatus, Number reqNum,
+ * String token, Buffer responseProtobuf)
+ *
+ * Include the javascript file.
+ * include(string)
+ *
+ * The following objects are defined in c++
+ *
+ * Buffer is defined in node_buffer and provides a wrapper
+ * for a buffer that can be shared between c++ and js.
+ * Buffer(length)
+ * Buffer::length()
+ * Buffer::data()
+ *
+ * Schema is defined in protobuf_v8 and converts between
+ * a buffer and an object. A protobuf descriptor, ril.desc
+ * and ctrl.desc, is used to drive the conversation.
+ * Object Schema::parse(Buffer protobuf)
+ * Buffer Schema::serialize(object)
+ *
+ * Worker is a thread which receives messages to be handled.
+ * It is passed a function which is called once for each
+ * message as it arrives. Call the add method to queue up
+ * requests for the worker function to process.
+ * Object Worker(function (req))
+ * Worker::add(req);
+ */
+
+print("mock_ril.js BOF");
+
+include("ril_vars.js");
+
+// Initial value of radioState
+radioState = RADIO_STATE_UNAVAILABLE;
+
+/**
+ * Get the ril description file and create a schema
+ */
+var packageNameAndSeperator = 'ril_proto.';
+var rilSchema = new Schema(readFileToBuffer('ril.desc'));
+var ctrlSchema = new Schema(readFileToBuffer('ctrl.desc'));
+
+/**
+ * Print properties of an object
+ */
+function printProperties(obj, maxDepth, depth) {
+ if (typeof maxDepth == 'undefined') {
+ maxDepth = 1;
+ }
+ if (typeof depth == 'undefined') {
+ depth = 1;
+ }
+ if (depth == 1) {
+ print('printProperties:');
+ }
+ for (var property in obj) {
+ try {
+ if ((typeof obj[property] == 'object')
+ && (depth < maxDepth)) {
+ printProperties(obj[property], maxDepth, depth+1);
+ } else {
+ print(depth + ': ' + property + '=' + obj[property] +
+ ' type=' + typeof obj[property]);
+ }
+ } catch (err) {
+ print('err=' + err)
+ }
+ }
+}
+
+// Test printProperties
+if (false) {
+ var myObject = { 'field1' : '1', 'field2' : '2', 'hello' : [ 'hi', 'there' ] };
+ printProperties(myObject, 3);
+}
+
+// Empty Protobuf, defined here so we don't have
+// to recreate an empty Buffer frequently
+var emptyProtobuf = new Buffer();
+
+/**
+ * Construct a new request which is passed to the
+ * Worker handler method.
+ */
+function Request(reqNum, token, protobuf, schema, schemaName) {
+ req = new Object();
+ req.reqNum = reqNum;
+ req.token = token;
+ req.data = schema[packageNameAndSeperator + schemaName].parse(protobuf);
+ return req;
+}
+
+/**
+ * Simulated Radio
+ */
+var simulatedRadio = new Worker(function (req) {
+ try {
+ print('simulatedRadio E: req.reqNum=' + req.reqNum + ' req.token=' + req.token);
+
+ // Assume we will send a response and we are successful an empty responseProtobuf
+ var sendTheResponse = true;
+ var rilErrCode = RIL_E_SUCCESS;
+ var responseProtobuf = emptyProtobuf;
+
+ switch (req.reqNum) {
+ case RIL_REQUEST_HANGUP:
+ print('simulatedRadio: req.data.connection_index=' + req.data.connectionIndex);
+ break;
+ case RIL_REQUEST_SCREEN_STATE:
+ print('simulatedRadio: req.data.state=' + req.data.state);
+ break;
+ default:
+ print('simulatedRadio: Unknown reqNum ' + reqNum);
+ rilErrCode = RIL_E_REQUEST_NOT_SUPPORTED;
+ break;
+ }
+
+ if (sendTheResponse) {
+ sendRilRequestComplete(rilErrCode, req.reqNum, req.token, responseProtobuf);
+ }
+
+ print('simulatedRadio X: req.reqNum=' + req.reqNum);
+ } catch (err) {
+ print('simulatedRadio X: Exception err=' + err);
+ }
+});
+simulatedRadio.run();
+
+/**
+ * Simulated Sim
+ */
+var simulatedSim = new Worker(function (req) {
+ try {
+ print('simulatedSim E: req.reqNum=' + req.reqNum);
+
+ // Assume we will send a response and we are successful an empty responseProtobuf
+ var sendTheResponse = true;
+ var rilErrCode = RIL_E_SUCCESS;
+ var responseProtobuf = emptyProtobuf;
+
+ switch (req.reqNum) {
+ case RIL_REQUEST_ENTER_SIM_PIN:
+ print('simulatedSim: EnterSimPin req.data.pin=' + req.data.pin);
+ rsp = Object();
+ rsp.cmd = req.reqNum;
+ rsp.token = req.token;
+ rsp.retriesRemaining = 3;
+ responseProtobuf = rilSchema[packageNameAndSeperator +
+ 'RspEnterSimPin'].serialize(rsp);
+ case RIL_REQUEST_SCREEN_STATE:
+ print('simulatedSim: req.data.state=' + req.data.state);
+ // Only one response, simulatedRadio will return it.
+ sendTheResponse = false;
+ break;
+ default:
+ print('simulatedSim: Unknown reqNum ' + reqNum);
+ rilErrCode = RIL_E_REQUEST_NOT_SUPPORTED;
+ break;
+ }
+
+ if (sendTheResponse) {
+ sendRilRequestComplete(rilErrCode, req.reqNum, req.token, responseProtobuf);
+ }
+
+ print('simulatedSim X: req.reqNum=' + req.reqNum);
+ } catch (err) {
+ print('simulatedSim X: Exception err=' + err);
+ }
+});
+simulatedSim.run();
+
+/**
+ * Control Server
+ */
+var ctrlServer = new Worker(function (req) {
+ try {
+ print('ctrlServer E: req.cmd=' + req.cmd);
+
+ // Assume we will send a response and we are successful an empty responseProtobuf
+ var sendTheResponse = true;
+ var ctrlStatus = 0; // ctrl_proto.CTRL_STATUS_OK;
+ var responseProtobuf = emptyProtobuf;
+
+ switch (req.cmd) {
+ case 1: //ctrl_proto.CTRL_CMD_GET_RADIO_STATE:
+ print('ctrlServer: CTRL_CMD_GET_RADIO_STATE');
+ rsp = Object();
+ rsp.state = radioState;
+ responseProtobuf = ctrlSchema['ctrl_proto.CtrlRspRadioState'].serialize(rsp);
+ break;
+ default:
+ print('ctrlServer: Unknown cmd ' + req.cmd);
+ ctrlStatus = 1; //ctrl_proto.CTRL_STATUS_ERR;
+ break;
+ }
+
+ if (sendTheResponse) {
+ sendCtrlRequestComplete(ctrlStatus, req.cmd, req.token, responseProtobuf);
+ }
+
+ print('ctrlServer X: req.cmd=' + req.cmd);
+ } catch (err) {
+ print('ctrlServer X: Exception err=' + err);
+ }
+});
+ctrlServer.run();
+
+function onCtrlServerCmd(cmd, token, protobuf) {
+ try {
+ //print('onCtrlServerCmd E cmd=' + cmd + ' token=' + token);
+
+ req = new Object();
+ req.cmd = cmd;
+ req.token = token;
+ req.protobuf = protobuf;
+ ctrlServer.add(req);
+
+ //print('onCtrlServerCmd X cmd=' + cmd + ' token=' + token);
+ } catch (err) {
+ print('onCtrlServerCmd X Exception err=' + err);
+ }
+}
+
+/**
+ * Dispatch table for requests
+ *
+ * Each table entry is index by the RIL_REQUEST_xxxx
+ * and contains an array of components this request
+ * is to be sent to and the name of the schema
+ * that converts the incoming protobuf to the
+ * appropriate request data.
+ *
+ * DispatchTable[RIL_REQUEST_xxx].components = Array of components
+ * DisptachTable[RIL_REQUEST_xxx].Entry.schemaName = 'Name-of-schema';
+ */
+var dispatchTable = new Array();
+
+dispatchTable[RIL_REQUEST_ENTER_SIM_PIN] = {
+ 'components' : [simulatedSim],
+ 'schemaName' : 'ReqEnterSimPin',
+},
+dispatchTable[RIL_REQUEST_HANGUP] = {
+ 'components' : [simulatedSim],
+ 'schemaName' : 'ReqHangUp',
+};
+dispatchTable[RIL_REQUEST_SCREEN_STATE] = {
+ 'components' : [simulatedSim, simulatedRadio],
+ 'schemaName' : 'ReqScreenState',
+};
+
+/**
+ * Dispatch incoming requests from RIL to the appropriate component.
+ */
+function onRilRequest(reqNum, token, requestProtobuf) {
+ try {
+ //print('onRilRequest E: reqNum=' + reqNum + ' token=' + token);
+
+ /**
+ * Validate parameters
+ */
+ rilErrCode = RIL_E_SUCCESS;
+ if (typeof reqNum != 'number') {
+ print('onRilRequest: reqNum is not a number');
+ rilErrCode = RIL_E_GENERIC_FAILURE;
+ }
+ if (typeof token != 'number') {
+ print('onRilRequest: token is not a number');
+ rilErrCode = RIL_E_GENERIC_FAILURE;
+ }
+ if (typeof requestProtobuf != 'object') {
+ print('onRilRequest: requestProtobuf is not an object');
+ rilErrCode = RIL_E_GENERIC_FAILURE;
+ }
+ if (rilErrCode != RIL_E_SUCCESS) {
+ sendRilRequestComplete(rilErrCode, reqNum, token);
+ return 'onRilRequest X: invalid parameter';
+ }
+
+ /**
+ * Assume we're going to send a response, rilErrCode is RIL_E_SUCCESS
+ * and there is no responseProtobuf.
+ */
+ sendTheResponse = true;
+ rilErrCode = RIL_E_SUCCESS;
+ try {
+ print('onRilRequest: get entry from dispatchTable reqNum=' + reqNum);
+ entry = dispatchTable[reqNum];
+ req = new Request(reqNum, token, requestProtobuf, rilSchema, entry.schemaName);
+ for(i = 0; i < entry.components.length; i++) {
+ entry.components[i].add(req);
+ }
+ } catch (err) {
+ print('onRilRequest: Unknown reqNum ' + reqNum + ' err=' + err);
+ sendRilRequestComplete(RIL_E_REQUEST_NOT_SUPPORTED, reqNum, token);
+ }
+ // print('onRilRequest X: reqNum=' + reqNum + ' token=' + token);
+ } catch (err) {
+ print('onRilRequest X: Exception err=' + err);
+ }
+ return 'onRilRequest X';
+}
+
+function onUnsolicitedTick(tick) {
+ print('onUnsolicitedTick EX tick=' + tick);
+ return 3;
+}
+
+function setRadioState(newRadioState) {
+ radioState = newRadioState;
+ sendRilUnsolicitedResponse(RIL_UNSOLICITED_STATE_CHANGED);
+}
+
+
+print("mock_ril.js EOF");
diff --git a/mock-ril/node_buffer.cpp b/mock-ril/node_buffer.cpp
new file mode 100644
index 0000000..d72e19e
--- /dev/null
+++ b/mock-ril/node_buffer.cpp
@@ -0,0 +1,642 @@
+/**
+ * Copied from node_buffer.cc
+ * see http://www.nodejs.org/
+ *
+ * Node's license follows:
+ *
+ * Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "node_buffer.h"
+
+#include <assert.h>
+#include <stdlib.h> // malloc, free
+#include <v8.h>
+
+#include <string.h> // memcpy
+
+#include <arpa/inet.h> // htons, htonl
+
+#include "logging.h"
+#include "node_util.h"
+#include "util.h"
+
+//#define BUFFER_DEBUG
+#ifdef BUFFER_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+using namespace v8;
+
+#define SLICE_ARGS(start_arg, end_arg) \
+ if (!start_arg->IsInt32() || !end_arg->IsInt32()) { \
+ return ThrowException(Exception::TypeError( \
+ v8::String::New("Bad argument."))); \
+ } \
+ int32_t start = start_arg->Int32Value(); \
+ int32_t end = end_arg->Int32Value(); \
+ if (start < 0 || end < 0) { \
+ return ThrowException(Exception::TypeError( \
+ v8::String::New("Bad argument."))); \
+ } \
+ if (!(start <= end)) { \
+ return ThrowException(Exception::Error( \
+ v8::String::New("Must have start <= end"))); \
+ } \
+ if ((size_t)end > parent->length_) { \
+ return ThrowException(Exception::Error( \
+ v8::String::New("end cannot be longer than parent.length"))); \
+ }
+
+static Persistent<String> length_symbol;
+static Persistent<String> chars_written_sym;
+static Persistent<String> write_sym;
+Persistent<FunctionTemplate> Buffer::constructor_template;
+
+
+// Each javascript Buffer object is backed by a Blob object.
+// the Blob is just a C-level chunk of bytes.
+// It has a reference count.
+struct Blob_ {
+ unsigned int refs;
+ size_t length;
+ char *data;
+};
+typedef struct Blob_ Blob;
+
+
+static inline Blob * blob_new(size_t length) {
+ DBG("blob_new E");
+ Blob * blob = (Blob*) malloc(sizeof(Blob));
+ if (!blob) return NULL;
+
+ blob->data = (char*) malloc(length);
+ if (!blob->data) {
+ DBG("blob_new X no memory for data");
+ free(blob);
+ return NULL;
+ }
+
+ V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Blob) + length);
+ blob->length = length;
+ blob->refs = 0;
+ DBG("blob_new X");
+ return blob;
+}
+
+
+static inline void blob_ref(Blob *blob) {
+ blob->refs++;
+}
+
+
+static inline void blob_unref(Blob *blob) {
+ assert(blob->refs > 0);
+ if (--blob->refs == 0) {
+ DBG("blob_unref == 0");
+ //fprintf(stderr, "free %d bytes\n", blob->length);
+ V8::AdjustAmountOfExternalAllocatedMemory(-(sizeof(Blob) + blob->length));
+ free(blob->data);
+ free(blob);
+ DBG("blob_unref blob and its data freed");
+ }
+}
+
+#if 0
+// When someone calls buffer.asciiSlice, data is not copied. Instead V8
+// references in the underlying Blob with this ExternalAsciiStringResource.
+class AsciiSliceExt: public String::ExternalAsciiStringResource {
+ friend class Buffer;
+ public:
+ AsciiSliceExt(Buffer *parent, size_t start, size_t end) {
+ blob_ = parent->blob();
+ blob_ref(blob_);
+
+ assert(start <= end);
+ length_ = end - start;
+ assert(start + length_ <= parent->length());
+ data_ = parent->data() + start;
+ }
+
+
+ ~AsciiSliceExt() {
+ //fprintf(stderr, "free ascii slice (%d refs left)\n", blob_->refs);
+ blob_unref(blob_);
+ }
+
+
+ const char* data() const { return data_; }
+ size_t length() const { return length_; }
+
+ private:
+ const char *data_;
+ size_t length_;
+ Blob *blob_;
+};
+#endif
+
+Buffer* Buffer::New(size_t size) {
+ DBG("Buffer::New(size) E");
+ HandleScope scope;
+
+ Local<Value> arg = Integer::NewFromUnsigned(size);
+ Local<Object> b = constructor_template->GetFunction()->NewInstance(1, &arg);
+
+ DBG("Buffer::New(size) X");
+ return ObjectWrap::Unwrap<Buffer>(b);
+}
+
+
+Handle<Value> Buffer::New(const Arguments &args) {
+ DBG("Buffer::New(args) E");
+ HandleScope scope;
+
+ Buffer *buffer;
+ if ((args.Length() == 0) || args[0]->IsInt32()) {
+ size_t length = 0;
+ if (args[0]->IsInt32()) {
+ length = args[0]->Uint32Value();
+ }
+ buffer = new Buffer(length);
+ } else if (args[0]->IsArray()) {
+ Local<Array> a = Local<Array>::Cast(args[0]);
+ buffer = new Buffer(a->Length());
+ char *p = buffer->data();
+ for (unsigned int i = 0; i < a->Length(); i++) {
+ p[i] = a->Get(i)->Uint32Value();
+ }
+ } else if (args[0]->IsString()) {
+ Local<String> s = args[0]->ToString();
+ enum encoding e = ParseEncoding(args[1], UTF8);
+ int length = e == UTF8 ? s->Utf8Length() : s->Length();
+ buffer = new Buffer(length);
+ } else if (Buffer::HasInstance(args[0]) && args.Length() > 2) {
+ // var slice = new Buffer(buffer, 123, 130);
+ // args: parent, start, end
+ Buffer *parent = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
+ SLICE_ARGS(args[1], args[2])
+ buffer = new Buffer(parent, start, end);
+ } else {
+ DBG("Buffer::New(args) X Bad argument");
+ return ThrowException(Exception::TypeError(String::New("Bad argument")));
+ }
+
+ buffer->Wrap(args.This());
+ args.This()->SetIndexedPropertiesToExternalArrayData(buffer->data(),
+ kExternalUnsignedByteArray,
+ buffer->length());
+ args.This()->Set(length_symbol, Integer::New(buffer->length_));
+
+ if (args[0]->IsString()) {
+ if (write_sym.IsEmpty()) {
+ write_sym = Persistent<String>::New(String::NewSymbol("write"));
+ }
+
+ Local<Value> write_v = args.This()->Get(write_sym);
+ assert(write_v->IsFunction());
+ Local<Function> write = Local<Function>::Cast(write_v);
+
+ Local<Value> argv[2] = { args[0], args[1] };
+
+ TryCatch try_catch;
+
+ write->Call(args.This(), 2, argv);
+
+ if (try_catch.HasCaught()) {
+ ReportException(&try_catch);
+ }
+ }
+
+ DBG("Buffer::New(args) X");
+ return args.This();
+}
+
+
+Buffer::Buffer(size_t length) : ObjectWrap() {
+ DBG("Buffer::Buffer(length) E");
+ blob_ = blob_new(length);
+ off_ = 0;
+ length_ = length;
+
+ blob_ref(blob_);
+
+ V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer));
+ DBG("Buffer::Buffer(length) X");
+}
+
+
+Buffer::Buffer(Buffer *parent, size_t start, size_t end) : ObjectWrap() {
+ DBG("Buffer::Buffer(parent, start, end) E");
+ blob_ = parent->blob_;
+ assert(blob_->refs > 0);
+ blob_ref(blob_);
+
+ assert(start <= end);
+ off_ = parent->off_ + start;
+ length_ = end - start;
+ assert(length_ <= parent->length_);
+
+ V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer));
+ DBG("Buffer::Buffer(parent, start, end) X");
+}
+
+
+Buffer::~Buffer() {
+ DBG("Buffer::~Buffer() E");
+ assert(blob_->refs > 0);
+ //fprintf(stderr, "free buffer (%d refs left)\n", blob_->refs);
+ blob_unref(blob_);
+ V8::AdjustAmountOfExternalAllocatedMemory(-static_cast<long int>(sizeof(Buffer)));
+ DBG("Buffer::~Buffer() X");
+}
+
+
+char* Buffer::data() {
+ char *p = blob_->data + off_;
+ DBG("Buffer::data() EX p=%p", p);
+ return p;
+}
+
+void Buffer::NewBlob(size_t length) {
+ DBG("Buffer::NewBlob(length) E");
+ blob_unref(blob_);
+ blob_ = blob_new(length);
+ off_ = 0;
+ length_ = length;
+
+ blob_ref(blob_);
+
+ V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer));
+ DBG("Buffer::NewBlob(length) X");
+}
+
+
+Handle<Value> Buffer::BinarySlice(const Arguments &args) {
+ DBG("Buffer::BinarySlice(args) E");
+ HandleScope scope;
+ Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
+ SLICE_ARGS(args[0], args[1])
+
+ const char *data = const_cast<char*>(parent->data() + start);
+ //Local<String> string = String::New(data, end - start);
+
+ Local<Value> b = Encode(data, end - start, BINARY);
+
+ DBG("Buffer::BinarySlice(args) X");
+ return scope.Close(b);
+}
+
+
+Handle<Value> Buffer::AsciiSlice(const Arguments &args) {
+ DBG("Buffer::AsciiSlice(args) E");
+ HandleScope scope;
+ Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
+ SLICE_ARGS(args[0], args[1])
+
+#if 0
+ AsciiSliceExt *ext = new AsciiSliceExt(parent, start, end);
+ Local<String> string = String::NewExternal(ext);
+ // There should be at least two references to the blob now - the parent
+ // and the slice.
+ assert(parent->blob_->refs >= 2);
+#endif
+
+ const char *data = const_cast<char*>(parent->data() + start);
+ Local<String> string = String::New(data, end - start);
+
+
+ DBG("Buffer::AsciiSlice(args) X");
+ return scope.Close(string);
+}
+
+
+Handle<Value> Buffer::Utf8Slice(const Arguments &args) {
+ DBG("Buffer::Utf8Slice(args) E");
+ HandleScope scope;
+ Buffer *parent = ObjectWrap::Unwrap<Buffer>(args.This());
+ SLICE_ARGS(args[0], args[1])
+ const char *data = const_cast<char*>(parent->data() + start);
+ Local<String> string = String::New(data, end - start);
+ DBG("Buffer::Utf8Slice(args) X");
+ return scope.Close(string);
+}
+
+
+Handle<Value> Buffer::Slice(const Arguments &args) {
+ DBG("Buffer::Slice(args) E");
+ HandleScope scope;
+ Local<Value> argv[3] = { args.This(), args[0], args[1] };
+ Local<Object> slice =
+ constructor_template->GetFunction()->NewInstance(3, argv);
+ DBG("Buffer::Slice(args) X");
+ return scope.Close(slice);
+}
+
+
+// var bytesCopied = buffer.copy(target, targetStart, sourceStart, sourceEnd);
+Handle<Value> Buffer::Copy(const Arguments &args) {
+ DBG("Buffer::Copy(args) E");
+ HandleScope scope;
+
+ Buffer *source = ObjectWrap::Unwrap<Buffer>(args.This());
+
+ if (!Buffer::HasInstance(args[0])) {
+ DBG("Buffer::Copy(args) X arg[0] not buffer");
+ return ThrowException(Exception::TypeError(String::New(
+ "First arg should be a Buffer")));
+ }
+
+ Buffer *target = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
+
+ ssize_t target_start = args[1]->Int32Value();
+ ssize_t source_start = args[2]->Int32Value();
+ ssize_t source_end = args[3]->IsInt32() ? args[3]->Int32Value()
+ : source->length();
+
+ if (source_end < source_start) {
+ DBG("Buffer::Copy(args) X end < start");
+ return ThrowException(Exception::Error(String::New(
+ "sourceEnd < sourceStart")));
+ }
+
+ if (target_start < 0 || ((size_t)target_start) > target->length()) {
+ DBG("Buffer::Copy(args) X targetStart bad");
+ return ThrowException(Exception::Error(String::New(
+ "targetStart out of bounds")));
+ }
+
+ if (source_start < 0 || ((size_t)source_start) > source->length()) {
+ DBG("Buffer::Copy(args) X base source start");
+ return ThrowException(Exception::Error(String::New(
+ "sourceStart out of bounds")));
+ }
+
+ if (source_end < 0 || ((size_t)source_end) > source->length()) {
+ DBG("Buffer::Copy(args) X bad source");
+ return ThrowException(Exception::Error(String::New(
+ "sourceEnd out of bounds")));
+ }
+
+ ssize_t to_copy = MIN(source_end - source_start,
+ target->length() - target_start);
+
+ memcpy((void*)(target->data() + target_start),
+ (const void*)(source->data() + source_start),
+ to_copy);
+
+ DBG("Buffer::Copy(args) X");
+ return scope.Close(Integer::New(to_copy));
+}
+
+
+// var charsWritten = buffer.utf8Write(string, offset);
+Handle<Value> Buffer::Utf8Write(const Arguments &args) {
+ DBG("Buffer::Utf8Write(args) X");
+ HandleScope scope;
+ Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
+
+ if (!args[0]->IsString()) {
+ DBG("Buffer::Utf8Write(args) X arg[0] not string");
+ return ThrowException(Exception::TypeError(String::New(
+ "Argument must be a string")));
+ }
+
+ Local<String> s = args[0]->ToString();
+
+ size_t offset = args[1]->Int32Value();
+
+ if (offset >= buffer->length_) {
+ DBG("Buffer::Utf8Write(args) X offset bad");
+ return ThrowException(Exception::TypeError(String::New(
+ "Offset is out of bounds")));
+ }
+
+ const char *p = buffer->data() + offset;
+
+ int char_written;
+
+ int written = s->WriteUtf8((char*)p,
+ buffer->length_ - offset,
+ &char_written,
+ String::HINT_MANY_WRITES_EXPECTED);
+
+ constructor_template->GetFunction()->Set(chars_written_sym,
+ Integer::New(char_written));
+
+ if (written > 0 && p[written-1] == '\0') written--;
+
+ DBG("Buffer::Utf8Write(args) X");
+ return scope.Close(Integer::New(written));
+}
+
+
+// var charsWritten = buffer.asciiWrite(string, offset);
+Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
+ DBG("Buffer::AsciiWrite(args) E");
+ HandleScope scope;
+
+ Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
+
+ if (!args[0]->IsString()) {
+ DBG("Buffer::AsciiWrite(args) X arg[0] not string");
+ return ThrowException(Exception::TypeError(String::New(
+ "Argument must be a string")));
+ }
+
+ Local<String> s = args[0]->ToString();
+
+ size_t offset = args[1]->Int32Value();
+
+ if (offset >= buffer->length_) {
+ DBG("Buffer::AsciiWrite(args) X bad offset");
+ return ThrowException(Exception::TypeError(String::New(
+ "Offset is out of bounds")));
+ }
+
+ const char *p = buffer->data() + offset;
+
+ size_t towrite = MIN((unsigned long) s->Length(), buffer->length_ - offset);
+
+ int written = s->WriteAscii((char*)p, 0, towrite, String::HINT_MANY_WRITES_EXPECTED);
+ DBG("Buffer::AsciiWrite(args) X");
+ return scope.Close(Integer::New(written));
+}
+
+
+Handle<Value> Buffer::BinaryWrite(const Arguments &args) {
+ DBG("Buffer::BinaryWrite(args) E");
+ HandleScope scope;
+
+ Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
+
+ if (!args[0]->IsString()) {
+ DBG("Buffer::BinaryWrite(args) X arg[0] not string");
+ return ThrowException(Exception::TypeError(String::New(
+ "Argument must be a string")));
+ }
+
+ Local<String> s = args[0]->ToString();
+
+ size_t offset = args[1]->Int32Value();
+
+ if (offset >= buffer->length_) {
+ DBG("Buffer::BinaryWrite(args) X offset bad");
+ return ThrowException(Exception::TypeError(String::New(
+ "Offset is out of bounds")));
+ }
+
+ char *p = (char*)buffer->data() + offset;
+
+ size_t towrite = MIN((unsigned long) s->Length(), buffer->length_ - offset);
+
+ int written = DecodeWrite(p, towrite, s, BINARY);
+ DBG("Buffer::BinaryWrite(args) X");
+ return scope.Close(Integer::New(written));
+}
+
+
+// buffer.unpack(format, index);
+// Starting at 'index', unpacks binary from the buffer into an array.
+// 'format' is a string
+//
+// FORMAT RETURNS
+// N uint32_t a 32bit unsigned integer in network byte order
+// n uint16_t a 16bit unsigned integer in network byte order
+// o uint8_t a 8bit unsigned integer
+Handle<Value> Buffer::Unpack(const Arguments &args) {
+ DBG("Buffer::Unpack(args) E");
+ HandleScope scope;
+ Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args.This());
+
+ if (!args[0]->IsString()) {
+ DBG("Buffer::Unpack(args) X arg[0] not string");
+ return ThrowException(Exception::TypeError(String::New(
+ "Argument must be a string")));
+ }
+
+ String::AsciiValue format(args[0]->ToString());
+ uint32_t index = args[1]->Uint32Value();
+
+#define OUT_OF_BOUNDS ThrowException(Exception::Error(String::New("Out of bounds")))
+
+ Local<Array> array = Array::New(format.length());
+
+ uint8_t uint8;
+ uint16_t uint16;
+ uint32_t uint32;
+
+ for (int i = 0; i < format.length(); i++) {
+ switch ((*format)[i]) {
+ // 32bit unsigned integer in network byte order
+ case 'N':
+ if (index + 3 >= buffer->length_) return OUT_OF_BOUNDS;
+ uint32 = htonl(*(uint32_t*)(buffer->data() + index));
+ array->Set(Integer::New(i), Integer::NewFromUnsigned(uint32));
+ index += 4;
+ break;
+
+ // 16bit unsigned integer in network byte order
+ case 'n':
+ if (index + 1 >= buffer->length_) return OUT_OF_BOUNDS;
+ uint16 = htons(*(uint16_t*)(buffer->data() + index));
+ array->Set(Integer::New(i), Integer::NewFromUnsigned(uint16));
+ index += 2;
+ break;
+
+ // a single octet, unsigned.
+ case 'o':
+ if (index >= buffer->length_) return OUT_OF_BOUNDS;
+ uint8 = (uint8_t)buffer->data()[index];
+ array->Set(Integer::New(i), Integer::NewFromUnsigned(uint8));
+ index += 1;
+ break;
+
+ default:
+ DBG("Buffer::Unpack(args) X unknown format character");
+ return ThrowException(Exception::Error(
+ String::New("Unknown format character")));
+ }
+ }
+
+ DBG("Buffer::Unpack(args) X");
+ return scope.Close(array);
+}
+
+
+// var nbytes = Buffer.byteLength("string", "utf8")
+Handle<Value> Buffer::ByteLength(const Arguments &args) {
+ DBG("Buffer::ByteLength(args) E");
+ HandleScope scope;
+
+ if (!args[0]->IsString()) {
+ DBG("Buffer::ByteLength(args) X arg[0] not a string");
+ return ThrowException(Exception::TypeError(String::New(
+ "Argument must be a string")));
+ }
+
+ Local<String> s = args[0]->ToString();
+ enum encoding e = ParseEncoding(args[1], UTF8);
+
+ Local<Integer> length =
+ Integer::New(e == UTF8 ? s->Utf8Length() : s->Length());
+
+ DBG("Buffer::ByteLength(args) X");
+ return scope.Close(length);
+}
+
+void Buffer::InitializeObjectTemplate(Handle<ObjectTemplate> target) {
+ DBG("InitializeObjectTemplate(target) E:");
+ HandleScope scope;
+
+ length_symbol = Persistent<String>::New(String::NewSymbol("length"));
+ chars_written_sym = Persistent<String>::New(String::NewSymbol("_charsWritten"));
+
+ Local<FunctionTemplate> t = FunctionTemplate::New(Buffer::New);
+ constructor_template = Persistent<FunctionTemplate>::New(t);
+ constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
+ constructor_template->SetClassName(String::NewSymbol("Buffer"));
+
+ // copy free
+ SET_PROTOTYPE_METHOD(constructor_template, "binarySlice", Buffer::BinarySlice);
+ SET_PROTOTYPE_METHOD(constructor_template, "asciiSlice", Buffer::AsciiSlice);
+ SET_PROTOTYPE_METHOD(constructor_template, "slice", Buffer::Slice);
+ // TODO SET_PROTOTYPE_METHOD(t, "utf16Slice", Utf16Slice);
+ // copy
+ SET_PROTOTYPE_METHOD(constructor_template, "utf8Slice", Buffer::Utf8Slice);
+
+ SET_PROTOTYPE_METHOD(constructor_template, "utf8Write", Buffer::Utf8Write);
+ SET_PROTOTYPE_METHOD(constructor_template, "asciiWrite", Buffer::AsciiWrite);
+ SET_PROTOTYPE_METHOD(constructor_template, "binaryWrite", Buffer::BinaryWrite);
+ SET_PROTOTYPE_METHOD(constructor_template, "unpack", Buffer::Unpack);
+ SET_PROTOTYPE_METHOD(constructor_template, "copy", Buffer::Copy);
+
+ SET_PROTOTYPE_METHOD(constructor_template, "byteLength", Buffer::ByteLength);
+
+ target->Set(String::NewSymbol("Buffer"), constructor_template);
+ DBG("InitializeObjectTemplate(target) X:");
+}
diff --git a/mock-ril/node_buffer.h b/mock-ril/node_buffer.h
new file mode 100644
index 0000000..0d3d774
--- /dev/null
+++ b/mock-ril/node_buffer.h
@@ -0,0 +1,98 @@
+/**
+ * Copied from node_buffer.h
+ * see http://www.nodejs.org/
+ *
+ * Node's license follows:
+ *
+ * Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef MOCK_RIL_NODE_BUFFER_H_
+#define MOCK_RIL_NODE_BUFFER_H_
+
+#include <v8.h>
+#include "node_object_wrap.h"
+
+/* A buffer is a chunk of memory stored outside the V8 heap, mirrored by an
+ * object in javascript. The object is not totally opaque, one can access
+ * individual bytes with [] and slice it into substrings or sub-buffers
+ * without copying memory.
+ *
+ * // return an ascii encoded string - no memory iscopied
+ * buffer.asciiSlide(0, 3)
+ *
+ * // returns another buffer - no memory is copied
+ * buffer.slice(0, 3)
+ *
+ * Interally, each javascript buffer object is backed by a "struct buffer"
+ * object. These "struct buffer" objects are either a root buffer (in the
+ * case that buffer->root == NULL) or slice objects (in which case
+ * buffer->root != NULL). A root buffer is only GCed once all its slices
+ * are GCed.
+ */
+
+
+struct Blob_;
+
+class Buffer : public ObjectWrap {
+ public:
+ ~Buffer();
+
+ static void Initialize(v8::Handle<v8::Object> target);
+ static void InitializeObjectTemplate(v8::Handle<v8::ObjectTemplate> target);
+ static Buffer* New(size_t length); // public constructor
+ static inline bool HasInstance(v8::Handle<v8::Value> val) {
+ if (!val->IsObject()) return false;
+ v8::Local<v8::Object> obj = val->ToObject();
+ return constructor_template->HasInstance(obj);
+ }
+
+ char* data();
+ size_t length() const { return length_; }
+ struct Blob_* blob() const { return blob_; }
+ void NewBlob(size_t length);
+
+ int AsciiWrite(char *string, int offset, int length);
+ int Utf8Write(char *string, int offset, int length);
+
+ private:
+ static v8::Persistent<v8::FunctionTemplate> constructor_template;
+
+ static v8::Handle<v8::Value> New(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Slice(const v8::Arguments &args);
+ static v8::Handle<v8::Value> BinarySlice(const v8::Arguments &args);
+ static v8::Handle<v8::Value> AsciiSlice(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Utf8Slice(const v8::Arguments &args);
+ static v8::Handle<v8::Value> BinaryWrite(const v8::Arguments &args);
+ static v8::Handle<v8::Value> AsciiWrite(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Utf8Write(const v8::Arguments &args);
+ static v8::Handle<v8::Value> ByteLength(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Unpack(const v8::Arguments &args);
+ static v8::Handle<v8::Value> Copy(const v8::Arguments &args);
+
+ Buffer(size_t length);
+ Buffer(Buffer *parent, size_t start, size_t end);
+
+ size_t off_; // offset inside blob_
+ size_t length_; // length inside blob_
+ struct Blob_ *blob_;
+};
+
+#endif // MOCK_RIL_NODE_BUFFER_H_
diff --git a/mock-ril/node_object_wrap.h b/mock-ril/node_object_wrap.h
new file mode 100644
index 0000000..1bcee62
--- /dev/null
+++ b/mock-ril/node_object_wrap.h
@@ -0,0 +1,112 @@
+/**
+ * Copied from node_object_wrap.h
+ * see http://www.nodejs.org/
+ *
+ * Node's license follows:
+ *
+ * Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef MOCK_RIL_NODE_OBJECT_WRAP_H_
+#define MOCK_RIL_NODE_OBJECT_WRAP_H_
+
+#include <v8.h>
+#include <assert.h>
+
+class ObjectWrap {
+ public:
+ ObjectWrap ( ) {
+ refs_ = 0;
+ }
+
+ virtual ~ObjectWrap ( ) {
+ if (!handle_.IsEmpty()) {
+ assert(handle_.IsNearDeath());
+ handle_->SetInternalField(0, v8::Undefined());
+ handle_.Dispose();
+ handle_.Clear();
+ }
+ }
+
+ template <class T>
+ static inline T* Unwrap (v8::Handle<v8::Object> handle)
+ {
+ assert(!handle.IsEmpty());
+ assert(handle->InternalFieldCount() > 0);
+ return static_cast<T*>(v8::Handle<v8::External>::Cast(
+ handle->GetInternalField(0))->Value());
+ }
+
+ v8::Persistent<v8::Object> handle_; // ro
+
+ protected:
+ inline void Wrap (v8::Handle<v8::Object> handle)
+ {
+ assert(handle_.IsEmpty());
+ assert(handle->InternalFieldCount() > 0);
+ handle_ = v8::Persistent<v8::Object>::New(handle);
+ handle_->SetInternalField(0, v8::External::New(this));
+ MakeWeak();
+ }
+
+ inline void MakeWeak (void)
+ {
+ handle_.MakeWeak(this, WeakCallback);
+ }
+
+ /* Ref() marks the object as being attached to an event loop.
+ * Refed objects will not be garbage collected, even if
+ * all references are lost.
+ */
+ virtual void Ref() {
+ assert(!handle_.IsEmpty());
+ refs_++;
+ handle_.ClearWeak();
+ }
+
+ /* Unref() marks an object as detached from the event loop. This is its
+ * default state. When an object with a "weak" reference changes from
+ * attached to detached state it will be freed. Be careful not to access
+ * the object after making this call as it might be gone!
+ * (A "weak reference" means an object that only has a
+ * persistant handle.)
+ *
+ * DO NOT CALL THIS FROM DESTRUCTOR
+ */
+ virtual void Unref() {
+ assert(!handle_.IsEmpty());
+ assert(!handle_.IsWeak());
+ assert(refs_ > 0);
+ if (--refs_ == 0) { MakeWeak(); }
+ }
+
+ int refs_; // ro
+
+ private:
+ static void WeakCallback (v8::Persistent<v8::Value> value, void *data)
+ {
+ ObjectWrap *obj = static_cast<ObjectWrap*>(data);
+ assert(value == obj->handle_);
+ assert(!obj->refs_);
+ if (value.IsNearDeath()) delete obj;
+ }
+};
+
+#endif // MOCK_RIL_NODE_OBJECT_WRAP_H_
diff --git a/mock-ril/node_util.cpp b/mock-ril/node_util.cpp
new file mode 100644
index 0000000..5048e53
--- /dev/null
+++ b/mock-ril/node_util.cpp
@@ -0,0 +1,144 @@
+/**
+ * Contents of this file are snippets from node.cc
+ * see http://www.nodejs.org/
+ *
+ * Node's license follows:
+ *
+ * Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ */
+#include <v8.h>
+#include <string.h>
+
+#include "logging.h"
+#include "node_object_wrap.h"
+
+#include "node_util.h"
+
+enum encoding ParseEncoding(v8::Handle<v8::Value> encoding_v, enum encoding _default) {
+ v8::HandleScope scope;
+
+ if (!encoding_v->IsString()) return _default;
+
+ v8::String::Utf8Value encoding(encoding_v->ToString());
+
+ if (strcasecmp(*encoding, "utf8") == 0) {
+ return UTF8;
+ } else if (strcasecmp(*encoding, "utf-8") == 0) {
+ return UTF8;
+ } else if (strcasecmp(*encoding, "ascii") == 0) {
+ return ASCII;
+ } else if (strcasecmp(*encoding, "binary") == 0) {
+ return BINARY;
+ } else if (strcasecmp(*encoding, "raw") == 0) {
+ fprintf(stderr, "'raw' (array of integers) has been removed. "
+ "Use 'binary'.\n");
+ return BINARY;
+ } else if (strcasecmp(*encoding, "raws") == 0) {
+ fprintf(stderr, "'raws' encoding has been renamed to 'binary'. "
+ "Please update your code.\n");
+ return BINARY;
+ } else {
+ return _default;
+ }
+}
+
+v8::Local<v8::Value> Encode(const void *buf, size_t len, enum encoding encoding) {
+ v8::HandleScope scope;
+
+ if (!len) return scope.Close(v8::String::Empty());
+
+ if (encoding == BINARY) {
+ const unsigned char *cbuf = static_cast<const unsigned char*>(buf);
+ uint16_t * twobytebuf = new uint16_t[len];
+ for (size_t i = 0; i < len; i++) {
+ // XXX is the following line platform independent?
+ twobytebuf[i] = cbuf[i];
+ }
+ v8::Local<v8::String> chunk = v8::String::New(twobytebuf, len);
+ delete [] twobytebuf; // TODO use ExternalTwoBytev8::String?
+ return scope.Close(chunk);
+ }
+
+ // utf8 or ascii encoding
+ v8::Local<v8::String> chunk = v8::String::New((const char*)buf, len);
+ return scope.Close(chunk);
+}
+
+// Returns -1 if the handle was not valid for decoding
+ssize_t DecodeBytes(v8::Handle<v8::Value> val, enum encoding encoding) {
+ v8::HandleScope scope;
+
+ if (val->IsArray()) {
+ fprintf(stderr, "'raw' encoding (array of integers) has been removed. "
+ "Use 'binary'.\n");
+ assert(0);
+ return -1;
+ }
+
+ v8::Local<v8::String> str = val->ToString();
+
+ if (encoding == UTF8) return str->Utf8Length();
+
+ return str->Length();
+}
+
+#ifndef MIN
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+// Returns number of bytes written.
+ssize_t DecodeWrite(char *buf,
+ size_t buflen,
+ v8::Handle<v8::Value> val,
+ enum encoding encoding) {
+ v8::HandleScope scope;
+
+ // XXX
+ // A lot of improvement can be made here. See:
+ // http://code.google.com/p/v8/issues/detail?id=270
+ // http://groups.google.com/group/v8-dev/browse_thread/thread/dba28a81d9215291/ece2b50a3b4022c
+ // http://groups.google.com/group/v8-users/browse_thread/thread/1f83b0ba1f0a611
+
+ if (val->IsArray()) {
+ fprintf(stderr, "'raw' encoding (array of integers) has been removed. "
+ "Use 'binary'.\n");
+ assert(0);
+ return -1;
+ }
+
+ v8::Local<v8::String> str = val->ToString();
+
+ if (encoding == UTF8) {
+ str->WriteUtf8(buf, buflen, NULL, v8::String::HINT_MANY_WRITES_EXPECTED);
+ return buflen;
+ }
+
+ if (encoding == ASCII) {
+ str->WriteAscii(buf, 0, buflen, v8::String::HINT_MANY_WRITES_EXPECTED);
+ return buflen;
+ }
+
+ // THIS IS AWFUL!!! FIXME
+
+ assert(encoding == BINARY);
+
+ uint16_t * twobytebuf = new uint16_t[buflen];
+
+ str->Write(twobytebuf, 0, buflen, v8::String::HINT_MANY_WRITES_EXPECTED);
+
+ for (size_t i = 0; i < buflen; i++) {
+ unsigned char *b = reinterpret_cast<unsigned char*>(&twobytebuf[i]);
+ assert(b[1] == 0);
+ buf[i] = b[0];
+ }
+
+ delete [] twobytebuf;
+
+ return buflen;
+}
diff --git a/mock-ril/node_util.h b/mock-ril/node_util.h
new file mode 100644
index 0000000..e19a8e7
--- /dev/null
+++ b/mock-ril/node_util.h
@@ -0,0 +1,53 @@
+/**
+ * Contents of this file are snippets from node.h and node.cc
+ * see http://www.nodejs.org/
+ *
+ * Node's license follows:
+ *
+ * Copyright 2009, 2010 Ryan Lienhart Dahl. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ */
+
+
+#ifndef MOCK_RIL_NODE_UTIL_H_
+#define MOCK_RIL_NODE_UTIL_H_
+
+#include <v8.h>
+
+enum encoding {ASCII, UTF8, BINARY};
+
+enum encoding ParseEncoding(v8::Handle<v8::Value> encoding_v,
+ enum encoding _default = BINARY);
+
+void FatalException(v8::TryCatch &try_catch);
+
+v8::Local<v8::Value> Encode(const void *buf, size_t len,
+ enum encoding encoding = BINARY);
+
+// returns bytes written.
+ssize_t DecodeWrite(char *buf,
+ size_t buflen,
+ v8::Handle<v8::Value>,
+ enum encoding encoding = BINARY);
+
+#define SET_PROTOTYPE_METHOD(templ, name, callback) \
+do { \
+ v8::Local<v8::Signature> __callback##_SIG = v8::Signature::New(templ); \
+ v8::Local<v8::FunctionTemplate> __callback##_TEM = \
+ v8::FunctionTemplate::New(callback, v8::Handle<v8::Value>(), \
+ __callback##_SIG); \
+ templ->PrototypeTemplate()->Set(v8::String::NewSymbol(name), \
+ __callback##_TEM); \
+} while (0)
+
+#define SET_METHOD(obj, name, callback) \
+ obj->Set(v8::String::NewSymbol(name), \
+ v8::FunctionTemplate::New(callback)->GetFunction())
+
+
+#endif // MOCK_RIL_NODE_UTIL_H_
diff --git a/mock-ril/protobuf_v8.cpp b/mock-ril/protobuf_v8.cpp
new file mode 100644
index 0000000..420fecf
--- /dev/null
+++ b/mock-ril/protobuf_v8.cpp
@@ -0,0 +1,508 @@
+// Copyright 2010 Google Inc.
+//
+// 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 "protobuf_v8.h"
+
+#include <map>
+#include <string>
+#include <iostream>
+#include <sstream>
+
+#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.pb.h>
+
+#include "logging.h"
+#include "node_buffer.h"
+#include "node_object_wrap.h"
+
+#include "node_util.h"
+
+//#define PROTOBUF_V8_DEBUG
+#ifdef PROTOBUF_V8_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+using google::protobuf::Descriptor;
+using google::protobuf::DescriptorPool;
+using google::protobuf::DynamicMessageFactory;
+using google::protobuf::FieldDescriptor;
+using google::protobuf::FileDescriptorSet;
+using google::protobuf::Message;
+using google::protobuf::Reflection;
+
+//using ObjectWrap;
+//using Buffer;
+
+using std::map;
+using std::string;
+
+using v8::Array;
+using v8::AccessorInfo;
+using v8::Arguments;
+using v8::Boolean;
+using v8::Context;
+using v8::External;
+using v8::Function;
+using v8::FunctionTemplate;
+using v8::Integer;
+using v8::Handle;
+using v8::HandleScope;
+using v8::InvocationCallback;
+using v8::Local;
+using v8::NamedPropertyGetter;
+using v8::Number;
+using v8::Object;
+using v8::ObjectTemplate;
+using v8::Persistent;
+using v8::Script;
+using v8::String;
+using v8::Value;
+using v8::V8;
+
+namespace protobuf_v8 {
+
+ template <typename T>
+ static T* UnwrapThis(const Arguments& args) {
+ return ObjectWrap::Unwrap<T>(args.This());
+ }
+
+ template <typename T>
+ static T* UnwrapThis(const AccessorInfo& args) {
+ return ObjectWrap::Unwrap<T>(args.This());
+ }
+
+ Persistent<FunctionTemplate> SchemaTemplate;
+ Persistent<FunctionTemplate> TypeTemplate;
+ Persistent<FunctionTemplate> ParseTemplate;
+ Persistent<FunctionTemplate> SerializeTemplate;
+
+ class Schema : public ObjectWrap {
+ public:
+ Schema(Handle<Object> self, const DescriptorPool* pool)
+ : pool_(pool) {
+ DBG("Schema::Schema E:");
+ factory_.SetDelegateToGeneratedFactory(true);
+ self->SetInternalField(1, Array::New());
+ Wrap(self);
+ DBG("Schema::Schema X:");
+ }
+
+ virtual ~Schema() {
+ DBG("~Schema::Schema E:");
+ if (pool_ != DescriptorPool::generated_pool())
+ delete pool_;
+ DBG("~Schema::Schema X:");
+ }
+
+ class Type : public ObjectWrap {
+ public:
+ Schema* schema_;
+ const Descriptor* descriptor_;
+
+ Message* NewMessage() const {
+ DBG("Type::NewMessage() EX:");
+ return schema_->NewMessage(descriptor_);
+ }
+
+ Handle<Function> Constructor() const {
+ DBG("Type::Constrocutor() EX:");
+ return handle_->GetInternalField(2).As<Function>();
+ }
+
+ Local<Object> NewObject(Handle<Value> properties) const {
+ DBG("Type::NewObjext(properties) EX:");
+ return Constructor()->NewInstance(1, &properties);
+ }
+
+ Type(Schema* schema, const Descriptor* descriptor, Handle<Object> self)
+ : schema_(schema), descriptor_(descriptor) {
+ DBG("Type::Type(schema, descriptor, self) E:");
+ // Generate functions for bulk conversion between a JS object
+ // and an array in descriptor order:
+ // from = function(arr) { this.f0 = arr[0]; this.f1 = arr[1]; ... }
+ // to = function() { return [ this.f0, this.f1, ... ] }
+ // This is faster than repeatedly calling Get/Set on a v8::Object.
+ std::ostringstream from, to;
+ from << "(function(arr) { if(arr) {";
+ to << "(function() { return [ ";
+
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ from <<
+ "var x = arr[" << i << "]; "
+ "if(x !== undefined) this['" <<
+ descriptor->field(i)->camelcase_name() <<
+ "'] = x; ";
+
+ if (i > 0) to << ", ";
+ to << "this['" << descriptor->field(i)->camelcase_name() << "']";
+ DBG("field name=%s", descriptor->field(i)->name().c_str());
+ }
+
+ from << " }})";
+ to << " ]; })";
+
+ // managed type->schema link
+ self->SetInternalField(1, schema_->handle_);
+
+ Handle<Function> constructor =
+ Script::Compile(String::New(from.str().c_str()))->Run().As<Function>();
+ constructor->SetHiddenValue(String::New("type"), self);
+
+ Handle<Function> bind =
+ Script::Compile(String::New(
+ "(function(self) {"
+ " var f = this;"
+ " return function(arg) {"
+ " return f.call(self, arg);"
+ " };"
+ "})"))->Run().As<Function>();
+ Handle<Value> arg = self;
+ constructor->Set(String::New("parse"), bind->Call(ParseTemplate->GetFunction(), 1, &arg));
+ constructor->Set(String::New("serialize"), bind->Call(SerializeTemplate->GetFunction(), 1, &arg));
+ self->SetInternalField(2, constructor);
+ self->SetInternalField(3, Script::Compile(String::New(to.str().c_str()))->Run());
+
+ Wrap(self);
+ DBG("Type::Type(schema, descriptor, self) X:");
+ }
+
+#define GET(TYPE) \
+ (index >= 0 ? \
+ reflection->GetRepeated##TYPE(instance, field, index) : \
+ reflection->Get##TYPE(instance, field))
+
+ static Handle<Value> ToJs(const Message& instance,
+ const Reflection* reflection,
+ const FieldDescriptor* field,
+ const Type* message_type,
+ int index) {
+ DBG("Type::ToJs(instance, refelction, field, message_type) E:");
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ DBG("Type::ToJs CPPTYPE_MESSAGE");
+ return message_type->ToJs(GET(Message));
+ case FieldDescriptor::CPPTYPE_STRING: {
+ DBG("Type::ToJs CPPTYPE_STRING");
+ const string& value = GET(String);
+ return String::New(value.data(), value.length());
+ }
+ case FieldDescriptor::CPPTYPE_INT32:
+ DBG("Type::ToJs CPPTYPE_INT32");
+ return Integer::New(GET(Int32));
+ case FieldDescriptor::CPPTYPE_UINT32:
+ DBG("Type::ToJs CPPTYPE_UINT32");
+ return Integer::NewFromUnsigned(GET(UInt32));
+ case FieldDescriptor::CPPTYPE_INT64:
+ DBG("Type::ToJs CPPTYPE_INT64");
+ return Number::New(GET(Int64));
+ case FieldDescriptor::CPPTYPE_UINT64:
+ DBG("Type::ToJs CPPTYPE_UINT64");
+ return Number::New(GET(UInt64));
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ DBG("Type::ToJs CPPTYPE_FLOAT");
+ return Number::New(GET(Float));
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ DBG("Type::ToJs CPPTYPE_DOUBLE");
+ return Number::New(GET(Double));
+ case FieldDescriptor::CPPTYPE_BOOL:
+ DBG("Type::ToJs CPPTYPE_BOOL");
+ return Boolean::New(GET(Bool));
+ case FieldDescriptor::CPPTYPE_ENUM:
+ DBG("Type::ToJs CPPTYPE_ENUM");
+ return String::New(GET(Enum)->name().c_str());
+ }
+
+ return Handle<Value>(); // NOTREACHED
+ }
+#undef GET
+
+ Handle<Object> ToJs(const Message& instance) const {
+ DBG("Type::ToJs(Message) E:");
+ const Reflection* reflection = instance.GetReflection();
+ const Descriptor* descriptor = instance.GetDescriptor();
+
+ Handle<Array> properties = Array::New(descriptor->field_count());
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ HandleScope scope;
+
+ const FieldDescriptor* field = descriptor->field(i);
+ bool repeated = field->is_repeated();
+ if (repeated && !reflection->FieldSize(instance, field)) {
+ DBG("Ignore repeated field with no size in reflection data");
+ continue;
+ }
+ if (!repeated && !reflection->HasField(instance, field)) {
+ DBG("Ignore field with no field in relfection data");
+ continue;
+ }
+
+ const Type* child_type =
+ (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?
+ schema_->GetType(field->message_type()) : NULL;
+
+ Handle<Value> value;
+ if (field->is_repeated()) {
+ int size = reflection->FieldSize(instance, field);
+ Handle<Array> array = Array::New(size);
+ for (int j = 0; j < size; j++) {
+ array->Set(j, ToJs(instance, reflection, field, child_type, j));
+ }
+ value = array;
+ } else {
+ value = ToJs(instance, reflection, field, child_type, -1);
+ }
+
+ DBG("Type::ToJs: set property[%d]=%s", i, ToCString(value));
+ properties->Set(i, value);
+ }
+
+ DBG("Type::ToJs(Message) X:");
+ return NewObject(properties);
+ }
+
+ static Handle<Value> Parse(const Arguments& args) {
+ DBG("Type::Parse(args) E:");
+ Type* type = UnwrapThis<Type>(args);
+ Buffer* buf = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
+
+ Message* message = type->NewMessage();
+ message->ParseFromArray(buf->data(), buf->length());
+ Handle<Object> result = type->ToJs(*message);
+ delete message;
+
+ DBG("Type::Parse(args) X:");
+ return result;
+ }
+
+#define SET(TYPE, EXPR) \
+ if (repeated) reflection->Add##TYPE(instance, field, EXPR); \
+ else reflection->Set##TYPE(instance, field, EXPR)
+
+ static void ToProto(Message* instance,
+ const FieldDescriptor* field,
+ Handle<Value> value,
+ const Type* type,
+ bool repeated) {
+ DBG("Type::ToProto(instance, field, value, type, repeated) E:");
+ HandleScope scope;
+
+ DBG("Type::ToProto field->name()=%s", field->name().c_str());
+ const Reflection* reflection = instance->GetReflection();
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ DBG("Type::ToProto CPPTYPE_MESSAGE");
+ type->ToProto(repeated ?
+ reflection->AddMessage(instance, field) :
+ reflection->MutableMessage(instance, field),
+ value.As<Object>());
+ break;
+ case FieldDescriptor::CPPTYPE_STRING: {
+ DBG("Type::ToProto CPPTYPE_STRING");
+ String::AsciiValue ascii(value);
+ SET(String, string(*ascii, ascii.length()));
+ break;
+ }
+ case FieldDescriptor::CPPTYPE_INT32:
+ DBG("Type::ToProto CPPTYPE_INT32");
+ SET(Int32, value->NumberValue());
+ break;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ DBG("Type::ToProto CPPTYPE_UINT32");
+ SET(UInt32, value->NumberValue());
+ break;
+ case FieldDescriptor::CPPTYPE_INT64:
+ DBG("Type::ToProto CPPTYPE_INT64");
+ SET(Int64, value->NumberValue());
+ break;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ DBG("Type::ToProto CPPTYPE_UINT64");
+ SET(UInt64, value->NumberValue());
+ break;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ DBG("Type::ToProto CPPTYPE_FLOAT");
+ SET(Float, value->NumberValue());
+ break;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ DBG("Type::ToProto CPPTYPE_DOUBLE");
+ SET(Double, value->NumberValue());
+ break;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ DBG("Type::ToProto CPPTYPE_BOOL");
+ SET(Bool, value->BooleanValue());
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ DBG("Type::ToProto CPPTYPE_ENUM");
+ SET(Enum,
+ value->IsNumber() ?
+ field->enum_type()->FindValueByNumber(value->Int32Value()) :
+ field->enum_type()->FindValueByName(*String::AsciiValue(value)));
+ break;
+ }
+ DBG("Type::ToProto(instance, field, value, type, repeated) X:");
+ }
+#undef SET
+
+ void ToProto(Message* instance, Handle<Object> src) const {
+ DBG("ToProto(Message *, Handle<Object>) E:");
+ Handle<Function> to_array = handle_->GetInternalField(3).As<Function>();
+ Handle<Array> properties = to_array->Call(src, 0, NULL).As<Array>();
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ Handle<Value> value = properties->Get(i);
+ if (value->IsUndefined()) continue;
+
+ const FieldDescriptor* field = descriptor_->field(i);
+ const Type* child_type =
+ (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?
+ schema_->GetType(field->message_type()) : NULL;
+ if (field->is_repeated()) {
+ if(!value->IsArray()) {
+ ToProto(instance, field, value, child_type, true);
+ } else {
+ Handle<Array> array = value.As<Array>();
+ int length = array->Length();
+ for (int j = 0; j < length; j++) {
+ ToProto(instance, field, array->Get(j), child_type, true);
+ }
+ }
+ } else {
+ ToProto(instance, field, value, child_type, false);
+ }
+ }
+ DBG("ToProto(Message *, Handle<Object>) X:");
+ }
+
+ static Handle<Value> Serialize(const Arguments& args) {
+ DBG("Serialize(Arguments&) E:");
+ if (!args[0]->IsObject()) {
+ DBG("Serialize(Arguments&) X: not an object");
+ return v8::ThrowException(args[0]);
+ }
+
+ Type* type = UnwrapThis<Type>(args);
+ Message* message = type->NewMessage();
+ type->ToProto(message, args[0].As<Object>());
+ int length = message->ByteSize();
+ Buffer* buffer = Buffer::New(length);
+ message->SerializeWithCachedSizesToArray((google::protobuf::uint8*)buffer->data());
+ delete message;
+
+ DBG("Serialize(Arguments&) X");
+ return buffer->handle_;
+ }
+
+ static Handle<Value> ToString(const Arguments& args) {
+ return String::New(UnwrapThis<Type>(args)->descriptor_->full_name().c_str());
+ }
+ };
+
+ Message* NewMessage(const Descriptor* descriptor) {
+ DBG("Schema::NewMessage(descriptor) EX:");
+ return factory_.GetPrototype(descriptor)->New();
+ }
+
+ Type* GetType(const Descriptor* descriptor) {
+ DBG("Schema::GetType(descriptor) E:");
+ Type* result = types_[descriptor];
+ if (result) return result;
+
+ result = types_[descriptor] =
+ new Type(this, descriptor, TypeTemplate->GetFunction()->NewInstance());
+
+ // managed schema->[type] link
+ Handle<Array> types = handle_->GetInternalField(1).As<Array>();
+ types->Set(types->Length(), result->handle_);
+ DBG("Schema::GetType(descriptor) X:");
+ return result;
+ }
+
+ const DescriptorPool* pool_;
+ map<const Descriptor*, Type*> types_;
+ DynamicMessageFactory factory_;
+
+ static Handle<Value> GetType(const Local<String> name,
+ const AccessorInfo& args) {
+ DBG("Schema::GetType(name, args) E:");
+ Schema* schema = UnwrapThis<Schema>(args);
+ const Descriptor* descriptor =
+ schema->pool_->FindMessageTypeByName(*String::AsciiValue(name));
+
+ DBG("Schema::GetType(name, args) X:");
+ return descriptor ?
+ schema->GetType(descriptor)->Constructor() :
+ Handle<Function>();
+ }
+
+ static Handle<Value> NewSchema(const Arguments& args) {
+ DBG("Schema::NewSchema E: args.Length()=%d", args.Length());
+ if (!args.Length()) {
+ return (new Schema(args.This(),
+ DescriptorPool::generated_pool()))->handle_;
+ }
+
+ Buffer* buf = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
+
+ FileDescriptorSet descriptors;
+ if (!descriptors.ParseFromArray(buf->data(), buf->length())) {
+ DBG("Schema::NewSchema X: bad descriptor");
+ return v8::ThrowException(String::New("Malformed descriptor"));
+ }
+
+ DescriptorPool* pool = new DescriptorPool;
+ for (int i = 0; i < descriptors.file_size(); i++) {
+ pool->BuildFile(descriptors.file(i));
+ }
+
+ DBG("Schema::NewSchema X");
+ return (new Schema(args.This(), pool))->handle_;
+ }
+ };
+
+ void Init() {
+ DBG("Init E:");
+ HandleScope handle_scope;
+
+ TypeTemplate = Persistent<FunctionTemplate>::New(FunctionTemplate::New());
+ TypeTemplate->SetClassName(String::New("Type"));
+ // native self
+ // owning schema (so GC can manage our lifecyle)
+ // constructor
+ // toArray
+ TypeTemplate->InstanceTemplate()->SetInternalFieldCount(4);
+
+ SchemaTemplate = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Schema::NewSchema));
+ SchemaTemplate->SetClassName(String::New("Schema"));
+ // native self
+ // array of types (so GC can manage our lifecyle)
+ SchemaTemplate->InstanceTemplate()->SetInternalFieldCount(2);
+ SchemaTemplate->InstanceTemplate()->SetNamedPropertyHandler(Schema::GetType);
+
+ ParseTemplate = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Schema::Type::Parse));
+ SerializeTemplate = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Schema::Type::Serialize));
+
+ DBG("Init X:");
+ }
+
+} // namespace protobuf_v8
+
+extern "C" void SchemaObjectTemplateInit(Handle<ObjectTemplate> target) {
+ DBG("SchemaObjectTemplateInit(target) EX:");
+ target->Set(String::New("Schema"), protobuf_v8::SchemaTemplate);
+}
diff --git a/mock-ril/protobuf_v8.h b/mock-ril/protobuf_v8.h
new file mode 100644
index 0000000..4244e27
--- /dev/null
+++ b/mock-ril/protobuf_v8.h
@@ -0,0 +1,22 @@
+// Copyright 2010 Google Inc.
+//
+// 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 <v8.h>
+
+namespace protobuf_v8 {
+ extern void Init();
+} // namespace protobuf_v8
+
+// Add Schema to the object template
+extern "C" void SchemaObjectTemplateInit(v8::Handle<v8::ObjectTemplate> target);
diff --git a/mock-ril/requests.cpp b/mock-ril/requests.cpp
new file mode 100644
index 0000000..9e2ffdd
--- /dev/null
+++ b/mock-ril/requests.cpp
@@ -0,0 +1,313 @@
+/**
+ * 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.
+ */
+
+#include <map>
+
+#include <v8.h>
+#include <telephony/ril.h>
+
+
+#include "ril.pb.h"
+
+#include "logging.h"
+#include "js_support.h"
+#include "mock_ril.h"
+#include "node_buffer.h"
+#include "node_object_wrap.h"
+#include "node_util.h"
+#include "protobuf_v8.h"
+#include "status.h"
+#include "util.h"
+#include "worker.h"
+
+#include "requests.h"
+
+//#define REQUESTS_DEBUG
+#ifdef REQUESTS_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+
+int cvrtReqEnterSimPinToBuffer(Buffer **pBuffer,
+ const void *data, const size_t datalen, const RIL_Token t) {
+ int status;
+ Buffer *buffer;
+
+ DBG("cvrtReqEnterSimPinToBuffer E");
+ if (datalen < sizeof(int)) {
+ LOGE("cvrtReqEnterSimPinToBuffer: data to small err size < sizeof int");
+ status = STATUS_BAD_DATA;
+ } else {
+ ril_proto::ReqEnterSimPin *req = new ril_proto::ReqEnterSimPin();
+ req->set_pin((((char **)data)[0]));
+ buffer = Buffer::New(req->ByteSize());
+ req->SerializeToArray(buffer->data(), buffer->length());
+ delete req;
+ *pBuffer = buffer;
+ status = STATUS_OK;
+ }
+ DBG("cvrtReqEnterSimPinToBuffer X status=%d", status);
+ return status;
+}
+
+int cvrtReqHangUpToBuffer(Buffer **pBuffer,
+ const void *data, const size_t datalen, const RIL_Token t) {
+ int status;
+ Buffer *buffer;
+
+ DBG("cvrtReqHangUpToBuffer E");
+ if (datalen < sizeof(int)) {
+ LOGE("cvrtReqHangUpToBuffer: data to small err size < sizeof int");
+ status = STATUS_BAD_DATA;
+ } else {
+ ril_proto::ReqHangUp *req = new ril_proto::ReqHangUp();
+ req->set_connection_index(((int *)data)[0]);
+ buffer = Buffer::New(req->ByteSize());
+ req->SerializeToArray(buffer->data(), buffer->length());
+ delete req;
+ *pBuffer = buffer;
+ status = STATUS_OK;
+ }
+ DBG("cvrtReqHangUpToBuffer X status=%d", status);
+ return status;
+}
+
+int cvrtReqScreenStateToBuffer(Buffer **pBuffer,
+ const void *data, const size_t datalen, const RIL_Token t) {
+ int status;
+ Buffer *buffer;
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ DBG("cvrtReqScreenStateToBuffer E data=%p datalen=%d t=%p",
+ data, datalen, t);
+ if (datalen < sizeof(int)) {
+ LOGE("cvrtReqScreenStateToBuffer: data to small err size < sizeof int");
+ status = STATUS_BAD_DATA;
+ } else {
+ ril_proto::ReqScreenState *req = new ril_proto::ReqScreenState();
+ req->set_state(((int *)data)[0]);
+ if (try_catch.HasCaught()) {
+ ReportException(&try_catch);
+ }
+ buffer = Buffer::New(req->ByteSize());
+ DBG("cvrtReqScreenStateToBuffer: serialize");
+ req->SerializeToArray(buffer->data(), buffer->length());
+ delete req;
+ *pBuffer = buffer;
+ status = STATUS_OK;
+ }
+ DBG("cvrtReqScreenStateToBuffer X status=%d", status);
+ return status;
+}
+
+/**
+ * Map from indexed by cmd and used to convert Data to Protobuf.
+ */
+typedef int (*CvrtDataToBuffer)(Buffer** protobuf, const void *data,
+ const size_t datalen, const RIL_Token t);
+typedef std::map<int, CvrtDataToBuffer> RequestMap;
+RequestMap requestMap;
+
+
+int callOnRilRequest(v8::Handle<v8::Context> context, int cmd,
+ const void *data, size_t datalen, RIL_Token t) {
+ DBG("callOnRilRequest E: cmd=%d", cmd);
+
+ int status;
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+
+ // Get the onRilRequest Function
+ v8::Handle<v8::String> name = v8::String::New("onRilRequest");
+ v8::Handle<v8::Value> onRilRequestFunctionValue = context->Global()->Get(name);
+ v8::Handle<v8::Function> onRilRequestFunction =
+ v8::Handle<v8::Function>::Cast(onRilRequestFunctionValue);
+
+ // Create the cmd and token
+ v8::Handle<v8::Value> v8RequestValue = v8::Number::New(cmd);
+ v8::Handle<v8::Value> v8TokenValue = v8::Number::New(int64_t(t));
+
+ // Convert the data to a protobuf Buffer
+ Buffer *buffer = NULL;
+ RequestMap::iterator itr;
+ itr = requestMap.find(cmd);
+ if (itr != requestMap.end()) {
+ status = itr->second(&buffer, data, datalen, t);
+ } else {
+ LOGE("callOnRilRequest X unknown request");
+ status = STATUS_UNSUPPORTED_REQUEST;
+ }
+
+ if (status == STATUS_OK) {
+ // Invoke onRilRequest
+ const int argc = 3;
+ v8::Handle<v8::Value> argv[argc] = {
+ v8RequestValue, v8TokenValue, buffer->handle_ };
+ v8::Handle<v8::Value> result =
+ onRilRequestFunction->Call(context->Global(), argc, argv);
+ if (try_catch.HasCaught()) {
+ LOGE("callOnRilRequest error");
+ ReportException(&try_catch);
+ status = STATUS_ERR;
+ } else {
+ v8::String::Utf8Value result_string(result);
+ DBG("callOnRilRequest result=%s", ToCString(result_string));
+ status = STATUS_OK;
+ }
+ }
+
+ if (status != STATUS_OK) {
+ // An error report complete now
+ RIL_Errno rilErrCode = (status == STATUS_UNSUPPORTED_REQUEST) ?
+ RIL_E_REQUEST_NOT_SUPPORTED : RIL_E_GENERIC_FAILURE;
+ s_rilenv->OnRequestComplete(t, rilErrCode, NULL, 0);
+ }
+
+ DBG("callOnRilRequest X: status=%d", status);
+ return status;
+}
+
+RilRequestWorkerQueue::RilRequestWorkerQueue(v8::Handle<v8::Context> context) {
+ DBG("RilRequestWorkerQueue E:");
+
+ context_ = context;
+ pthread_mutex_init(&free_list_mutex_, NULL);
+
+ DBG("RilRequestWorkerQueue X:");
+}
+
+RilRequestWorkerQueue::~RilRequestWorkerQueue() {
+ DBG("~RilRequestWorkerQueue E:");
+ Request *req;
+ pthread_mutex_lock(&free_list_mutex_);
+ while(free_list_.size() != 0) {
+ req = free_list_.front();
+ delete req;
+ free_list_.pop();
+ }
+ pthread_mutex_unlock(&free_list_mutex_);
+ pthread_mutex_destroy(&free_list_mutex_);
+ DBG("~RilRequestWorkerQueue X:");
+}
+
+void RilRequestWorkerQueue::AddRequest (const int request,
+ const void *data, const size_t datalen, const RIL_Token token) {
+ Request *req;
+ pthread_mutex_lock(&free_list_mutex_);
+ if (free_list_.size() == 0) {
+ req = new Request(request, data, datalen, token);
+ pthread_mutex_unlock(&free_list_mutex_);
+ } else {
+ req = free_list_.front();
+ free_list_.pop();
+ pthread_mutex_unlock(&free_list_mutex_);
+ req->Set(request, data, datalen, token);
+ }
+ Add(req);
+ DBG("RilRequestWorkerQueue::AddRequest: X"
+ " request=%d data=%p datalen=%d token=%p",
+ request, data, datalen, token);
+}
+
+void RilRequestWorkerQueue::Process(void *p) {
+
+ Request *req = (Request *)p;
+ DBG("RilRequestWorkerQueue::Process: E"
+ " request=%d data=%p datalen=%d t=%p",
+ req->request_, req->data_, req->datalen_, req->token_);
+
+ v8::Locker locker;
+ v8::HandleScope handle_scope;
+ v8::Context::Scope context_scope(context_);
+ callOnRilRequest(context_, req->request_,
+ req->data_, req->datalen_, req->token_);
+
+ DBG("RilRequestWorkerQueue::Process: X"
+ " request=%d data=%p datalen=%d t=%p",
+ req->request_, req->data_, req->datalen_, req->token_);
+
+ pthread_mutex_lock(&free_list_mutex_);
+ free_list_.push(req);
+ pthread_mutex_unlock(&free_list_mutex_);
+}
+
+int requestsInit(v8::Handle<v8::Context> context, RilRequestWorkerQueue **rwq) {
+ LOGD("requestsInit E");
+
+ requestMap[RIL_REQUEST_ENTER_SIM_PIN] = cvrtReqEnterSimPinToBuffer;
+ requestMap[RIL_REQUEST_HANGUP] = cvrtReqHangUpToBuffer;
+ requestMap[RIL_REQUEST_SCREEN_STATE] = cvrtReqScreenStateToBuffer;
+ RequestMap::iterator itr;
+
+ *rwq = new RilRequestWorkerQueue(context);
+ int status = (*rwq)->Run();
+
+ LOGD("requestsInit X: status=%d", status);
+ return status;
+}
+
+void testRequests(v8::Handle<v8::Context> context) {
+ LOGD("testRequests E: ********");
+
+ v8::TryCatch try_catch;
+
+ char *buffer;
+ const char *fileName= "/sdcard/data/mock_ril.js";
+ int status = ReadFile(fileName, &buffer);
+ if (status == 0) {
+ runJs(context, &try_catch, fileName, buffer);
+ if (!try_catch.HasCaught()) {
+ {
+ const char *data[1] = { "winks-pin" };
+ callOnRilRequest(context, RIL_REQUEST_ENTER_SIM_PIN, data,
+ sizeof(data), (void *)0x12345678);
+ }
+ {
+ const int data[1] = { 1 };
+ callOnRilRequest(context, RIL_REQUEST_HANGUP, data,
+ sizeof(data), (void *)0x12345679);
+ }
+ {
+ const int data[1] = { 1 };
+ callOnRilRequest(context, RIL_REQUEST_SCREEN_STATE, data,
+ sizeof(data), (void *)0x1234567A);
+ }
+
+ {
+ RilRequestWorkerQueue *rwq = new RilRequestWorkerQueue(context);
+ if (rwq->Run() == STATUS_OK) {
+ const int data[1] = { 1 };
+ rwq->AddRequest(RIL_REQUEST_SCREEN_STATE,
+ data, sizeof(data), (void *)0x1234567A);
+ // Sleep to let it be processed
+ v8::Unlocker unlocker;
+ sleep(3);
+ v8::Locker locker;
+ }
+ delete rwq;
+ }
+ }
+ }
+
+ LOGD("testRequests X: ********\n");
+}
diff --git a/mock-ril/requests.h b/mock-ril/requests.h
new file mode 100644
index 0000000..f82a94b
--- /dev/null
+++ b/mock-ril/requests.h
@@ -0,0 +1,113 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_REQUESTS_H_
+#define MOCK_RIL_REQUESTS_H_
+
+#include <queue>
+#include <pthread.h>
+
+#include <v8.h>
+#include <worker.h>
+
+
+/**
+ * A request
+ */
+struct Request {
+ int request_;
+ char *data_;
+ size_t datalen_;
+ size_t maxlen_;
+ RIL_Token token_;
+
+ Request(const int request, const void *data,
+ const size_t datalen, const RIL_Token token) :
+ request_(0),
+ data_(NULL),
+ datalen_(0),
+ maxlen_(0),
+ token_(0) {
+ Set(request, data, datalen, token);
+ }
+
+ ~Request() {
+ delete [] data_;
+ }
+
+ void Set(const int request,
+ const void *data, const size_t datalen, const RIL_Token token) {
+ request_ = request;
+ token_ = token;
+ if (datalen > maxlen_) {
+ // TODO: MAKE A POOL ?
+ delete [] data_;
+ data_ = new char[datalen];
+ maxlen_ = datalen;
+ }
+ datalen_ = datalen;
+ memmove(data_, data, datalen);
+ }
+};
+
+/**
+ * Ril request worker queue.
+ *
+ * Pass requests to mock-ril.js for processing
+ */
+class RilRequestWorkerQueue : public WorkerQueue {
+ private:
+ v8::Handle<v8::Context> context_;
+ // TODO: Need a thread-safe queue
+ std::queue<Request *> free_list_;
+ pthread_mutex_t free_list_mutex_;
+
+ public:
+ /**
+ * Constructor
+ */
+ RilRequestWorkerQueue(v8::Handle<v8::Context> context);
+
+ /**
+ * Destructor
+ */
+ virtual ~RilRequestWorkerQueue();
+
+ /**
+ * Add a request to the Queue
+ */
+ void AddRequest(const int request,
+ const void *data, const size_t datalen, const RIL_Token t);
+
+ /**
+ * Processes a request sending it to mock-ril.js
+ */
+ virtual void Process(void *p);
+};
+
+/**
+ * Initialize module
+ *
+ * @return 0 if no errors
+ */
+int requestsInit(v8::Handle<v8::Context> context, RilRequestWorkerQueue **rwq);
+
+/**
+ * Run tests
+ */
+void testRequests(v8::Handle<v8::Context> context);
+
+#endif // MOCK_RIL_REQUESTS_H_
diff --git a/mock-ril/responses.cpp b/mock-ril/responses.cpp
new file mode 100644
index 0000000..6accaf9
--- /dev/null
+++ b/mock-ril/responses.cpp
@@ -0,0 +1,250 @@
+/**
+ * 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.
+ */
+
+#include <map>
+
+#include <v8.h>
+#include <telephony/ril.h>
+
+#include "ril.pb.h"
+
+#include "logging.h"
+#include "mock_ril.h"
+#include "node_buffer.h"
+#include "node_object_wrap.h"
+#include "protobuf_v8.h"
+#include "status.h"
+#include "util.h"
+#include "worker.h"
+
+#include "responses.h"
+
+//#define RESPONSES_DEBUG
+#ifdef RESPONSES_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+
+/**
+ * No buffer
+ * @return STATUS_OK and *data = NULL *datalen = 0;
+ */
+int noBuffer(Buffer *buffer, void **data, size_t *datalen) {
+ DBG("noBuffer E");
+
+ if ((data == NULL) || (datalen == NULL)) {
+ return STATUS_BAD_PARAMETER;
+ }
+ data = NULL;
+ datalen = 0;
+
+ DBG("noBuffer X");
+ return STATUS_OK;
+}
+
+/**
+ * Convert EnterSimPinData
+ */
+int cvrtBufferToRspEnterSimPinData(Buffer *buffer, void **data,
+ size_t *datalen) {
+ int status;
+
+ DBG("cvrtBufferToRspEnterSimPinData E");
+ if ((buffer == NULL) || (data == NULL) || (datalen == NULL)) {
+ return STATUS_BAD_PARAMETER;
+ }
+
+ ril_proto::RspEnterSimPin *rsp = new ril_proto::RspEnterSimPin();
+ rsp->ParseFromArray(buffer->data(), buffer->length());
+ DBG("retries_remaining=%d", rsp->retries_remaining());
+ int retries_remaining = rsp->retries_remaining();
+ *data = (void *)&retries_remaining;
+ *datalen = sizeof retries_remaining;
+ status = STATUS_OK;
+
+ DBG("cvrtBufferToRspEnterSimPinData X status=%d", status);
+ return status;
+}
+
+/**
+ * Maps for converting request complete and unsoliciated response
+ * to a conversation routine.
+ */
+typedef int (*CvrtRilResponseBufferToData)(Buffer* protobuf, void **data, size_t *len);
+typedef std::map<int, CvrtRilResponseBufferToData> CvrtRilResponseBufferToDataMap;
+
+CvrtRilResponseBufferToDataMap rilResponseMap;
+CvrtRilResponseBufferToDataMap rilUnsolicitedResponseMap;
+
+/**
+ * Send a ril request complete response.
+ */
+v8::Handle<v8::Value> SendRilRequestComplete(const v8::Arguments& args) {
+ DBG("SendRilRequestComplete E");
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> retValue;
+
+ void *data;
+ size_t datalen;
+
+ int cmd;
+ RIL_Errno rilErrCode;
+ RIL_Token token;
+ Buffer* buffer;
+
+ /**
+ * Get the arguments. There should be at least 3, cmd,
+ * ril error code and token. Optionally a Buffer containing
+ * the protobuf representation of the data to return.
+ */
+ if (args.Length() < REQUEST_COMPLETE_REQUIRED_CMDS) {
+ // Expecting a cmd, ERROR and token
+ LOGE("SendRilRequestComplete X %d parameters"
+ " expecting at least %d: rilErrCode, cmd, and token",
+ args.Length(), REQUEST_COMPLETE_REQUIRED_CMDS);
+ return v8::Undefined();
+ }
+ v8::Handle<v8::Value> v8RilErrCode(
+ args[REQUEST_COMPLETE_RIL_ERR_CODE_INDEX]->ToObject());
+ rilErrCode = RIL_Errno(v8RilErrCode->NumberValue());
+
+ v8::Handle<v8::Value> v8Cmd(
+ args[REQUEST_COMPLETE_CMD_INDEX]->ToObject());
+ cmd = int(v8Cmd->NumberValue());
+
+ v8::Handle<v8::Value> v8Token(
+ args[REQUEST_COMPLETE_TOKEN_INDEX]->ToObject());
+ token = RIL_Token(int64_t(v8Token->NumberValue()));
+
+ if (args.Length() >= (REQUEST_COMPLETE_DATA_INDEX+1)) {
+ buffer = ObjectWrap::Unwrap<Buffer>(
+ args[REQUEST_COMPLETE_DATA_INDEX]->ToObject());
+ } else {
+ buffer = NULL;
+ }
+
+ CvrtRilResponseBufferToDataMap::iterator itr;
+ itr = rilResponseMap.find(cmd);
+ if (itr != rilResponseMap.end()) {
+ int status = itr->second(buffer, &data, &datalen);
+ if (status == STATUS_OK) {
+ rilErrCode = RIL_E_SUCCESS;
+ } else {
+ // TODO: Add mapping from status to rilErrCode
+ rilErrCode = RIL_E_GENERIC_FAILURE;
+ }
+ } else {
+ if ((buffer == NULL) || (buffer->length() <= 0)) {
+ // Nothing to convert
+ rilErrCode = RIL_E_SUCCESS;
+ data = NULL;
+ datalen = 0;
+ } else {
+ // There was a buffer but we don't support the resonse yet.
+ LOGE("SendRilRequestComplete: No conversion routine for cmd %d,"
+ " return RIL_E_REQUEST_NOT_SUPPORTED", cmd);
+ rilErrCode = RIL_E_REQUEST_NOT_SUPPORTED;
+ data = NULL;
+ datalen = 0;
+ }
+ }
+
+ // Complete the request
+ s_rilenv->OnRequestComplete(token, rilErrCode, data, datalen);
+
+ DBG("SendRilRequestComplete X rilErrCode=%d", rilErrCode);
+ return v8::Undefined();
+}
+
+/**
+ * Send an unsolicited response.
+ */
+v8::Handle<v8::Value> SendRilUnsolicitedResponse(const v8::Arguments& args) {
+ DBG("SendRilUnsolicitedResponse E");
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> retValue;
+
+ int status;
+ void *data;
+ size_t datalen;
+
+ int cmd;
+ Buffer* buffer;
+
+ /**
+ * Get the cmd number and data arguments
+ */
+ if (args.Length() < UNSOL_RESPONSE_REQUIRED_CMDS) {
+ // Expecting a cmd
+ LOGE("SendRilUnsolicitedResponse X %d parameters"
+ " expecting at least a cmd",
+ args.Length());
+ return v8::Undefined();
+ }
+ v8::Handle<v8::Value> v8RilErrCode(args[UNSOL_RESPONSE_CMD_INDEX]->ToObject());
+ cmd = int(v8RilErrCode->NumberValue());
+
+ // data is optional
+ if (args.Length() >= (UNSOL_RESPONSE_DATA_INDEX+1)) {
+ buffer = ObjectWrap::Unwrap<Buffer>(args[UNSOL_RESPONSE_DATA_INDEX]->ToObject());
+ } else {
+ buffer = NULL;
+ }
+
+ CvrtRilResponseBufferToDataMap::iterator itr;
+ itr = rilUnsolicitedResponseMap.find(cmd);
+ if (itr != rilUnsolicitedResponseMap.end()) {
+ status = itr->second(buffer, &data, &datalen);
+ } else {
+ if ((buffer == NULL) || (buffer->length() <= 0)) {
+ // Nothing to convert
+ status = STATUS_OK;
+ data = NULL;
+ datalen = 0;
+ } else {
+ // There was a buffer but we don't support the resonse yet.
+ LOGE("SendRilUnsolicitedResponse: No conversion routine for cmd %d,"
+ " return RIL_E_REQUEST_NOT_SUPPORTED", cmd);
+ status = STATUS_ERR;
+ data = NULL;
+ datalen = 0;
+ }
+ }
+
+ if (status == STATUS_OK) {
+ s_rilenv->OnUnsolicitedResponse(cmd, data, datalen);
+ }
+
+ DBG("SendRilUnsolicitedResponse X status=%d", status);
+ return v8::Undefined();
+}
+
+int responsesInit(v8::Handle<v8::Context> context) {
+ LOGD("responsesInit E");
+ int status = STATUS_OK;
+
+ rilResponseMap[RIL_REQUEST_ENTER_SIM_PIN] = cvrtBufferToRspEnterSimPinData;
+ rilResponseMap[RIL_REQUEST_SCREEN_STATE] = noBuffer;
+
+ LOGD("responsesInit X: status=%d", status);
+ return STATUS_OK;
+}
diff --git a/mock-ril/responses.h b/mock-ril/responses.h
new file mode 100644
index 0000000..e177066
--- /dev/null
+++ b/mock-ril/responses.h
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_RESPONSES_H_
+#define MOCK_RIL_RESPONSES_H_
+
+#include <v8.h>
+
+/**
+ * Send a ril request complete, data is optional
+ *
+ * args[0] = rilErrCode
+ * args[1] = cmd
+ * args[2] = token
+ * args[3] = optional data
+ */
+#define REQUEST_COMPLETE_REQUIRED_CMDS 3
+#define REQUEST_COMPLETE_RIL_ERR_CODE_INDEX 0
+#define REQUEST_COMPLETE_CMD_INDEX 1
+#define REQUEST_COMPLETE_TOKEN_INDEX 2
+#define REQUEST_COMPLETE_DATA_INDEX 3
+v8::Handle<v8::Value> SendRilRequestComplete(const v8::Arguments& args);
+
+/**
+ * Send a ril unsolicited response, buffer is optional
+ *
+ * args[0] = cmd
+ * args[1] = optional data
+ */
+#define UNSOL_RESPONSE_REQUIRED_CMDS 1
+#define UNSOL_RESPONSE_CMD_INDEX 0
+#define UNSOL_RESPONSE_DATA_INDEX 1
+v8::Handle<v8::Value> SendRilUnsolicitedResponse(const v8::Arguments& args);
+
+// Initialize module
+int responsesInit(v8::Handle<v8::Context> context);
+
+#endif // MOCK_RIL_RESPONSES_H_
diff --git a/mock-ril/ril.desc b/mock-ril/ril.desc
new file mode 100644
index 0000000..0514655
--- /dev/null
+++ b/mock-ril/ril.desc
Binary files differ
diff --git a/mock-ril/ril.pb.cpp b/mock-ril/ril.pb.cpp
new file mode 100644
index 0000000..d49209f
--- /dev/null
+++ b/mock-ril/ril.pb.cpp
@@ -0,0 +1,2684 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "ril.pb.h"
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+// @@protoc_insertion_point(includes)
+
+namespace ril_proto {
+
+namespace {
+
+const ::google::protobuf::Descriptor* RilAppStatus_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ RilAppStatus_reflection_ = NULL;
+const ::google::protobuf::Descriptor* RilCardStatus_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ RilCardStatus_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ReqGetSimStatus_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReqGetSimStatus_reflection_ = NULL;
+const ::google::protobuf::Descriptor* RspGetSimStatus_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ RspGetSimStatus_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ReqEnterSimPin_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReqEnterSimPin_reflection_ = NULL;
+const ::google::protobuf::Descriptor* RspEnterSimPin_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ RspEnterSimPin_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ReqHangUp_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReqHangUp_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ReqScreenState_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReqScreenState_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* RilCommand_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* RadioState_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* RilCardState_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* RilPersoSubstate_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* RilAppState_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* RilPinState_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* RilAppType_descriptor_ = NULL;
+
+} // namespace
+
+
+void protobuf_AssignDesc_ril_2eproto() {
+ protobuf_AddDesc_ril_2eproto();
+ const ::google::protobuf::FileDescriptor* file =
+ ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
+ "ril.proto");
+ GOOGLE_CHECK(file != NULL);
+ RilAppStatus_descriptor_ = file->message_type(0);
+ static const int RilAppStatus_offsets_[8] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, app_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, app_state_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, perso_substate_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, aid_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, app_label_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, pin1_replaced_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, pin1_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, pin2_),
+ };
+ RilAppStatus_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ RilAppStatus_descriptor_,
+ RilAppStatus::default_instance_,
+ RilAppStatus_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilAppStatus, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(RilAppStatus));
+ RilCardStatus_descriptor_ = file->message_type(1);
+ static const int RilCardStatus_offsets_[6] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, card_state_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, universal_pin_state_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, gsm_umts_subscription_app_index_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, cdma_subscription_app_index_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, num_applications_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, applications_),
+ };
+ RilCardStatus_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ RilCardStatus_descriptor_,
+ RilCardStatus::default_instance_,
+ RilCardStatus_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RilCardStatus, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(RilCardStatus));
+ ReqGetSimStatus_descriptor_ = file->message_type(2);
+ static const int ReqGetSimStatus_offsets_[1] = {
+ };
+ ReqGetSimStatus_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ ReqGetSimStatus_descriptor_,
+ ReqGetSimStatus::default_instance_,
+ ReqGetSimStatus_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqGetSimStatus, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqGetSimStatus, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(ReqGetSimStatus));
+ RspGetSimStatus_descriptor_ = file->message_type(3);
+ static const int RspGetSimStatus_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RspGetSimStatus, card_status_),
+ };
+ RspGetSimStatus_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ RspGetSimStatus_descriptor_,
+ RspGetSimStatus::default_instance_,
+ RspGetSimStatus_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RspGetSimStatus, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RspGetSimStatus, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(RspGetSimStatus));
+ ReqEnterSimPin_descriptor_ = file->message_type(4);
+ static const int ReqEnterSimPin_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqEnterSimPin, pin_),
+ };
+ ReqEnterSimPin_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ ReqEnterSimPin_descriptor_,
+ ReqEnterSimPin::default_instance_,
+ ReqEnterSimPin_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqEnterSimPin, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqEnterSimPin, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(ReqEnterSimPin));
+ RspEnterSimPin_descriptor_ = file->message_type(5);
+ static const int RspEnterSimPin_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RspEnterSimPin, retries_remaining_),
+ };
+ RspEnterSimPin_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ RspEnterSimPin_descriptor_,
+ RspEnterSimPin::default_instance_,
+ RspEnterSimPin_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RspEnterSimPin, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RspEnterSimPin, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(RspEnterSimPin));
+ ReqHangUp_descriptor_ = file->message_type(6);
+ static const int ReqHangUp_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqHangUp, connection_index_),
+ };
+ ReqHangUp_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ ReqHangUp_descriptor_,
+ ReqHangUp::default_instance_,
+ ReqHangUp_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqHangUp, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqHangUp, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(ReqHangUp));
+ ReqScreenState_descriptor_ = file->message_type(7);
+ static const int ReqScreenState_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqScreenState, state_),
+ };
+ ReqScreenState_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ ReqScreenState_descriptor_,
+ ReqScreenState::default_instance_,
+ ReqScreenState_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqScreenState, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReqScreenState, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(ReqScreenState));
+ RilCommand_descriptor_ = file->enum_type(0);
+ RadioState_descriptor_ = file->enum_type(1);
+ RilCardState_descriptor_ = file->enum_type(2);
+ RilPersoSubstate_descriptor_ = file->enum_type(3);
+ RilAppState_descriptor_ = file->enum_type(4);
+ RilPinState_descriptor_ = file->enum_type(5);
+ RilAppType_descriptor_ = file->enum_type(6);
+}
+
+namespace {
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+inline void protobuf_AssignDescriptorsOnce() {
+ ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
+ &protobuf_AssignDesc_ril_2eproto);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ RilAppStatus_descriptor_, &RilAppStatus::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ RilCardStatus_descriptor_, &RilCardStatus::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReqGetSimStatus_descriptor_, &ReqGetSimStatus::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ RspGetSimStatus_descriptor_, &RspGetSimStatus::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReqEnterSimPin_descriptor_, &ReqEnterSimPin::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ RspEnterSimPin_descriptor_, &RspEnterSimPin::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReqHangUp_descriptor_, &ReqHangUp::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReqScreenState_descriptor_, &ReqScreenState::default_instance());
+}
+
+} // namespace
+
+void protobuf_ShutdownFile_ril_2eproto() {
+ delete RilAppStatus::default_instance_;
+ delete RilAppStatus_reflection_;
+ delete RilCardStatus::default_instance_;
+ delete RilCardStatus_reflection_;
+ delete ReqGetSimStatus::default_instance_;
+ delete ReqGetSimStatus_reflection_;
+ delete RspGetSimStatus::default_instance_;
+ delete RspGetSimStatus_reflection_;
+ delete ReqEnterSimPin::default_instance_;
+ delete ReqEnterSimPin_reflection_;
+ delete RspEnterSimPin::default_instance_;
+ delete RspEnterSimPin_reflection_;
+ delete ReqHangUp::default_instance_;
+ delete ReqHangUp_reflection_;
+ delete ReqScreenState::default_instance_;
+ delete ReqScreenState_reflection_;
+}
+
+void protobuf_AddDesc_ril_2eproto() {
+ static bool already_here = false;
+ if (already_here) return;
+ already_here = true;
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+ "\n\tril.proto\022\tril_proto\"\232\002\n\014RilAppStatus\022"
+ "\'\n\010app_type\030\001 \001(\0162\025.ril_proto.RilAppType"
+ "\022)\n\tapp_state\030\002 \001(\0162\026.ril_proto.RilAppSt"
+ "ate\0223\n\016perso_substate\030\003 \001(\0162\033.ril_proto."
+ "RilPersoSubstate\022\013\n\003aid\030\004 \001(\t\022\021\n\tapp_lab"
+ "el\030\005 \001(\t\022\025\n\rpin1_replaced\030\006 \001(\005\022$\n\004pin1\030"
+ "\007 \001(\0162\026.ril_proto.RilPinState\022$\n\004pin2\030\010 "
+ "\001(\0162\026.ril_proto.RilPinState\"\210\002\n\rRilCardS"
+ "tatus\022+\n\ncard_state\030\001 \001(\0162\027.ril_proto.Ri"
+ "lCardState\0223\n\023universal_pin_state\030\002 \001(\0162"
+ "\026.ril_proto.RilPinState\022\'\n\037gsm_umts_subs"
+ "cription_app_index\030\003 \001(\005\022#\n\033cdma_subscri"
+ "ption_app_index\030\004 \001(\005\022\030\n\020num_application"
+ "s\030\005 \001(\005\022-\n\014applications\030\006 \003(\0132\027.ril_prot"
+ "o.RilAppStatus\"\021\n\017ReqGetSimStatus\"@\n\017Rsp"
+ "GetSimStatus\022-\n\013card_status\030\001 \002(\0132\030.ril_"
+ "proto.RilCardStatus\"\035\n\016ReqEnterSimPin\022\013\n"
+ "\003pin\030\001 \002(\t\"+\n\016RspEnterSimPin\022\031\n\021retries_"
+ "remaining\030\001 \002(\005\"%\n\tReqHangUp\022\030\n\020connecti"
+ "on_index\030\001 \002(\005\"\037\n\016ReqScreenState\022\r\n\005stat"
+ "e\030\001 \002(\010*a\n\nRilCommand\022\026\n\022CMD_GET_SIM_STA"
+ "TUS\020\001\022\025\n\021CMD_ENTER_SIM_PIN\020\002\022\016\n\nCMD_HANG"
+ "UP\020\014\022\024\n\020CMD_SCREEN_STATE\020=*\271\002\n\nRadioStat"
+ "e\022\023\n\017RADIO_STATE_OFF\020\000\022\033\n\027RADIO_STATE_UN"
+ "AVAILABLE\020\001\022\035\n\031RADIO_STATE_SIM_NOT_READY"
+ "\020\002\022$\n RADIO_STATE_SIM_LOCKED_OR_ABSENT\020\003"
+ "\022\031\n\025RADIO_STATE_SIM_READY\020\004\022\036\n\032RADIO_STA"
+ "TE_RUIM_NOT_READY\020\005\022\032\n\026RADIO_STATE_RUIM_"
+ "READY\020\006\022%\n!RADIO_STATE_RUIM_LOCKED_OR_AB"
+ "SENT\020\007\022\034\n\030RADIO_STATE_NV_NOT_READY\020\010\022\030\n\024"
+ "RADIO_STATE_NV_READY\020\t*P\n\014RilCardState\022\024"
+ "\n\020CARDSTATE_ABSENT\020\000\022\025\n\021CARDSTATE_PRESEN"
+ "T\020\001\022\023\n\017CARDSTATE_ERROR\020\002*\361\006\n\020RilPersoSub"
+ "state\022\031\n\025PERSOSUBSTATE_UNKNOWN\020\000\022\035\n\031PERS"
+ "OSUBSTATE_IN_PROGRESS\020\001\022\027\n\023PERSOSUBSTATE"
+ "_READY\020\002\022\035\n\031PERSOSUBSTATE_SIM_NETWORK\020\003\022"
+ "$\n PERSOSUBSTATE_SIM_NETWORK_SUBSET\020\004\022\037\n"
+ "\033PERSOSUBSTATE_SIM_CORPORATE\020\005\022&\n\"PERSOS"
+ "UBSTATE_SIM_SERVICE_PROVIDER\020\006\022\031\n\025PERSOS"
+ "UBSTATE_SIM_SIM\020\007\022!\n\035PERSOSUBSTATE_SIM_N"
+ "ETWORK_PUK\020\010\022(\n$PERSOSUBSTATE_SIM_NETWOR"
+ "K_SUBSET_PUK\020\t\022#\n\037PERSOSUBSTATE_SIM_CORP"
+ "ORATE_PUK\020\n\022*\n&PERSOSUBSTATE_SIM_SERVICE"
+ "_PROVIDER_PUK\020\013\022\035\n\031PERSOSUBSTATE_SIM_SIM"
+ "_PUK\020\014\022\037\n\033PERSOSUBSTATE_RUIM_NETWORK1\020\r\022"
+ "\037\n\033PERSOSUBSTATE_RUIM_NETWORK2\020\016\022\033\n\027PERS"
+ "OSUBSTATE_RUIM_HRPD\020\017\022 \n\034PERSOSUBSTATE_R"
+ "UIM_CORPORATE\020\020\022\'\n#PERSOSUBSTATE_RUIM_SE"
+ "RVICE_PROVIDER\020\021\022\033\n\027PERSOSUBSTATE_RUIM_R"
+ "UIM\020\022\022#\n\037PERSOSUBSTATE_RUIM_NETWORK1_PUK"
+ "\020\023\022#\n\037PERSOSUBSTATE_RUIM_NETWORK2_PUK\020\024\022"
+ "\037\n\033PERSOSUBSTATE_RUIM_HRPD_PUK\020\025\022$\n PERS"
+ "OSUBSTATE_RUIM_CORPORATE_PUK\020\026\022+\n\'PERSOS"
+ "UBSTATE_RUIM_SERVICE_PROVIDER_PUK\020\027\022\037\n\033P"
+ "ERSOSUBSTATE_RUIM_RUIM_PUK\020\030*\223\001\n\013RilAppS"
+ "tate\022\024\n\020APPSTATE_UNKNOWN\020\000\022\025\n\021APPSTATE_D"
+ "ETECTED\020\001\022\020\n\014APPSTATE_PIN\020\002\022\020\n\014APPSTATE_"
+ "PUK\020\003\022\037\n\033APPSTATE_SUBSCRIPTION_PERSO\020\004\022\022"
+ "\n\016APPSTATE_READY\020\005*\275\001\n\013RilPinState\022\024\n\020PI"
+ "NSTATE_UNKNOWN\020\000\022!\n\035PINSTATE_ENABLED_NOT"
+ "_VERIFIED\020\001\022\035\n\031PINSTATE_ENABLED_VERIFIED"
+ "\020\002\022\025\n\021PINSTATE_DISABLED\020\003\022\034\n\030PINSTATE_EN"
+ "ABLED_BLOCKED\020\004\022!\n\035PINSTATE_ENABLED_PERM"
+ "_BLOCKED\020\005*h\n\nRilAppType\022\023\n\017APPTYPE_UNKN"
+ "OWN\020\000\022\017\n\013APPTYPE_SIM\020\001\022\020\n\014APPTYPE_USIM\020\002"
+ "\022\020\n\014APPTYPE_RUIM\020\003\022\020\n\014APPTYPE_CSIM\020\004", 2636);
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+ "ril.proto", &protobuf_RegisterTypes);
+ RilAppStatus::default_instance_ = new RilAppStatus();
+ RilCardStatus::default_instance_ = new RilCardStatus();
+ ReqGetSimStatus::default_instance_ = new ReqGetSimStatus();
+ RspGetSimStatus::default_instance_ = new RspGetSimStatus();
+ ReqEnterSimPin::default_instance_ = new ReqEnterSimPin();
+ RspEnterSimPin::default_instance_ = new RspEnterSimPin();
+ ReqHangUp::default_instance_ = new ReqHangUp();
+ ReqScreenState::default_instance_ = new ReqScreenState();
+ RilAppStatus::default_instance_->InitAsDefaultInstance();
+ RilCardStatus::default_instance_->InitAsDefaultInstance();
+ ReqGetSimStatus::default_instance_->InitAsDefaultInstance();
+ RspGetSimStatus::default_instance_->InitAsDefaultInstance();
+ ReqEnterSimPin::default_instance_->InitAsDefaultInstance();
+ RspEnterSimPin::default_instance_->InitAsDefaultInstance();
+ ReqHangUp::default_instance_->InitAsDefaultInstance();
+ ReqScreenState::default_instance_->InitAsDefaultInstance();
+ ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_ril_2eproto);
+}
+
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_ril_2eproto {
+ StaticDescriptorInitializer_ril_2eproto() {
+ protobuf_AddDesc_ril_2eproto();
+ }
+} static_descriptor_initializer_ril_2eproto_;
+
+const ::google::protobuf::EnumDescriptor* RilCommand_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilCommand_descriptor_;
+}
+bool RilCommand_IsValid(int value) {
+ switch(value) {
+ case 1:
+ case 2:
+ case 12:
+ case 61:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* RadioState_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RadioState_descriptor_;
+}
+bool RadioState_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* RilCardState_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilCardState_descriptor_;
+}
+bool RilCardState_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* RilPersoSubstate_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilPersoSubstate_descriptor_;
+}
+bool RilPersoSubstate_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* RilAppState_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilAppState_descriptor_;
+}
+bool RilAppState_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* RilPinState_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilPinState_descriptor_;
+}
+bool RilPinState_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return true;
+ default:
+ return false;
+ }
+}
+
+const ::google::protobuf::EnumDescriptor* RilAppType_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilAppType_descriptor_;
+}
+bool RilAppType_IsValid(int value) {
+ switch(value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+// ===================================================================
+
+const ::std::string RilAppStatus::_default_aid_;
+const ::std::string RilAppStatus::_default_app_label_;
+#ifndef _MSC_VER
+const int RilAppStatus::kAppTypeFieldNumber;
+const int RilAppStatus::kAppStateFieldNumber;
+const int RilAppStatus::kPersoSubstateFieldNumber;
+const int RilAppStatus::kAidFieldNumber;
+const int RilAppStatus::kAppLabelFieldNumber;
+const int RilAppStatus::kPin1ReplacedFieldNumber;
+const int RilAppStatus::kPin1FieldNumber;
+const int RilAppStatus::kPin2FieldNumber;
+#endif // !_MSC_VER
+
+RilAppStatus::RilAppStatus()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void RilAppStatus::InitAsDefaultInstance() {
+}
+
+RilAppStatus::RilAppStatus(const RilAppStatus& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void RilAppStatus::SharedCtor() {
+ _cached_size_ = 0;
+ app_type_ = 0;
+ app_state_ = 0;
+ perso_substate_ = 0;
+ aid_ = const_cast< ::std::string*>(&_default_aid_);
+ app_label_ = const_cast< ::std::string*>(&_default_app_label_);
+ pin1_replaced_ = 0;
+ pin1_ = 0;
+ pin2_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+RilAppStatus::~RilAppStatus() {
+ SharedDtor();
+}
+
+void RilAppStatus::SharedDtor() {
+ if (aid_ != &_default_aid_) {
+ delete aid_;
+ }
+ if (app_label_ != &_default_app_label_) {
+ delete app_label_;
+ }
+ if (this != default_instance_) {
+ }
+}
+
+void RilAppStatus::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* RilAppStatus::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilAppStatus_descriptor_;
+}
+
+const RilAppStatus& RilAppStatus::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+RilAppStatus* RilAppStatus::default_instance_ = NULL;
+
+RilAppStatus* RilAppStatus::New() const {
+ return new RilAppStatus;
+}
+
+void RilAppStatus::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ app_type_ = 0;
+ app_state_ = 0;
+ perso_substate_ = 0;
+ if (_has_bit(3)) {
+ if (aid_ != &_default_aid_) {
+ aid_->clear();
+ }
+ }
+ if (_has_bit(4)) {
+ if (app_label_ != &_default_app_label_) {
+ app_label_->clear();
+ }
+ }
+ pin1_replaced_ = 0;
+ pin1_ = 0;
+ pin2_ = 0;
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool RilAppStatus::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)) {
+ // optional .ril_proto.RilAppType app_type = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilAppType_IsValid(value)) {
+ set_app_type(static_cast< ril_proto::RilAppType >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(16)) goto parse_app_state;
+ break;
+ }
+
+ // optional .ril_proto.RilAppState app_state = 2;
+ case 2: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_app_state:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilAppState_IsValid(value)) {
+ set_app_state(static_cast< ril_proto::RilAppState >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(2, value);
+ }
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(24)) goto parse_perso_substate;
+ break;
+ }
+
+ // optional .ril_proto.RilPersoSubstate perso_substate = 3;
+ case 3: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_perso_substate:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilPersoSubstate_IsValid(value)) {
+ set_perso_substate(static_cast< ril_proto::RilPersoSubstate >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(3, value);
+ }
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(34)) goto parse_aid;
+ break;
+ }
+
+ // optional string aid = 4;
+ case 4: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ parse_aid:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_aid()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->aid().data(), this->aid().length(),
+ ::google::protobuf::internal::WireFormat::PARSE);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(42)) goto parse_app_label;
+ break;
+ }
+
+ // optional string app_label = 5;
+ case 5: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ parse_app_label:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_app_label()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->app_label().data(), this->app_label().length(),
+ ::google::protobuf::internal::WireFormat::PARSE);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(48)) goto parse_pin1_replaced;
+ break;
+ }
+
+ // optional int32 pin1_replaced = 6;
+ case 6: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_pin1_replaced:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &pin1_replaced_)));
+ _set_bit(5);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(56)) goto parse_pin1;
+ break;
+ }
+
+ // optional .ril_proto.RilPinState pin1 = 7;
+ case 7: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_pin1:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilPinState_IsValid(value)) {
+ set_pin1(static_cast< ril_proto::RilPinState >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(7, value);
+ }
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(64)) goto parse_pin2;
+ break;
+ }
+
+ // optional .ril_proto.RilPinState pin2 = 8;
+ case 8: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_pin2:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilPinState_IsValid(value)) {
+ set_pin2(static_cast< ril_proto::RilPinState >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(8, value);
+ }
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void RilAppStatus::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // optional .ril_proto.RilAppType app_type = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->app_type(), output);
+ }
+
+ // optional .ril_proto.RilAppState app_state = 2;
+ if (_has_bit(1)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 2, this->app_state(), output);
+ }
+
+ // optional .ril_proto.RilPersoSubstate perso_substate = 3;
+ if (_has_bit(2)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 3, this->perso_substate(), output);
+ }
+
+ // optional string aid = 4;
+ if (_has_bit(3)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->aid().data(), this->aid().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 4, this->aid(), output);
+ }
+
+ // optional string app_label = 5;
+ if (_has_bit(4)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->app_label().data(), this->app_label().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 5, this->app_label(), output);
+ }
+
+ // optional int32 pin1_replaced = 6;
+ if (_has_bit(5)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->pin1_replaced(), output);
+ }
+
+ // optional .ril_proto.RilPinState pin1 = 7;
+ if (_has_bit(6)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 7, this->pin1(), output);
+ }
+
+ // optional .ril_proto.RilPinState pin2 = 8;
+ if (_has_bit(7)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 8, this->pin2(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* RilAppStatus::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // optional .ril_proto.RilAppType app_type = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->app_type(), target);
+ }
+
+ // optional .ril_proto.RilAppState app_state = 2;
+ if (_has_bit(1)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 2, this->app_state(), target);
+ }
+
+ // optional .ril_proto.RilPersoSubstate perso_substate = 3;
+ if (_has_bit(2)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 3, this->perso_substate(), target);
+ }
+
+ // optional string aid = 4;
+ if (_has_bit(3)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->aid().data(), this->aid().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 4, this->aid(), target);
+ }
+
+ // optional string app_label = 5;
+ if (_has_bit(4)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->app_label().data(), this->app_label().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 5, this->app_label(), target);
+ }
+
+ // optional int32 pin1_replaced = 6;
+ if (_has_bit(5)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(6, this->pin1_replaced(), target);
+ }
+
+ // optional .ril_proto.RilPinState pin1 = 7;
+ if (_has_bit(6)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 7, this->pin1(), target);
+ }
+
+ // optional .ril_proto.RilPinState pin2 = 8;
+ if (_has_bit(7)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 8, this->pin2(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int RilAppStatus::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // optional .ril_proto.RilAppType app_type = 1;
+ if (has_app_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->app_type());
+ }
+
+ // optional .ril_proto.RilAppState app_state = 2;
+ if (has_app_state()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->app_state());
+ }
+
+ // optional .ril_proto.RilPersoSubstate perso_substate = 3;
+ if (has_perso_substate()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->perso_substate());
+ }
+
+ // optional string aid = 4;
+ if (has_aid()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->aid());
+ }
+
+ // optional string app_label = 5;
+ if (has_app_label()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->app_label());
+ }
+
+ // optional int32 pin1_replaced = 6;
+ if (has_pin1_replaced()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->pin1_replaced());
+ }
+
+ // optional .ril_proto.RilPinState pin1 = 7;
+ if (has_pin1()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->pin1());
+ }
+
+ // optional .ril_proto.RilPinState pin2 = 8;
+ if (has_pin2()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->pin2());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void RilAppStatus::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const RilAppStatus* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const RilAppStatus*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void RilAppStatus::MergeFrom(const RilAppStatus& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_app_type(from.app_type());
+ }
+ if (from._has_bit(1)) {
+ set_app_state(from.app_state());
+ }
+ if (from._has_bit(2)) {
+ set_perso_substate(from.perso_substate());
+ }
+ if (from._has_bit(3)) {
+ set_aid(from.aid());
+ }
+ if (from._has_bit(4)) {
+ set_app_label(from.app_label());
+ }
+ if (from._has_bit(5)) {
+ set_pin1_replaced(from.pin1_replaced());
+ }
+ if (from._has_bit(6)) {
+ set_pin1(from.pin1());
+ }
+ if (from._has_bit(7)) {
+ set_pin2(from.pin2());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void RilAppStatus::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void RilAppStatus::CopyFrom(const RilAppStatus& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool RilAppStatus::IsInitialized() const {
+
+ return true;
+}
+
+void RilAppStatus::Swap(RilAppStatus* other) {
+ if (other != this) {
+ std::swap(app_type_, other->app_type_);
+ std::swap(app_state_, other->app_state_);
+ std::swap(perso_substate_, other->perso_substate_);
+ std::swap(aid_, other->aid_);
+ std::swap(app_label_, other->app_label_);
+ std::swap(pin1_replaced_, other->pin1_replaced_);
+ std::swap(pin1_, other->pin1_);
+ std::swap(pin2_, other->pin2_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata RilAppStatus::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = RilAppStatus_descriptor_;
+ metadata.reflection = RilAppStatus_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int RilCardStatus::kCardStateFieldNumber;
+const int RilCardStatus::kUniversalPinStateFieldNumber;
+const int RilCardStatus::kGsmUmtsSubscriptionAppIndexFieldNumber;
+const int RilCardStatus::kCdmaSubscriptionAppIndexFieldNumber;
+const int RilCardStatus::kNumApplicationsFieldNumber;
+const int RilCardStatus::kApplicationsFieldNumber;
+#endif // !_MSC_VER
+
+RilCardStatus::RilCardStatus()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void RilCardStatus::InitAsDefaultInstance() {
+}
+
+RilCardStatus::RilCardStatus(const RilCardStatus& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void RilCardStatus::SharedCtor() {
+ _cached_size_ = 0;
+ card_state_ = 0;
+ universal_pin_state_ = 0;
+ gsm_umts_subscription_app_index_ = 0;
+ cdma_subscription_app_index_ = 0;
+ num_applications_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+RilCardStatus::~RilCardStatus() {
+ SharedDtor();
+}
+
+void RilCardStatus::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+void RilCardStatus::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* RilCardStatus::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RilCardStatus_descriptor_;
+}
+
+const RilCardStatus& RilCardStatus::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+RilCardStatus* RilCardStatus::default_instance_ = NULL;
+
+RilCardStatus* RilCardStatus::New() const {
+ return new RilCardStatus;
+}
+
+void RilCardStatus::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ card_state_ = 0;
+ universal_pin_state_ = 0;
+ gsm_umts_subscription_app_index_ = 0;
+ cdma_subscription_app_index_ = 0;
+ num_applications_ = 0;
+ }
+ applications_.Clear();
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool RilCardStatus::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)) {
+ // optional .ril_proto.RilCardState card_state = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilCardState_IsValid(value)) {
+ set_card_state(static_cast< ril_proto::RilCardState >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(16)) goto parse_universal_pin_state;
+ break;
+ }
+
+ // optional .ril_proto.RilPinState universal_pin_state = 2;
+ case 2: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_universal_pin_state:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (ril_proto::RilPinState_IsValid(value)) {
+ set_universal_pin_state(static_cast< ril_proto::RilPinState >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(2, value);
+ }
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(24)) goto parse_gsm_umts_subscription_app_index;
+ break;
+ }
+
+ // optional int32 gsm_umts_subscription_app_index = 3;
+ case 3: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_gsm_umts_subscription_app_index:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &gsm_umts_subscription_app_index_)));
+ _set_bit(2);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(32)) goto parse_cdma_subscription_app_index;
+ break;
+ }
+
+ // optional int32 cdma_subscription_app_index = 4;
+ case 4: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_cdma_subscription_app_index:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &cdma_subscription_app_index_)));
+ _set_bit(3);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(40)) goto parse_num_applications;
+ break;
+ }
+
+ // optional int32 num_applications = 5;
+ case 5: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ parse_num_applications:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &num_applications_)));
+ _set_bit(4);
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(50)) goto parse_applications;
+ break;
+ }
+
+ // repeated .ril_proto.RilAppStatus applications = 6;
+ case 6: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ parse_applications:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, add_applications()));
+ } else {
+ goto handle_uninterpreted;
+ }
+ if (input->ExpectTag(50)) goto parse_applications;
+ 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void RilCardStatus::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // optional .ril_proto.RilCardState card_state = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->card_state(), output);
+ }
+
+ // optional .ril_proto.RilPinState universal_pin_state = 2;
+ if (_has_bit(1)) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 2, this->universal_pin_state(), output);
+ }
+
+ // optional int32 gsm_umts_subscription_app_index = 3;
+ if (_has_bit(2)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->gsm_umts_subscription_app_index(), output);
+ }
+
+ // optional int32 cdma_subscription_app_index = 4;
+ if (_has_bit(3)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->cdma_subscription_app_index(), output);
+ }
+
+ // optional int32 num_applications = 5;
+ if (_has_bit(4)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->num_applications(), output);
+ }
+
+ // repeated .ril_proto.RilAppStatus applications = 6;
+ for (int i = 0; i < this->applications_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 6, this->applications(i), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* RilCardStatus::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // optional .ril_proto.RilCardState card_state = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->card_state(), target);
+ }
+
+ // optional .ril_proto.RilPinState universal_pin_state = 2;
+ if (_has_bit(1)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 2, this->universal_pin_state(), target);
+ }
+
+ // optional int32 gsm_umts_subscription_app_index = 3;
+ if (_has_bit(2)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->gsm_umts_subscription_app_index(), target);
+ }
+
+ // optional int32 cdma_subscription_app_index = 4;
+ if (_has_bit(3)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->cdma_subscription_app_index(), target);
+ }
+
+ // optional int32 num_applications = 5;
+ if (_has_bit(4)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->num_applications(), target);
+ }
+
+ // repeated .ril_proto.RilAppStatus applications = 6;
+ for (int i = 0; i < this->applications_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteMessageNoVirtualToArray(
+ 6, this->applications(i), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int RilCardStatus::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // optional .ril_proto.RilCardState card_state = 1;
+ if (has_card_state()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->card_state());
+ }
+
+ // optional .ril_proto.RilPinState universal_pin_state = 2;
+ if (has_universal_pin_state()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->universal_pin_state());
+ }
+
+ // optional int32 gsm_umts_subscription_app_index = 3;
+ if (has_gsm_umts_subscription_app_index()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->gsm_umts_subscription_app_index());
+ }
+
+ // optional int32 cdma_subscription_app_index = 4;
+ if (has_cdma_subscription_app_index()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->cdma_subscription_app_index());
+ }
+
+ // optional int32 num_applications = 5;
+ if (has_num_applications()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->num_applications());
+ }
+
+ }
+ // repeated .ril_proto.RilAppStatus applications = 6;
+ total_size += 1 * this->applications_size();
+ for (int i = 0; i < this->applications_size(); i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->applications(i));
+ }
+
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void RilCardStatus::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const RilCardStatus* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const RilCardStatus*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void RilCardStatus::MergeFrom(const RilCardStatus& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ applications_.MergeFrom(from.applications_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_card_state(from.card_state());
+ }
+ if (from._has_bit(1)) {
+ set_universal_pin_state(from.universal_pin_state());
+ }
+ if (from._has_bit(2)) {
+ set_gsm_umts_subscription_app_index(from.gsm_umts_subscription_app_index());
+ }
+ if (from._has_bit(3)) {
+ set_cdma_subscription_app_index(from.cdma_subscription_app_index());
+ }
+ if (from._has_bit(4)) {
+ set_num_applications(from.num_applications());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void RilCardStatus::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void RilCardStatus::CopyFrom(const RilCardStatus& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool RilCardStatus::IsInitialized() const {
+
+ return true;
+}
+
+void RilCardStatus::Swap(RilCardStatus* other) {
+ if (other != this) {
+ std::swap(card_state_, other->card_state_);
+ std::swap(universal_pin_state_, other->universal_pin_state_);
+ std::swap(gsm_umts_subscription_app_index_, other->gsm_umts_subscription_app_index_);
+ std::swap(cdma_subscription_app_index_, other->cdma_subscription_app_index_);
+ std::swap(num_applications_, other->num_applications_);
+ applications_.Swap(&other->applications_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata RilCardStatus::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = RilCardStatus_descriptor_;
+ metadata.reflection = RilCardStatus_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+#endif // !_MSC_VER
+
+ReqGetSimStatus::ReqGetSimStatus()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void ReqGetSimStatus::InitAsDefaultInstance() {
+}
+
+ReqGetSimStatus::ReqGetSimStatus(const ReqGetSimStatus& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void ReqGetSimStatus::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+ReqGetSimStatus::~ReqGetSimStatus() {
+ SharedDtor();
+}
+
+void ReqGetSimStatus::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+void ReqGetSimStatus::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReqGetSimStatus::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReqGetSimStatus_descriptor_;
+}
+
+const ReqGetSimStatus& ReqGetSimStatus::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+ReqGetSimStatus* ReqGetSimStatus::default_instance_ = NULL;
+
+ReqGetSimStatus* ReqGetSimStatus::New() const {
+ return new ReqGetSimStatus;
+}
+
+void ReqGetSimStatus::Clear() {
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool ReqGetSimStatus::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
+ ::google::protobuf::uint32 tag;
+ while ((tag = input->ReadTag()) != 0) {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ return true;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ }
+ return true;
+#undef DO_
+}
+
+void ReqGetSimStatus::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* ReqGetSimStatus::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int ReqGetSimStatus::ByteSize() const {
+ int total_size = 0;
+
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReqGetSimStatus::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const ReqGetSimStatus* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const ReqGetSimStatus*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void ReqGetSimStatus::MergeFrom(const ReqGetSimStatus& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void ReqGetSimStatus::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReqGetSimStatus::CopyFrom(const ReqGetSimStatus& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool ReqGetSimStatus::IsInitialized() const {
+
+ return true;
+}
+
+void ReqGetSimStatus::Swap(ReqGetSimStatus* other) {
+ if (other != this) {
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata ReqGetSimStatus::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReqGetSimStatus_descriptor_;
+ metadata.reflection = ReqGetSimStatus_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int RspGetSimStatus::kCardStatusFieldNumber;
+#endif // !_MSC_VER
+
+RspGetSimStatus::RspGetSimStatus()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void RspGetSimStatus::InitAsDefaultInstance() {
+ card_status_ = const_cast< ::ril_proto::RilCardStatus*>(&::ril_proto::RilCardStatus::default_instance());
+}
+
+RspGetSimStatus::RspGetSimStatus(const RspGetSimStatus& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void RspGetSimStatus::SharedCtor() {
+ _cached_size_ = 0;
+ card_status_ = NULL;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+RspGetSimStatus::~RspGetSimStatus() {
+ SharedDtor();
+}
+
+void RspGetSimStatus::SharedDtor() {
+ if (this != default_instance_) {
+ delete card_status_;
+ }
+}
+
+void RspGetSimStatus::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* RspGetSimStatus::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RspGetSimStatus_descriptor_;
+}
+
+const RspGetSimStatus& RspGetSimStatus::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+RspGetSimStatus* RspGetSimStatus::default_instance_ = NULL;
+
+RspGetSimStatus* RspGetSimStatus::New() const {
+ return new RspGetSimStatus;
+}
+
+void RspGetSimStatus::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (_has_bit(0)) {
+ if (card_status_ != NULL) card_status_->::ril_proto::RilCardStatus::Clear();
+ }
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool RspGetSimStatus::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 .ril_proto.RilCardStatus card_status = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_card_status()));
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void RspGetSimStatus::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required .ril_proto.RilCardStatus card_status = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, this->card_status(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* RspGetSimStatus::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required .ril_proto.RilCardStatus card_status = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteMessageNoVirtualToArray(
+ 1, this->card_status(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int RspGetSimStatus::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required .ril_proto.RilCardStatus card_status = 1;
+ if (has_card_status()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->card_status());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void RspGetSimStatus::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const RspGetSimStatus* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const RspGetSimStatus*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void RspGetSimStatus::MergeFrom(const RspGetSimStatus& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ mutable_card_status()->::ril_proto::RilCardStatus::MergeFrom(from.card_status());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void RspGetSimStatus::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void RspGetSimStatus::CopyFrom(const RspGetSimStatus& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool RspGetSimStatus::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void RspGetSimStatus::Swap(RspGetSimStatus* other) {
+ if (other != this) {
+ std::swap(card_status_, other->card_status_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata RspGetSimStatus::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = RspGetSimStatus_descriptor_;
+ metadata.reflection = RspGetSimStatus_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+const ::std::string ReqEnterSimPin::_default_pin_;
+#ifndef _MSC_VER
+const int ReqEnterSimPin::kPinFieldNumber;
+#endif // !_MSC_VER
+
+ReqEnterSimPin::ReqEnterSimPin()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void ReqEnterSimPin::InitAsDefaultInstance() {
+}
+
+ReqEnterSimPin::ReqEnterSimPin(const ReqEnterSimPin& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void ReqEnterSimPin::SharedCtor() {
+ _cached_size_ = 0;
+ pin_ = const_cast< ::std::string*>(&_default_pin_);
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+ReqEnterSimPin::~ReqEnterSimPin() {
+ SharedDtor();
+}
+
+void ReqEnterSimPin::SharedDtor() {
+ if (pin_ != &_default_pin_) {
+ delete pin_;
+ }
+ if (this != default_instance_) {
+ }
+}
+
+void ReqEnterSimPin::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReqEnterSimPin::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReqEnterSimPin_descriptor_;
+}
+
+const ReqEnterSimPin& ReqEnterSimPin::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+ReqEnterSimPin* ReqEnterSimPin::default_instance_ = NULL;
+
+ReqEnterSimPin* ReqEnterSimPin::New() const {
+ return new ReqEnterSimPin;
+}
+
+void ReqEnterSimPin::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (_has_bit(0)) {
+ if (pin_ != &_default_pin_) {
+ pin_->clear();
+ }
+ }
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool ReqEnterSimPin::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 string pin = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_pin()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->pin().data(), this->pin().length(),
+ ::google::protobuf::internal::WireFormat::PARSE);
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void ReqEnterSimPin::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required string pin = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->pin().data(), this->pin().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 1, this->pin(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* ReqEnterSimPin::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required string pin = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->pin().data(), this->pin().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->pin(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int ReqEnterSimPin::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required string pin = 1;
+ if (has_pin()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->pin());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReqEnterSimPin::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const ReqEnterSimPin* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const ReqEnterSimPin*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void ReqEnterSimPin::MergeFrom(const ReqEnterSimPin& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_pin(from.pin());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void ReqEnterSimPin::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReqEnterSimPin::CopyFrom(const ReqEnterSimPin& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool ReqEnterSimPin::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void ReqEnterSimPin::Swap(ReqEnterSimPin* other) {
+ if (other != this) {
+ std::swap(pin_, other->pin_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata ReqEnterSimPin::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReqEnterSimPin_descriptor_;
+ metadata.reflection = ReqEnterSimPin_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int RspEnterSimPin::kRetriesRemainingFieldNumber;
+#endif // !_MSC_VER
+
+RspEnterSimPin::RspEnterSimPin()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void RspEnterSimPin::InitAsDefaultInstance() {
+}
+
+RspEnterSimPin::RspEnterSimPin(const RspEnterSimPin& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void RspEnterSimPin::SharedCtor() {
+ _cached_size_ = 0;
+ retries_remaining_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+RspEnterSimPin::~RspEnterSimPin() {
+ SharedDtor();
+}
+
+void RspEnterSimPin::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+void RspEnterSimPin::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* RspEnterSimPin::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RspEnterSimPin_descriptor_;
+}
+
+const RspEnterSimPin& RspEnterSimPin::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+RspEnterSimPin* RspEnterSimPin::default_instance_ = NULL;
+
+RspEnterSimPin* RspEnterSimPin::New() const {
+ return new RspEnterSimPin;
+}
+
+void RspEnterSimPin::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ retries_remaining_ = 0;
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool RspEnterSimPin::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 retries_remaining = 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, &retries_remaining_)));
+ _set_bit(0);
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void RspEnterSimPin::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required int32 retries_remaining = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->retries_remaining(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* RspEnterSimPin::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required int32 retries_remaining = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->retries_remaining(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int RspEnterSimPin::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required int32 retries_remaining = 1;
+ if (has_retries_remaining()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->retries_remaining());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void RspEnterSimPin::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const RspEnterSimPin* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const RspEnterSimPin*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void RspEnterSimPin::MergeFrom(const RspEnterSimPin& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_retries_remaining(from.retries_remaining());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void RspEnterSimPin::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void RspEnterSimPin::CopyFrom(const RspEnterSimPin& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool RspEnterSimPin::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void RspEnterSimPin::Swap(RspEnterSimPin* other) {
+ if (other != this) {
+ std::swap(retries_remaining_, other->retries_remaining_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata RspEnterSimPin::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = RspEnterSimPin_descriptor_;
+ metadata.reflection = RspEnterSimPin_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int ReqHangUp::kConnectionIndexFieldNumber;
+#endif // !_MSC_VER
+
+ReqHangUp::ReqHangUp()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void ReqHangUp::InitAsDefaultInstance() {
+}
+
+ReqHangUp::ReqHangUp(const ReqHangUp& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void ReqHangUp::SharedCtor() {
+ _cached_size_ = 0;
+ connection_index_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+ReqHangUp::~ReqHangUp() {
+ SharedDtor();
+}
+
+void ReqHangUp::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+void ReqHangUp::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReqHangUp::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReqHangUp_descriptor_;
+}
+
+const ReqHangUp& ReqHangUp::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+ReqHangUp* ReqHangUp::default_instance_ = NULL;
+
+ReqHangUp* ReqHangUp::New() const {
+ return new ReqHangUp;
+}
+
+void ReqHangUp::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ connection_index_ = 0;
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool ReqHangUp::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 connection_index = 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, &connection_index_)));
+ _set_bit(0);
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void ReqHangUp::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required int32 connection_index = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->connection_index(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* ReqHangUp::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required int32 connection_index = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->connection_index(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int ReqHangUp::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required int32 connection_index = 1;
+ if (has_connection_index()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->connection_index());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReqHangUp::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const ReqHangUp* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const ReqHangUp*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void ReqHangUp::MergeFrom(const ReqHangUp& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_connection_index(from.connection_index());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void ReqHangUp::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReqHangUp::CopyFrom(const ReqHangUp& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool ReqHangUp::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void ReqHangUp::Swap(ReqHangUp* other) {
+ if (other != this) {
+ std::swap(connection_index_, other->connection_index_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata ReqHangUp::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReqHangUp_descriptor_;
+ metadata.reflection = ReqHangUp_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int ReqScreenState::kStateFieldNumber;
+#endif // !_MSC_VER
+
+ReqScreenState::ReqScreenState()
+ : ::google::protobuf::Message() {
+ SharedCtor();
+}
+
+void ReqScreenState::InitAsDefaultInstance() {
+}
+
+ReqScreenState::ReqScreenState(const ReqScreenState& from)
+ : ::google::protobuf::Message() {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void ReqScreenState::SharedCtor() {
+ _cached_size_ = 0;
+ state_ = false;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+ReqScreenState::~ReqScreenState() {
+ SharedDtor();
+}
+
+void ReqScreenState::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+void ReqScreenState::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReqScreenState::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReqScreenState_descriptor_;
+}
+
+const ReqScreenState& ReqScreenState::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_ril_2eproto(); return *default_instance_;
+}
+
+ReqScreenState* ReqScreenState::default_instance_ = NULL;
+
+ReqScreenState* ReqScreenState::New() const {
+ return new ReqScreenState;
+}
+
+void ReqScreenState::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ state_ = false;
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool ReqScreenState::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 bool state = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &state_)));
+ _set_bit(0);
+ } 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::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+ return true;
+#undef DO_
+}
+
+void ReqScreenState::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // required bool state = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->state(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* ReqScreenState::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required bool state = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->state(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int ReqScreenState::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required bool state = 1;
+ if (has_state()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = total_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReqScreenState::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const ReqScreenState* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const ReqScreenState*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void ReqScreenState::MergeFrom(const ReqScreenState& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_state(from.state());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void ReqScreenState::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReqScreenState::CopyFrom(const ReqScreenState& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool ReqScreenState::IsInitialized() const {
+ if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+ return true;
+}
+
+void ReqScreenState::Swap(ReqScreenState* other) {
+ if (other != this) {
+ std::swap(state_, other->state_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _unknown_fields_.Swap(&other->_unknown_fields_);
+ std::swap(_cached_size_, other->_cached_size_);
+ }
+}
+
+::google::protobuf::Metadata ReqScreenState::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReqScreenState_descriptor_;
+ metadata.reflection = ReqScreenState_reflection_;
+ return metadata;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace ril_proto
+
+// @@protoc_insertion_point(global_scope)
diff --git a/mock-ril/ril.pb.h b/mock-ril/ril.pb.h
new file mode 100644
index 0000000..6340d52
--- /dev/null
+++ b/mock-ril/ril.pb.h
@@ -0,0 +1,1517 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: ril.proto
+
+#ifndef PROTOBUF_ril_2eproto__INCLUDED
+#define PROTOBUF_ril_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>
+#include <google/protobuf/generated_message_reflection.h>
+// @@protoc_insertion_point(includes)
+
+namespace ril_proto {
+
+// Internal implementation detail -- do not call these.
+void protobuf_AddDesc_ril_2eproto();
+void protobuf_AssignDesc_ril_2eproto();
+void protobuf_ShutdownFile_ril_2eproto();
+
+class RilAppStatus;
+class RilCardStatus;
+class ReqGetSimStatus;
+class RspGetSimStatus;
+class ReqEnterSimPin;
+class RspEnterSimPin;
+class ReqHangUp;
+class ReqScreenState;
+
+enum RilCommand {
+ CMD_GET_SIM_STATUS = 1,
+ CMD_ENTER_SIM_PIN = 2,
+ CMD_HANGUP = 12,
+ CMD_SCREEN_STATE = 61
+};
+bool RilCommand_IsValid(int value);
+const RilCommand RilCommand_MIN = CMD_GET_SIM_STATUS;
+const RilCommand RilCommand_MAX = CMD_SCREEN_STATE;
+const int RilCommand_ARRAYSIZE = RilCommand_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RilCommand_descriptor();
+inline const ::std::string& RilCommand_Name(RilCommand value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RilCommand_descriptor(), value);
+}
+inline bool RilCommand_Parse(
+ const ::std::string& name, RilCommand* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RilCommand>(
+ RilCommand_descriptor(), name, value);
+}
+enum RadioState {
+ RADIO_STATE_OFF = 0,
+ RADIO_STATE_UNAVAILABLE = 1,
+ RADIO_STATE_SIM_NOT_READY = 2,
+ RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3,
+ RADIO_STATE_SIM_READY = 4,
+ RADIO_STATE_RUIM_NOT_READY = 5,
+ RADIO_STATE_RUIM_READY = 6,
+ RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7,
+ RADIO_STATE_NV_NOT_READY = 8,
+ RADIO_STATE_NV_READY = 9
+};
+bool RadioState_IsValid(int value);
+const RadioState RadioState_MIN = RADIO_STATE_OFF;
+const RadioState RadioState_MAX = RADIO_STATE_NV_READY;
+const int RadioState_ARRAYSIZE = RadioState_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RadioState_descriptor();
+inline const ::std::string& RadioState_Name(RadioState value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RadioState_descriptor(), value);
+}
+inline bool RadioState_Parse(
+ const ::std::string& name, RadioState* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RadioState>(
+ RadioState_descriptor(), name, value);
+}
+enum RilCardState {
+ CARDSTATE_ABSENT = 0,
+ CARDSTATE_PRESENT = 1,
+ CARDSTATE_ERROR = 2
+};
+bool RilCardState_IsValid(int value);
+const RilCardState RilCardState_MIN = CARDSTATE_ABSENT;
+const RilCardState RilCardState_MAX = CARDSTATE_ERROR;
+const int RilCardState_ARRAYSIZE = RilCardState_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RilCardState_descriptor();
+inline const ::std::string& RilCardState_Name(RilCardState value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RilCardState_descriptor(), value);
+}
+inline bool RilCardState_Parse(
+ const ::std::string& name, RilCardState* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RilCardState>(
+ RilCardState_descriptor(), name, value);
+}
+enum RilPersoSubstate {
+ PERSOSUBSTATE_UNKNOWN = 0,
+ PERSOSUBSTATE_IN_PROGRESS = 1,
+ PERSOSUBSTATE_READY = 2,
+ PERSOSUBSTATE_SIM_NETWORK = 3,
+ PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4,
+ PERSOSUBSTATE_SIM_CORPORATE = 5,
+ PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6,
+ PERSOSUBSTATE_SIM_SIM = 7,
+ PERSOSUBSTATE_SIM_NETWORK_PUK = 8,
+ PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9,
+ PERSOSUBSTATE_SIM_CORPORATE_PUK = 10,
+ PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11,
+ PERSOSUBSTATE_SIM_SIM_PUK = 12,
+ PERSOSUBSTATE_RUIM_NETWORK1 = 13,
+ PERSOSUBSTATE_RUIM_NETWORK2 = 14,
+ PERSOSUBSTATE_RUIM_HRPD = 15,
+ PERSOSUBSTATE_RUIM_CORPORATE = 16,
+ PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17,
+ PERSOSUBSTATE_RUIM_RUIM = 18,
+ PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19,
+ PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20,
+ PERSOSUBSTATE_RUIM_HRPD_PUK = 21,
+ PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22,
+ PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,
+ PERSOSUBSTATE_RUIM_RUIM_PUK = 24
+};
+bool RilPersoSubstate_IsValid(int value);
+const RilPersoSubstate RilPersoSubstate_MIN = PERSOSUBSTATE_UNKNOWN;
+const RilPersoSubstate RilPersoSubstate_MAX = PERSOSUBSTATE_RUIM_RUIM_PUK;
+const int RilPersoSubstate_ARRAYSIZE = RilPersoSubstate_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RilPersoSubstate_descriptor();
+inline const ::std::string& RilPersoSubstate_Name(RilPersoSubstate value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RilPersoSubstate_descriptor(), value);
+}
+inline bool RilPersoSubstate_Parse(
+ const ::std::string& name, RilPersoSubstate* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RilPersoSubstate>(
+ RilPersoSubstate_descriptor(), name, value);
+}
+enum RilAppState {
+ APPSTATE_UNKNOWN = 0,
+ APPSTATE_DETECTED = 1,
+ APPSTATE_PIN = 2,
+ APPSTATE_PUK = 3,
+ APPSTATE_SUBSCRIPTION_PERSO = 4,
+ APPSTATE_READY = 5
+};
+bool RilAppState_IsValid(int value);
+const RilAppState RilAppState_MIN = APPSTATE_UNKNOWN;
+const RilAppState RilAppState_MAX = APPSTATE_READY;
+const int RilAppState_ARRAYSIZE = RilAppState_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RilAppState_descriptor();
+inline const ::std::string& RilAppState_Name(RilAppState value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RilAppState_descriptor(), value);
+}
+inline bool RilAppState_Parse(
+ const ::std::string& name, RilAppState* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RilAppState>(
+ RilAppState_descriptor(), name, value);
+}
+enum RilPinState {
+ PINSTATE_UNKNOWN = 0,
+ PINSTATE_ENABLED_NOT_VERIFIED = 1,
+ PINSTATE_ENABLED_VERIFIED = 2,
+ PINSTATE_DISABLED = 3,
+ PINSTATE_ENABLED_BLOCKED = 4,
+ PINSTATE_ENABLED_PERM_BLOCKED = 5
+};
+bool RilPinState_IsValid(int value);
+const RilPinState RilPinState_MIN = PINSTATE_UNKNOWN;
+const RilPinState RilPinState_MAX = PINSTATE_ENABLED_PERM_BLOCKED;
+const int RilPinState_ARRAYSIZE = RilPinState_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RilPinState_descriptor();
+inline const ::std::string& RilPinState_Name(RilPinState value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RilPinState_descriptor(), value);
+}
+inline bool RilPinState_Parse(
+ const ::std::string& name, RilPinState* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RilPinState>(
+ RilPinState_descriptor(), name, value);
+}
+enum RilAppType {
+ APPTYPE_UNKNOWN = 0,
+ APPTYPE_SIM = 1,
+ APPTYPE_USIM = 2,
+ APPTYPE_RUIM = 3,
+ APPTYPE_CSIM = 4
+};
+bool RilAppType_IsValid(int value);
+const RilAppType RilAppType_MIN = APPTYPE_UNKNOWN;
+const RilAppType RilAppType_MAX = APPTYPE_CSIM;
+const int RilAppType_ARRAYSIZE = RilAppType_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* RilAppType_descriptor();
+inline const ::std::string& RilAppType_Name(RilAppType value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ RilAppType_descriptor(), value);
+}
+inline bool RilAppType_Parse(
+ const ::std::string& name, RilAppType* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<RilAppType>(
+ RilAppType_descriptor(), name, value);
+}
+// ===================================================================
+
+class RilAppStatus : public ::google::protobuf::Message {
+ public:
+ RilAppStatus();
+ virtual ~RilAppStatus();
+
+ RilAppStatus(const RilAppStatus& from);
+
+ inline RilAppStatus& operator=(const RilAppStatus& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const RilAppStatus& default_instance();
+
+ void Swap(RilAppStatus* other);
+
+ // implements Message ----------------------------------------------
+
+ RilAppStatus* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const RilAppStatus& from);
+ void MergeFrom(const RilAppStatus& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .ril_proto.RilAppType app_type = 1;
+ inline bool has_app_type() const;
+ inline void clear_app_type();
+ static const int kAppTypeFieldNumber = 1;
+ inline ril_proto::RilAppType app_type() const;
+ inline void set_app_type(ril_proto::RilAppType value);
+
+ // optional .ril_proto.RilAppState app_state = 2;
+ inline bool has_app_state() const;
+ inline void clear_app_state();
+ static const int kAppStateFieldNumber = 2;
+ inline ril_proto::RilAppState app_state() const;
+ inline void set_app_state(ril_proto::RilAppState value);
+
+ // optional .ril_proto.RilPersoSubstate perso_substate = 3;
+ inline bool has_perso_substate() const;
+ inline void clear_perso_substate();
+ static const int kPersoSubstateFieldNumber = 3;
+ inline ril_proto::RilPersoSubstate perso_substate() const;
+ inline void set_perso_substate(ril_proto::RilPersoSubstate value);
+
+ // optional string aid = 4;
+ inline bool has_aid() const;
+ inline void clear_aid();
+ static const int kAidFieldNumber = 4;
+ inline const ::std::string& aid() const;
+ inline void set_aid(const ::std::string& value);
+ inline void set_aid(const char* value);
+ inline void set_aid(const char* value, size_t size);
+ inline ::std::string* mutable_aid();
+
+ // optional string app_label = 5;
+ inline bool has_app_label() const;
+ inline void clear_app_label();
+ static const int kAppLabelFieldNumber = 5;
+ inline const ::std::string& app_label() const;
+ inline void set_app_label(const ::std::string& value);
+ inline void set_app_label(const char* value);
+ inline void set_app_label(const char* value, size_t size);
+ inline ::std::string* mutable_app_label();
+
+ // optional int32 pin1_replaced = 6;
+ inline bool has_pin1_replaced() const;
+ inline void clear_pin1_replaced();
+ static const int kPin1ReplacedFieldNumber = 6;
+ inline ::google::protobuf::int32 pin1_replaced() const;
+ inline void set_pin1_replaced(::google::protobuf::int32 value);
+
+ // optional .ril_proto.RilPinState pin1 = 7;
+ inline bool has_pin1() const;
+ inline void clear_pin1();
+ static const int kPin1FieldNumber = 7;
+ inline ril_proto::RilPinState pin1() const;
+ inline void set_pin1(ril_proto::RilPinState value);
+
+ // optional .ril_proto.RilPinState pin2 = 8;
+ inline bool has_pin2() const;
+ inline void clear_pin2();
+ static const int kPin2FieldNumber = 8;
+ inline ril_proto::RilPinState pin2() const;
+ inline void set_pin2(ril_proto::RilPinState value);
+
+ // @@protoc_insertion_point(class_scope:ril_proto.RilAppStatus)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ int app_type_;
+ int app_state_;
+ int perso_substate_;
+ ::std::string* aid_;
+ static const ::std::string _default_aid_;
+ ::std::string* app_label_;
+ static const ::std::string _default_app_label_;
+ ::google::protobuf::int32 pin1_replaced_;
+ int pin1_;
+ int pin2_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(8 + 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 RilAppStatus* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class RilCardStatus : public ::google::protobuf::Message {
+ public:
+ RilCardStatus();
+ virtual ~RilCardStatus();
+
+ RilCardStatus(const RilCardStatus& from);
+
+ inline RilCardStatus& operator=(const RilCardStatus& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const RilCardStatus& default_instance();
+
+ void Swap(RilCardStatus* other);
+
+ // implements Message ----------------------------------------------
+
+ RilCardStatus* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const RilCardStatus& from);
+ void MergeFrom(const RilCardStatus& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .ril_proto.RilCardState card_state = 1;
+ inline bool has_card_state() const;
+ inline void clear_card_state();
+ static const int kCardStateFieldNumber = 1;
+ inline ril_proto::RilCardState card_state() const;
+ inline void set_card_state(ril_proto::RilCardState value);
+
+ // optional .ril_proto.RilPinState universal_pin_state = 2;
+ inline bool has_universal_pin_state() const;
+ inline void clear_universal_pin_state();
+ static const int kUniversalPinStateFieldNumber = 2;
+ inline ril_proto::RilPinState universal_pin_state() const;
+ inline void set_universal_pin_state(ril_proto::RilPinState value);
+
+ // optional int32 gsm_umts_subscription_app_index = 3;
+ inline bool has_gsm_umts_subscription_app_index() const;
+ inline void clear_gsm_umts_subscription_app_index();
+ static const int kGsmUmtsSubscriptionAppIndexFieldNumber = 3;
+ inline ::google::protobuf::int32 gsm_umts_subscription_app_index() const;
+ inline void set_gsm_umts_subscription_app_index(::google::protobuf::int32 value);
+
+ // optional int32 cdma_subscription_app_index = 4;
+ inline bool has_cdma_subscription_app_index() const;
+ inline void clear_cdma_subscription_app_index();
+ static const int kCdmaSubscriptionAppIndexFieldNumber = 4;
+ inline ::google::protobuf::int32 cdma_subscription_app_index() const;
+ inline void set_cdma_subscription_app_index(::google::protobuf::int32 value);
+
+ // optional int32 num_applications = 5;
+ inline bool has_num_applications() const;
+ inline void clear_num_applications();
+ static const int kNumApplicationsFieldNumber = 5;
+ inline ::google::protobuf::int32 num_applications() const;
+ inline void set_num_applications(::google::protobuf::int32 value);
+
+ // repeated .ril_proto.RilAppStatus applications = 6;
+ inline int applications_size() const;
+ inline void clear_applications();
+ static const int kApplicationsFieldNumber = 6;
+ inline const ::ril_proto::RilAppStatus& applications(int index) const;
+ inline ::ril_proto::RilAppStatus* mutable_applications(int index);
+ inline ::ril_proto::RilAppStatus* add_applications();
+ inline const ::google::protobuf::RepeatedPtrField< ::ril_proto::RilAppStatus >&
+ applications() const;
+ inline ::google::protobuf::RepeatedPtrField< ::ril_proto::RilAppStatus >*
+ mutable_applications();
+
+ // @@protoc_insertion_point(class_scope:ril_proto.RilCardStatus)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ int card_state_;
+ int universal_pin_state_;
+ ::google::protobuf::int32 gsm_umts_subscription_app_index_;
+ ::google::protobuf::int32 cdma_subscription_app_index_;
+ ::google::protobuf::int32 num_applications_;
+ ::google::protobuf::RepeatedPtrField< ::ril_proto::RilAppStatus > applications_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(6 + 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 RilCardStatus* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class ReqGetSimStatus : public ::google::protobuf::Message {
+ public:
+ ReqGetSimStatus();
+ virtual ~ReqGetSimStatus();
+
+ ReqGetSimStatus(const ReqGetSimStatus& from);
+
+ inline ReqGetSimStatus& operator=(const ReqGetSimStatus& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReqGetSimStatus& default_instance();
+
+ void Swap(ReqGetSimStatus* other);
+
+ // implements Message ----------------------------------------------
+
+ ReqGetSimStatus* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReqGetSimStatus& from);
+ void MergeFrom(const ReqGetSimStatus& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // @@protoc_insertion_point(class_scope:ril_proto.ReqGetSimStatus)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[1];
+
+ // 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 ReqGetSimStatus* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class RspGetSimStatus : public ::google::protobuf::Message {
+ public:
+ RspGetSimStatus();
+ virtual ~RspGetSimStatus();
+
+ RspGetSimStatus(const RspGetSimStatus& from);
+
+ inline RspGetSimStatus& operator=(const RspGetSimStatus& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const RspGetSimStatus& default_instance();
+
+ void Swap(RspGetSimStatus* other);
+
+ // implements Message ----------------------------------------------
+
+ RspGetSimStatus* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const RspGetSimStatus& from);
+ void MergeFrom(const RspGetSimStatus& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required .ril_proto.RilCardStatus card_status = 1;
+ inline bool has_card_status() const;
+ inline void clear_card_status();
+ static const int kCardStatusFieldNumber = 1;
+ inline const ::ril_proto::RilCardStatus& card_status() const;
+ inline ::ril_proto::RilCardStatus* mutable_card_status();
+
+ // @@protoc_insertion_point(class_scope:ril_proto.RspGetSimStatus)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ ::ril_proto::RilCardStatus* card_status_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 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 RspGetSimStatus* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class ReqEnterSimPin : public ::google::protobuf::Message {
+ public:
+ ReqEnterSimPin();
+ virtual ~ReqEnterSimPin();
+
+ ReqEnterSimPin(const ReqEnterSimPin& from);
+
+ inline ReqEnterSimPin& operator=(const ReqEnterSimPin& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReqEnterSimPin& default_instance();
+
+ void Swap(ReqEnterSimPin* other);
+
+ // implements Message ----------------------------------------------
+
+ ReqEnterSimPin* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReqEnterSimPin& from);
+ void MergeFrom(const ReqEnterSimPin& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required string pin = 1;
+ inline bool has_pin() const;
+ inline void clear_pin();
+ static const int kPinFieldNumber = 1;
+ inline const ::std::string& pin() const;
+ inline void set_pin(const ::std::string& value);
+ inline void set_pin(const char* value);
+ inline void set_pin(const char* value, size_t size);
+ inline ::std::string* mutable_pin();
+
+ // @@protoc_insertion_point(class_scope:ril_proto.ReqEnterSimPin)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ ::std::string* pin_;
+ static const ::std::string _default_pin_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 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 ReqEnterSimPin* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class RspEnterSimPin : public ::google::protobuf::Message {
+ public:
+ RspEnterSimPin();
+ virtual ~RspEnterSimPin();
+
+ RspEnterSimPin(const RspEnterSimPin& from);
+
+ inline RspEnterSimPin& operator=(const RspEnterSimPin& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const RspEnterSimPin& default_instance();
+
+ void Swap(RspEnterSimPin* other);
+
+ // implements Message ----------------------------------------------
+
+ RspEnterSimPin* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const RspEnterSimPin& from);
+ void MergeFrom(const RspEnterSimPin& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required int32 retries_remaining = 1;
+ inline bool has_retries_remaining() const;
+ inline void clear_retries_remaining();
+ static const int kRetriesRemainingFieldNumber = 1;
+ inline ::google::protobuf::int32 retries_remaining() const;
+ inline void set_retries_remaining(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:ril_proto.RspEnterSimPin)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ ::google::protobuf::int32 retries_remaining_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 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 RspEnterSimPin* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class ReqHangUp : public ::google::protobuf::Message {
+ public:
+ ReqHangUp();
+ virtual ~ReqHangUp();
+
+ ReqHangUp(const ReqHangUp& from);
+
+ inline ReqHangUp& operator=(const ReqHangUp& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReqHangUp& default_instance();
+
+ void Swap(ReqHangUp* other);
+
+ // implements Message ----------------------------------------------
+
+ ReqHangUp* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReqHangUp& from);
+ void MergeFrom(const ReqHangUp& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required int32 connection_index = 1;
+ inline bool has_connection_index() const;
+ inline void clear_connection_index();
+ static const int kConnectionIndexFieldNumber = 1;
+ inline ::google::protobuf::int32 connection_index() const;
+ inline void set_connection_index(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:ril_proto.ReqHangUp)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ ::google::protobuf::int32 connection_index_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 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 ReqHangUp* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class ReqScreenState : public ::google::protobuf::Message {
+ public:
+ ReqScreenState();
+ virtual ~ReqScreenState();
+
+ ReqScreenState(const ReqScreenState& from);
+
+ inline ReqScreenState& operator=(const ReqScreenState& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _unknown_fields_;
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return &_unknown_fields_;
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReqScreenState& default_instance();
+
+ void Swap(ReqScreenState* other);
+
+ // implements Message ----------------------------------------------
+
+ ReqScreenState* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReqScreenState& from);
+ void MergeFrom(const ReqScreenState& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ int ByteSize() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required bool state = 1;
+ inline bool has_state() const;
+ inline void clear_state();
+ static const int kStateFieldNumber = 1;
+ inline bool state() const;
+ inline void set_state(bool value);
+
+ // @@protoc_insertion_point(class_scope:ril_proto.ReqScreenState)
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ bool state_;
+ friend void protobuf_AddDesc_ril_2eproto();
+ friend void protobuf_AssignDesc_ril_2eproto();
+ friend void protobuf_ShutdownFile_ril_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 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 ReqScreenState* default_instance_;
+};
+// ===================================================================
+
+
+// ===================================================================
+
+// RilAppStatus
+
+// optional .ril_proto.RilAppType app_type = 1;
+inline bool RilAppStatus::has_app_type() const {
+ return _has_bit(0);
+}
+inline void RilAppStatus::clear_app_type() {
+ app_type_ = 0;
+ _clear_bit(0);
+}
+inline ril_proto::RilAppType RilAppStatus::app_type() const {
+ return static_cast< ril_proto::RilAppType >(app_type_);
+}
+inline void RilAppStatus::set_app_type(ril_proto::RilAppType value) {
+ GOOGLE_DCHECK(ril_proto::RilAppType_IsValid(value));
+ _set_bit(0);
+ app_type_ = value;
+}
+
+// optional .ril_proto.RilAppState app_state = 2;
+inline bool RilAppStatus::has_app_state() const {
+ return _has_bit(1);
+}
+inline void RilAppStatus::clear_app_state() {
+ app_state_ = 0;
+ _clear_bit(1);
+}
+inline ril_proto::RilAppState RilAppStatus::app_state() const {
+ return static_cast< ril_proto::RilAppState >(app_state_);
+}
+inline void RilAppStatus::set_app_state(ril_proto::RilAppState value) {
+ GOOGLE_DCHECK(ril_proto::RilAppState_IsValid(value));
+ _set_bit(1);
+ app_state_ = value;
+}
+
+// optional .ril_proto.RilPersoSubstate perso_substate = 3;
+inline bool RilAppStatus::has_perso_substate() const {
+ return _has_bit(2);
+}
+inline void RilAppStatus::clear_perso_substate() {
+ perso_substate_ = 0;
+ _clear_bit(2);
+}
+inline ril_proto::RilPersoSubstate RilAppStatus::perso_substate() const {
+ return static_cast< ril_proto::RilPersoSubstate >(perso_substate_);
+}
+inline void RilAppStatus::set_perso_substate(ril_proto::RilPersoSubstate value) {
+ GOOGLE_DCHECK(ril_proto::RilPersoSubstate_IsValid(value));
+ _set_bit(2);
+ perso_substate_ = value;
+}
+
+// optional string aid = 4;
+inline bool RilAppStatus::has_aid() const {
+ return _has_bit(3);
+}
+inline void RilAppStatus::clear_aid() {
+ if (aid_ != &_default_aid_) {
+ aid_->clear();
+ }
+ _clear_bit(3);
+}
+inline const ::std::string& RilAppStatus::aid() const {
+ return *aid_;
+}
+inline void RilAppStatus::set_aid(const ::std::string& value) {
+ _set_bit(3);
+ if (aid_ == &_default_aid_) {
+ aid_ = new ::std::string;
+ }
+ aid_->assign(value);
+}
+inline void RilAppStatus::set_aid(const char* value) {
+ _set_bit(3);
+ if (aid_ == &_default_aid_) {
+ aid_ = new ::std::string;
+ }
+ aid_->assign(value);
+}
+inline void RilAppStatus::set_aid(const char* value, size_t size) {
+ _set_bit(3);
+ if (aid_ == &_default_aid_) {
+ aid_ = new ::std::string;
+ }
+ aid_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* RilAppStatus::mutable_aid() {
+ _set_bit(3);
+ if (aid_ == &_default_aid_) {
+ aid_ = new ::std::string;
+ }
+ return aid_;
+}
+
+// optional string app_label = 5;
+inline bool RilAppStatus::has_app_label() const {
+ return _has_bit(4);
+}
+inline void RilAppStatus::clear_app_label() {
+ if (app_label_ != &_default_app_label_) {
+ app_label_->clear();
+ }
+ _clear_bit(4);
+}
+inline const ::std::string& RilAppStatus::app_label() const {
+ return *app_label_;
+}
+inline void RilAppStatus::set_app_label(const ::std::string& value) {
+ _set_bit(4);
+ if (app_label_ == &_default_app_label_) {
+ app_label_ = new ::std::string;
+ }
+ app_label_->assign(value);
+}
+inline void RilAppStatus::set_app_label(const char* value) {
+ _set_bit(4);
+ if (app_label_ == &_default_app_label_) {
+ app_label_ = new ::std::string;
+ }
+ app_label_->assign(value);
+}
+inline void RilAppStatus::set_app_label(const char* value, size_t size) {
+ _set_bit(4);
+ if (app_label_ == &_default_app_label_) {
+ app_label_ = new ::std::string;
+ }
+ app_label_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* RilAppStatus::mutable_app_label() {
+ _set_bit(4);
+ if (app_label_ == &_default_app_label_) {
+ app_label_ = new ::std::string;
+ }
+ return app_label_;
+}
+
+// optional int32 pin1_replaced = 6;
+inline bool RilAppStatus::has_pin1_replaced() const {
+ return _has_bit(5);
+}
+inline void RilAppStatus::clear_pin1_replaced() {
+ pin1_replaced_ = 0;
+ _clear_bit(5);
+}
+inline ::google::protobuf::int32 RilAppStatus::pin1_replaced() const {
+ return pin1_replaced_;
+}
+inline void RilAppStatus::set_pin1_replaced(::google::protobuf::int32 value) {
+ _set_bit(5);
+ pin1_replaced_ = value;
+}
+
+// optional .ril_proto.RilPinState pin1 = 7;
+inline bool RilAppStatus::has_pin1() const {
+ return _has_bit(6);
+}
+inline void RilAppStatus::clear_pin1() {
+ pin1_ = 0;
+ _clear_bit(6);
+}
+inline ril_proto::RilPinState RilAppStatus::pin1() const {
+ return static_cast< ril_proto::RilPinState >(pin1_);
+}
+inline void RilAppStatus::set_pin1(ril_proto::RilPinState value) {
+ GOOGLE_DCHECK(ril_proto::RilPinState_IsValid(value));
+ _set_bit(6);
+ pin1_ = value;
+}
+
+// optional .ril_proto.RilPinState pin2 = 8;
+inline bool RilAppStatus::has_pin2() const {
+ return _has_bit(7);
+}
+inline void RilAppStatus::clear_pin2() {
+ pin2_ = 0;
+ _clear_bit(7);
+}
+inline ril_proto::RilPinState RilAppStatus::pin2() const {
+ return static_cast< ril_proto::RilPinState >(pin2_);
+}
+inline void RilAppStatus::set_pin2(ril_proto::RilPinState value) {
+ GOOGLE_DCHECK(ril_proto::RilPinState_IsValid(value));
+ _set_bit(7);
+ pin2_ = value;
+}
+
+// -------------------------------------------------------------------
+
+// RilCardStatus
+
+// optional .ril_proto.RilCardState card_state = 1;
+inline bool RilCardStatus::has_card_state() const {
+ return _has_bit(0);
+}
+inline void RilCardStatus::clear_card_state() {
+ card_state_ = 0;
+ _clear_bit(0);
+}
+inline ril_proto::RilCardState RilCardStatus::card_state() const {
+ return static_cast< ril_proto::RilCardState >(card_state_);
+}
+inline void RilCardStatus::set_card_state(ril_proto::RilCardState value) {
+ GOOGLE_DCHECK(ril_proto::RilCardState_IsValid(value));
+ _set_bit(0);
+ card_state_ = value;
+}
+
+// optional .ril_proto.RilPinState universal_pin_state = 2;
+inline bool RilCardStatus::has_universal_pin_state() const {
+ return _has_bit(1);
+}
+inline void RilCardStatus::clear_universal_pin_state() {
+ universal_pin_state_ = 0;
+ _clear_bit(1);
+}
+inline ril_proto::RilPinState RilCardStatus::universal_pin_state() const {
+ return static_cast< ril_proto::RilPinState >(universal_pin_state_);
+}
+inline void RilCardStatus::set_universal_pin_state(ril_proto::RilPinState value) {
+ GOOGLE_DCHECK(ril_proto::RilPinState_IsValid(value));
+ _set_bit(1);
+ universal_pin_state_ = value;
+}
+
+// optional int32 gsm_umts_subscription_app_index = 3;
+inline bool RilCardStatus::has_gsm_umts_subscription_app_index() const {
+ return _has_bit(2);
+}
+inline void RilCardStatus::clear_gsm_umts_subscription_app_index() {
+ gsm_umts_subscription_app_index_ = 0;
+ _clear_bit(2);
+}
+inline ::google::protobuf::int32 RilCardStatus::gsm_umts_subscription_app_index() const {
+ return gsm_umts_subscription_app_index_;
+}
+inline void RilCardStatus::set_gsm_umts_subscription_app_index(::google::protobuf::int32 value) {
+ _set_bit(2);
+ gsm_umts_subscription_app_index_ = value;
+}
+
+// optional int32 cdma_subscription_app_index = 4;
+inline bool RilCardStatus::has_cdma_subscription_app_index() const {
+ return _has_bit(3);
+}
+inline void RilCardStatus::clear_cdma_subscription_app_index() {
+ cdma_subscription_app_index_ = 0;
+ _clear_bit(3);
+}
+inline ::google::protobuf::int32 RilCardStatus::cdma_subscription_app_index() const {
+ return cdma_subscription_app_index_;
+}
+inline void RilCardStatus::set_cdma_subscription_app_index(::google::protobuf::int32 value) {
+ _set_bit(3);
+ cdma_subscription_app_index_ = value;
+}
+
+// optional int32 num_applications = 5;
+inline bool RilCardStatus::has_num_applications() const {
+ return _has_bit(4);
+}
+inline void RilCardStatus::clear_num_applications() {
+ num_applications_ = 0;
+ _clear_bit(4);
+}
+inline ::google::protobuf::int32 RilCardStatus::num_applications() const {
+ return num_applications_;
+}
+inline void RilCardStatus::set_num_applications(::google::protobuf::int32 value) {
+ _set_bit(4);
+ num_applications_ = value;
+}
+
+// repeated .ril_proto.RilAppStatus applications = 6;
+inline int RilCardStatus::applications_size() const {
+ return applications_.size();
+}
+inline void RilCardStatus::clear_applications() {
+ applications_.Clear();
+}
+inline const ::ril_proto::RilAppStatus& RilCardStatus::applications(int index) const {
+ return applications_.Get(index);
+}
+inline ::ril_proto::RilAppStatus* RilCardStatus::mutable_applications(int index) {
+ return applications_.Mutable(index);
+}
+inline ::ril_proto::RilAppStatus* RilCardStatus::add_applications() {
+ return applications_.Add();
+}
+inline const ::google::protobuf::RepeatedPtrField< ::ril_proto::RilAppStatus >&
+RilCardStatus::applications() const {
+ return applications_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::ril_proto::RilAppStatus >*
+RilCardStatus::mutable_applications() {
+ return &applications_;
+}
+
+// -------------------------------------------------------------------
+
+// ReqGetSimStatus
+
+// -------------------------------------------------------------------
+
+// RspGetSimStatus
+
+// required .ril_proto.RilCardStatus card_status = 1;
+inline bool RspGetSimStatus::has_card_status() const {
+ return _has_bit(0);
+}
+inline void RspGetSimStatus::clear_card_status() {
+ if (card_status_ != NULL) card_status_->::ril_proto::RilCardStatus::Clear();
+ _clear_bit(0);
+}
+inline const ::ril_proto::RilCardStatus& RspGetSimStatus::card_status() const {
+ return card_status_ != NULL ? *card_status_ : *default_instance_->card_status_;
+}
+inline ::ril_proto::RilCardStatus* RspGetSimStatus::mutable_card_status() {
+ _set_bit(0);
+ if (card_status_ == NULL) card_status_ = new ::ril_proto::RilCardStatus;
+ return card_status_;
+}
+
+// -------------------------------------------------------------------
+
+// ReqEnterSimPin
+
+// required string pin = 1;
+inline bool ReqEnterSimPin::has_pin() const {
+ return _has_bit(0);
+}
+inline void ReqEnterSimPin::clear_pin() {
+ if (pin_ != &_default_pin_) {
+ pin_->clear();
+ }
+ _clear_bit(0);
+}
+inline const ::std::string& ReqEnterSimPin::pin() const {
+ return *pin_;
+}
+inline void ReqEnterSimPin::set_pin(const ::std::string& value) {
+ _set_bit(0);
+ if (pin_ == &_default_pin_) {
+ pin_ = new ::std::string;
+ }
+ pin_->assign(value);
+}
+inline void ReqEnterSimPin::set_pin(const char* value) {
+ _set_bit(0);
+ if (pin_ == &_default_pin_) {
+ pin_ = new ::std::string;
+ }
+ pin_->assign(value);
+}
+inline void ReqEnterSimPin::set_pin(const char* value, size_t size) {
+ _set_bit(0);
+ if (pin_ == &_default_pin_) {
+ pin_ = new ::std::string;
+ }
+ pin_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* ReqEnterSimPin::mutable_pin() {
+ _set_bit(0);
+ if (pin_ == &_default_pin_) {
+ pin_ = new ::std::string;
+ }
+ return pin_;
+}
+
+// -------------------------------------------------------------------
+
+// RspEnterSimPin
+
+// required int32 retries_remaining = 1;
+inline bool RspEnterSimPin::has_retries_remaining() const {
+ return _has_bit(0);
+}
+inline void RspEnterSimPin::clear_retries_remaining() {
+ retries_remaining_ = 0;
+ _clear_bit(0);
+}
+inline ::google::protobuf::int32 RspEnterSimPin::retries_remaining() const {
+ return retries_remaining_;
+}
+inline void RspEnterSimPin::set_retries_remaining(::google::protobuf::int32 value) {
+ _set_bit(0);
+ retries_remaining_ = value;
+}
+
+// -------------------------------------------------------------------
+
+// ReqHangUp
+
+// required int32 connection_index = 1;
+inline bool ReqHangUp::has_connection_index() const {
+ return _has_bit(0);
+}
+inline void ReqHangUp::clear_connection_index() {
+ connection_index_ = 0;
+ _clear_bit(0);
+}
+inline ::google::protobuf::int32 ReqHangUp::connection_index() const {
+ return connection_index_;
+}
+inline void ReqHangUp::set_connection_index(::google::protobuf::int32 value) {
+ _set_bit(0);
+ connection_index_ = value;
+}
+
+// -------------------------------------------------------------------
+
+// ReqScreenState
+
+// required bool state = 1;
+inline bool ReqScreenState::has_state() const {
+ return _has_bit(0);
+}
+inline void ReqScreenState::clear_state() {
+ state_ = false;
+ _clear_bit(0);
+}
+inline bool ReqScreenState::state() const {
+ return state_;
+}
+inline void ReqScreenState::set_state(bool value) {
+ _set_bit(0);
+ state_ = value;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace ril_proto
+
+#ifndef SWIG
+namespace google {
+namespace protobuf {
+
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RilCommand>() {
+ return ril_proto::RilCommand_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RadioState>() {
+ return ril_proto::RadioState_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RilCardState>() {
+ return ril_proto::RilCardState_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RilPersoSubstate>() {
+ return ril_proto::RilPersoSubstate_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RilAppState>() {
+ return ril_proto::RilAppState_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RilPinState>() {
+ return ril_proto::RilPinState_descriptor();
+}
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::RilAppType>() {
+ return ril_proto::RilAppType_descriptor();
+}
+
+} // namespace google
+} // namespace protobuf
+#endif // SWIG
+
+// @@protoc_insertion_point(global_scope)
+
+#endif // PROTOBUF_ril_2eproto__INCLUDED
diff --git a/mock-ril/ril.proto b/mock-ril/ril.proto
new file mode 100644
index 0000000..e95550e
--- /dev/null
+++ b/mock-ril/ril.proto
@@ -0,0 +1,137 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+// Author: wink@google.com (Wink Saville)
+
+package ril_proto;
+
+enum RilCommand {
+ CMD_GET_SIM_STATUS = 1;
+ CMD_ENTER_SIM_PIN = 2;
+ CMD_HANGUP = 12;
+ CMD_SCREEN_STATE = 61;
+}
+
+enum RadioState {
+ 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 */
+}
+
+enum RilCardState {
+ CARDSTATE_ABSENT = 0;
+ CARDSTATE_PRESENT = 1;
+ CARDSTATE_ERROR = 2;
+}
+
+enum RilPersoSubstate {
+ PERSOSUBSTATE_UNKNOWN = 0; /* initial state */
+ PERSOSUBSTATE_IN_PROGRESS = 1; /* in between each lock transition */
+ PERSOSUBSTATE_READY = 2; /* when either SIM or RUIM Perso is finished
+ since each app can only have 1 active perso
+ involved */
+ PERSOSUBSTATE_SIM_NETWORK = 3;
+ PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4;
+ PERSOSUBSTATE_SIM_CORPORATE = 5;
+ PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6;
+ PERSOSUBSTATE_SIM_SIM = 7;
+ PERSOSUBSTATE_SIM_NETWORK_PUK = 8; /* The corresponding perso lock is blocked */
+ PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9;
+ PERSOSUBSTATE_SIM_CORPORATE_PUK = 10;
+ PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11;
+ PERSOSUBSTATE_SIM_SIM_PUK = 12;
+ PERSOSUBSTATE_RUIM_NETWORK1 = 13;
+ PERSOSUBSTATE_RUIM_NETWORK2 = 14;
+ PERSOSUBSTATE_RUIM_HRPD = 15;
+ PERSOSUBSTATE_RUIM_CORPORATE = 16;
+ PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17;
+ PERSOSUBSTATE_RUIM_RUIM = 18;
+ PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19; /* The corresponding perso lock is blocked */
+ PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20;
+ PERSOSUBSTATE_RUIM_HRPD_PUK = 21;
+ PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22;
+ PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23;
+ PERSOSUBSTATE_RUIM_RUIM_PUK = 24;
+}
+
+enum RilAppState {
+ APPSTATE_UNKNOWN = 0;
+ APPSTATE_DETECTED = 1;
+ APPSTATE_PIN = 2; /* If PIN1 or UPin is required */
+ APPSTATE_PUK = 3; /* If PUK1 or Puk for UPin is required */
+ APPSTATE_SUBSCRIPTION_PERSO = 4; /* perso_substate should be look at
+ when app_state is assigned to this value */
+ APPSTATE_READY = 5;
+}
+
+enum RilPinState {
+ PINSTATE_UNKNOWN = 0;
+ PINSTATE_ENABLED_NOT_VERIFIED = 1;
+ PINSTATE_ENABLED_VERIFIED = 2;
+ PINSTATE_DISABLED = 3;
+ PINSTATE_ENABLED_BLOCKED = 4;
+ PINSTATE_ENABLED_PERM_BLOCKED = 5;
+}
+
+enum RilAppType {
+ APPTYPE_UNKNOWN = 0;
+ APPTYPE_SIM = 1;
+ APPTYPE_USIM = 2;
+ APPTYPE_RUIM = 3;
+ APPTYPE_CSIM = 4;
+}
+
+message RilAppStatus {
+ optional RilAppType app_type = 1;
+ optional RilAppState app_state = 2;
+ optional RilPersoSubstate perso_substate = 3; /* applicable only if app_state ==
+ APPSTATE_SUBSCRIPTION_PERSO */
+ optional string aid = 4; /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41,
+ 0x30, 0x30, 0x30 */
+ optional string app_label = 5; /* null terminated string */
+ optional int32 pin1_replaced = 6; /* applicable to USIM and CSIM */
+ optional RilPinState pin1 = 7;
+ optional RilPinState pin2 = 8;
+}
+
+
+message RilCardStatus {
+ optional RilCardState card_state = 1;
+ optional RilPinState universal_pin_state = 2; /* applicable to USIM and CSIM: PINSTATE_xxx */
+ optional int32 gsm_umts_subscription_app_index = 3; /* value < CARD_MAX_APPS */
+ optional int32 cdma_subscription_app_index = 4; /* value < CARD_MAX_APPS */
+ optional int32 num_applications = 5; /* value <= CARD_MAX_APPS */
+ repeated RilAppStatus applications = 6; /* CARD_MAX_APPS == 8 */
+}
+
+
+message ReqGetSimStatus {
+}
+message RspGetSimStatus {
+ required RilCardStatus card_status = 1;
+}
+
+
+message ReqEnterSimPin {
+ required string pin = 1;
+}
+message RspEnterSimPin {
+ required int32 retries_remaining = 1;
+}
+
+
+message ReqHangUp {
+ required int32 connection_index = 1;
+}
+
+
+message ReqScreenState {
+ required bool state = 1; // true screen is on, false screen is off
+}
diff --git a/mock-ril/ril_pb2.py b/mock-ril/ril_pb2.py
new file mode 100644
index 0000000..9c49fb9
--- /dev/null
+++ b/mock-ril/ril_pb2.py
@@ -0,0 +1,770 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+
+from google.protobuf import descriptor
+from google.protobuf import message
+from google.protobuf import reflection
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+
+DESCRIPTOR = descriptor.FileDescriptor(
+ name='ril.proto',
+ package='ril_proto',
+ serialized_pb='\n\tril.proto\x12\tril_proto\"\x9a\x02\n\x0cRilAppStatus\x12\'\n\x08\x61pp_type\x18\x01 \x01(\x0e\x32\x15.ril_proto.RilAppType\x12)\n\tapp_state\x18\x02 \x01(\x0e\x32\x16.ril_proto.RilAppState\x12\x33\n\x0eperso_substate\x18\x03 \x01(\x0e\x32\x1b.ril_proto.RilPersoSubstate\x12\x0b\n\x03\x61id\x18\x04 \x01(\t\x12\x11\n\tapp_label\x18\x05 \x01(\t\x12\x15\n\rpin1_replaced\x18\x06 \x01(\x05\x12$\n\x04pin1\x18\x07 \x01(\x0e\x32\x16.ril_proto.RilPinState\x12$\n\x04pin2\x18\x08 \x01(\x0e\x32\x16.ril_proto.RilPinState\"\x88\x02\n\rRilCardStatus\x12+\n\ncard_state\x18\x01 \x01(\x0e\x32\x17.ril_proto.RilCardState\x12\x33\n\x13universal_pin_state\x18\x02 \x01(\x0e\x32\x16.ril_proto.RilPinState\x12\'\n\x1fgsm_umts_subscription_app_index\x18\x03 \x01(\x05\x12#\n\x1b\x63\x64ma_subscription_app_index\x18\x04 \x01(\x05\x12\x18\n\x10num_applications\x18\x05 \x01(\x05\x12-\n\x0c\x61pplications\x18\x06 \x03(\x0b\x32\x17.ril_proto.RilAppStatus\"\x11\n\x0fReqGetSimStatus\"@\n\x0fRspGetSimStatus\x12-\n\x0b\x63\x61rd_status\x18\x01 \x02(\x0b\x32\x18.ril_proto.RilCardStatus\"\x1d\n\x0eReqEnterSimPin\x12\x0b\n\x03pin\x18\x01 \x02(\t\"+\n\x0eRspEnterSimPin\x12\x19\n\x11retries_remaining\x18\x01 \x02(\x05\"%\n\tReqHangUp\x12\x18\n\x10\x63onnection_index\x18\x01 \x02(\x05\"\x1f\n\x0eReqScreenState\x12\r\n\x05state\x18\x01 \x02(\x08*a\n\nRilCommand\x12\x16\n\x12\x43MD_GET_SIM_STATUS\x10\x01\x12\x15\n\x11\x43MD_ENTER_SIM_PIN\x10\x02\x12\x0e\n\nCMD_HANGUP\x10\x0c\x12\x14\n\x10\x43MD_SCREEN_STATE\x10=*\xb9\x02\n\nRadioState\x12\x13\n\x0fRADIO_STATE_OFF\x10\x00\x12\x1b\n\x17RADIO_STATE_UNAVAILABLE\x10\x01\x12\x1d\n\x19RADIO_STATE_SIM_NOT_READY\x10\x02\x12$\n RADIO_STATE_SIM_LOCKED_OR_ABSENT\x10\x03\x12\x19\n\x15RADIO_STATE_SIM_READY\x10\x04\x12\x1e\n\x1aRADIO_STATE_RUIM_NOT_READY\x10\x05\x12\x1a\n\x16RADIO_STATE_RUIM_READY\x10\x06\x12%\n!RADIO_STATE_RUIM_LOCKED_OR_ABSENT\x10\x07\x12\x1c\n\x18RADIO_STATE_NV_NOT_READY\x10\x08\x12\x18\n\x14RADIO_STATE_NV_READY\x10\t*P\n\x0cRilCardState\x12\x14\n\x10\x43\x41RDSTATE_ABSENT\x10\x00\x12\x15\n\x11\x43\x41RDSTATE_PRESENT\x10\x01\x12\x13\n\x0f\x43\x41RDSTATE_ERROR\x10\x02*\xf1\x06\n\x10RilPersoSubstate\x12\x19\n\x15PERSOSUBSTATE_UNKNOWN\x10\x00\x12\x1d\n\x19PERSOSUBSTATE_IN_PROGRESS\x10\x01\x12\x17\n\x13PERSOSUBSTATE_READY\x10\x02\x12\x1d\n\x19PERSOSUBSTATE_SIM_NETWORK\x10\x03\x12$\n PERSOSUBSTATE_SIM_NETWORK_SUBSET\x10\x04\x12\x1f\n\x1bPERSOSUBSTATE_SIM_CORPORATE\x10\x05\x12&\n\"PERSOSUBSTATE_SIM_SERVICE_PROVIDER\x10\x06\x12\x19\n\x15PERSOSUBSTATE_SIM_SIM\x10\x07\x12!\n\x1dPERSOSUBSTATE_SIM_NETWORK_PUK\x10\x08\x12(\n$PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK\x10\t\x12#\n\x1fPERSOSUBSTATE_SIM_CORPORATE_PUK\x10\n\x12*\n&PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK\x10\x0b\x12\x1d\n\x19PERSOSUBSTATE_SIM_SIM_PUK\x10\x0c\x12\x1f\n\x1bPERSOSUBSTATE_RUIM_NETWORK1\x10\r\x12\x1f\n\x1bPERSOSUBSTATE_RUIM_NETWORK2\x10\x0e\x12\x1b\n\x17PERSOSUBSTATE_RUIM_HRPD\x10\x0f\x12 \n\x1cPERSOSUBSTATE_RUIM_CORPORATE\x10\x10\x12\'\n#PERSOSUBSTATE_RUIM_SERVICE_PROVIDER\x10\x11\x12\x1b\n\x17PERSOSUBSTATE_RUIM_RUIM\x10\x12\x12#\n\x1fPERSOSUBSTATE_RUIM_NETWORK1_PUK\x10\x13\x12#\n\x1fPERSOSUBSTATE_RUIM_NETWORK2_PUK\x10\x14\x12\x1f\n\x1bPERSOSUBSTATE_RUIM_HRPD_PUK\x10\x15\x12$\n PERSOSUBSTATE_RUIM_CORPORATE_PUK\x10\x16\x12+\n\'PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK\x10\x17\x12\x1f\n\x1bPERSOSUBSTATE_RUIM_RUIM_PUK\x10\x18*\x93\x01\n\x0bRilAppState\x12\x14\n\x10\x41PPSTATE_UNKNOWN\x10\x00\x12\x15\n\x11\x41PPSTATE_DETECTED\x10\x01\x12\x10\n\x0c\x41PPSTATE_PIN\x10\x02\x12\x10\n\x0c\x41PPSTATE_PUK\x10\x03\x12\x1f\n\x1b\x41PPSTATE_SUBSCRIPTION_PERSO\x10\x04\x12\x12\n\x0e\x41PPSTATE_READY\x10\x05*\xbd\x01\n\x0bRilPinState\x12\x14\n\x10PINSTATE_UNKNOWN\x10\x00\x12!\n\x1dPINSTATE_ENABLED_NOT_VERIFIED\x10\x01\x12\x1d\n\x19PINSTATE_ENABLED_VERIFIED\x10\x02\x12\x15\n\x11PINSTATE_DISABLED\x10\x03\x12\x1c\n\x18PINSTATE_ENABLED_BLOCKED\x10\x04\x12!\n\x1dPINSTATE_ENABLED_PERM_BLOCKED\x10\x05*h\n\nRilAppType\x12\x13\n\x0f\x41PPTYPE_UNKNOWN\x10\x00\x12\x0f\n\x0b\x41PPTYPE_SIM\x10\x01\x12\x10\n\x0c\x41PPTYPE_USIM\x10\x02\x12\x10\n\x0c\x41PPTYPE_RUIM\x10\x03\x12\x10\n\x0c\x41PPTYPE_CSIM\x10\x04')
+
+_RILCOMMAND = descriptor.EnumDescriptor(
+ name='RilCommand',
+ full_name='ril_proto.RilCommand',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='CMD_GET_SIM_STATUS', index=0, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CMD_ENTER_SIM_PIN', index=1, number=2,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CMD_HANGUP', index=2, number=12,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CMD_SCREEN_STATE', index=3, number=61,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=809,
+ serialized_end=906,
+)
+
+
+_RADIOSTATE = descriptor.EnumDescriptor(
+ name='RadioState',
+ full_name='ril_proto.RadioState',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_OFF', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_UNAVAILABLE', index=1, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_SIM_NOT_READY', index=2, number=2,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_SIM_LOCKED_OR_ABSENT', index=3, number=3,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_SIM_READY', index=4, number=4,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_RUIM_NOT_READY', index=5, number=5,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_RUIM_READY', index=6, number=6,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_RUIM_LOCKED_OR_ABSENT', index=7, number=7,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_NV_NOT_READY', index=8, number=8,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='RADIO_STATE_NV_READY', index=9, number=9,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=909,
+ serialized_end=1222,
+)
+
+
+_RILCARDSTATE = descriptor.EnumDescriptor(
+ name='RilCardState',
+ full_name='ril_proto.RilCardState',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='CARDSTATE_ABSENT', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CARDSTATE_PRESENT', index=1, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='CARDSTATE_ERROR', index=2, number=2,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=1224,
+ serialized_end=1304,
+)
+
+
+_RILPERSOSUBSTATE = descriptor.EnumDescriptor(
+ name='RilPersoSubstate',
+ full_name='ril_proto.RilPersoSubstate',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_UNKNOWN', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_IN_PROGRESS', index=1, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_READY', index=2, number=2,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_NETWORK', index=3, number=3,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_NETWORK_SUBSET', index=4, number=4,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_CORPORATE', index=5, number=5,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_SERVICE_PROVIDER', index=6, number=6,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_SIM', index=7, number=7,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_NETWORK_PUK', index=8, number=8,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK', index=9, number=9,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_CORPORATE_PUK', index=10, number=10,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK', index=11, number=11,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_SIM_SIM_PUK', index=12, number=12,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_NETWORK1', index=13, number=13,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_NETWORK2', index=14, number=14,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_HRPD', index=15, number=15,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_CORPORATE', index=16, number=16,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_SERVICE_PROVIDER', index=17, number=17,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_RUIM', index=18, number=18,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_NETWORK1_PUK', index=19, number=19,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_NETWORK2_PUK', index=20, number=20,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_HRPD_PUK', index=21, number=21,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_CORPORATE_PUK', index=22, number=22,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK', index=23, number=23,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PERSOSUBSTATE_RUIM_RUIM_PUK', index=24, number=24,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=1307,
+ serialized_end=2188,
+)
+
+
+_RILAPPSTATE = descriptor.EnumDescriptor(
+ name='RilAppState',
+ full_name='ril_proto.RilAppState',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='APPSTATE_UNKNOWN', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPSTATE_DETECTED', index=1, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPSTATE_PIN', index=2, number=2,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPSTATE_PUK', index=3, number=3,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPSTATE_SUBSCRIPTION_PERSO', index=4, number=4,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPSTATE_READY', index=5, number=5,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=2191,
+ serialized_end=2338,
+)
+
+
+_RILPINSTATE = descriptor.EnumDescriptor(
+ name='RilPinState',
+ full_name='ril_proto.RilPinState',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='PINSTATE_UNKNOWN', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PINSTATE_ENABLED_NOT_VERIFIED', index=1, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PINSTATE_ENABLED_VERIFIED', index=2, number=2,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PINSTATE_DISABLED', index=3, number=3,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PINSTATE_ENABLED_BLOCKED', index=4, number=4,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='PINSTATE_ENABLED_PERM_BLOCKED', index=5, number=5,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=2341,
+ serialized_end=2530,
+)
+
+
+_RILAPPTYPE = descriptor.EnumDescriptor(
+ name='RilAppType',
+ full_name='ril_proto.RilAppType',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ descriptor.EnumValueDescriptor(
+ name='APPTYPE_UNKNOWN', index=0, number=0,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPTYPE_SIM', index=1, number=1,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPTYPE_USIM', index=2, number=2,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPTYPE_RUIM', index=3, number=3,
+ options=None,
+ type=None),
+ descriptor.EnumValueDescriptor(
+ name='APPTYPE_CSIM', index=4, number=4,
+ options=None,
+ type=None),
+ ],
+ containing_type=None,
+ options=None,
+ serialized_start=2532,
+ serialized_end=2636,
+)
+
+
+CMD_GET_SIM_STATUS = 1
+CMD_ENTER_SIM_PIN = 2
+CMD_HANGUP = 12
+CMD_SCREEN_STATE = 61
+RADIO_STATE_OFF = 0
+RADIO_STATE_UNAVAILABLE = 1
+RADIO_STATE_SIM_NOT_READY = 2
+RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3
+RADIO_STATE_SIM_READY = 4
+RADIO_STATE_RUIM_NOT_READY = 5
+RADIO_STATE_RUIM_READY = 6
+RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7
+RADIO_STATE_NV_NOT_READY = 8
+RADIO_STATE_NV_READY = 9
+CARDSTATE_ABSENT = 0
+CARDSTATE_PRESENT = 1
+CARDSTATE_ERROR = 2
+PERSOSUBSTATE_UNKNOWN = 0
+PERSOSUBSTATE_IN_PROGRESS = 1
+PERSOSUBSTATE_READY = 2
+PERSOSUBSTATE_SIM_NETWORK = 3
+PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4
+PERSOSUBSTATE_SIM_CORPORATE = 5
+PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6
+PERSOSUBSTATE_SIM_SIM = 7
+PERSOSUBSTATE_SIM_NETWORK_PUK = 8
+PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9
+PERSOSUBSTATE_SIM_CORPORATE_PUK = 10
+PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11
+PERSOSUBSTATE_SIM_SIM_PUK = 12
+PERSOSUBSTATE_RUIM_NETWORK1 = 13
+PERSOSUBSTATE_RUIM_NETWORK2 = 14
+PERSOSUBSTATE_RUIM_HRPD = 15
+PERSOSUBSTATE_RUIM_CORPORATE = 16
+PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17
+PERSOSUBSTATE_RUIM_RUIM = 18
+PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19
+PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20
+PERSOSUBSTATE_RUIM_HRPD_PUK = 21
+PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22
+PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23
+PERSOSUBSTATE_RUIM_RUIM_PUK = 24
+APPSTATE_UNKNOWN = 0
+APPSTATE_DETECTED = 1
+APPSTATE_PIN = 2
+APPSTATE_PUK = 3
+APPSTATE_SUBSCRIPTION_PERSO = 4
+APPSTATE_READY = 5
+PINSTATE_UNKNOWN = 0
+PINSTATE_ENABLED_NOT_VERIFIED = 1
+PINSTATE_ENABLED_VERIFIED = 2
+PINSTATE_DISABLED = 3
+PINSTATE_ENABLED_BLOCKED = 4
+PINSTATE_ENABLED_PERM_BLOCKED = 5
+APPTYPE_UNKNOWN = 0
+APPTYPE_SIM = 1
+APPTYPE_USIM = 2
+APPTYPE_RUIM = 3
+APPTYPE_CSIM = 4
+
+
+
+_RILAPPSTATUS = descriptor.Descriptor(
+ name='RilAppStatus',
+ full_name='ril_proto.RilAppStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='app_type', full_name='ril_proto.RilAppStatus.app_type', index=0,
+ number=1, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='app_state', full_name='ril_proto.RilAppStatus.app_state', index=1,
+ number=2, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='perso_substate', full_name='ril_proto.RilAppStatus.perso_substate', index=2,
+ number=3, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='aid', full_name='ril_proto.RilAppStatus.aid', index=3,
+ number=4, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=unicode("", "utf-8"),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='app_label', full_name='ril_proto.RilAppStatus.app_label', index=4,
+ number=5, type=9, cpp_type=9, label=1,
+ has_default_value=False, default_value=unicode("", "utf-8"),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='pin1_replaced', full_name='ril_proto.RilAppStatus.pin1_replaced', index=5,
+ number=6, type=5, cpp_type=1, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='pin1', full_name='ril_proto.RilAppStatus.pin1', index=6,
+ number=7, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='pin2', full_name='ril_proto.RilAppStatus.pin2', index=7,
+ number=8, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=25,
+ serialized_end=307,
+)
+
+
+_RILCARDSTATUS = descriptor.Descriptor(
+ name='RilCardStatus',
+ full_name='ril_proto.RilCardStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='card_state', full_name='ril_proto.RilCardStatus.card_state', index=0,
+ number=1, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='universal_pin_state', full_name='ril_proto.RilCardStatus.universal_pin_state', index=1,
+ number=2, type=14, cpp_type=8, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='gsm_umts_subscription_app_index', full_name='ril_proto.RilCardStatus.gsm_umts_subscription_app_index', index=2,
+ number=3, type=5, cpp_type=1, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='cdma_subscription_app_index', full_name='ril_proto.RilCardStatus.cdma_subscription_app_index', index=3,
+ number=4, type=5, cpp_type=1, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='num_applications', full_name='ril_proto.RilCardStatus.num_applications', index=4,
+ number=5, type=5, cpp_type=1, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='applications', full_name='ril_proto.RilCardStatus.applications', index=5,
+ number=6, type=11, cpp_type=10, label=3,
+ has_default_value=False, default_value=[],
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=310,
+ serialized_end=574,
+)
+
+
+_REQGETSIMSTATUS = descriptor.Descriptor(
+ name='ReqGetSimStatus',
+ full_name='ril_proto.ReqGetSimStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=576,
+ serialized_end=593,
+)
+
+
+_RSPGETSIMSTATUS = descriptor.Descriptor(
+ name='RspGetSimStatus',
+ full_name='ril_proto.RspGetSimStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='card_status', full_name='ril_proto.RspGetSimStatus.card_status', index=0,
+ number=1, type=11, cpp_type=10, label=2,
+ has_default_value=False, default_value=None,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=595,
+ serialized_end=659,
+)
+
+
+_REQENTERSIMPIN = descriptor.Descriptor(
+ name='ReqEnterSimPin',
+ full_name='ril_proto.ReqEnterSimPin',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='pin', full_name='ril_proto.ReqEnterSimPin.pin', index=0,
+ number=1, type=9, cpp_type=9, label=2,
+ has_default_value=False, default_value=unicode("", "utf-8"),
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=661,
+ serialized_end=690,
+)
+
+
+_RSPENTERSIMPIN = descriptor.Descriptor(
+ name='RspEnterSimPin',
+ full_name='ril_proto.RspEnterSimPin',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='retries_remaining', full_name='ril_proto.RspEnterSimPin.retries_remaining', index=0,
+ number=1, type=5, cpp_type=1, label=2,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=692,
+ serialized_end=735,
+)
+
+
+_REQHANGUP = descriptor.Descriptor(
+ name='ReqHangUp',
+ full_name='ril_proto.ReqHangUp',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='connection_index', full_name='ril_proto.ReqHangUp.connection_index', index=0,
+ number=1, type=5, cpp_type=1, label=2,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=737,
+ serialized_end=774,
+)
+
+
+_REQSCREENSTATE = descriptor.Descriptor(
+ name='ReqScreenState',
+ full_name='ril_proto.ReqScreenState',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='state', full_name='ril_proto.ReqScreenState.state', index=0,
+ number=1, type=8, cpp_type=7, label=2,
+ has_default_value=False, default_value=False,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=776,
+ serialized_end=807,
+)
+
+
+_RILAPPSTATUS.fields_by_name['app_type'].enum_type = _RILAPPTYPE
+_RILAPPSTATUS.fields_by_name['app_state'].enum_type = _RILAPPSTATE
+_RILAPPSTATUS.fields_by_name['perso_substate'].enum_type = _RILPERSOSUBSTATE
+_RILAPPSTATUS.fields_by_name['pin1'].enum_type = _RILPINSTATE
+_RILAPPSTATUS.fields_by_name['pin2'].enum_type = _RILPINSTATE
+_RILCARDSTATUS.fields_by_name['card_state'].enum_type = _RILCARDSTATE
+_RILCARDSTATUS.fields_by_name['universal_pin_state'].enum_type = _RILPINSTATE
+_RILCARDSTATUS.fields_by_name['applications'].message_type = _RILAPPSTATUS
+_RSPGETSIMSTATUS.fields_by_name['card_status'].message_type = _RILCARDSTATUS
+
+class RilAppStatus(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _RILAPPSTATUS
+
+ # @@protoc_insertion_point(class_scope:ril_proto.RilAppStatus)
+
+class RilCardStatus(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _RILCARDSTATUS
+
+ # @@protoc_insertion_point(class_scope:ril_proto.RilCardStatus)
+
+class ReqGetSimStatus(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _REQGETSIMSTATUS
+
+ # @@protoc_insertion_point(class_scope:ril_proto.ReqGetSimStatus)
+
+class RspGetSimStatus(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _RSPGETSIMSTATUS
+
+ # @@protoc_insertion_point(class_scope:ril_proto.RspGetSimStatus)
+
+class ReqEnterSimPin(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _REQENTERSIMPIN
+
+ # @@protoc_insertion_point(class_scope:ril_proto.ReqEnterSimPin)
+
+class RspEnterSimPin(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _RSPENTERSIMPIN
+
+ # @@protoc_insertion_point(class_scope:ril_proto.RspEnterSimPin)
+
+class ReqHangUp(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _REQHANGUP
+
+ # @@protoc_insertion_point(class_scope:ril_proto.ReqHangUp)
+
+class ReqScreenState(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _REQSCREENSTATE
+
+ # @@protoc_insertion_point(class_scope:ril_proto.ReqScreenState)
+
+# @@protoc_insertion_point(module_scope)
diff --git a/mock-ril/ril_vars.js b/mock-ril/ril_vars.js
new file mode 100644
index 0000000..5d79c20
--- /dev/null
+++ b/mock-ril/ril_vars.js
@@ -0,0 +1,208 @@
+/**
+ * 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.
+ */
+
+/**
+ * variables from ril.h
+ */
+print("ril-vars.js Beg");
+
+/**
+ * RIL Error codes
+ */
+var RIL_E_SUCCESS = 0;
+var RIL_E_RADIO_NOT_AVAILABLE = 1; /* If radio did not start or is resetting */
+var RIL_E_GENERIC_FAILURE = 2;
+var RIL_E_PASSWORD_INCORRECT = 3; /* for PIN/PIN2 methods only! */
+var RIL_E_SIM_PIN2 = 4; /* Operation requires SIM PIN2 to be entered */
+var RIL_E_SIM_PUK2 = 5; /* Operation requires SIM PIN2 to be entered */
+var RIL_E_REQUEST_NOT_SUPPORTED = 6;
+var RIL_E_CANCELLED = 7;
+var RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8; /* data ops are not allowed during voice
+ call on a Class C GPRS device */
+var RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9; /* data ops are not allowed before device
+ registers in network */
+var RIL_E_SMS_SEND_FAIL_RETRY = 10; /* fail to send sms and need retry */
+var RIL_E_SIM_ABSENT = 11; /* fail to set the location where CDMA subscription
+ shall be retrieved because of SIM or RUIM
+ card absent */
+var RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12; /* fail to find CDMA subscription from specified
+ location */
+var RIL_E_MODE_NOT_SUPPORTED = 13; /* HW does not support preferred network type */
+var RIL_E_FDN_CHECK_FAILURE = 14; /* command failed because recipient is not on FDN
+ list */
+var RIL_E_ILLEGAL_SIM_OR_ME = 15; /* network selection failed due to */
+
+/**
+ * RIL_RadioState
+ */
+var RADIO_STATE_OFF = 0; /* Radio explictly powered off (eg CFUN=0) */
+var RADIO_STATE_UNAVAILABLE = 1; /* Radio unavailable (eg, resetting or not booted) */
+var RADIO_STATE_SIM_NOT_READY = 2; /* Radio is on, but the SIM interface is not ready */
+var RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3; /* SIM PIN locked, PUK required, network
+ personalization locked; or SIM absent */
+var RADIO_STATE_SIM_READY = 4; /* Radio is on and SIM interface is available */
+var RADIO_STATE_RUIM_NOT_READY = 5; /* Radio is on, but the RUIM interface is not ready */
+var RADIO_STATE_RUIM_READY = 6; /* Radio is on and the RUIM interface is available */
+var RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7; /* RUIM PIN locked, PUK required, network
+ personalization locked; or RUIM absent */
+var RADIO_STATE_NV_NOT_READY = 8; /* Radio is on, but the NV interface is not available */
+var RADIO_STATE_NV_READY = 9; /* Radio is on and the NV interface is available */
+
+/**
+ * RIL requests
+ */
+var RIL_REQUEST_GET_SIM_STATUS = 1
+var RIL_REQUEST_ENTER_SIM_PIN = 2
+var RIL_REQUEST_ENTER_SIM_PUK = 3
+var RIL_REQUEST_ENTER_SIM_PIN2 = 4
+var RIL_REQUEST_ENTER_SIM_PUK2 = 5
+var RIL_REQUEST_CHANGE_SIM_PIN = 6
+var RIL_REQUEST_CHANGE_SIM_PIN2 = 7
+var RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION = 8
+var RIL_REQUEST_GET_CURRENT_CALLS = 9
+var RIL_REQUEST_DIAL = 10
+var RIL_REQUEST_GET_IMSI = 11
+var RIL_REQUEST_HANGUP = 12
+var RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND = 13
+var RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND = 14
+var RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE = 15
+var RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE = 15
+var RIL_REQUEST_CONFERENCE = 16
+var RIL_REQUEST_UDUB = 17
+var RIL_REQUEST_LAST_CALL_FAIL_CAUSE = 18
+var RIL_REQUEST_SIGNAL_STRENGTH = 19
+var RIL_REQUEST_REGISTRATION_STATE = 20
+var RIL_REQUEST_GPRS_REGISTRATION_STATE = 21
+var RIL_REQUEST_OPERATOR = 22
+var RIL_REQUEST_RADIO_POWER = 23
+var RIL_REQUEST_DTMF = 24
+var RIL_REQUEST_SEND_SMS = 25
+var RIL_REQUEST_SEND_SMS_EXPECT_MORE = 26
+var RIL_REQUEST_SETUP_DATA_CALL = 27
+var RIL_REQUEST_SIM_IO = 28
+var RIL_REQUEST_SEND_USSD = 29
+var RIL_REQUEST_CANCEL_USSD = 30
+var RIL_REQUEST_GET_CLIR = 31
+var RIL_REQUEST_SET_CLIR = 32
+var RIL_REQUEST_QUERY_CALL_FORWARD_STATUS = 33
+var RIL_REQUEST_SET_CALL_FORWARD = 34
+var RIL_REQUEST_QUERY_CALL_WAITING = 35
+var RIL_REQUEST_SET_CALL_WAITING = 36
+var RIL_REQUEST_SMS_ACKNOWLEDGE = 37
+var RIL_REQUEST_GET_IMEI = 38
+var RIL_REQUEST_GET_IMEISV = 39
+var RIL_REQUEST_ANSWER = 40
+var RIL_REQUEST_DEACTIVATE_DATA_CALL = 41
+var RIL_REQUEST_QUERY_FACILITY_LOCK = 42
+var RIL_REQUEST_SET_FACILITY_LOCK = 43
+var RIL_REQUEST_CHANGE_BARRING_PASSWORD = 44
+var RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE = 45
+var RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC = 46
+var RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL = 47
+var RIL_REQUEST_QUERY_AVAILABLE_NETWORKS = 48
+var RIL_REQUEST_DTMF_START = 49
+var RIL_REQUEST_DTMF_STOP = 50
+var RIL_REQUEST_BASEBAND_VERSION = 51
+var RIL_REQUEST_SEPARATE_CONNECTION = 52
+var RIL_REQUEST_SET_MUTE = 53
+var RIL_REQUEST_GET_MUTE = 54
+var RIL_REQUEST_QUERY_CLIP = 55
+var RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE = 56
+var RIL_REQUEST_DATA_CALL_LIST = 57
+var RIL_REQUEST_RESET_RADIO = 58
+var RIL_REQUEST_OEM_HOOK_RAW = 59
+var RIL_REQUEST_OEM_HOOK_STRINGS = 60
+var RIL_REQUEST_SCREEN_STATE = 61
+var RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION = 62
+var RIL_REQUEST_WRITE_SMS_TO_SIM = 63
+var RIL_REQUEST_DELETE_SMS_ON_SIM = 64
+var RIL_REQUEST_SET_BAND_MODE = 65
+var RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE = 66
+var RIL_REQUEST_STK_GET_PROFILE = 67
+var RIL_REQUEST_STK_SET_PROFILE = 68
+var RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND = 69
+var RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE = 70
+var RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM = 71
+var RIL_REQUEST_EXPLICIT_CALL_TRANSFER = 72
+var RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE = 73
+var RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE = 74
+var RIL_REQUEST_GET_NEIGHBORING_CELL_IDS = 75
+var RIL_REQUEST_SET_LOCATION_UPDATES = 76
+var RIL_REQUEST_CDMA_SET_SUBSCRIPTION = 77
+var RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE = 78
+var RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE = 79
+var RIL_REQUEST_SET_TTY_MODE = 80
+var RIL_REQUEST_QUERY_TTY_MODE = 81
+var RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE = 82
+var RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE = 83
+var RIL_REQUEST_CDMA_FLASH = 84
+var RIL_REQUEST_CDMA_BURST_DTMF = 85
+var RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY = 86
+var RIL_REQUEST_CDMA_SEND_SMS = 87
+var RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE = 88
+var RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG = 89
+var RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG = 90
+var RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION = 91
+var RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG = 92
+var RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG = 93
+var RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION = 94
+var RIL_REQUEST_CDMA_SUBSCRIPTION = 95
+var RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM = 96
+var RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM = 97
+var RIL_REQUEST_DEVICE_IDENTITY = 98
+var RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE = 99
+var RIL_REQUEST_GET_SMSC_ADDRESS = 100
+var RIL_REQUEST_SET_SMSC_ADDRESS = 101
+var RIL_REQUEST_REPORT_SMS_MEMORY_STATUS = 102
+var RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING = 103
+
+/**
+ * RIL unsolicited requests
+ */
+var RIL_UNSOL_RESPONSE_BASE = 1000
+var RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000
+var RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED = 1001
+var RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED = 1002
+var RIL_UNSOL_RESPONSE_NEW_SMS = 1003
+var RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT = 1004
+var RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM = 1005
+var RIL_UNSOL_ON_USSD = 1006
+var RIL_UNSOL_ON_USSD_REQUEST = 1007
+var RIL_UNSOL_NITZ_TIME_RECEIVED = 1008
+var RIL_UNSOL_SIGNAL_STRENGTH = 1009
+var RIL_UNSOL_DATA_CALL_LIST_CHANGED = 1010
+var RIL_UNSOL_SUPP_SVC_NOTIFICATION = 1011
+var RIL_UNSOL_STK_SESSION_END = 1012
+var RIL_UNSOL_STK_PROACTIVE_COMMAND = 1013
+var RIL_UNSOL_STK_EVENT_NOTIFY = 1014
+var RIL_UNSOL_STK_CALL_SETUP = 1015
+var RIL_UNSOL_SIM_SMS_STORAGE_FULL = 1016
+var RIL_UNSOL_SIM_REFRESH = 1017
+var RIL_UNSOL_CALL_RING = 1018
+var RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED = 1019
+var RIL_UNSOL_RESPONSE_CDMA_NEW_SMS = 1020
+var RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS = 1021
+var RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL = 1022
+var RIL_UNSOL_RESTRICTED_STATE_CHANGED = 1023
+var RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE = 1024
+var RIL_UNSOL_CDMA_CALL_WAITING = 1025
+var RIL_UNSOL_CDMA_OTA_PROVISION_STATUS = 1026
+var RIL_UNSOL_CDMA_INFO_REC = 1027
+var RIL_UNSOL_OEM_HOOK_RAW = 1028
+var RIL_UNSOL_RINGBACK_TONE = 1029
+var RIL_UNSOL_RESEND_INCALL_MUTE = 1030
+
+print("ril-vars.js End");
diff --git a/mock-ril/status.h b/mock-ril/status.h
new file mode 100644
index 0000000..cbacf22
--- /dev/null
+++ b/mock-ril/status.h
@@ -0,0 +1,33 @@
+/**
+ * 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.
+ */
+
+#ifndef __STATUS_H_
+#define __STATUS_H_
+
+// Internal STATUS values
+#define STATUS_OK 0
+#define STATUS_ERR 1
+#define STATUS_BAD_DATA 2
+#define STATUS_BAD_PARAMETER 3
+#define STATUS_UNSUPPORTED_REQUEST 4
+#define STATUS_UNSUPPORTED_RESPONSE 5
+#define STATUS_NO_JS_ONREQUEST_FUNCTION 6
+#define STATUS_COULD_NOT_OPEN_FILE 7
+#define STATUS_COULD_NOT_READ_FILE 8
+#define STATUS_CLIENT_CLOSED_CONNECTION 9
+
+
+#endif // __STATUS_H_
diff --git a/mock-ril/t.pb.cpp b/mock-ril/t.pb.cpp
deleted file mode 100644
index ba573e3..0000000
--- a/mock-ril/t.pb.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-// 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
deleted file mode 100644
index 19fc07d..0000000
--- a/mock-ril/t.pb.h
+++ /dev/null
@@ -1,193 +0,0 @@
-// 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
deleted file mode 100644
index 2b33444..0000000
--- a/mock-ril/t.proto
+++ /dev/null
@@ -1,9 +0,0 @@
-// 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/mock-ril/tcs.py b/mock-ril/tcs.py
new file mode 100755
index 0000000..c45ea3a
--- /dev/null
+++ b/mock-ril/tcs.py
@@ -0,0 +1,250 @@
+#!/usr/bin/python
+#
+# 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.
+#
+
+"""Test server
+
+A detailed description of tms.
+"""
+
+__author__ = 'wink@google.com (Wink Saville)'
+
+import socket
+import struct
+import sys
+import time
+
+import ctrl_pb2
+import ril_pb2
+
+def recvall(s, count):
+ """Receive all of the data otherwise return none.
+
+ Args:
+ s: socket
+ count: number of bytes
+
+ Returns:
+ data received
+ None if no data is received
+ """
+ all_data = []
+ while (count > 0):
+ data = s.recv(count)
+ if (len(data) == 0):
+ return None
+ count -= len(data)
+ all_data.append(data)
+ result = ''.join(all_data);
+ return result
+
+def sendall(s, data):
+ """Send all of the data
+
+ Args:
+ s: socket
+ count: number of bytes
+
+ Returns:
+ Nothing
+ """
+ s.sendall(data)
+
+class MsgHeader:
+ """A fixed length message header; cmd, token, status and length of protobuf."""
+ def __init__(self):
+ self.cmd = 0
+ self.token = 0
+ self.status = 0
+ self.length_protobuf = 0
+
+ def packHeader(self):
+ """Return a packed string with the header information
+
+ Args:
+ s: socket
+ count: number of bytes
+
+ Returns:
+ Nothing
+ """
+ return struct.pack("<iqii", self.cmd, self.token, self.status, self.length_protobuf)
+
+ def unpackHeader(self, raw):
+ """Set the MsgHeader fields from raw which contains the packed header information."""
+ unpacked = struct.unpack("<iqii", raw)
+ self.cmd = unpacked[0]
+ self.token = unpacked[1]
+ self.status = unpacked[2]
+ self.length_protobuf = unpacked[3]
+
+ def sendHeader(self, s):
+ """Send the header to the socket as packed data
+
+ Args:
+ s: socket
+
+ Returns
+ nothing
+ """
+ sendall(s, self.packHeader())
+
+ def recvHeader(self, s):
+ """Receive the header from the socket and unpack"""
+ self.unpackHeader(recvall(s, 20))
+
+class Msg:
+ """A message consists of a fixed length MsgHeader followed by a protobuf.
+
+ This class sends and receives messages, when sending the status
+ will be zero and when receiving the protobuf field will be an
+ empty string if there was no protobuf.
+ """
+ def __init__(self):
+ """Initialize the protobuf to None and header to an empty"""
+ self.protobuf = None
+ self.header = MsgHeader()
+
+ # Keep a local copy of header for convenience
+ self.cmd = 0
+ self.token = 0
+ self.status = 0
+
+ def sendMsg(self, s, cmd, token, protobuf=''):
+ """Send a message to a socket
+
+ Args:
+ s: socket
+ cmd: command to send
+ token: token to send, will be returned unmodified
+ protobuf: optional protobuf to send
+
+ Returns
+ nothing
+ """
+ self.cmd = cmd
+ self.token = token
+ self.status = 0
+ self.protobuf = protobuf
+
+ self.header.cmd = self.cmd
+ self.header.token = self.token
+ self.header.status = self.status
+ if (len(protobuf) > 0):
+ self.header.length_protobuf = len(protobuf)
+ else:
+ self.header.length_protobuf = 0
+ self.protobuf = ''
+ self.header.sendHeader(s)
+ if (self.header.length_protobuf > 0):
+ sendall(s, self.protobuf)
+
+ def recvMsg(self, s):
+ """Receive a message from a socket
+
+ Args:
+ s: socket
+
+ Returns:
+ nothing
+ """
+ self.header.recvHeader(s)
+ self.cmd = self.header.cmd
+ self.token = self.header.token
+ self.status = self.header.status
+ if (self.header.length_protobuf > 0):
+ self.protobuf = recvall(s, self.header.length_protobuf)
+ else:
+ self.protobuf = ''
+
+def main(argv):
+ """Create a socket and connect.
+
+ Before using you'll need to forward the port
+ used by mock_ril, 54312 to a port on the PC.
+ The following worked for me:
+
+ adb forward tcp:11111 tcp:54312.
+
+ Then you can execute this test using:
+
+ tms.py 127.0.0.1 11111
+ """
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ host = sys.argv[1] # server address
+ print "host=%s" % host
+ port = int(sys.argv[2]) # server port
+ print "port=%d" % port
+ s.connect((host, port))
+
+ # Create an object which is serializable to a protobuf
+ rrs = ctrl_pb2.CtrlRspRadioState()
+ rrs.state = ril_pb2.RADIO_STATE_UNAVAILABLE
+ print "rrs.state=%d" % (rrs.state)
+
+ # Serialize
+ rrs_ser = rrs.SerializeToString()
+ print "len(rrs_ser)=%d" % (len(rrs_ser))
+
+ # Deserialize
+ rrs_new = ctrl_pb2.CtrlRspRadioState()
+ rrs_new.ParseFromString(rrs_ser)
+ print "rrs_new.state=%d" % (rrs_new.state)
+
+
+ # Do an echo test
+ req = Msg()
+ req.sendMsg(s, 0, 1234567890123, rrs_ser)
+ resp = Msg()
+ resp.recvMsg(s)
+ response = ctrl_pb2.CtrlRspRadioState()
+ response.ParseFromString(resp.protobuf)
+
+ print "cmd=%d" % (resp.cmd)
+ print "token=%d" % (resp.token)
+ print "status=%d" % (resp.status)
+ print "len(protobuf)=%d" % (len(resp.protobuf))
+ print "response.state=%d" % (response.state)
+ if ((resp.cmd == 0) & (resp.token == 1234567890123) &
+ (resp.status == 0) & (response.state == 1)):
+ print "SUCCESS: echo ok"
+ else:
+ print "ERROR: expecting cmd=0 token=1234567890123 status=0 state=1"
+
+ # Test CTRL_GET_RADIO_STATE
+ req.sendMsg(s, ctrl_pb2.CTRL_CMD_GET_RADIO_STATE, 4)
+ resp = Msg()
+ resp.recvMsg(s)
+
+ print "cmd=%d" % (resp.cmd)
+ print "token=%d" % (resp.token)
+ print "status=%d" % (resp.status)
+ print "length_protobuf=%d" % (len(resp.protobuf))
+
+ if (resp.cmd == ctrl_pb2.CTRL_CMD_GET_RADIO_STATE):
+ response = ctrl_pb2.CtrlRspRadioState()
+ response.ParseFromString(resp.protobuf)
+ print "SUCCESS: response.state=%d" % (response.state)
+ else:
+ print "ERROR: expecting resp.cmd == ctrl_pb2.CTRL_CMD_GET_RADIO_STATE"
+
+ # Close socket
+ print "closing socket"
+ s.close()
+
+
+if __name__ == '__main__':
+ main(sys.argv)
diff --git a/mock-ril/util.cpp b/mock-ril/util.cpp
new file mode 100644
index 0000000..40c8527
--- /dev/null
+++ b/mock-ril/util.cpp
@@ -0,0 +1,87 @@
+/**
+ * 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.
+ */
+
+#include <v8.h>
+#include <string.h>
+
+#include "logging.h"
+#include "util.h"
+
+// Extracts a C string from a V8 Utf8Value.
+const char* ToCString(const v8::String::Utf8Value& value) {
+ return *value ? *value : "<string conversion failed>";
+}
+
+// Extracts a C string from a V8 Utf8Value.
+const char* ToCString(v8::Handle<v8::Value> value) {
+ v8::String::Utf8Value strUtf8Value(value);
+ return ToCString(strUtf8Value);
+}
+
+// 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.
+ if (alternate_message == NULL || strlen(alternate_message) == 0) {
+ LOGD("LogErrorMessage no message");
+ } else {
+ LOGD("LogErrorMessage no message: %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();
+ int lenErr = end - start;
+ int size = end + 1;
+ if (lenErr == 0) {
+ lenErr += 1;
+ size += 1;
+ }
+ char *error_string = new char[size];
+ memset(error_string, ' ', start);
+ memset(&error_string[start], '^', lenErr);
+ error_string[size-1] = 0;
+ LOGD("%s", error_string);
+ LOGD("%s", ToCString(v8::String::Utf8Value(message->Get())));
+ delete [] error_string;
+ }
+}
+
+// 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?
+ // it is always empty on compile errors
+ }
+ LogErrorMessage(msg, ToCString(exception));
+}
diff --git a/mock-ril/util.h b/mock-ril/util.h
new file mode 100644
index 0000000..e094ed1
--- /dev/null
+++ b/mock-ril/util.h
@@ -0,0 +1,30 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_UTIL_H_
+#define MOCK_RIL_UTIL_H_
+
+const char* ToCString(const v8::String::Utf8Value& value);
+
+const char* ToCString(v8::Handle<v8::Value> value);
+
+void LogErrorMessage(v8::Handle<v8::Message> message,
+ const char *alternate_message);
+
+void ReportException(v8::TryCatch* try_catch);
+
+
+#endif // MOCK_RIL_UTIL_H_
diff --git a/mock-ril/worker.cpp b/mock-ril/worker.cpp
new file mode 100644
index 0000000..5a192e0
--- /dev/null
+++ b/mock-ril/worker.cpp
@@ -0,0 +1,239 @@
+/**
+ * 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.
+ */
+
+#include "logging.h"
+
+#include "worker.h"
+
+//#define WORKER_DEBUG
+#ifdef WORKER_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+void * WorkerThread::Work(void *param) {
+ WorkerThread *t = (WorkerThread *)param;
+ android_atomic_acquire_store(STATE_RUNNING, &t->state_);
+ void * v = t->Worker(t->workerParam_);
+ android_atomic_acquire_store(STATE_STOPPED, &t->state_);
+ return v;
+}
+
+bool WorkerThread::isRunning() {
+ DBG("WorkerThread::isRunning E");
+ bool ret_value = android_atomic_acquire_load(&state_) == STATE_RUNNING;
+ DBG("WorkerThread::isRunning X ret_value=%d", ret_value);
+ return ret_value;
+}
+
+WorkerThread::WorkerThread() {
+ DBG("WorkerThread::WorkerThread E");
+ state_ = STATE_INITIALIZED;
+ pthread_mutex_init(&mutex_, NULL);
+ pthread_cond_init(&cond_, NULL);
+ DBG("WorkerThread::WorkerThread X");
+}
+
+WorkerThread::~WorkerThread() {
+ DBG("WorkerThread::~WorkerThread E");
+ Stop();
+ DBG("WorkerThread::~WorkerThread X");
+}
+
+// Return true if changed from STATE_RUNNING to STATE_STOPPING
+bool WorkerThread::BeginStopping() {
+ DBG("WorkerThread::BeginStopping E");
+ bool ret_value = (android_atomic_acquire_cas(STATE_RUNNING, STATE_STOPPING, &state_) == 0);
+ DBG("WorkerThread::BeginStopping X ret_value=%d", ret_value);
+ return ret_value;
+}
+
+// Wait until state is not STATE_STOPPING
+void WorkerThread::WaitUntilStopped() {
+ DBG("WorkerThread::WaitUntilStopped E");
+ pthread_cond_signal(&cond_);
+ while(android_atomic_release_load(&state_) == STATE_STOPPING) {
+ usleep(200000);
+ }
+ DBG("WorkerThread::WaitUntilStopped X");
+}
+
+void WorkerThread::Stop() {
+ DBG("WorkerThread::Stop E");
+ if (BeginStopping()) {
+ WaitUntilStopped();
+ }
+ DBG("WorkerThread::Stop X");
+}
+
+int WorkerThread::Run(void *workerParam) {
+ DBG("WorkerThread::Run E workerParam=%p", workerParam);
+ int status;
+ int ret;
+
+ workerParam_ = workerParam;
+
+ ret = pthread_attr_init(&attr_);
+ if (ret != 0) {
+ LOGE("RIL_Init X: pthread_attr_init failed err=%s", strerror(ret));
+ return STATUS_ERR;
+ }
+ ret = pthread_attr_setdetachstate(&attr_, PTHREAD_CREATE_DETACHED);
+ if (ret != 0) {
+ LOGE("RIL_Init X: pthread_attr_setdetachstate failed err=%s",
+ strerror(ret));
+ return STATUS_ERR;
+ }
+ ret = pthread_create(&tid_, &attr_,
+ (void * (*)(void *))&WorkerThread::Work, this);
+ if (ret != 0) {
+ LOGE("RIL_Init X: pthread_create failed err=%s", strerror(ret));
+ return STATUS_ERR;
+ }
+
+ // Wait until worker is running
+ while (android_atomic_acquire_load(&state_) == STATE_INITIALIZED) {
+ usleep(200000);
+ }
+
+ DBG("WorkerThread::Run X workerParam=%p" workerParam);
+ return STATUS_OK;
+}
+
+
+class WorkerQueueThread : public WorkerThread {
+ private:
+ friend class WorkerQueue;
+
+ public:
+ WorkerQueueThread() {
+ }
+
+ virtual ~WorkerQueueThread() {
+ Stop();
+ }
+
+ void * Worker(void *param) {
+ DBG("WorkerQueueThread::Worker E");
+ WorkerQueue *wq = (WorkerQueue *)param;
+
+ // Do the work until we're told to stop
+ while (isRunning()) {
+ pthread_mutex_lock(&mutex_);
+ while (isRunning() && (wq->q_.size() == 0)) {
+ pthread_cond_wait(&cond_, &mutex_);
+ }
+ if (isRunning()) {
+ void *p = wq->q_.front();
+ wq->q_.pop();
+ pthread_mutex_unlock(&mutex_);
+ wq->Process(p);
+ } else {
+ pthread_mutex_unlock(&mutex_);
+ }
+ }
+ DBG("WorkerQueueThread::Worker X");
+ return NULL;
+ }
+};
+
+WorkerQueue::WorkerQueue() {
+ wqt_ = new WorkerQueueThread();
+}
+
+WorkerQueue::~WorkerQueue() {
+ Stop();
+ delete wqt_;
+}
+
+int WorkerQueue::Run() {
+ return wqt_->Run(this);
+}
+
+void WorkerQueue::Stop() {
+ wqt_->Stop();
+}
+
+void WorkerQueue::Add(void *p) {
+ DBG("WorkerQueue::Add E:");
+ pthread_mutex_lock(&wqt_->mutex_);
+ q_.push(p);
+ if (q_.size() == 1) {
+ pthread_cond_signal(&wqt_->cond_);
+ }
+ pthread_mutex_unlock(&wqt_->mutex_);
+ DBG("WorkerQueue::Add X:");
+}
+
+
+
+class TestWorkerQueue : public WorkerQueue {
+ virtual void Process(void *p) {
+ LOGD("TestWorkerQueue::Process: EX p=%p", p);
+ }
+};
+
+class TesterThread : public WorkerThread {
+ public:
+ void * Worker(void *param)
+ {
+ LOGD("TesterThread::Worker E param=%p", param);
+ WorkerQueue *wq = (WorkerQueue *)param;
+
+ for (int i = 0; isRunning(); i++) {
+ LOGD("TesterThread: looping %d", i);
+ wq->Add((void *)i);
+ wq->Add((void *)i);
+ wq->Add((void *)i);
+ wq->Add((void *)i);
+ sleep(1);
+ }
+
+ LOGD("TesterThread::Worker X param=%p", param);
+
+ return NULL;
+ }
+};
+
+void testWorker() {
+ LOGD("testWorker E: ********");
+
+ // Test we can create a thread and delete it
+ TesterThread *tester = new TesterThread();
+ delete tester;
+
+ TestWorkerQueue *wq = new TestWorkerQueue();
+ if (wq->Run() == STATUS_OK) {
+ LOGD("testWorker WorkerQueue %p running", wq);
+
+ // Test we can run a thread, stop it then delete it
+ tester = new TesterThread();
+ tester->Run(wq);
+ LOGD("testWorker tester %p running", tester);
+ sleep(10);
+ LOGD("testWorker tester %p stopping", tester);
+ tester->Stop();
+ LOGD("testWorker tester %p stopped", tester);
+ wq->Stop();
+ LOGD("testWorker wq %p stopped", wq);
+ }
+ LOGD("testWorker X: ********\n");
+}
diff --git a/mock-ril/worker.h b/mock-ril/worker.h
new file mode 100644
index 0000000..8d933da
--- /dev/null
+++ b/mock-ril/worker.h
@@ -0,0 +1,125 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_WORKER_H_
+#define MOCK_RIL_WORKER_H_
+
+#include <queue>
+#include <status.h>
+#include <pthread.h>
+#include <cutils/atomic.h>
+
+/**
+ * A Thread class.
+ *
+ * 0) Extend WorkerThread creating a Worker method which
+ * monitors isRunning(). For example:
+ *
+ * void * Worker(void *param) {
+ * while (isRunning() == 0) {
+ * pthread_mutex_lock(&mutex_);
+ * while (isRunning() && !SOME-CONDITION) {
+ * pthread_cond_wait(&cond_, &mutex_);
+ * }
+ * if (isRunning()) {
+ * DO-WORK
+ * } else {
+ * pthread_mutex_unlock(&mutex_);
+ * }
+ * }
+ * return NULL;
+ * }
+ *
+ * 1) Create the WorkerThread.
+ * 2) Execute Run passing a param which will be passed to Worker.
+ * 3) Call Stop() or destroy the thread to stop processing.
+ *
+ */
+class WorkerThread {
+ protected:
+ pthread_attr_t attr_;
+ pthread_mutex_t mutex_;
+ pthread_cond_t cond_;
+ pthread_t tid_;
+ void *workerParam_;
+
+ #define STATE_INITIALIZED 1
+ #define STATE_RUNNING 2
+ #define STATE_STOPPING 3
+ #define STATE_STOPPED 4
+ int32_t state_;
+
+ static void * Work(void *param);
+
+ virtual bool isRunning();
+
+ public:
+ WorkerThread();
+
+ virtual ~WorkerThread();
+
+ // Return true if changed from STATE_RUNNING to STATE_STOPPING
+ virtual bool BeginStopping();
+
+ // Wait until state is not STATE_STOPPING
+ virtual void WaitUntilStopped();
+
+ virtual void Stop();
+
+ virtual int Run(void *workerParam);
+
+ /**
+ * Method called to do work, see example above.
+ * While running isRunning() must be monitored.
+ */
+ virtual void *Worker(void *) = 0;
+};
+
+
+/**
+ * A WorkerQueue.
+ *
+ * 0) Extend overriding Process
+ * 1) Create an instance
+ * 2) Call Run.
+ * 3) Call Add, passing a pointer which is added to a queue
+ * 4) Process will be called with a pointer as work can be done.
+ */
+class WorkerQueue {
+ private:
+ friend class WorkerQueueThread;
+
+ std::queue<void *> q_;
+
+ class WorkerQueueThread *wqt_;
+
+ public:
+ WorkerQueue();
+
+ virtual ~WorkerQueue();
+
+ int Run();
+
+ void Stop();
+
+ void Add(void *p);
+
+ virtual void Process(void *) = 0;
+};
+
+extern void testWorker();
+
+#endif // MOCK_RIL_WORKER_H_
diff --git a/mock-ril/worker_v8.cpp b/mock-ril/worker_v8.cpp
new file mode 100644
index 0000000..b0f4e73
--- /dev/null
+++ b/mock-ril/worker_v8.cpp
@@ -0,0 +1,201 @@
+/**
+ * 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.
+ */
+
+#include <queue>
+#include <v8.h>
+
+#include "logging.h"
+#include "js_support.h"
+#include "node_object_wrap.h"
+#include "node_util.h"
+#include "util.h"
+#include "worker.h"
+
+#include "worker_v8.h"
+
+
+//#define WORKER_V8_V8_DEBUG
+#ifdef WORKER_V8_V8_DEBUG
+
+#define DBG(...) LOGD(__VA_ARGS__)
+
+#else
+
+#define DBG(...)
+
+#endif
+
+v8::Persistent<v8::FunctionTemplate> WorkerV8Template;
+
+class WorkerV8 : public ObjectWrap {
+ private:
+ friend class Handler;
+
+
+ struct ArgInfo {
+ v8::Persistent<v8::Object> js_this;
+ v8::Persistent<v8::Value> value;
+ };
+
+ pthread_mutex_t ai_free_list_mutex_;
+ std::queue<ArgInfo *> ai_free_list_;
+
+ ArgInfo *ObtainArgInfo() {
+ ArgInfo *ai;
+ pthread_mutex_lock(&ai_free_list_mutex_);
+ if (ai_free_list_.size() == 0) {
+ ai = new ArgInfo();
+ } else {
+ ai = ai_free_list_.front();
+ ai_free_list_.pop();
+ }
+ pthread_mutex_unlock(&ai_free_list_mutex_);
+ return ai;
+ }
+
+ void ReleaseArgInfo(ArgInfo *ai) {
+ pthread_mutex_lock(&ai_free_list_mutex_);
+ ai_free_list_.push(ai);
+ pthread_mutex_unlock(&ai_free_list_mutex_);
+ }
+
+ class Handler : public WorkerQueue {
+ private:
+ v8::Persistent<v8::Value> functionValue_;
+ WorkerV8 *worker_;
+
+ public:
+ Handler(WorkerV8 *worker, v8::Handle<v8::Value> value)
+ : worker_(worker) {
+ functionValue_ = v8::Persistent<v8::Value>::New(value);
+ }
+
+ void Process(void *param) {
+ DBG("Handler::Process: E");
+
+ v8::Locker locker;
+ v8::HandleScope handle_scope;
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ ArgInfo *ai = (ArgInfo*)param;
+ v8::Handle<v8::Value> args(ai->value);
+ v8::Function::Cast(*functionValue_)->Call(ai->js_this, 1, &args);
+
+ ai->js_this.Dispose();
+ ai->value.Dispose();
+
+ worker_->ReleaseArgInfo(ai);
+
+ DBG("Handler::Process: X");
+ }
+ };
+
+ Handler *handler_;
+
+ public:
+ WorkerV8(v8::Handle<v8::Object> self, v8::Handle<v8::Value> functionValue) {
+ DBG("WorkerV8::WorkerV8 E:");
+ pthread_mutex_init(&ai_free_list_mutex_, NULL);
+ handler_ = new Handler(this, functionValue);
+ Wrap(self);
+ DBG("WorkerV8::WorkerV8 X: this=%p handler_=%p", this, handler_);
+ }
+
+ virtual ~WorkerV8() {
+ DBG("~WorkerV8::WorkerV8 E:");
+ DBG("~WorkerV8::WorkerV8 X:");
+ }
+
+ static v8::Handle<v8::Value> Run(const v8::Arguments& args) {
+ WorkerV8 *workerV8 = ObjectWrap::Unwrap<WorkerV8>(args.This());
+ DBG("WorkerV8::Run(args) E:");
+ workerV8->handler_->Run();
+ DBG("WorkerV8::Run(args) X:");
+ return v8::Undefined();
+ }
+
+ static v8::Handle<v8::Value> Add(const v8::Arguments& args) {
+ DBG("WorkerV8::Add(args) E:");
+ WorkerV8 *workerV8 = ObjectWrap::Unwrap<WorkerV8>(args.This());
+
+ // Validate one argument to add
+ if (args.Length() != 1) {
+ DBG("WorkerV8::Add(args) X: expecting one param");
+ return v8::ThrowException(v8::String::New("Add has no parameter"));
+ }
+ ArgInfo *ai = workerV8->ObtainArgInfo();
+ ai->js_this = v8::Persistent<v8::Object>::New( args.This() );
+ ai->value = v8::Persistent<v8::Value>::New( args[0] );
+
+ workerV8->handler_->Add(ai);
+ DBG("WorkerV8::Add(args) X:");
+ return v8::Undefined();
+ }
+
+ static v8::Handle<v8::Value> NewWorkerV8(const v8::Arguments& args) {
+ DBG("WorkerV8::NewWorkerV8 E: args.Length()=%d", args.Length());
+ WorkerV8 *worker = new WorkerV8(args.This(), args[0]);
+ DBG("WorkerV8::NewWorkerV8 X:");
+ return worker->handle_;
+ }
+};
+
+void WorkerV8Init() {
+ DBG("WorkerV8Init E:");
+ v8::HandleScope handle_scope;
+
+ WorkerV8Template = v8::Persistent<v8::FunctionTemplate>::New(
+ v8::FunctionTemplate::New(WorkerV8::NewWorkerV8));
+ WorkerV8Template->SetClassName(v8::String::New("Worker"));
+ // native self (Field 0 is handle_) field count is at least 1
+ WorkerV8Template->InstanceTemplate()->SetInternalFieldCount(1);
+
+ // Set prototype methods
+ SET_PROTOTYPE_METHOD(WorkerV8Template, "run", WorkerV8::Run);
+ SET_PROTOTYPE_METHOD(WorkerV8Template, "add", WorkerV8::Add);
+
+ DBG("WorkerV8Init X:");
+}
+
+void testWorkerV8(v8::Handle<v8::Context> context) {
+ LOGD("testWorkerV8 E: ********");
+ v8::HandleScope handle_scope;
+
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ LOGD("testWorkerV8 runJs");
+ runJs(context, &try_catch, "local-string",
+ "var w1 = new Worker(function (msg) {"
+ " print('w1: ' + msg);\n"
+ "});\n"
+ "w1.run();\n"
+ "var w2 = new Worker(function (msg) {"
+ " print('w2: ' + msg);\n"
+ "});\n"
+ "w2.run();\n"
+ "w2.add('one');\n"
+ "w1.add('two');\n"
+ );
+ LOGD("testWorkerV8 X: ********");
+}
+
+extern void WorkerV8ObjectTemplateInit(v8::Handle<v8::ObjectTemplate> target) {
+ DBG("WorkerV8ObjectTemplateInit(target) E:");
+ target->Set(v8::String::New("Worker"), WorkerV8Template);
+ DBG("WorkerV8ObjectTemplateInit(target) X:\n");
+}
diff --git a/mock-ril/worker_v8.h b/mock-ril/worker_v8.h
new file mode 100644
index 0000000..7c9bb88
--- /dev/null
+++ b/mock-ril/worker_v8.h
@@ -0,0 +1,30 @@
+/**
+ * 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.
+ */
+
+#ifndef MOCK_RIL_WORKER_V8_H_
+#define MOCK_RIL_WORKER_V8_H_
+
+#include <v8.h>
+
+// Initialize this module
+extern void WorkerV8Init();
+
+// Add Worker to the object template
+extern void WorkerV8ObjectTemplateInit(v8::Handle<v8::ObjectTemplate> target);
+
+extern void testWorkerV8(v8::Handle<v8::Context> context);
+
+#endif // MOCK_RIL_WORKER_V8_H_