Personal Project Android patched QEMU NAT
Intro: The emulator of Android SDK comes from Qemu and is modified to support features such as bandwidth shaping. It is good to most developers, but it seems to be lacking some features, I guess some people out there are also interested in tweaking it to fit your needs.
Technical Background:
Because Qemu runs guest OS, it naturally needs to manipulates packets when it is under NAT mode. And to provide some small utilities, it has tcp/udp IP support in itself by using SLiRP, which was originally designed for PPP back in 90s.
Three pictures are attached in case you want to know the key points of NAT of UDP in Android. Sorry, TCP is not my interest at the moment.
Tuesday, August 23, 2011
Saturday, August 06, 2011
Friday, November 26, 2010
A Simple Flowchart for XML Parsing

I forget things easily. So I'd like to keep a note for my recent study about XML Document parsing and framing. Framing is easier as it is a controllable data source I provide. So I will focus on the parsing part of it.
I hereby is showing a flow chart I just drew for the XML parsing procedure. I guess I must have made some errors in it and it is not qualified to be good enough. However, like I said, this is a note I am trying to keep. If you know what can be improved, please don't hesitate.
Some notes that everyone should know:
- The most frustrating thing I found is there is *NO* single package that can provide me parsing, framing, validating, data-binding code generation in C language while this is the language we used in most embedded systems.
- Some of the steps in this flowchart be merged into one single step.
- There are commercial products available with all the needed functions. Even with HTTP client/server in case you need to use XML over Web.
- Links on Wikipedia about data-binding: http://en.wikipedia.org/wiki/XML_data_binding.
- The most comprehensive list of resources about XML data binding: http://www.rpbourret.com/xml/XMLDataBinding.htm
ps. Drawn with Dia 0.97.1 Windows version.
Labels:
Study
Saturday, November 13, 2010
Android ListActivity Problem
I met these error messages last night and found the cause was I did not read document thorough. :)
11-12 14:33:19.976: WARN/ActivityManager(73): Launch timeout has expired, giving up wake lock!
11-12 14:33:20.164: WARN/ActivityManager(73): Activity idle timeout for HistoryRecord{44f542b8 com.demo.wally/.listview}
ListActivity is another kind of Activity that has a built-in ListView. I called the method: setContentView, under a ListActivity context, so I was destined for this problem.
In this ListActivity, a fullscreen ListView is used. To customize my own screen, I need to either take advantage of possible ListView options or create another view with ListView in it and use a normal Activity to create data adapters, and so on.
Friday, November 12, 2010
XML File Indentation
I copied contents from a PDF file (I can't find its original version with proper indentation) and pasted into an XML file. The resulting file is flat with no indentation at all. After trying to fix it using vim and other text editors. I decide to give it a try to find a formatter. And I found one:
Useful to me a least.
Thursday, November 11, 2010
Cookie Flag: HttpOnly
Today when I am trying to understand how cookies work in libcurl (). I found some cookies from Google has a strange flag behind it: HttpOnly.
I know this is a common sense to every web developer. As an embedded system engineer that never dealt with any web programming in last 9 years, I think I am eligible to not knowing it...
Anyway, it is shown by an example source code of libcurl as:
[1]: .google.com.tw TRUE / FALSE 1352547231 PREF ID=id_removed:FF=0:TM=1289474431:LM=1289475431:S=oLGFV.....
[2]: #HttpOnly_.google.com.tw TRUE / FALSE 1305286631 NID 40=T9tf9Y.....
This #HttpOnly_ confused me. After some research, I found that because malicious Javascript code may be able to access other website's cookies and transfer them to its site. This is a cookie theft as described in Wikipedia (http://en.wikipedia.org/wiki/HTTP_cookie#Cookie_theft).
This flag blocks cookies flagged as HttpOnly being accessed by any scripts from originating website and hence prevents injected malicious code from sending important cookies to another site.
Wednesday, September 01, 2010
Python PyGtk + Multi-thread
I chose Python language to make UI development easier. With Glade, a buggy but still functionally okay utility, I can design UI in a short time and load it up with my Python program.
I am doing some socket operations in this program, but found that multi-threading in this program seems to be malfunctioning. And the socket accept action never returns and continue and running my code. After some hours research, I found that GTK will lockout all other threads if I do not perform proper init.
So here is the trick when using PyGtk + multi-thread:
1. import gtk
2. gtk.gdk.threads_init()
With these two lines of code, the thread works happily. Note that multi-threaded applications need to add UI related actions to GTK main loop instead of touching them directly.
Labels:
Misc
Monday, August 16, 2010
Interesting Question
Maybe not so interesting to most people. But it is good to have a chance to dig a hole and jump into it by myself. I am implementing this and hopefully get it resolved elegantly.
Target:
Design a data structure + algorithm to be able to respond to query requests in a timely manner.
1. Assume you have a set of string, say N strings.
2. The lengths of the N strings vary from 1 byte to X bytes.
3. Design a data structure + algorithm to provide a fast query based on:
4. If a string S is provided, we want to be able to find out all strings containing S as their substring in O (log (N)) time.
2. The lengths of the N strings vary from 1 byte to X bytes.
3. Design a data structure + algorithm to provide a fast query based on:
4. If a string S is provided, we want to be able to find out all strings containing S as their substring in O (log (N)) time.
Conditions:
A. Pre-processing time to make the data structure ready for query need not be considered. We can improve it later on. This is to simply the answer at beginning. I started with rigid requirement of this part and had trouble to have an answer quickly at beginning.
B. Assuming we to run the query many times, and hence first priority is to optimize complexity of the query.
C. You can use hash table in design at beginning. But it is really a memory hogger, so eventually you need to change it to something else.
Labels:
Fun of the day
Monday, May 17, 2010
Adding Logging Support to MaxiCom 0.2
I wanted a neat serial console tool. I hate pressing combination keys so minicom's full capability and key combos are not what I want. I am not used to the separated command line of CuteCom, either.
I found MaxiCom's simple and intuitive GUI fits my needs perfectly when I have access to desktop GUI interface. But my job routinely requires capturing console logs. So its lacking of this feature made me add this feature.

When you click on the "LOG" button, it generates a file under $HOME with filename containing the date and time the log file is started. When you finished the capture, click log again. The file is then completed. When the file is created, the date and time will be written to the log file and when it ends, the date and time are also written.
Labels:
Fun of the day,
tech
Sunday, May 09, 2010
Mike deGruy: Hooked by an octopus
This guys is really passionate about what he does. And all of us should try to think about what we can do to our backyard. (Although I do not have one.)
Subscribe to:
Posts (Atom)