OSDN Git Service

Add a java library and change so the message header is a protobuf.
authorWink Saville <wink@google.com>
Tue, 27 Jul 2010 00:00:34 +0000 (17:00 -0700)
committerWink Saville <wink@google.com>
Tue, 27 Jul 2010 00:00:34 +0000 (17:00 -0700)
Change-Id: Ie41b671089dce1081b2e535351d15aed7af2382f

26 files changed:
mock-ril/Android.mk
mock-ril/Makefile
mock-ril/com/android/internal/communication/Msg.java [new file with mode: 0644]
mock-ril/com/android/internal/communication/MsgHeader.java [new file with mode: 0644]
mock-ril/com/android/internal/telephony/RilChannel.java [new file with mode: 0644]
mock-ril/com/android/internal/telephony/ril_proto/RilCmds.java [new file with mode: 0644]
mock-ril/com/android/internal/telephony/ril_proto/RilCtrlCmds.java [new file with mode: 0644]
mock-ril/ctrl.desc
mock-ril/ctrl.pb.cpp
mock-ril/ctrl.pb.h
mock-ril/ctrl.proto
mock-ril/ctrl_pb2.py
mock-ril/ctrl_server.cpp
mock-ril/ctrl_server.h
mock-ril/mock_ril.js
mock-ril/msgheader.desc [new file with mode: 0644]
mock-ril/msgheader.pb.cc [new file with mode: 0644]
mock-ril/msgheader.pb.cpp [new file with mode: 0644]
mock-ril/msgheader.pb.h [new file with mode: 0644]
mock-ril/msgheader.proto [new file with mode: 0644]
mock-ril/msgheader_pb2.py [new file with mode: 0644]
mock-ril/ril.desc
mock-ril/ril.pb.cpp
mock-ril/ril.proto
mock-ril/ril_pb2.py
mock-ril/tcs.py

index a3c0b2a..dc0ddf9 100644 (file)
@@ -14,6 +14,7 @@ LOCAL_SRC_FILES:= \
     ctrl_server.cpp \
     experiments.cpp \
     js_support.cpp \
+    msgheader.pb.cpp \
     mock_ril.cpp \
     node_buffer.cpp \
     node_util.cpp \
@@ -58,6 +59,19 @@ LOCAL_MODULE:= libmock_ril
 
 include $(BUILD_SHARED_LIBRARY)
 
+# Java librilproto
+# =======================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := librilproto-java
+
+LOCAL_STATIC_JAVA_LIBRARIES := libprotobuf-java-2.3.0-micro
+
+LOCAL_SRC_FILES := $(call all-java-files-under, com)
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+# =======================================================
+
 endif
 
 endif
index 792850d..a7456f9 100644 (file)
@@ -1,19 +1,61 @@
-# A Makefile to run protoc and also allow testing.
+# This has various targets to assist in developing
+# and testing the mock ril. The default "all" target
+# invokes protoc to generate the appropriate protobuf
+# code. The other targest are used for testing.
+
+# Assume this Makefile is run in place then top
+# point to the top of the android source tree
+top=../../../
+
+# A Makefile to run protoc and simplify 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
+all : msgheader.pb.cpp msgheader.pb.h msgheader.desc msgheader_pb2.py com/android/internal/communication/MsgHeader.java \
+       ril.pb.cpp ril.pb.h ril.desc ril_pb2.py com/android/internal/telephony/ril_proto/RilCmds.java \
+       ctrl.pb.cpp ctrl.pb.h ctrl.desc ctrl_pb2.py com/android/internal/telephony/ril_proto/RilCtrlCmds.java
+option java_package='com.android.internal.ril_proto';
+
+# TODO: Document/cleanup these testing targets as we learn whats needed.
+
+# Make the unit tests
+.PHONY : ut
+ut :
+       source $(top)build/envsetup.sh ; mmm $(top)frameworks/base/telephony/tests/telephonytests
+       adb install -r $(top)out/target/product/passion/data/app/FrameworksTelephonyTests.apk
+
+# Run protoc to create the c++ files for msgheader
+msgheader.pb.cpp pmsgheader.pb.h : msgheader.proto
+       protoc --cpp_out=. $<
+       mv msgheader.pb.cc msgheader.pb.cpp
+
+# Run protoc to create the python files for msgheader
+msgheader.desc : msgheader.proto
+       protoc --cpp_out=. $<
+       protoc --descriptor_set_out=$@ --include_imports $<
+
+# Run protoc to create the pyhton files for msgheader
+msgheader_pb2.py : msgheader.proto
+       protoc --python_out=. $<
+
+# Run protoc to create the java files for ril
+com/android/internal/communication/MsgHeader.java : msgheader.proto
+       protoc --javamicro_out=. $<
 
 # 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 ril descriptor file for ril
+ril.desc : ril.proto
+       protoc --descriptor_set_out=$@ --include_imports $<
+
 # 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 java files for ril
+com/android/internal/telephony/ril_proto/RilCmds.java : ril.proto
+       protoc --javamicro_out=. $<
 
 # Run protoc to create the c++ files for control
 ctrl.pb.cpp ctrl.pb.h : ctrl.proto
@@ -28,49 +70,79 @@ ctrl_pb2.py : ctrl.proto
 ctrl.desc : ctrl.proto
        protoc --descriptor_set_out=$@ --include_imports $<
 
+# Run protoc to create the java files for ril
+com/android/internal/telephony/ril_proto/RilCtrlCmds.java : ctrl.proto
+       protoc --javamicro_out=. $<
+
 # 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
+first : root_remount copy_all forward
 
-.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/
+# copy js and descriptors, restart rild and run mockril_tests
+.PHONY : tmr
+tmr : copy_js_desc restart_rild mockril_tests
+
+# Copy all files, restart rild and run mockril_tests
+.PHONY : test
+test : copy_all restart_rild install_mockril_tests mockril_tests
+
+# Restart rild
+.PHONY : restart_rild
+restart_rild :
        adb shell ps | awk '/rild/ { print $$2 }' | xargs adb shell kill
 
+# Update only the js/copy and restart rild
+.PHONY : tjs
+tjs : copy_js_desc restart_rild
+
+# Run test control server python script
 .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
+# Run the mock ril tests (use adb shell pm list instrumentation to see the Runner)
+.PHONY : mockril_tests
+mockril_tests :
+       adb  shell am instrument -e class 'com.android.internal.telephony.mockril.MockRilTest' -w com.android.frameworks.telephonytests/.TelephonyMockRilTestRunner
+
+# forward the control server tcp port (54312) to a port on the PC side (11111)
+.PHONY : forward
+forward :
+       adb forward tcp:11111 tcp:54312
+
+# change to root and remount device
+.PHONY : root_remount
+root_remount :
+       adb root ; sleep 3 ; adb remount ; adb shell setprop rild.libpath /data/lib/libmock_ril.so
+
+# Copy all files
+.PHONY : copy_all
+copy_all : copy_js_desc copy_mockril
 
-# Push a new libmock_ril.so and kill rild to run a test
-.PHONY : mockriltest
-mockriltest :
+# Copy js and the protobuf descriptor files
+.PHONY : copy_js_desc
+copy_js_desc :
        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
+       adb forward tcp:11111 tcp:54312
+
+# Copy the mock ril library
+.PHONY : copy_mockril
+copy_mockril :
+       adb push $(top)out/target/product/passion/system/lib/libmock_ril.so /data/lib/
+
+.PHONY : install_mockril_tests
+install_mockril_tests :
+       adb install -r $(top)out/target/product/passion/data/app/FrameworksTelephonyTests.apk
 
 # 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
