title: Android : Logging all API calls
body: <p>I'm working on a collage project about security in Android. One part of the project attempts to capture and log all API function called by the selected APK. This can't be done with a external programs so in the project we are working with the Android source code to modify the ROM.</p>
  
  <p>At the present time we only have two possible solutions:</p>
  
  <p>DVM JNI Bridge</p>
  
  <p>The API is Java code so, obviously, the Dalvik Virtual Machine needs a bridge to execute JNI code.  The function which handle all cases is dvmCallJNIMethod(const u4* args, JValue* pResult, const Method* method, Thread* self). In this function we can get the name and the class of the called function.</p>
  
  <p>This function can log all the JNI code executed, which includes API calls. But there is no easy way to distinct between private calls and API calls. And, if we wanted to execute some code depending on the risk of the API call executed, we would have to create a huge and inefficient switch.</p>
  
  <p>API Framework</p>
  
  <p>another solution To log all API calls is creating a new interface for the framework. With a new logging class and a simple inheritance should be easy to log all calls and add a risk parameter. But it would mean changing a lot of code. Also, Java code has worst performance than C, so it might not be the most efficient way.</p>
  
  <p>More over, we would like to ask you a few questions about Android DVM and the API.</p>
  
  <p>1.Which is exactly the call flow between DVM and the API?
  2.Could be the DVM monitor a good idea to log the calls?
  3.Which role have the shared libraries in all of this?
  4.Are all API calls really Java code?</p>
  
  <p>Thanks for your time.</p>