0

I have an android connected to PC for testing purposes (test automation that involves sms receiving).

Is it possible to check if new message is available and get its text via adb?

At this moment I only can start the messages app with this command:

>adb shell monkey -p com.android.mms -c android.intent.category.LAUNCHER 1

I cannot find anything that help me to get the messages without recurring to DB or cellphone rooting. Is it possible?

Thanks.

koxta
  • 846
  • 2
  • 8
  • 30
  • Have a look at [this post](https://stackoverflow.com/q/27988069). For example, to pull the whole SMS inbox, you can do something like `adb shell content query --uri content://sms/inbox`. However, in my quick tests just now, I can't get the `--sort` to work with `ASC` or `DESC` specified. Even the example in the query command help page doesn't work. Not sure what's going on there. The default sort order for SMS is `date DESC`, though, which seems appropriate for what you need. – Mike M. Jun 29 '20 at 09:51
  • @MikeM. where I can add that missing permission? I am executing only in cmd, not from an App that I can give permission. adb shell content query --uri content://sms/inbox Error while accessing provider:sms java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/inbox from pid=xxx, uid=xxxrequires android.permission.READ_SMS, or grantUriPermission() – koxta Jun 29 '20 at 11:51
  • Oh, shoot. I didn't even think about that. I ran my test on an emulator. – Mike M. Jun 29 '20 at 12:01
  • Well, admittedly, I don't use adb all that much, but it looks my suggestion above just isn't viable without root. Sorry 'bout that. The only other thing that comes to mind, atm, would be to create some simple intermediary app with the necessary permissions that can dump SMS messages to some file that you could pull to your PC through adb. – Mike M. Jun 29 '20 at 12:39

0 Answers0