title: android read SMS Inbox messages
body: <p>I write a program to read android phone sms records. The like this:</p>
  
  <pre><code>    package com.example.read_sms;
  
      import android.app.Activity;
      import android.database.Cursor;
      import android.net.Uri;
      import android.os.Bundle;
      import android.widget.TextView;
  
      public class MainActivity extends Activity {
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
              TextView textView = (TextView) findViewById(R.id.textView1);
              Uri uriSMSURI = Uri.parse("content://sms/inbox");
              Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,
                      null);
              String sms = "";
              while (cur.moveToNext()) {
                  sms += "From :"
                          + cur.getString(cur.getColumnIndexOrThrow("address"))
                          + " : " + cur.getString(cur.getColumnIndexOrThrow("body")) + "\n";
              }
              textView.setText(sms);
          }
  
      }
  </code></pre>
  
  <p>I run this on a emulator, the emulator run on my goldfish kernel. I insert a kernel to hook read sms, the code like this:</p>
  
  <pre><code>asmlinkage int our_sys_open(const char* file, int flags, int mode)
  {
  //联系人 /data/data/com.android.providers.contacts/databases/contacts2.db            //通话记录                 /data/data/com.android.providers.telephony/databases/telephony.db
   //短信记录  /data/data/com.android.providers.telephony/databases/mmssms.db
    char * contact =        "/data/data/com.android.providers.contacts/databases/contacts2.db";
    char * telephony =     "/data/data/com.android.providers.telephony/databases/telephony.db";
    char * sms = "/data/data/com.android.providers.telephony/databases/mmssms.db";
  if (strcmp(file, contact) == 0){
    printk("应用程序正在读取手机的联系人记录！！！\n");
   }
  if (strcmp(file, telephony) == 0){
   printk("应用程序正在读取手机的通话记录！！！\n");
  }
  if (strcmp(file, sms) == 0){
   printk("应用程序正在读取手机的短信记录！！！\n");
  }
  
  
   // printk("A file was opened\n%s\n%d\n%d\n",file,flags,mode);
   return original_call_open(file, flags, mode);
  }
  </code></pre>
  
  <p>Above is my own hook function, I across "cat /proc/kmsg" to look kernel info.
  When i install this apk, the kernel show 
  "应用程序正在读取手机的联系人记录！！！"
  “/data/data/com.android.providers.contacts/databases/contacts.db-mj4dec6bdb”
  "应用程序的名称是ContactsProvide"
  "该应用程序的进程id是：222"
  I don't know why the kernel show "...contacts.db....", but I read sms. In my opinion it should show "/data/data/com.android.providers.telephony/databases/mmssms.db....". Can anybody help me?THX.</p>