+       rm -f ril.pb.cpp ril.pb.h ril.desc ril_pb2.py
+       rm -f com/android/internal/telephony/ril_proto/RilCmds.java
+       rm -f ctrl.pb.cpp ctrl.pb.h ctrl.desc ctrl_pb2.py
+       rm -f com/android/internal/telephony/ril_proto/RilCtrlCmds.java
+       rm -f msgheader.pb.cpp msgheader.pb.h msgheader.desc msgheader_pb2.py
+       rm -f com/android/internal/communication/MsgHeader.java
diff --git a/mock-ril/com/android/internal/communication/Msg.java b/mock-ril/com/android/internal/communication/Msg.java
new file mode 100644 (file)
index 0000000..6046fe7
--- /dev/null
@@ -0,0 +1,336 @@
+/*
+ * 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.
+ */
+
+package com.android.internal.communication;
+
+import android.util.Log;
+
+import com.android.internal.communication.MsgHeader;
+import com.android.internal.telephony.RilChannel;
+import com.google.protobuf.micro.InvalidProtocolBufferMicroException;
+import com.google.protobuf.micro.MessageMicro;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * A message
+ */
+public class Msg {
+    private MsgHeader  mHeader;
+    private ByteBuffer mData;
+
+    /**
+     * Send a message header
+     *
+     * @param mh is message header to write
+     * @throws IOException
+     */
+    private static void sendHeader(RilChannel rc, MsgHeader mh) throws IOException {
+        ByteBuffer lenBuffer = ByteBuffer.allocateDirect(4);
+        lenBuffer.order(ByteOrder.LITTLE_ENDIAN);
+        lenBuffer.putInt(mh.getSerializedSize());
+
+        ByteBuffer mhBuffer = ByteBuffer.allocateDirect(mh.getCachedSize());
+        mhBuffer.put(mh.toByteArray());
+
+        rc.rewindSendAll(lenBuffer);
+        rc.rewindSendAll(mhBuffer);
+    }
+
+    /**
+     * Read a message header
+     *
+     * @returns message header
+     * @throws IOException
+     */
+    private static MsgHeader recvHeader(RilChannel rc) throws IOException {
+        ByteBuffer lenBuffer = ByteBuffer.allocate(4);
+        lenBuffer.order(ByteOrder.LITTLE_ENDIAN);
+        int lenRead = rc.recvAllRewind(lenBuffer);
+        int lenHeader = lenBuffer.getInt();
+
+        ByteBuffer mhBuffer = ByteBuffer.allocate(lenHeader);
+        lenRead = rc.recvAllRewind(mhBuffer);
+        MsgHeader mh = MsgHeader.parseFrom(mhBuffer.array());
+        return mh;
+    }
+
+    /**
+     * Msg Constructor
+     */
+    private Msg() {
+    }
+
+    /**
+     * Get a message
+     */
+    public static Msg obtain() {
+        // TODO: Get from a free list
+        return new Msg();
+    }
+
+    /**
+     * Release a message
+     */
+    public void release() {
+        // TODO: place back on free list
+    }
+
+    /**
+     * Send a message header followed by the data if present
+     *
+     * The length data field will be filled in as appropriate
+     * @param mh header
+     * @param data if not null and length > 0 sent after header
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, MsgHeader mh, ByteBuffer data)
+            throws IOException {
+        int lenData;
+
+        if (data == null) {
+            lenData = 0;
+        } else {
+            data.rewind();
+            lenData = data.remaining();
+        }
+        mh.setLengthData(lenData);
+        sendHeader(rc, mh);
+        if (lenData > 0) {
+            rc.sendAll(data);
+        }
+    }
+
+    /**
+     * Send a message with cmd, token, status followed by the data.
+     *
+     * The length data field will be filled in as appropriate
+     * @param cmd for the header
+     * @param token for the header
+     * @param status for the header
+     * @param pb is the protobuf to send
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, int cmd, long token, int status, MessageMicro pb)
+            throws IOException {
+        MsgHeader mh = new MsgHeader();
+        mh.setCmd(cmd);
+        mh.setToken(token);
+        mh.setStatus(status);
+
+        ByteBuffer data;
+        if (pb != null) {
+            data = ByteBuffer.wrap(pb.toByteArray());
+        } else {
+            data = null;
+        }
+        send(rc, mh, data);
+    }
+
+    /**
+     * Send a message with cmd, token, status followed by the data.
+     *
+     * The length data field will be filled in as appropriate
+     * @param cmd for the header
+     * @param token for the header
+     * @param pb is the protobuf to send
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, int cmd, long token, MessageMicro pb)
+            throws IOException {
+        send(rc, cmd, token, 0, pb);
+    }
+
+    /**
+     * Send a message with cmd followed by the data.
+     *
+     * The length data field will be filled in as appropriate
+     * @param cmd for the header
+     * @param pb is the protobuf to send
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, int cmd, MessageMicro pb) throws IOException {
+        send(rc, cmd, 0, 0, pb);
+    }
+
+    /**
+     * Send a message with cmd, token and status but no data
+     *
+     * The length data field will be filled in as appropriate
+     * @param cmd for the header
+     * @param token for the header
+     * @param status for the header
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, int cmd, long token, int status)
+            throws IOException {
+        send(rc, cmd, token, status, null);
+    }
+
+    /**
+     * Send a message with cmd and token but no data
+     *
+     * The length data field will be filled in as appropriate
+     * @param cmd for the header
+     * @param token for the header
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, int cmd, long token) throws IOException {
+        send(rc, cmd, token, 0, null);
+    }
+
+    /**
+     * Send a message with cmd but no data
+     *
+     * The length data field will be filled in as appropriate
+     * @param cmd for the header
+     * @throws IOException
+     */
+    public static final void send(RilChannel rc, int cmd) throws IOException {
+        send(rc, cmd, 0, 0, null);
+    }
+
+    /**
+     * Read a message
+     *
+     * @return Msg
+     * @throws IOException
+     */
+    public static final Msg recv(RilChannel rc) throws IOException {
+        Msg msg = Msg.obtain();
+        msg.read(rc);
+        return msg;
+    }
+
+    /**
+     * Read a message header and data.
+     *
+     * @throws IOException
+     */
+    public void read(RilChannel rc) throws IOException {
+        mHeader = recvHeader(rc);
+        if (mHeader.getLengthData() > 0) {
+            ByteBuffer bb = ByteBuffer.allocate(mHeader.getLengthData());
+            rc.recvAllRewind(bb);
+            mData = bb;
+        }
+    }
+
+    /**
+     * Print the message header.
+     *
+     * @param tag for the header
+     */
+    public void printHeader(String tag) {
+        Log.d(tag, " cmd=" + mHeader.getCmd() + " token=" + mHeader.getToken() + " status="
+                        + mHeader.getStatus() + " lengthData=" + mHeader.getLengthData());
+    }
+
+    /**
+     * Set data (for testing purposes only).
+     */
+    public void setData(ByteBuffer data) {
+        mData = data;
+    }
+
+    /**
+     * Set header (for testing purposes only).
+     */
+    public void setHeader(MsgHeader header) {
+        mHeader = header;
+    }
+
+    /**
+     * @return cmd
+     */
+    public int getCmd() {
+        return mHeader.getCmd();
+    }
+
+    /**
+     * @return token
+     */
+    public long getToken() {
+        return mHeader.getToken();
+    }
+
+    /**
+     * @return status
+     */
+    public int getStatus() {
+        return mHeader.getStatus();
+    }
+
+    /**
+     * @return data ByteBuffer
+     */
+    public ByteBuffer getData() {
+        return mData;
+    }
+
+    /**
+     * @return data at index
+     */
+    public byte getData(int index) {
+        return mData.get(index);
+    }
+
+    /**
+     * Return data as a Class<T>.
+     *
+     * @param <T> a class that extends MessageMicro.
+     * @param c the T.class to create from the data.
+     * @param data is the MessageMicro protobuf to be converted.
+     * @return null if an error occurs.
+     */
+    @SuppressWarnings("unchecked")
+    public static final <T extends MessageMicro> T getAs(Class<T> c, byte[] data) {
+        Object o = null;
+        if ((data != null) && (data.length > 0)) {
+            try {
+                o = c.newInstance().mergeFrom(data);
+            } catch (InvalidProtocolBufferMicroException e) {
+                e.printStackTrace();
+            } catch (InstantiationException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return (T)o;
+    }
+
+    /**
+     * Return data as a Class<T>.
+     *
+     * @param <T> a class that extends MessageMicro.
+     * @param c the T.class to create from data.
+     * @return null if an error occurs
+     */
+    @SuppressWarnings("unchecked")
+    public <T extends MessageMicro> T getDataAs(Class<T> c) {
+        Object o;
+
+        if ((mData != null) && (mData.remaining() > 0)) {
+            o = getAs(c, mData.array());
+        } else {
+            o = null;
+        }
+        return (T)o;
+    }
+}
diff --git a/mock-ril/com/android/internal/communication/MsgHeader.java b/mock-ril/com/android/internal/communication/MsgHeader.java
new file mode 100644 (file)
index 0000000..6d756d4
--- /dev/null
@@ -0,0 +1,185 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+
+package com.android.internal.communication;
+
+public  final class MsgHeader extends
+    com.google.protobuf.micro.MessageMicro {
+  public MsgHeader() {}
+  
+  // required uint32 cmd = 1;
+  public static final int CMD_FIELD_NUMBER = 1;
+  private boolean hasCmd;
+  private int cmd_ = 0;
+  public int getCmd() { return cmd_; }
+  public boolean hasCmd() { return hasCmd; }
+  public MsgHeader setCmd(int value) {
+    hasCmd = true;
+    cmd_ = value;
+    return this;
+  }
+  public MsgHeader clearCmd() {
+    hasCmd = false;
+    cmd_ = 0;
+    return this;
+  }
+  
+  // required uint32 length_data = 2;
+  public static final int LENGTH_DATA_FIELD_NUMBER = 2;
+  private boolean hasLengthData;
+  private int lengthData_ = 0;
+  public int getLengthData() { return lengthData_; }
+  public boolean hasLengthData() { return hasLengthData; }
+  public MsgHeader setLengthData(int value) {
+    hasLengthData = true;
+    lengthData_ = value;
+    return this;
+  }
+  public MsgHeader clearLengthData() {
+    hasLengthData = false;
+    lengthData_ = 0;
+    return this;
+  }
+  
+  // optional uint32 status = 3;
+  public static final int STATUS_FIELD_NUMBER = 3;
+  private boolean hasStatus;
+  private int status_ = 0;
+  public int getStatus() { return status_; }
+  public boolean hasStatus() { return hasStatus; }
+  public MsgHeader setStatus(int value) {
+    hasStatus = true;
+    status_ = value;
+    return this;
+  }
+  public MsgHeader clearStatus() {
+    hasStatus = false;
+    status_ = 0;
+    return this;
+  }
+  
+  // optional uint64 token = 4;
+  public static final int TOKEN_FIELD_NUMBER = 4;
+  private boolean hasToken;
+  private long token_ = 0L;
+  public long getToken() { return token_; }
+  public boolean hasToken() { return hasToken; }
+  public MsgHeader setToken(long value) {
+    hasToken = true;
+    token_ = value;
+    return this;
+  }
+  public MsgHeader clearToken() {
+    hasToken = false;
+    token_ = 0L;
+    return this;
+  }
+  
+  public final MsgHeader clear() {
+    clearCmd();
+    clearLengthData();
+    clearStatus();
+    clearToken();
+    cachedSize = -1;
+    return this;
+  }
+  
+  public final boolean isInitialized() {
+    if (!hasCmd) return false;
+    if (!hasLengthData) return false;
+    return true;
+  }
+  
+  public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                      throws java.io.IOException {
+    if (hasCmd()) {
+      output.writeUInt32(1, getCmd());
+    }
+    if (hasLengthData()) {
+      output.writeUInt32(2, getLengthData());
+    }
+    if (hasStatus()) {
+      output.writeUInt32(3, getStatus());
+    }
+    if (hasToken()) {
+      output.writeUInt64(4, getToken());
+    }
+  }
+  
+  private int cachedSize = -1;
+  public int getCachedSize() {
+    if (cachedSize < 0) {
+      // getSerializedSize sets cachedSize
+      getSerializedSize();
+    }
+    return cachedSize;
+  }
+  
+  public int getSerializedSize() {
+    int size = 0;
+    if (hasCmd()) {
+      size += com.google.protobuf.micro.CodedOutputStreamMicro
+        .computeUInt32Size(1, getCmd());
+    }
+    if (hasLengthData()) {
+      size += com.google.protobuf.micro.CodedOutputStreamMicro
+        .computeUInt32Size(2, getLengthData());
+    }
+    if (hasStatus()) {
+      size += com.google.protobuf.micro.CodedOutputStreamMicro
+        .computeUInt32Size(3, getStatus());
+    }
+    if (hasToken()) {
+      size += com.google.protobuf.micro.CodedOutputStreamMicro
+        .computeUInt64Size(4, getToken());
+    }
+    cachedSize = size;
+    return size;
+  }
+  
+  public MsgHeader mergeFrom(
+      com.google.protobuf.micro.CodedInputStreamMicro input)
+      throws java.io.IOException {
+    while (true) {
+      int tag = input.readTag();
+      switch (tag) {
+        case 0:
+          return this;
+        default: {
+          if (!parseUnknownField(input, tag)) {
+            return this;
+          }
+          break;
+        }
+        case 8: {
+          setCmd(input.readUInt32());
+          break;
+        }
+        case 16: {
+          setLengthData(input.readUInt32());
+          break;
+        }
+        case 24: {
+          setStatus(input.readUInt32());
+          break;
+        }
+        case 32: {
+          setToken(input.readUInt64());
+          break;
+        }
+      }
+    }
+  }
+  
+  public static MsgHeader parseFrom(byte[] data)
+      throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+    return (MsgHeader) (new MsgHeader().mergeFrom(data));
+  }
+  
+  public static MsgHeader parseFrom(
+          com.google.protobuf.micro.CodedInputStreamMicro input)
+      throws java.io.IOException {
+    return (MsgHeader) (new MsgHeader().mergeFrom(input));
+  }
+  
+}
+
diff --git a/mock-ril/com/android/internal/telephony/RilChannel.java b/mock-ril/com/android/internal/telephony/RilChannel.java
new file mode 100644 (file)
index 0000000..abe32c7
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+package com.android.internal.telephony;
+
+import android.util.Log;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.channels.SocketChannel;
+import java.nio.ByteBuffer;
+
+public class RilChannel {
+    private static final boolean DBG = false;
+
+    private static final String MOCKRIL_ADDR_STR = "127.0.0.1";
+    private static final int MOCKRIL_PORT = 54312;
+    private SocketChannel mChannel = null;
+
+    /**
+     * Constructor
+     */
+    private RilChannel() {
+        if (DBG) log("ctor EX");
+    }
+
+    /**
+     * Open the channel
+     *
+     * @throws IOException
+     */
+    private void open() throws IOException {
+        InetSocketAddress mockRilAddr = new InetSocketAddress(MOCKRIL_ADDR_STR, MOCKRIL_PORT);
+        mChannel= SocketChannel.open(mockRilAddr);
+    }
+
+    /**
+     * Make the channel
+     *
+     * @return the channel
+     * @throws IOException
+     */
+    public static RilChannel makeRilChannel() throws IOException {
+        if (DBG) log("makeMockRilChannel E");
+        RilChannel sm = new RilChannel();
+        sm.open();
+        if (DBG) log("makeMockRilChannel X");
+        return sm;
+    }
+
+    /**
+     * Close an open channel
+     */
+    public void close() {
+        try {
+            if (mChannel != null) {
+                mChannel.close();
+                if (DBG) log("DefaultState.enter closed socket");
+            }
+        } catch (IOException e) {
+            log("Could not close conection to mock-ril");
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @return the channel
+     */
+    public SocketChannel getChannel() {
+        return mChannel;
+    }
+
+    /**
+     * write the bb contents to sc
+     *
+     * @param bb is the ByteBuffer to write
+     * @return number of bytes written
+     * @throws IOException
+     */
+    public final int sendAll(ByteBuffer bb) throws IOException {
+        int count = 0;
+        while (bb.remaining() != 0) {
+            count += mChannel.write(bb);
+        }
+        return count;
+    }
+
+    /**
+     * read from sc until bb is filled then rewind bb
+     *
+     * @param bb is the ByteBuffer to fill
+     * @return number of bytes read
+     * @throws IOException
+     */
+    public final int recvAll(ByteBuffer bb) throws IOException {
+        int count = 0;
+        while (bb.remaining() != 0) {
+            count += mChannel.read(bb);
+        }
+        return count;
+    }
+
+    /**
+     * Rewind bb then write the contents to sc
+     *
+     * @param bb is the ByteBuffer to write
+     * @return number of bytes written
+     * @throws IOException
+     */
+    public final int rewindSendAll(ByteBuffer bb) throws IOException {
+        bb.rewind();
+        return sendAll(bb);
+    }
+
+    /**
+     * read from sc until bb is filled then rewind bb
+     *
+     * @param bb is the ByteBuffer to fill
+     * @return number of bytes read
+     * @throws IOException
+     */
+    public final int recvAllRewind(ByteBuffer bb) throws IOException {
+        int count = recvAll(bb);
+        bb.rewind();
+        return count;
+    }
+
+    /**
+     * Write to log.
+     *
+     * @param s
+     */
+    static void log(String s) {
+        Log.v("MockRilChannel", s);
+    }
+}
diff --git a/mock-ril/com/android/internal/telephony/ril_proto/RilCmds.java b/mock-ril/com/android/internal/telephony/ril_proto/RilCmds.java
new file mode 100644 (file)
index 0000000..b5f385c
--- /dev/null
@@ -0,0 +1,1163 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+
+package com.android.internal.telephony.ril_proto;
+
+public final class RilCmds {
+  private RilCmds() {}
+  // enum RilCommand
+  public static final int CMD_GET_SIM_STATUS = 1;
+  public static final int CMD_ENTER_SIM_PIN = 2;
+  public static final int CMD_HANGUP = 12;
+  public static final int CMD_SCREEN_STATE = 61;
+  
+  // enum RadioState
+  public static final int RADIO_STATE_OFF = 0;
+  public static final int RADIO_STATE_UNAVAILABLE = 1;
+  public static final int RADIO_STATE_SIM_NOT_READY = 2;
+  public static final int RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3;
+  public static final int RADIO_STATE_SIM_READY = 4;
+  public static final int RADIO_STATE_RUIM_NOT_READY = 5;
+  public static final int RADIO_STATE_RUIM_READY = 6;
+  public static final int RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7;
+  public static final int RADIO_STATE_NV_NOT_READY = 8;
+  public static final int RADIO_STATE_NV_READY = 9;
+  
+  // enum RilCardState
+  public static final int CARDSTATE_ABSENT = 0;
+  public static final int CARDSTATE_PRESENT = 1;
+  public static final int CARDSTATE_ERROR = 2;
+  
+  // enum RilPersoSubstate
+  public static final int PERSOSUBSTATE_UNKNOWN = 0;
+  public static final int PERSOSUBSTATE_IN_PROGRESS = 1;
+  public static final int PERSOSUBSTATE_READY = 2;
+  public static final int PERSOSUBSTATE_SIM_NETWORK = 3;
+  public static final int PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4;
+  public static final int PERSOSUBSTATE_SIM_CORPORATE = 5;
+  public static final int PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6;
+  public static final int PERSOSUBSTATE_SIM_SIM = 7;
+  public static final int PERSOSUBSTATE_SIM_NETWORK_PUK = 8;
+  public static final int PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9;
+  public static final int PERSOSUBSTATE_SIM_CORPORATE_PUK = 10;
+  public static final int PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11;
+  public static final int PERSOSUBSTATE_SIM_SIM_PUK = 12;
+  public static final int PERSOSUBSTATE_RUIM_NETWORK1 = 13;
+  public static final int PERSOSUBSTATE_RUIM_NETWORK2 = 14;
+  public static final int PERSOSUBSTATE_RUIM_HRPD = 15;
+  public static final int PERSOSUBSTATE_RUIM_CORPORATE = 16;
+  public static final int PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17;
+  public static final int PERSOSUBSTATE_RUIM_RUIM = 18;
+  public static final int PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19;
+  public static final int PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20;
+  public static final int PERSOSUBSTATE_RUIM_HRPD_PUK = 21;
+  public static final int PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22;
+  public static final int PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23;
+  public static final int PERSOSUBSTATE_RUIM_RUIM_PUK = 24;
+  
+  // enum RilAppState
+  public static final int APPSTATE_UNKNOWN = 0;
+  public static final int APPSTATE_DETECTED = 1;
+  public static final int APPSTATE_PIN = 2;
+  public static final int APPSTATE_PUK = 3;
+  public static final int APPSTATE_SUBSCRIPTION_PERSO = 4;
+  public static final int APPSTATE_READY = 5;
+  
+  // enum RilPinState
+  public static final int PINSTATE_UNKNOWN = 0;
+  public static final int PINSTATE_ENABLED_NOT_VERIFIED = 1;
+  public static final int PINSTATE_ENABLED_VERIFIED = 2;
+  public static final int PINSTATE_DISABLED = 3;
+  public static final int PINSTATE_ENABLED_BLOCKED = 4;
+  public static final int PINSTATE_ENABLED_PERM_BLOCKED = 5;
+  
+  // enum RilAppType
+  public static final int APPTYPE_UNKNOWN = 0;
+  public static final int APPTYPE_SIM = 1;
+  public static final int APPTYPE_USIM = 2;
+  public static final int APPTYPE_RUIM = 3;
+  public static final int APPTYPE_CSIM = 4;
+  
+  public static final class RilAppStatus extends
+      com.google.protobuf.micro.MessageMicro {
+    public RilAppStatus() {}
+    
+    // optional .ril_proto.RilAppType app_type = 1;
+    public static final int APP_TYPE_FIELD_NUMBER = 1;
+    private boolean hasAppType;
+    private int appType_ = com.android.internal.telephony.ril_proto.RilCmds.APPTYPE_UNKNOWN;
+    public boolean hasAppType() { return hasAppType; }
+    public int getAppType() { return appType_; }
+    public RilAppStatus setAppType(int value) {
+      hasAppType = true;
+      appType_ = value;
+      return this;
+    }
+    public RilAppStatus clearAppType() {
+      hasAppType = false;
+      appType_ = com.android.internal.telephony.ril_proto.RilCmds.APPTYPE_UNKNOWN;
+      return this;
+    }
+    
+    // optional .ril_proto.RilAppState app_state = 2;
+    public static final int APP_STATE_FIELD_NUMBER = 2;
+    private boolean hasAppState;
+    private int appState_ = com.android.internal.telephony.ril_proto.RilCmds.APPSTATE_UNKNOWN;
+    public boolean hasAppState() { return hasAppState; }
+    public int getAppState() { return appState_; }
+    public RilAppStatus setAppState(int value) {
+      hasAppState = true;
+      appState_ = value;
+      return this;
+    }
+    public RilAppStatus clearAppState() {
+      hasAppState = false;
+      appState_ = com.android.internal.telephony.ril_proto.RilCmds.APPSTATE_UNKNOWN;
+      return this;
+    }
+    
+    // optional .ril_proto.RilPersoSubstate perso_substate = 3;
+    public static final int PERSO_SUBSTATE_FIELD_NUMBER = 3;
+    private boolean hasPersoSubstate;
+    private int persoSubstate_ = com.android.internal.telephony.ril_proto.RilCmds.PERSOSUBSTATE_UNKNOWN;
+    public boolean hasPersoSubstate() { return hasPersoSubstate; }
+    public int getPersoSubstate() { return persoSubstate_; }
+    public RilAppStatus setPersoSubstate(int value) {
+      hasPersoSubstate = true;
+      persoSubstate_ = value;
+      return this;
+    }
+    public RilAppStatus clearPersoSubstate() {
+      hasPersoSubstate = false;
+      persoSubstate_ = com.android.internal.telephony.ril_proto.RilCmds.PERSOSUBSTATE_UNKNOWN;
+      return this;
+    }
+    
+    // optional string aid = 4;
+    public static final int AID_FIELD_NUMBER = 4;
+    private boolean hasAid;
+    private java.lang.String aid_ = "";
+    public java.lang.String getAid() { return aid_; }
+    public boolean hasAid() { return hasAid; }
+    public RilAppStatus setAid(java.lang.String value) {
+      hasAid = true;
+      aid_ = value;
+      return this;
+    }
+    public RilAppStatus clearAid() {
+      hasAid = false;
+      aid_ = "";
+      return this;
+    }
+    
+    // optional string app_label = 5;
+    public static final int APP_LABEL_FIELD_NUMBER = 5;
+    private boolean hasAppLabel;
+    private java.lang.String appLabel_ = "";
+    public java.lang.String getAppLabel() { return appLabel_; }
+    public boolean hasAppLabel() { return hasAppLabel; }
+    public RilAppStatus setAppLabel(java.lang.String value) {
+      hasAppLabel = true;
+      appLabel_ = value;
+      return this;
+    }
+    public RilAppStatus clearAppLabel() {
+      hasAppLabel = false;
+      appLabel_ = "";
+      return this;
+    }
+    
+    // optional int32 pin1_replaced = 6;
+    public static final int PIN1_REPLACED_FIELD_NUMBER = 6;
+    private boolean hasPin1Replaced;
+    private int pin1Replaced_ = 0;
+    public int getPin1Replaced() { return pin1Replaced_; }
+    public boolean hasPin1Replaced() { return hasPin1Replaced; }
+    public RilAppStatus setPin1Replaced(int value) {
+      hasPin1Replaced = true;
+      pin1Replaced_ = value;
+      return this;
+    }
+    public RilAppStatus clearPin1Replaced() {
+      hasPin1Replaced = false;
+      pin1Replaced_ = 0;
+      return this;
+    }
+    
+    // optional .ril_proto.RilPinState pin1 = 7;
+    public static final int PIN1_FIELD_NUMBER = 7;
+    private boolean hasPin1;
+    private int pin1_ = com.android.internal.telephony.ril_proto.RilCmds.PINSTATE_UNKNOWN;
+    public boolean hasPin1() { return hasPin1; }
+    public int getPin1() { return pin1_; }
+    public RilAppStatus setPin1(int value) {
+      hasPin1 = true;
+      pin1_ = value;
+      return this;
+    }
+    public RilAppStatus clearPin1() {
+      hasPin1 = false;
+      pin1_ = com.android.internal.telephony.ril_proto.RilCmds.PINSTATE_UNKNOWN;
+      return this;
+    }
+    
+    // optional .ril_proto.RilPinState pin2 = 8;
+    public static final int PIN2_FIELD_NUMBER = 8;
+    private boolean hasPin2;
+    private int pin2_ = com.android.internal.telephony.ril_proto.RilCmds.PINSTATE_UNKNOWN;
+    public boolean hasPin2() { return hasPin2; }
+    public int getPin2() { return pin2_; }
+    public RilAppStatus setPin2(int value) {
+      hasPin2 = true;
+      pin2_ = value;
+      return this;
+    }
+    public RilAppStatus clearPin2() {
+      hasPin2 = false;
+      pin2_ = com.android.internal.telephony.ril_proto.RilCmds.PINSTATE_UNKNOWN;
+      return this;
+    }
+    
+    public final RilAppStatus clear() {
+      clearAppType();
+      clearAppState();
+      clearPersoSubstate();
+      clearAid();
+      clearAppLabel();
+      clearPin1Replaced();
+      clearPin1();
+      clearPin2();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasAppType()) {
+        output.writeInt32(1, getAppType());
+      }
+      if (hasAppState()) {
+        output.writeInt32(2, getAppState());
+      }
+      if (hasPersoSubstate()) {
+        output.writeInt32(3, getPersoSubstate());
+      }
+      if (hasAid()) {
+        output.writeString(4, getAid());
+      }
+      if (hasAppLabel()) {
+        output.writeString(5, getAppLabel());
+      }
+      if (hasPin1Replaced()) {
+        output.writeInt32(6, getPin1Replaced());
+      }
+      if (hasPin1()) {
+        output.writeInt32(7, getPin1());
+      }
+      if (hasPin2()) {
+        output.writeInt32(8, getPin2());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasAppType()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(1, getAppType());
+      }
+      if (hasAppState()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(2, getAppState());
+      }
+      if (hasPersoSubstate()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(3, getPersoSubstate());
+      }
+      if (hasAid()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeStringSize(4, getAid());
+      }
+      if (hasAppLabel()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeStringSize(5, getAppLabel());
+      }
+      if (hasPin1Replaced()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(6, getPin1Replaced());
+      }
+      if (hasPin1()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(7, getPin1());
+      }
+      if (hasPin2()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(8, getPin2());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public RilAppStatus mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 8: {
+              setAppType(input.readInt32());
+            break;
+          }
+          case 16: {
+              setAppState(input.readInt32());
+            break;
+          }
+          case 24: {
+              setPersoSubstate(input.readInt32());
+            break;
+          }
+          case 34: {
+            setAid(input.readString());
+            break;
+          }
+          case 42: {
+            setAppLabel(input.readString());
+            break;
+          }
+          case 48: {
+            setPin1Replaced(input.readInt32());
+            break;
+          }
+          case 56: {
+              setPin1(input.readInt32());
+            break;
+          }
+          case 64: {
+              setPin2(input.readInt32());
+            break;
+          }
+        }
+      }
+    }
+    
+    public static RilAppStatus parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (RilAppStatus) (new RilAppStatus().mergeFrom(data));
+    }
+    
+    public static RilAppStatus parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (RilAppStatus) (new RilAppStatus().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class RilCardStatus extends
+      com.google.protobuf.micro.MessageMicro {
+    public RilCardStatus() {}
+    
+    // optional .ril_proto.RilCardState card_state = 1;
+    public static final int CARD_STATE_FIELD_NUMBER = 1;
+    private boolean hasCardState;
+    private int cardState_ = com.android.internal.telephony.ril_proto.RilCmds.CARDSTATE_ABSENT;
+    public boolean hasCardState() { return hasCardState; }
+    public int getCardState() { return cardState_; }
+    public RilCardStatus setCardState(int value) {
+      hasCardState = true;
+      cardState_ = value;
+      return this;
+    }
+    public RilCardStatus clearCardState() {
+      hasCardState = false;
+      cardState_ = com.android.internal.telephony.ril_proto.RilCmds.CARDSTATE_ABSENT;
+      return this;
+    }
+    
+    // optional .ril_proto.RilPinState universal_pin_state = 2;
+    public static final int UNIVERSAL_PIN_STATE_FIELD_NUMBER = 2;
+    private boolean hasUniversalPinState;
+    private int universalPinState_ = com.android.internal.telephony.ril_proto.RilCmds.PINSTATE_UNKNOWN;
+    public boolean hasUniversalPinState() { return hasUniversalPinState; }
+    public int getUniversalPinState() { return universalPinState_; }
+    public RilCardStatus setUniversalPinState(int value) {
+      hasUniversalPinState = true;
+      universalPinState_ = value;
+      return this;
+    }
+    public RilCardStatus clearUniversalPinState() {
+      hasUniversalPinState = false;
+      universalPinState_ = com.android.internal.telephony.ril_proto.RilCmds.PINSTATE_UNKNOWN;
+      return this;
+    }
+    
+    // optional int32 gsm_umts_subscription_app_index = 3;
+    public static final int GSM_UMTS_SUBSCRIPTION_APP_INDEX_FIELD_NUMBER = 3;
+    private boolean hasGsmUmtsSubscriptionAppIndex;
+    private int gsmUmtsSubscriptionAppIndex_ = 0;
+    public int getGsmUmtsSubscriptionAppIndex() { return gsmUmtsSubscriptionAppIndex_; }
+    public boolean hasGsmUmtsSubscriptionAppIndex() { return hasGsmUmtsSubscriptionAppIndex; }
+    public RilCardStatus setGsmUmtsSubscriptionAppIndex(int value) {
+      hasGsmUmtsSubscriptionAppIndex = true;
+      gsmUmtsSubscriptionAppIndex_ = value;
+      return this;
+    }
+    public RilCardStatus clearGsmUmtsSubscriptionAppIndex() {
+      hasGsmUmtsSubscriptionAppIndex = false;
+      gsmUmtsSubscriptionAppIndex_ = 0;
+      return this;
+    }
+    
+    // optional int32 cdma_subscription_app_index = 4;
+    public static final int CDMA_SUBSCRIPTION_APP_INDEX_FIELD_NUMBER = 4;
+    private boolean hasCdmaSubscriptionAppIndex;
+    private int cdmaSubscriptionAppIndex_ = 0;
+    public int getCdmaSubscriptionAppIndex() { return cdmaSubscriptionAppIndex_; }
+    public boolean hasCdmaSubscriptionAppIndex() { return hasCdmaSubscriptionAppIndex; }
+    public RilCardStatus setCdmaSubscriptionAppIndex(int value) {
+      hasCdmaSubscriptionAppIndex = true;
+      cdmaSubscriptionAppIndex_ = value;
+      return this;
+    }
+    public RilCardStatus clearCdmaSubscriptionAppIndex() {
+      hasCdmaSubscriptionAppIndex = false;
+      cdmaSubscriptionAppIndex_ = 0;
+      return this;
+    }
+    
+    // optional int32 num_applications = 5;
+    public static final int NUM_APPLICATIONS_FIELD_NUMBER = 5;
+    private boolean hasNumApplications;
+    private int numApplications_ = 0;
+    public int getNumApplications() { return numApplications_; }
+    public boolean hasNumApplications() { return hasNumApplications; }
+    public RilCardStatus setNumApplications(int value) {
+      hasNumApplications = true;
+      numApplications_ = value;
+      return this;
+    }
+    public RilCardStatus clearNumApplications() {
+      hasNumApplications = false;
+      numApplications_ = 0;
+      return this;
+    }
+    
+    // repeated .ril_proto.RilAppStatus applications = 6;
+    public static final int APPLICATIONS_FIELD_NUMBER = 6;
+    private java.util.List<com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus> applications_ =
+      java.util.Collections.emptyList();
+    public java.util.List<com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus> getApplicationsList() {
+      return applications_;
+    }
+    public int getApplicationsCount() { return applications_.size(); }
+    public com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus getApplications(int index) {
+      return applications_.get(index);
+    }
+    public RilCardStatus setApplications(int index, com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus value) {
+      if (value == null) {
+        throw new NullPointerException();
+      }
+      applications_.set(index, value);
+      return this;
+    }
+    public RilCardStatus addApplications(com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus value) {
+      if (value == null) {
+        throw new NullPointerException();
+      }
+      if (applications_.isEmpty()) {
+        applications_ = new java.util.ArrayList<com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus>();
+      }
+      applications_.add(value);
+      return this;
+    }
+    public RilCardStatus clearApplications() {
+      applications_ = java.util.Collections.emptyList();
+      return this;
+    }
+    
+    public final RilCardStatus clear() {
+      clearCardState();
+      clearUniversalPinState();
+      clearGsmUmtsSubscriptionAppIndex();
+      clearCdmaSubscriptionAppIndex();
+      clearNumApplications();
+      clearApplications();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasCardState()) {
+        output.writeInt32(1, getCardState());
+      }
+      if (hasUniversalPinState()) {
+        output.writeInt32(2, getUniversalPinState());
+      }
+      if (hasGsmUmtsSubscriptionAppIndex()) {
+        output.writeInt32(3, getGsmUmtsSubscriptionAppIndex());
+      }
+      if (hasCdmaSubscriptionAppIndex()) {
+        output.writeInt32(4, getCdmaSubscriptionAppIndex());
+      }
+      if (hasNumApplications()) {
+        output.writeInt32(5, getNumApplications());
+      }
+      for (com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus element : getApplicationsList()) {
+        output.writeMessage(6, element);
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasCardState()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(1, getCardState());
+      }
+      if (hasUniversalPinState()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(2, getUniversalPinState());
+      }
+      if (hasGsmUmtsSubscriptionAppIndex()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(3, getGsmUmtsSubscriptionAppIndex());
+      }
+      if (hasCdmaSubscriptionAppIndex()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(4, getCdmaSubscriptionAppIndex());
+      }
+      if (hasNumApplications()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(5, getNumApplications());
+      }
+      for (com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus element : getApplicationsList()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeMessageSize(6, element);
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public RilCardStatus mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 8: {
+              setCardState(input.readInt32());
+            break;
+          }
+          case 16: {
+              setUniversalPinState(input.readInt32());
+            break;
+          }
+          case 24: {
+            setGsmUmtsSubscriptionAppIndex(input.readInt32());
+            break;
+          }
+          case 32: {
+            setCdmaSubscriptionAppIndex(input.readInt32());
+            break;
+          }
+          case 40: {
+            setNumApplications(input.readInt32());
+            break;
+          }
+          case 50: {
+            com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus value = new com.android.internal.telephony.ril_proto.RilCmds.RilAppStatus();
+            input.readMessage(value);
+            addApplications(value);
+            break;
+          }
+        }
+      }
+    }
+    
+    public static RilCardStatus parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (RilCardStatus) (new RilCardStatus().mergeFrom(data));
+    }
+    
+    public static RilCardStatus parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (RilCardStatus) (new RilCardStatus().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class ReqGetSimStatus extends
+      com.google.protobuf.micro.MessageMicro {
+    public ReqGetSimStatus() {}
+    
+    public final ReqGetSimStatus clear() {
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      cachedSize = size;
+      return size;
+    }
+    
+    public ReqGetSimStatus mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+        }
+      }
+    }
+    
+    public static ReqGetSimStatus parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (ReqGetSimStatus) (new ReqGetSimStatus().mergeFrom(data));
+    }
+    
+    public static ReqGetSimStatus parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (ReqGetSimStatus) (new ReqGetSimStatus().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class RspGetSimStatus extends
+      com.google.protobuf.micro.MessageMicro {
+    public RspGetSimStatus() {}
+    
+    // required .ril_proto.RilCardStatus card_status = 1;
+    public static final int CARD_STATUS_FIELD_NUMBER = 1;
+    private boolean hasCardStatus;
+    private com.android.internal.telephony.ril_proto.RilCmds.RilCardStatus cardStatus_ = null;
+    public boolean hasCardStatus() { return hasCardStatus; }
+    public com.android.internal.telephony.ril_proto.RilCmds.RilCardStatus getCardStatus() { return cardStatus_; }
+    public RspGetSimStatus setCardStatus(com.android.internal.telephony.ril_proto.RilCmds.RilCardStatus value) {
+      if (value == null) {
+        throw new NullPointerException();
+      }
+      hasCardStatus = true;
+      cardStatus_ = value;
+      return this;
+    }
+    public RspGetSimStatus clearCardStatus() {
+      hasCardStatus = false;
+      cardStatus_ = null;
+      return this;
+    }
+    
+    public final RspGetSimStatus clear() {
+      clearCardStatus();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      if (!hasCardStatus) return false;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasCardStatus()) {
+        output.writeMessage(1, getCardStatus());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasCardStatus()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeMessageSize(1, getCardStatus());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public RspGetSimStatus mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 10: {
+            com.android.internal.telephony.ril_proto.RilCmds.RilCardStatus value = new com.android.internal.telephony.ril_proto.RilCmds.RilCardStatus();
+            input.readMessage(value);
+            setCardStatus(value);
+            break;
+          }
+        }
+      }
+    }
+    
+    public static RspGetSimStatus parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (RspGetSimStatus) (new RspGetSimStatus().mergeFrom(data));
+    }
+    
+    public static RspGetSimStatus parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (RspGetSimStatus) (new RspGetSimStatus().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class ReqEnterSimPin extends
+      com.google.protobuf.micro.MessageMicro {
+    public ReqEnterSimPin() {}
+    
+    // required string pin = 1;
+    public static final int PIN_FIELD_NUMBER = 1;
+    private boolean hasPin;
+    private java.lang.String pin_ = "";
+    public java.lang.String getPin() { return pin_; }
+    public boolean hasPin() { return hasPin; }
+    public ReqEnterSimPin setPin(java.lang.String value) {
+      hasPin = true;
+      pin_ = value;
+      return this;
+    }
+    public ReqEnterSimPin clearPin() {
+      hasPin = false;
+      pin_ = "";
+      return this;
+    }
+    
+    public final ReqEnterSimPin clear() {
+      clearPin();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      if (!hasPin) return false;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasPin()) {
+        output.writeString(1, getPin());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasPin()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeStringSize(1, getPin());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public ReqEnterSimPin mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 10: {
+            setPin(input.readString());
+            break;
+          }
+        }
+      }
+    }
+    
+    public static ReqEnterSimPin parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (ReqEnterSimPin) (new ReqEnterSimPin().mergeFrom(data));
+    }
+    
+    public static ReqEnterSimPin parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (ReqEnterSimPin) (new ReqEnterSimPin().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class RspEnterSimPin extends
+      com.google.protobuf.micro.MessageMicro {
+    public RspEnterSimPin() {}
+    
+    // required int32 retries_remaining = 1;
+    public static final int RETRIES_REMAINING_FIELD_NUMBER = 1;
+    private boolean hasRetriesRemaining;
+    private int retriesRemaining_ = 0;
+    public int getRetriesRemaining() { return retriesRemaining_; }
+    public boolean hasRetriesRemaining() { return hasRetriesRemaining; }
+    public RspEnterSimPin setRetriesRemaining(int value) {
+      hasRetriesRemaining = true;
+      retriesRemaining_ = value;
+      return this;
+    }
+    public RspEnterSimPin clearRetriesRemaining() {
+      hasRetriesRemaining = false;
+      retriesRemaining_ = 0;
+      return this;
+    }
+    
+    public final RspEnterSimPin clear() {
+      clearRetriesRemaining();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      if (!hasRetriesRemaining) return false;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasRetriesRemaining()) {
+        output.writeInt32(1, getRetriesRemaining());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasRetriesRemaining()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(1, getRetriesRemaining());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public RspEnterSimPin mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 8: {
+            setRetriesRemaining(input.readInt32());
+            break;
+          }
+        }
+      }
+    }
+    
+    public static RspEnterSimPin parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (RspEnterSimPin) (new RspEnterSimPin().mergeFrom(data));
+    }
+    
+    public static RspEnterSimPin parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (RspEnterSimPin) (new RspEnterSimPin().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class ReqHangUp extends
+      com.google.protobuf.micro.MessageMicro {
+    public ReqHangUp() {}
+    
+    // required int32 connection_index = 1;
+    public static final int CONNECTION_INDEX_FIELD_NUMBER = 1;
+    private boolean hasConnectionIndex;
+    private int connectionIndex_ = 0;
+    public int getConnectionIndex() { return connectionIndex_; }
+    public boolean hasConnectionIndex() { return hasConnectionIndex; }
+    public ReqHangUp setConnectionIndex(int value) {
+      hasConnectionIndex = true;
+      connectionIndex_ = value;
+      return this;
+    }
+    public ReqHangUp clearConnectionIndex() {
+      hasConnectionIndex = false;
+      connectionIndex_ = 0;
+      return this;
+    }
+    
+    public final ReqHangUp clear() {
+      clearConnectionIndex();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      if (!hasConnectionIndex) return false;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasConnectionIndex()) {
+        output.writeInt32(1, getConnectionIndex());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasConnectionIndex()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(1, getConnectionIndex());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public ReqHangUp mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 8: {
+            setConnectionIndex(input.readInt32());
+            break;
+          }
+        }
+      }
+    }
+    
+    public static ReqHangUp parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (ReqHangUp) (new ReqHangUp().mergeFrom(data));
+    }
+    
+    public static ReqHangUp parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (ReqHangUp) (new ReqHangUp().mergeFrom(input));
+    }
+    
+  }
+  
+  public static final class ReqScreenState extends
+      com.google.protobuf.micro.MessageMicro {
+    public ReqScreenState() {}
+    
+    // required bool state = 1;
+    public static final int STATE_FIELD_NUMBER = 1;
+    private boolean hasState;
+    private boolean state_ = false;
+    public boolean getState() { return state_; }
+    public boolean hasState() { return hasState; }
+    public ReqScreenState setState(boolean value) {
+      hasState = true;
+      state_ = value;
+      return this;
+    }
+    public ReqScreenState clearState() {
+      hasState = false;
+      state_ = false;
+      return this;
+    }
+    
+    public final ReqScreenState clear() {
+      clearState();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      if (!hasState) return false;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasState()) {
+        output.writeBool(1, getState());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasState()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeBoolSize(1, getState());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public ReqScreenState mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 8: {
+            setState(input.readBool());
+            break;
+          }
+        }
+      }
+    }
+    
+    public static ReqScreenState parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (ReqScreenState) (new ReqScreenState().mergeFrom(data));
+    }
+    
+    public static ReqScreenState parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (ReqScreenState) (new ReqScreenState().mergeFrom(input));
+    }
+    
+  }
+  
+}
diff --git a/mock-ril/com/android/internal/telephony/ril_proto/RilCtrlCmds.java b/mock-ril/com/android/internal/telephony/ril_proto/RilCtrlCmds.java
new file mode 100644 (file)
index 0000000..053dba6
--- /dev/null
@@ -0,0 +1,108 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+
+package com.android.internal.telephony.ril_proto;
+
+public final class RilCtrlCmds {
+  private RilCtrlCmds() {}
+  // enum CtrlCmd
+  public static final int CTRL_CMD_ECHO = 0;
+  public static final int CTRL_CMD_GET_RADIO_STATE = 1;
+  
+  // enum CtrlStatus
+  public static final int CTRL_STATUS_OK = 0;
+  public static final int CTRL_STATUS_ERR = 1;
+  
+  public static final class CtrlRspRadioState extends
+      com.google.protobuf.micro.MessageMicro {
+    public CtrlRspRadioState() {}
+    
+    // required .ril_proto.RadioState state = 1;
+    public static final int STATE_FIELD_NUMBER = 1;
+    private boolean hasState;
+    private int state_ = com.android.internal.telephony.ril_proto.RilCmds.RADIO_STATE_OFF;
+    public boolean hasState() { return hasState; }
+    public int getState() { return state_; }
+    public CtrlRspRadioState setState(int value) {
+      hasState = true;
+      state_ = value;
+      return this;
+    }
+    public CtrlRspRadioState clearState() {
+      hasState = false;
+      state_ = com.android.internal.telephony.ril_proto.RilCmds.RADIO_STATE_OFF;
+      return this;
+    }
+    
+    public final CtrlRspRadioState clear() {
+      clearState();
+      cachedSize = -1;
+      return this;
+    }
+    
+    public final boolean isInitialized() {
+      if (!hasState) return false;
+      return true;
+    }
+    
+    public void writeTo(com.google.protobuf.micro.CodedOutputStreamMicro output)
+                        throws java.io.IOException {
+      if (hasState()) {
+        output.writeInt32(1, getState());
+      }
+    }
+    
+    private int cachedSize = -1;
+    public int getCachedSize() {
+      if (cachedSize < 0) {
+        // getSerializedSize sets cachedSize
+        getSerializedSize();
+      }
+      return cachedSize;
+    }
+    
+    public int getSerializedSize() {
+      int size = 0;
+      if (hasState()) {
+        size += com.google.protobuf.micro.CodedOutputStreamMicro
+          .computeInt32Size(1, getState());
+      }
+      cachedSize = size;
+      return size;
+    }
+    
+    public CtrlRspRadioState mergeFrom(
+        com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      while (true) {
+        int tag = input.readTag();
+        switch (tag) {
+          case 0:
+            return this;
+          default: {
+            if (!parseUnknownField(input, tag)) {
+              return this;
+            }
+            break;
+          }
+          case 8: {
+              setState(input.readInt32());
+            break;
+          }
+        }
+      }
+    }
+    
+    public static CtrlRspRadioState parseFrom(byte[] data)
+        throws com.google.protobuf.micro.InvalidProtocolBufferMicroException {
+      return (CtrlRspRadioState) (new CtrlRspRadioState().mergeFrom(data));
+    }
+    
+    public static CtrlRspRadioState parseFrom(
+            com.google.protobuf.micro.CodedInputStreamMicro input)
+        throws java.io.IOException {
+      return (CtrlRspRadioState) (new CtrlRspRadioState().mergeFrom(input));
+    }
+    
+  }
+  
+}
index b38de52..f5f023b 100644 (file)
Binary files a/mock-ril/ctrl.desc and b/mock-ril/ctrl.desc differ
index 49bc5f6..bdd0a50 100644 (file)
@@ -10,7 +10,7 @@
 #include <google/protobuf/wire_format.h>
 // @@protoc_insertion_point(includes)
 
