| Wink Saville | 3d6d348 | 2010-07-19 20:37:44 -0700 | [diff] [blame] | 1 | Mock-ril: |
| 2 | |
| 3 | Install: |
| 4 | |
| Wink Saville | a3260a5 | 2010-11-08 19:18:30 -0800 | [diff] [blame] | 5 | The protoc is now part of the Android build but its |
| 6 | called "aprotoc" so it doesn't conflict with versions |
| 7 | already installed. If you wish to install it permanetly |
| 8 | see external/protobuf/INSTALL.txt and |
| 9 | external/protobuf/python/README.txt. If you get |
| 10 | "from google.protobuf import xxxx" statements that |
| 11 | google.protobuf is not found, you didn't install the |
| Wink Saville | 3d6d348 | 2010-07-19 20:37:44 -0700 | [diff] [blame] | 12 | python support for protobuf. Also on Mac OSX I got an |
| 13 | error running the protoc tests but installing was fine. |
| 14 | |
| 15 | Running/testing: |
| 16 | |
| 17 | See "Testing a new ril:" below for general instructions but |
| 18 | for the mock-ril I've added some targets to the Makefile to |
| Wink Saville | 2c1fb3a | 2011-03-19 13:42:45 -0700 | [diff] [blame^] | 19 | ease testing. Also Makefile needs to know the device being |
| 20 | used as this determines the directory where files are found |
| 21 | and stored. ANDROID_DEVICE is an environment variable and |
| 22 | maybe either exported: |
| 23 | $ export ANDROID_DEVICE=stingray |
| 24 | |
| 25 | or it can be passed on the command line: |
| 26 | $ make clean ANDROID_DEVICE=stingray |
| 27 | |
| 28 | If it's not set "passion" is the default. |
| Wink Saville | 3d6d348 | 2010-07-19 20:37:44 -0700 | [diff] [blame] | 29 | |
| 30 | Execute the "first" target first to setup appropriate |
| 31 | environment: |
| 32 | $ cd hardware/ril/mock-ril |
| 33 | $ make first |
| 34 | |
| 35 | If changes made to ".proto" files run make with the default |
| 36 | "all" target: |
| 37 | $ make |
| 38 | |
| 39 | If changes are made to "c++" file create a new library and |
| 40 | run the "test" target: |
| 41 | $ mm |
| 42 | $ make test |
| 43 | |
| 44 | If changes to only the execute "js" target: |
| 45 | $ make js |
| 46 | |
| 47 | To run the test control server: |
| 48 | $ make tcs |
| 49 | |
| 50 | Implementation: |
| 51 | |
| 52 | The mock-ril is a library where the ril is implemented primarily |
| 53 | in javascript, mock-ril.js. In addition it can be controlled by |
| 54 | sending messages from another computer to port 54312 (TODO make |
| 55 | programmable) to the ctrlServer, a Worker in In mock-ril.js. |
| 56 | |
| 57 | See mock_ril.js for additional documentation. |
| 58 | |
| 59 | files: |
| 60 | ctrl.proto Protobuf messages for the control server |
| 61 | ctrl.* Protobuf generated files. |
| 62 | ctrl_pb2.py Python files generated from ctrl.proto |
| 63 | ctrl_server.* Cpp interface routines between ctrlServer |
| 64 | in javascript and the controller. |
| 65 | experiments.* Early experiments |
| 66 | js_support.* Java script support methods. Exposes various |
| 67 | routines to javascript, such as print, readFile |
| 68 | and include. |
| 69 | logging.h LOG_TAG and include utils/log.h |
| 70 | mock_ril.[cpp|h] Main module inteface code. |
| 71 | mock_ril.js The mock ril |
| 72 | node_buffer.* A Buffer for communicating between c++ and js. |
| 73 | This was ported from nodejs.org. |
| 74 | node_object.* An object wrapper to make it easier to expose |
| 75 | c++ code to js. Ported from nodejs.org. |
| 76 | node_util.* Some utilities ported from nodejs.org. |
| 77 | protobuf_v8.* Protobuf code for javascript ported from |
| 78 | http://code.google.com/p/protobuf-for-node/. |
| 79 | requests.* Interface code for handling framework requests. |
| 80 | responses* Interface code for handling framework responses. |
| 81 | ril.proto The protobuf version of ril.h |
| 82 | ril_vars.js Some additional variables defined for enums in |
| 83 | ril.h. |
| 84 | ril_pb2.py Python files generated from ril.proto. |
| 85 | status.h STATUS constants. |
| 86 | tcs.py Test the ctrlServer. |
| 87 | util.* Utility routines |
| 88 | worker.* Define WorkerThread and WorkerQueue. |
| 89 | worker_v8.* Expose WorkerQueue to js. |
| 90 | |
| 91 | |
| 92 | TODO: more documentation. |
| 93 | |
| 94 | |
| Wink Saville | c651f24 | 2010-05-28 17:52:55 -0700 | [diff] [blame] | 95 | Testing a new ril: |
| 96 | |
| Wink Saville | 3d6d348 | 2010-07-19 20:37:44 -0700 | [diff] [blame] | 97 | The Makefile is used to generate files and make testing easier. |
| Wink Saville | 2c1fb3a | 2011-03-19 13:42:45 -0700 | [diff] [blame^] | 98 | and there are has several targets: |
| Wink Saville | 3d6d348 | 2010-07-19 20:37:44 -0700 | [diff] [blame] | 99 | |
| 100 | all runs protoc and generates files, ril.desc ril.pb.* |
| 101 | |
| 102 | clean target removes generated files. |
| 103 | |
| 104 | first changes to root, remounts r/w and copies some files. |
| 105 | |
| 106 | test copies the latest libmock_ril.so and kills rild |
| 107 | to run the new mockril |
| 108 | |
| 109 | General instructions for testing ril's: |
| 110 | |
| Wink Saville | c651f24 | 2010-05-28 17:52:55 -0700 | [diff] [blame] | 111 | 1) On the device login in as root and remount file system so it's read/write: |
| 112 | $ adb root |
| 113 | restarting adbd as root |
| 114 | |
| 115 | $ adb remount |
| 116 | remount succeeded |
| 117 | |
| 118 | 2) Set rild.libpath to the name of the ril: |
| 119 | adb shell setprop rild.libpath /system/lib/libmock_ril.so |
| 120 | |
| 121 | Using setprop makes the change temporary and the old ril will be |
| 122 | used after rebooting. (Another option is to set rild.libpath in |
| 123 | /data/local.prop, but don't forget to reboot for it to take effect). |
| 124 | |
| 125 | 3) Compile and copy the ril to /system/lib/: |
| 126 | adb push out/target/product/passion/system/lib/libmock_ril.so /system/lib/ |
| 127 | |
| 128 | 4) To restart the ril, kill the currently running ril and the new one |
| 129 | will automatically be restarted. You can use the ps command to find |
| 130 | /system/bin/rild PID, 3212 below and kill it: |
| 131 | $ adb shell ps | grep rild |
| 132 | radio 3212 1 3224 628 ffffffff afd0e4fc S /system/bin/rild |
| 133 | |
| 134 | $ adb shell kill 3212 |
| 135 | |
| Wink Saville | a3260a5 | 2010-11-08 19:18:30 -0800 | [diff] [blame] | 136 | or |
| 137 | |
| 138 | $ adb shell setprop ctl.restart ril-daemon |
| 139 | |
| Wink Saville | 934c2e2 | 2010-06-03 15:39:13 -0700 | [diff] [blame] | 140 | 5) Make modifications, go to step 3. |