-namespace ctrl_proto {
+namespace ril_proto {
 
 namespace {
 
@@ -77,12 +77,13 @@ void protobuf_AddDesc_ctrl_2eproto() {
 
   ::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);
+    "\n\nctrl.proto\022\tril_proto\032\tril.proto\"9\n\021Ct"
+    "rlRspRadioState\022$\n\005state\030\001 \002(\0162\025.ril_pro"
+    "to.RadioState*:\n\007CtrlCmd\022\021\n\rCTRL_CMD_ECH"
+    "O\020\000\022\034\n\030CTRL_CMD_GET_RADIO_STATE\020\001*5\n\nCtr"
+    "lStatus\022\022\n\016CTRL_STATUS_OK\020\000\022\023\n\017CTRL_STAT"
+    "US_ERR\020\001B7\n(com.android.internal.telepho"
+    "ny.ril_protoB\013RilCtrlCmds", 265);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "ctrl.proto", &protobuf_RegisterTypes);
   CtrlRspRadioState::default_instance_ = new CtrlRspRadioState();
@@ -342,6 +343,6 @@ void CtrlRspRadioState::Swap(CtrlRspRadioState* other) {
 
 // @@protoc_insertion_point(namespace_scope)
 
-}  // namespace ctrl_proto
+}  // namespace ril_proto
 
 // @@protoc_insertion_point(global_scope)
index 1bfaed5..97cd0bd 100644 (file)
@@ -26,7 +26,7 @@
 #include "ril.pb.h"
 // @@protoc_insertion_point(includes)
 
-namespace ctrl_proto {
+namespace ril_proto {
 
 // Internal implementation detail -- do not call these.
 void  protobuf_AddDesc_ctrl_2eproto();
@@ -136,7 +136,7 @@ class CtrlRspRadioState : public ::google::protobuf::Message {
   inline ril_proto::RadioState state() const;
   inline void set_state(ril_proto::RadioState value);
   
-  // @@protoc_insertion_point(class_scope:ctrl_proto.CtrlRspRadioState)
+  // @@protoc_insertion_point(class_scope:ril_proto.CtrlRspRadioState)
  private:
   ::google::protobuf::UnknownFieldSet _unknown_fields_;
   mutable int _cached_size_;
@@ -189,19 +189,19 @@ inline void CtrlRspRadioState::set_state(ril_proto::RadioState value) {
 
 // @@protoc_insertion_point(namespace_scope)
 
-}  // namespace ctrl_proto
+}  // namespace ril_proto
 
 #ifndef SWIG
 namespace google {
 namespace protobuf {
 
 template <>
-inline const EnumDescriptor* GetEnumDescriptor< ctrl_proto::CtrlCmd>() {
-  return ctrl_proto::CtrlCmd_descriptor();
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::CtrlCmd>() {
+  return ril_proto::CtrlCmd_descriptor();
 }
 template <>
-inline const EnumDescriptor* GetEnumDescriptor< ctrl_proto::CtrlStatus>() {
-  return ctrl_proto::CtrlStatus_descriptor();
+inline const EnumDescriptor* GetEnumDescriptor< ril_proto::CtrlStatus>() {
+  return ril_proto::CtrlStatus_descriptor();
 }
 
 }  // namespace google
index da0069c..761c87a 100644 (file)
@@ -1,7 +1,10 @@
 // Copyright 2010 Google Inc. All Rights Reserved.
 // Author: wink@google.com (Wink Saville)
 
-package ctrl_proto;
+package ril_proto;
+
+option java_package='com.android.internal.telephony.ril_proto';
+option java_outer_classname='RilCtrlCmds';
 
 import "ril.proto";
 
index a56589a..09ef582 100644 (file)
@@ -9,12 +9,12 @@ from google.protobuf import descriptor_pb2
 
 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')
+  package='ril_proto',
+  serialized_pb='\n\nctrl.proto\x12\tril_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\x42\x37\n(com.android.internal.telephony.ril_protoB\x0bRilCtrlCmds')
 
 _CTRLCMD = descriptor.EnumDescriptor(
   name='CtrlCmd',
-  full_name='ctrl_proto.CtrlCmd',
+  full_name='ril_proto.CtrlCmd',
   filename=None,
   file=DESCRIPTOR,
   values=[
@@ -29,14 +29,14 @@ _CTRLCMD = descriptor.EnumDescriptor(
   ],
   containing_type=None,
   options=None,
-  serialized_start=96,
-  serialized_end=154,
+  serialized_start=95,
+  serialized_end=153,
 )
 
 
 _CTRLSTATUS = descriptor.EnumDescriptor(
   name='CtrlStatus',
-  full_name='ctrl_proto.CtrlStatus',
+  full_name='ril_proto.CtrlStatus',
   filename=None,
   file=DESCRIPTOR,
   values=[
@@ -51,8 +51,8 @@ _CTRLSTATUS = descriptor.EnumDescriptor(
   ],
   containing_type=None,
   options=None,
-  serialized_start=156,
-  serialized_end=209,
+  serialized_start=155,
+  serialized_end=208,
 )
 
 
@@ -65,13 +65,13 @@ CTRL_STATUS_ERR = 1
 
 _CTRLRSPRADIOSTATE = descriptor.Descriptor(
   name='CtrlRspRadioState',
-  full_name='ctrl_proto.CtrlRspRadioState',
+  full_name='ril_proto.CtrlRspRadioState',
   filename=None,
   file=DESCRIPTOR,
   containing_type=None,
   fields=[
     descriptor.FieldDescriptor(
-      name='state', full_name='ctrl_proto.CtrlRspRadioState.state', index=0,
+      name='state', full_name='ril_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,
@@ -86,8 +86,8 @@ _CTRLRSPRADIOSTATE = descriptor.Descriptor(
   options=None,
   is_extendable=False,
   extension_ranges=[],
-  serialized_start=37,
-  serialized_end=94,
+  serialized_start=36,
+  serialized_end=93,
 )
 
 import ril_pb2
@@ -98,6 +98,6 @@ class CtrlRspRadioState(message.Message):
   __metaclass__ = reflection.GeneratedProtocolMessageType
   DESCRIPTOR = _CTRLRSPRADIOSTATE
   
-  # @@protoc_insertion_point(class_scope:ctrl_proto.CtrlRspRadioState)
+  # @@protoc_insertion_point(class_scope:ril_proto.CtrlRspRadioState)
 
 # @@protoc_insertion_point(module_scope)
index 65338ca..2dc9634 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <alloca.h>
 #include <pthread.h>
 #include <stdio.h>
 #include <string.h>
@@ -30,6 +31,8 @@
 #include "util.h"
 #include "worker.h"
 
+#include "msgheader.pb.h"
+
 #include "ctrl.pb.h"
 #include "ctrl_server.h"
 
@@ -47,6 +50,8 @@
 #define MOCK_RIL_CONTROL_SERVER_STOPPING_SOCKET 54311
 #define MOCK_RIL_CONTROL_SERVER_SOCKET 54312
 
+using communication::MsgHeader;
+
 class CtrlServerThread;
 static CtrlServerThread *g_ctrl_server;
 
@@ -110,36 +115,30 @@ class CtrlServerThread : public WorkerThread {
 
     int ReadMessage(MsgHeader *mh, Buffer **pBuffer) {
         int status;
+        int32_t len_msg_header;
 
-        status = ReadAll(server_to_client_socket_, &mh->cmd, 4);
-        mh->cmd = letoh32(mh->cmd);
-        DBG("rm: mh->cmd=%d status=%d", mh->cmd, status);
+        // Reader header length
+        status = ReadAll(server_to_client_socket_, &len_msg_header, sizeof(len_msg_header));
+        len_msg_header = letoh32(len_msg_header);
+        DBG("rm: read len_msg_header=%d  status=%d", len_msg_header, 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);
+        // Read header into an array allocated on the stack and unmarshall
+        uint8_t *msg_header_raw = (uint8_t *)alloca(len_msg_header);
+        status = ReadAll(server_to_client_socket_, msg_header_raw, len_msg_header);
+        DBG("rm: read msg_header_raw=%p  status=%d", msg_header_raw, status);
         if (status != STATUS_OK) return status;
+        mh->ParseFromArray(msg_header_raw, len_msg_header);
 
+        // Read auxillary data
         Buffer *buffer;
-        if (mh->length_protobuf > 0) {
-            buffer = ObtainBuffer(mh->length_protobuf);
+        if (mh->length_data() > 0) {
+            buffer = ObtainBuffer(mh->length_data());
             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;
         }
 
@@ -153,37 +152,29 @@ class CtrlServerThread : public WorkerThread {
         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;
-
+        // Set length of data
         if (buffer == NULL) {
-            mh->length_protobuf = 0;
+            mh->set_length_data(0);
         } else {
-            mh->length_protobuf = buffer->length();
+            mh->set_length_data(buffer->length());
         }
-        if (mh->length_protobuf < 0) {
-            LOGE("wm: length_protobuf=zero");
-            mh->length_protobuf = 0;
-        }
-        i = htole32(mh->length_protobuf);
+
+        // Serialize header
+        uint32_t len_msg_header = mh->ByteSize();
+        uint8_t *msg_header_raw = (uint8_t *)alloca(len_msg_header);
+        mh->SerializeToArray(msg_header_raw, len_msg_header);
+
+        // Write length in little endian followed by the header
+        i = htole32(len_msg_header);
         status = WriteAll(server_to_client_socket_, &i, 4);
-        DBG("wm: mh->length_protobuf=%d status=%d",
-                   mh->length_protobuf, status);
+        DBG("wm: write len_msg_header=%d status=%d", len_msg_header, status);
+        if (status != 0) return status;
+        status = WriteAll(server_to_client_socket_, msg_header_raw, len_msg_header);
+        DBG("wm: write msg_header_raw=%p  status=%d", msg_header_raw, status);
         if (status != 0) return status;
 
-        if (mh->length_protobuf > 0) {
+        // Write data
+        if (mh->length_data() > 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);
@@ -277,7 +268,7 @@ class CtrlServerThread : public WorkerThread {
     }
 
     int sendToCtrlServer(MsgHeader *mh, Buffer *buffer) {
-        DBG("sendToCtrlServer E: cmd=%d token=%lld", mh->cmd, mh->token);
+        DBG("sendToCtrlServer E: cmd=%d token=%lld", mh->cmd(), mh->token());
 
         int status = STATUS_OK;
         v8::HandleScope handle_scope;
@@ -292,13 +283,13 @@ class CtrlServerThread : public WorkerThread {
                 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);
+        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) {
+        if (mh->length_data() == 0) {
             buf = v8::Undefined();
         } else {
             buf = buffer->handle_;
@@ -319,8 +310,8 @@ class CtrlServerThread : public WorkerThread {
         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;
+            mh->set_length_data(0);
+            mh->set_status(ril_proto::CTRL_STATUS_ERR);
             g_ctrl_server->WriteMessage(mh, NULL);
         }
 
@@ -364,7 +355,7 @@ class CtrlServerThread : public WorkerThread {
                     status = ReadMessage(&mh, &buffer);
                     if (status != STATUS_OK) break;
 
-                    if (mh.cmd == ctrl_proto::CTRL_CMD_ECHO) {
+                    if (mh.cmd() == ril_proto::CTRL_CMD_ECHO) {
                         LOGD("CtrlServerThread::Worker echo");
                         status = WriteMessage(&mh, buffer);
                         if (status != STATUS_OK) break;
@@ -422,24 +413,24 @@ v8::Handle<v8::Value> SendCtrlRequestComplete(const v8::Arguments& args) {
         return v8::Undefined();
     }
     v8::Handle<v8::Value> v8CtrlStatus(args[0]->ToObject());
-    mh.status = ctrl_proto::CtrlStatus(v8CtrlStatus->NumberValue());
-    DBG("SendCtrlRequestComplete: status=%d", mh.status);
+    mh.set_status(ril_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);
+    mh.set_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);
+    mh.set_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);
+        mh.set_length_data(buffer->length());
+        DBG("SendCtrlRequestComplete: mh.length_data=%d",
+                mh.length_data());
     } else {
-        mh.length_protobuf = 0;
+        mh.set_length_data(0);
         buffer = NULL;
         DBG("SendCtrlRequestComplete: NO PROTOBUF");
     }
index c964597..2850f04 100644 (file)
 
 #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);
index ac29b7f..ef07837 100644 (file)
@@ -216,19 +216,19 @@ var ctrlServer = new Worker(function (req) {
 
         // 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 ctrlStatus = 0; // ril_proto.CTRL_STATUS_OK;
         var responseProtobuf = emptyProtobuf;
 
         switch (req.cmd) {
-            case 1: //ctrl_proto.CTRL_CMD_GET_RADIO_STATE:
+            case 1: //ril_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);
+                responseProtobuf = ctrlSchema['ril_proto.CtrlRspRadioState'].serialize(rsp);
                 break;
             default:
                 print('ctrlServer: Unknown cmd ' + req.cmd);
-                ctrlStatus = 1; //ctrl_proto.CTRL_STATUS_ERR;
+                ctrlStatus = 1; //ril_proto.CTRL_STATUS_ERR;
                 break;
         }
 
diff --git a/mock-ril/msgheader.desc b/mock-ril/msgheader.desc
new file mode 100644 (file)
index 0000000..22ea028
--- /dev/null
@@ -0,0 +1,9 @@
+
+\94\ 1
+\ fmsgheader.proto\12\rcommunication"L
+       MsgHeader\12\v
+\ 3cmd\18\ 1 \ 2(\r\12\13
+\vlength_data\18\ 2 \ 2(\r\12\ e
+\ 6status\18\ 3 \ 1(\r\12\r
+\ 5token\18\ 4 \ 1(\ 4B$
+"com.android.internal.communication
\ No newline at end of file
diff --git a/mock-ril/msgheader.pb.cc b/mock-ril/msgheader.pb.cc
new file mode 100644 (file)
index 0000000..b4bd1a5
--- /dev/null
@@ -0,0 +1,429 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "msgheader.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 communication {
+
+namespace {
+
+const ::google::protobuf::Descriptor* MsgHeader_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+  MsgHeader_reflection_ = NULL;
+
+}  // namespace
+
+
+void protobuf_AssignDesc_msgheader_2eproto() {
+  protobuf_AddDesc_msgheader_2eproto();
+  const ::google::protobuf::FileDescriptor* file =
+    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
+      "msgheader.proto");
+  GOOGLE_CHECK(file != NULL);
+  MsgHeader_descriptor_ = file->message_type(0);
+  static const int MsgHeader_offsets_[4] = {
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, cmd_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, length_data_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, status_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, token_),
+  };
+  MsgHeader_reflection_ =
+    new ::google::protobuf::internal::GeneratedMessageReflection(
+      MsgHeader_descriptor_,
+      MsgHeader::default_instance_,
+      MsgHeader_offsets_,
+      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, _has_bits_[0]),
+      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, _unknown_fields_),
+      -1,
+      ::google::protobuf::DescriptorPool::generated_pool(),
+      ::google::protobuf::MessageFactory::generated_factory(),
+      sizeof(MsgHeader));
+}
+
+namespace {
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+inline void protobuf_AssignDescriptorsOnce() {
+  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
+                 &protobuf_AssignDesc_msgheader_2eproto);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) {
+  protobuf_AssignDescriptorsOnce();
+  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+    MsgHeader_descriptor_, &MsgHeader::default_instance());
+}
+
+}  // namespace
+
+void protobuf_ShutdownFile_msgheader_2eproto() {
+  delete MsgHeader::default_instance_;
+  delete MsgHeader_reflection_;
+}
+
+void protobuf_AddDesc_msgheader_2eproto() {
+  static bool already_here = false;
+  if (already_here) return;
+  already_here = true;
+  GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+    "\n\017msgheader.proto\022\rcommunication\"L\n\tMsgH"
+    "eader\022\013\n\003cmd\030\001 \002(\r\022\023\n\013length_data\030\002 \002(\r\022"
+    "\016\n\006status\030\003 \001(\r\022\r\n\005token\030\004 \001(\004B$\n\"com.an"
+    "droid.internal.communication", 148);
+  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+    "msgheader.proto", &protobuf_RegisterTypes);
+  MsgHeader::default_instance_ = new MsgHeader();
+  MsgHeader::default_instance_->InitAsDefaultInstance();
+  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgheader_2eproto);
+}
+
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_msgheader_2eproto {
+  StaticDescriptorInitializer_msgheader_2eproto() {
+    protobuf_AddDesc_msgheader_2eproto();
+  }
+} static_descriptor_initializer_msgheader_2eproto_;
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int MsgHeader::kCmdFieldNumber;
+const int MsgHeader::kLengthDataFieldNumber;
+const int MsgHeader::kStatusFieldNumber;
+const int MsgHeader::kTokenFieldNumber;
+#endif  // !_MSC_VER
+
+MsgHeader::MsgHeader()
+  : ::google::protobuf::Message() {
+  SharedCtor();
+}
+
+void MsgHeader::InitAsDefaultInstance() {
+}
+
+MsgHeader::MsgHeader(const MsgHeader& from)
+  : ::google::protobuf::Message() {
+  SharedCtor();
+  MergeFrom(from);
+}
+
+void MsgHeader::SharedCtor() {
+  _cached_size_ = 0;
+  cmd_ = 0u;
+  length_data_ = 0u;
+  status_ = 0u;
+  token_ = GOOGLE_ULONGLONG(0);
+  ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+MsgHeader::~MsgHeader() {
+  SharedDtor();
+}
+
+void MsgHeader::SharedDtor() {
+  if (this != default_instance_) {
+  }
+}
+
+void MsgHeader::SetCachedSize(int size) const {
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* MsgHeader::descriptor() {
+  protobuf_AssignDescriptorsOnce();
+  return MsgHeader_descriptor_;
+}
+
+const MsgHeader& MsgHeader::default_instance() {
+  if (default_instance_ == NULL) protobuf_AddDesc_msgheader_2eproto();  return *default_instance_;
+}
+
+MsgHeader* MsgHeader::default_instance_ = NULL;
+
+MsgHeader* MsgHeader::New() const {
+  return new MsgHeader;
+}
+
+void MsgHeader::Clear() {
+  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    cmd_ = 0u;
+    length_data_ = 0u;
+    status_ = 0u;
+    token_ = GOOGLE_ULONGLONG(0);
+  }
+  ::memset(_has_bits_, 0, sizeof(_has_bits_));
+  mutable_unknown_fields()->Clear();
+}
+
+bool MsgHeader::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 uint32 cmd = 1;
+      case 1: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+                 input, &cmd_)));
+          _set_bit(0);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(16)) goto parse_length_data;
+        break;
+      }
+      
+      // required uint32 length_data = 2;
+      case 2: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+         parse_length_data:
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+                 input, &length_data_)));
+          _set_bit(1);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(24)) goto parse_status;
+        break;
+      }
+      
+      // optional uint32 status = 3;
+      case 3: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+         parse_status:
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+                 input, &status_)));
+          _set_bit(2);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(32)) goto parse_token;
+        break;
+      }
+      
+      // optional uint64 token = 4;
+      case 4: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+         parse_token:
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
+                 input, &token_)));
+          _set_bit(3);
+        } 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 MsgHeader::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // required uint32 cmd = 1;
+  if (_has_bit(0)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->cmd(), output);
+  }
+  
+  // required uint32 length_data = 2;
+  if (_has_bit(1)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->length_data(), output);
+  }
+  
+  // optional uint32 status = 3;
+  if (_has_bit(2)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->status(), output);
+  }
+  
+  // optional uint64 token = 4;
+  if (_has_bit(3)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->token(), output);
+  }
+  
+  if (!unknown_fields().empty()) {
+    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+        unknown_fields(), output);
+  }
+}
+
+::google::protobuf::uint8* MsgHeader::SerializeWithCachedSizesToArray(
+    ::google::protobuf::uint8* target) const {
+  // required uint32 cmd = 1;
+  if (_has_bit(0)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->cmd(), target);
+  }
+  
+  // required uint32 length_data = 2;
+  if (_has_bit(1)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->length_data(), target);
+  }
+  
+  // optional uint32 status = 3;
+  if (_has_bit(2)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->status(), target);
+  }
+  
+  // optional uint64 token = 4;
+  if (_has_bit(3)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->token(), target);
+  }
+  
+  if (!unknown_fields().empty()) {
+    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+        unknown_fields(), target);
+  }
+  return target;
+}
+
+int MsgHeader::ByteSize() const {
+  int total_size = 0;
+  
+  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    // required uint32 cmd = 1;
+    if (has_cmd()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt32Size(
+          this->cmd());
+    }
+    
+    // required uint32 length_data = 2;
+    if (has_length_data()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt32Size(
+          this->length_data());
+    }
+    
+    // optional uint32 status = 3;
+    if (has_status()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt32Size(
+          this->status());
+    }
+    
+    // optional uint64 token = 4;
+    if (has_token()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt64Size(
+          this->token());
+    }
+    
+  }
+  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 MsgHeader::MergeFrom(const ::google::protobuf::Message& from) {
+  GOOGLE_CHECK_NE(&from, this);
+  const MsgHeader* source =
+    ::google::protobuf::internal::dynamic_cast_if_available<const MsgHeader*>(
+      &from);
+  if (source == NULL) {
+    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+  } else {
+    MergeFrom(*source);
+  }
+}
+
+void MsgHeader::MergeFrom(const MsgHeader& from) {
+  GOOGLE_CHECK_NE(&from, this);
+  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    if (from._has_bit(0)) {
+      set_cmd(from.cmd());
+    }
+    if (from._has_bit(1)) {
+      set_length_data(from.length_data());
+    }
+    if (from._has_bit(2)) {
+      set_status(from.status());
+    }
+    if (from._has_bit(3)) {
+      set_token(from.token());
+    }
+  }
+  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void MsgHeader::CopyFrom(const ::google::protobuf::Message& from) {
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+void MsgHeader::CopyFrom(const MsgHeader& from) {
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool MsgHeader::IsInitialized() const {
+  if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
+  
+  return true;
+}
+
+void MsgHeader::Swap(MsgHeader* other) {
+  if (other != this) {
+    std::swap(cmd_, other->cmd_);
+    std::swap(length_data_, other->length_data_);
+    std::swap(status_, other->status_);
+    std::swap(token_, other->token_);
+    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 MsgHeader::GetMetadata() const {
+  protobuf_AssignDescriptorsOnce();
+  ::google::protobuf::Metadata metadata;
+  metadata.descriptor = MsgHeader_descriptor_;
+  metadata.reflection = MsgHeader_reflection_;
+  return metadata;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+}  // namespace communication
+
+// @@protoc_insertion_point(global_scope)
diff --git a/mock-ril/msgheader.pb.cpp b/mock-ril/msgheader.pb.cpp
new file mode 100644 (file)
index 0000000..b4bd1a5
--- /dev/null
@@ -0,0 +1,429 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "msgheader.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 communication {
+
+namespace {
+
+const ::google::protobuf::Descriptor* MsgHeader_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+  MsgHeader_reflection_ = NULL;
+
+}  // namespace
+
+
+void protobuf_AssignDesc_msgheader_2eproto() {
+  protobuf_AddDesc_msgheader_2eproto();
+  const ::google::protobuf::FileDescriptor* file =
+    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
+      "msgheader.proto");
+  GOOGLE_CHECK(file != NULL);
+  MsgHeader_descriptor_ = file->message_type(0);
+  static const int MsgHeader_offsets_[4] = {
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, cmd_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, length_data_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, status_),
+    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, token_),
+  };
+  MsgHeader_reflection_ =
+    new ::google::protobuf::internal::GeneratedMessageReflection(
+      MsgHeader_descriptor_,
+      MsgHeader::default_instance_,
+      MsgHeader_offsets_,
+      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, _has_bits_[0]),
+      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MsgHeader, _unknown_fields_),
+      -1,
+      ::google::protobuf::DescriptorPool::generated_pool(),
+      ::google::protobuf::MessageFactory::generated_factory(),
+      sizeof(MsgHeader));
+}
+
+namespace {
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+inline void protobuf_AssignDescriptorsOnce() {
+  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
+                 &protobuf_AssignDesc_msgheader_2eproto);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) {
+  protobuf_AssignDescriptorsOnce();
+  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+    MsgHeader_descriptor_, &MsgHeader::default_instance());
+}
+
+}  // namespace
+
+void protobuf_ShutdownFile_msgheader_2eproto() {
+  delete MsgHeader::default_instance_;
+  delete MsgHeader_reflection_;
+}
+
+void protobuf_AddDesc_msgheader_2eproto() {
+  static bool already_here = false;
+  if (already_here) return;
+  already_here = true;
+  GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+    "\n\017msgheader.proto\022\rcommunication\"L\n\tMsgH"
+    "eader\022\013\n\003cmd\030\001 \002(\r\022\023\n\013length_data\030\002 \002(\r\022"
+    "\016\n\006status\030\003 \001(\r\022\r\n\005token\030\004 \001(\004B$\n\"com.an"
+    "droid.internal.communication", 148);
+  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+    "msgheader.proto", &protobuf_RegisterTypes);
+  MsgHeader::default_instance_ = new MsgHeader();
+  MsgHeader::default_instance_->InitAsDefaultInstance();
+  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgheader_2eproto);
+}
+
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_msgheader_2eproto {
+  StaticDescriptorInitializer_msgheader_2eproto() {
+    protobuf_AddDesc_msgheader_2eproto();
+  }
+} static_descriptor_initializer_msgheader_2eproto_;
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int MsgHeader::kCmdFieldNumber;
+const int MsgHeader::kLengthDataFieldNumber;
+const int MsgHeader::kStatusFieldNumber;
+const int MsgHeader::kTokenFieldNumber;
+#endif  // !_MSC_VER
+
+MsgHeader::MsgHeader()
+  : ::google::protobuf::Message() {
+  SharedCtor();
+}
+
+void MsgHeader::InitAsDefaultInstance() {
+}
+
+MsgHeader::MsgHeader(const MsgHeader& from)
+  : ::google::protobuf::Message() {
+  SharedCtor();
+  MergeFrom(from);
+}
+
+void MsgHeader::SharedCtor() {
+  _cached_size_ = 0;
+  cmd_ = 0u;
+  length_data_ = 0u;
+  status_ = 0u;
+  token_ = GOOGLE_ULONGLONG(0);
+  ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+MsgHeader::~MsgHeader() {
+  SharedDtor();
+}
+
+void MsgHeader::SharedDtor() {
+  if (this != default_instance_) {
+  }
+}
+
+void MsgHeader::SetCachedSize(int size) const {
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* MsgHeader::descriptor() {
+  protobuf_AssignDescriptorsOnce();
+  return MsgHeader_descriptor_;
+}
+
+const MsgHeader& MsgHeader::default_instance() {
+  if (default_instance_ == NULL) protobuf_AddDesc_msgheader_2eproto();  return *default_instance_;
+}
+
+MsgHeader* MsgHeader::default_instance_ = NULL;
+
+MsgHeader* MsgHeader::New() const {
+  return new MsgHeader;
+}
+
+void MsgHeader::Clear() {
+  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    cmd_ = 0u;
+    length_data_ = 0u;
+    status_ = 0u;
+    token_ = GOOGLE_ULONGLONG(0);
+  }
+  ::memset(_has_bits_, 0, sizeof(_has_bits_));
+  mutable_unknown_fields()->Clear();
+}
+
+bool MsgHeader::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 uint32 cmd = 1;
+      case 1: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+                 input, &cmd_)));
+          _set_bit(0);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(16)) goto parse_length_data;
+        break;
+      }
+      
+      // required uint32 length_data = 2;
+      case 2: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+         parse_length_data:
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+                 input, &length_data_)));
+          _set_bit(1);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(24)) goto parse_status;
+        break;
+      }
+      
+      // optional uint32 status = 3;
+      case 3: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+         parse_status:
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+                 input, &status_)));
+          _set_bit(2);
+        } else {
+          goto handle_uninterpreted;
+        }
+        if (input->ExpectTag(32)) goto parse_token;
+        break;
+      }
+      
+      // optional uint64 token = 4;
+      case 4: {
+        if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+         parse_token:
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
+                 input, &token_)));
+          _set_bit(3);
+        } 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 MsgHeader::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // required uint32 cmd = 1;
+  if (_has_bit(0)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->cmd(), output);
+  }
+  
+  // required uint32 length_data = 2;
+  if (_has_bit(1)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->length_data(), output);
+  }
+  
+  // optional uint32 status = 3;
+  if (_has_bit(2)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->status(), output);
+  }
+  
+  // optional uint64 token = 4;
+  if (_has_bit(3)) {
+    ::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->token(), output);
+  }
+  
+  if (!unknown_fields().empty()) {
+    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+        unknown_fields(), output);
+  }
+}
+
+::google::protobuf::uint8* MsgHeader::SerializeWithCachedSizesToArray(
+    ::google::protobuf::uint8* target) const {
+  // required uint32 cmd = 1;
+  if (_has_bit(0)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->cmd(), target);
+  }
+  
+  // required uint32 length_data = 2;
+  if (_has_bit(1)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->length_data(), target);
+  }
+  
+  // optional uint32 status = 3;
+  if (_has_bit(2)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->status(), target);
+  }
+  
+  // optional uint64 token = 4;
+  if (_has_bit(3)) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->token(), target);
+  }
+  
+  if (!unknown_fields().empty()) {
+    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+        unknown_fields(), target);
+  }
+  return target;
+}
+
+int MsgHeader::ByteSize() const {
+  int total_size = 0;
+  
+  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    // required uint32 cmd = 1;
+    if (has_cmd()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt32Size(
+          this->cmd());
+    }
+    
+    // required uint32 length_data = 2;
+    if (has_length_data()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt32Size(
+          this->length_data());
+    }
+    
+    // optional uint32 status = 3;
+    if (has_status()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt32Size(
+          this->status());
+    }
+    
+    // optional uint64 token = 4;
+    if (has_token()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::UInt64Size(
+          this->token());
+    }
+    
+  }
+  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 MsgHeader::MergeFrom(const ::google::protobuf::Message& from) {
+  GOOGLE_CHECK_NE(&from, this);
+  const MsgHeader* source =
+    ::google::protobuf::internal::dynamic_cast_if_available<const MsgHeader*>(
+      &from);
+  if (source == NULL) {
+    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+  } else {
+    MergeFrom(*source);
+  }
+}
+
+void MsgHeader::MergeFrom(const MsgHeader& from) {
+  GOOGLE_CHECK_NE(&from, this);
+  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    if (from._has_bit(0)) {
+      set_cmd(from.cmd());
+    }
+    if (from._has_bit(1)) {
+      set_length_data(from.length_data());
+    }
+    if (from._has_bit(2)) {
+      set_status(from.status());
+    }
+    if (from._has_bit(3)) {
+      set_token(from.token());
+    }
+  }
+  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void MsgHeader::CopyFrom(const ::google::protobuf::Message& from) {
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+void MsgHeader::CopyFrom(const MsgHeader& from) {
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool MsgHeader::IsInitialized() const {
+  if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
+  
+  return true;
+}
+
+void MsgHeader::Swap(MsgHeader* other) {
+  if (other != this) {
+    std::swap(cmd_, other->cmd_);
+    std::swap(length_data_, other->length_data_);
+    std::swap(status_, other->status_);
+    std::swap(token_, other->token_);
+    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 MsgHeader::GetMetadata() const {
+  protobuf_AssignDescriptorsOnce();
+  ::google::protobuf::Metadata metadata;
+  metadata.descriptor = MsgHeader_descriptor_;
+  metadata.reflection = MsgHeader_reflection_;
+  return metadata;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+}  // namespace communication
+
+// @@protoc_insertion_point(global_scope)
diff --git a/mock-ril/msgheader.pb.h b/mock-ril/msgheader.pb.h
new file mode 100644 (file)
index 0000000..a98bf3e
--- /dev/null
@@ -0,0 +1,237 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: msgheader.proto
+
+#ifndef PROTOBUF_msgheader_2eproto__INCLUDED
+#define PROTOBUF_msgheader_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 communication {
+
+// Internal implementation detail -- do not call these.
+void  protobuf_AddDesc_msgheader_2eproto();
+void protobuf_AssignDesc_msgheader_2eproto();
+void protobuf_ShutdownFile_msgheader_2eproto();
+
+class MsgHeader;
+
+// ===================================================================
+
+class MsgHeader : public ::google::protobuf::Message {
+ public:
+  MsgHeader();
+  virtual ~MsgHeader();
+  
+  MsgHeader(const MsgHeader& from);
+  
+  inline MsgHeader& operator=(const MsgHeader& 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 MsgHeader& default_instance();
+  
+  void Swap(MsgHeader* other);
+  
+  // implements Message ----------------------------------------------
+  
+  MsgHeader* New() const;
+  void CopyFrom(const ::google::protobuf::Message& from);
+  void MergeFrom(const ::google::protobuf::Message& from);
+  void CopyFrom(const MsgHeader& from);
+  void MergeFrom(const MsgHeader& 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 uint32 cmd = 1;
+  inline bool has_cmd() const;
+  inline void clear_cmd();
+  static const int kCmdFieldNumber = 1;
+  inline ::google::protobuf::uint32 cmd() const;
+  inline void set_cmd(::google::protobuf::uint32 value);
+  
+  // required uint32 length_data = 2;
+  inline bool has_length_data() const;
+  inline void clear_length_data();
+  static const int kLengthDataFieldNumber = 2;
+  inline ::google::protobuf::uint32 length_data() const;
+  inline void set_length_data(::google::protobuf::uint32 value);
+  
+  // optional uint32 status = 3;
+  inline bool has_status() const;
+  inline void clear_status();
+  static const int kStatusFieldNumber = 3;
+  inline ::google::protobuf::uint32 status() const;
+  inline void set_status(::google::protobuf::uint32 value);
+  
+  // optional uint64 token = 4;
+  inline bool has_token() const;
+  inline void clear_token();
+  static const int kTokenFieldNumber = 4;
+  inline ::google::protobuf::uint64 token() const;
+  inline void set_token(::google::protobuf::uint64 value);
+  
+  // @@protoc_insertion_point(class_scope:communication.MsgHeader)
+ private:
+  ::google::protobuf::UnknownFieldSet _unknown_fields_;
+  mutable int _cached_size_;
+  
+  ::google::protobuf::uint32 cmd_;
+  ::google::protobuf::uint32 length_data_;
+  ::google::protobuf::uint32 status_;
+  ::google::protobuf::uint64 token_;
+  friend void  protobuf_AddDesc_msgheader_2eproto();
+  friend void protobuf_AssignDesc_msgheader_2eproto();
+  friend void protobuf_ShutdownFile_msgheader_2eproto();
+  
+  ::google::protobuf::uint32 _has_bits_[(4 + 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 MsgHeader* default_instance_;
+};
+// ===================================================================
+
+
+// ===================================================================
+
+// MsgHeader
+
+// required uint32 cmd = 1;
+inline bool MsgHeader::has_cmd() const {
+  return _has_bit(0);
+}
+inline void MsgHeader::clear_cmd() {
+  cmd_ = 0u;
+  _clear_bit(0);
+}
+inline ::google::protobuf::uint32 MsgHeader::cmd() const {
+  return cmd_;
+}
+inline void MsgHeader::set_cmd(::google::protobuf::uint32 value) {
+  _set_bit(0);
+  cmd_ = value;
+}
+
+// required uint32 length_data = 2;
+inline bool MsgHeader::has_length_data() const {
+  return _has_bit(1);
+}
+inline void MsgHeader::clear_length_data() {
+  length_data_ = 0u;
+  _clear_bit(1);
+}
+inline ::google::protobuf::uint32 MsgHeader::length_data() const {
+  return length_data_;
+}
+inline void MsgHeader::set_length_data(::google::protobuf::uint32 value) {
+  _set_bit(1);
+  length_data_ = value;
+}
+
+// optional uint32 status = 3;
+inline bool MsgHeader::has_status() const {
+  return _has_bit(2);
+}
+inline void MsgHeader::clear_status() {
+  status_ = 0u;
+  _clear_bit(2);
+}
+inline ::google::protobuf::uint32 MsgHeader::status() const {
+  return status_;
+}
+inline void MsgHeader::set_status(::google::protobuf::uint32 value) {
+  _set_bit(2);
+  status_ = value;
+}
+
+// optional uint64 token = 4;
+inline bool MsgHeader::has_token() const {
+  return _has_bit(3);
+}
+inline void MsgHeader::clear_token() {
+  token_ = GOOGLE_ULONGLONG(0);
+  _clear_bit(3);
+}
+inline ::google::protobuf::uint64 MsgHeader::token() const {
+  return token_;
+}
+inline void MsgHeader::set_token(::google::protobuf::uint64 value) {
+  _set_bit(3);
+  token_ = value;
+}
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+}  // namespace communication
+
+#ifndef SWIG
+namespace google {
+namespace protobuf {
+
+
+}  // namespace google
+}  // namespace protobuf
+#endif  // SWIG
+
+// @@protoc_insertion_point(global_scope)
+
+#endif  // PROTOBUF_msgheader_2eproto__INCLUDED
diff --git a/mock-ril/msgheader.proto b/mock-ril/msgheader.proto
new file mode 100644 (file)
index 0000000..0886de9
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+// Author: wink@google.com (Wink Saville)
+
+package communication;
+
+option java_package='com.android.internal.communication';
+
+message MsgHeader {
+  required uint32 cmd = 1;
+  required uint32 length_data = 2;
+  optional uint32 status = 3;
+  optional uint64 token = 4;
+}
diff --git a/mock-ril/msgheader_pb2.py b/mock-ril/msgheader_pb2.py
new file mode 100644 (file)
index 0000000..0b70cc9
--- /dev/null
@@ -0,0 +1,74 @@
+# 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='msgheader.proto',
+  package='communication',
+  serialized_pb='\n\x0fmsgheader.proto\x12\rcommunication\"L\n\tMsgHeader\x12\x0b\n\x03\x63md\x18\x01 \x02(\r\x12\x13\n\x0blength_data\x18\x02 \x02(\r\x12\x0e\n\x06status\x18\x03 \x01(\r\x12\r\n\x05token\x18\x04 \x01(\x04\x42$\n\"com.android.internal.communication')
+
+
+
+
+_MSGHEADER = descriptor.Descriptor(
+  name='MsgHeader',
+  full_name='communication.MsgHeader',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    descriptor.FieldDescriptor(
+      name='cmd', full_name='communication.MsgHeader.cmd', index=0,
+      number=1, type=13, cpp_type=3, 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),
+    descriptor.FieldDescriptor(
+      name='length_data', full_name='communication.MsgHeader.length_data', index=1,
+      number=2, type=13, cpp_type=3, 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),
+    descriptor.FieldDescriptor(
+      name='status', full_name='communication.MsgHeader.status', index=2,
+      number=3, type=13, cpp_type=3, 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='token', full_name='communication.MsgHeader.token', index=3,
+      number=4, type=4, cpp_type=4, 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=34,
+  serialized_end=110,
+)
+
+
+
+class MsgHeader(message.Message):
+  __metaclass__ = reflection.GeneratedProtocolMessageType
+  DESCRIPTOR = _MSGHEADER
+  
+  # @@protoc_insertion_point(class_scope:communication.MsgHeader)
+
+# @@protoc_insertion_point(module_scope)
index 0514655..11e2da9 100644 (file)
Binary files a/mock-ril/ril.desc and b/mock-ril/ril.desc differ
index d49209f..8bc9287 100644 (file)
@@ -316,7 +316,9 @@ void protobuf_AddDesc_ril_2eproto() {
     "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);
+    "\022\020\n\014APPTYPE_RUIM\020\003\022\020\n\014APPTYPE_CSIM\020\004B3\n("
+    "com.android.internal.telephony.ril_proto"
+    "B\007RilCmds", 2689);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "ril.proto", &protobuf_RegisterTypes);
   RilAppStatus::default_instance_ = new RilAppStatus();
index e95550e..5e93446 100644 (file)
@@ -3,6 +3,9 @@
 
 package ril_proto;
 
+option java_package='com.android.internal.telephony.ril_proto';
+option java_outer_classname='RilCmds';
+
 enum RilCommand {
   CMD_GET_SIM_STATUS                        = 1;
   CMD_ENTER_SIM_PIN                         = 2;
index 9c49fb9..67edaba 100644 (file)
@@ -10,7 +10,7 @@ from google.protobuf import descriptor_pb2
 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')
+  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\x42\x33\n(com.android.internal.telephony.ril_protoB\x07RilCmds')
 
 _RILCOMMAND = descriptor.EnumDescriptor(
   name='RilCommand',
index c45ea3a..08b082e 100755 (executable)
@@ -29,6 +29,7 @@ import time
 
 import ctrl_pb2
 import ril_pb2
+import msgheader_pb2
 
 def recvall(s, count):
   """Receive all of the data otherwise return none.
@@ -71,28 +72,8 @@ class MsgHeader:
     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
+    """Send the header to the socket
 
     Args:
       s: socket
@@ -100,11 +81,27 @@ class MsgHeader:
     Returns
       nothing
     """
-    sendall(s, self.packHeader())
+    mh = msgheader_pb2.MsgHeader()
+    mh.cmd = self.cmd
+    mh.token = self.token
+    mh.status = self.status
+    mh.length_data = self.length_protobuf
+    mhser = mh.SerializeToString()
+    len_msg_header_raw = struct.pack('<i', len(mhser))
+    sendall(s, len_msg_header_raw)
+    sendall(s, mhser)
 
   def recvHeader(self, s):
-    """Receive the header from the socket and unpack"""
-    self.unpackHeader(recvall(s, 20))
+    """Receive the header from the socket"""
+    len_msg_header_raw = recvall(s, 4)
+    len_msg_hdr = struct.unpack('<i', len_msg_header_raw)
+    mh = msgheader_pb2.MsgHeader()
+    mh_raw = recvall(s, len_msg_hdr[0])
+    mh.ParseFromString(mh_raw)
+    self.cmd = mh.cmd
+    self.token = mh.token
+    self.status = mh.status
+    self.length_protobuf = mh.length_data;
 
 class Msg:
   """A message consists of a fixed length MsgHeader followed by a protobuf.