#StackBounty: #adb #notifications #usb-debugging #shell Interact with notification action from ADB Shell

Bounty: 250

I have an Android(7) phone and a Linux pc. By enabling USB debugging and using the terminal of my pc, I am able to read the notifications of my phone using the command: adb shell dumpsys notification --noredact

Now, there are some notifications in android in which we can interact with the app directly from the notification. For example, in a Whatsapp notification, there are usually two buttons: Reply & Mark as read. In YouTube, there are options like Play, Turn off, Watch later. In the output of the above command, these options are visible in the following form:

actions={
        [0] "Reply" -> PendingIntent{6becf48: PendingIntentRecord{87b8050 com.whatsapp startService (whitelist: +30s0ms)}}
        [1] "Mark as read" -> PendingIntent{c1661e1: PendingIntentRecord{b8e3249 com.whatsapp startService (whitelist: +30s0ms)}}
      }

I have two questions:

  1. Can we interact with these options from adb shell? For example, is there any command like adb shell <SOME COMMAND> 'Message to be sent in whatsapp with reply option' which will send the text as a reply in whatsapp without opening the app?
  2. Is it possible to swipe the notifications using any adb command? (Not the adb shell input swipe x0 y0 x1 y1, it requires to unlock the phone each time)

Thank you in advance!

Edit:

Here is what I found that may be relevant to this question.

I think that I have to somehow launch the specific intent linked to the mentioned PendingIntent id (in this case 6becf48 or 87b8050)

Using tthe command adb shell dumpsys activity intents > output.txt and then searching for 87b8050 in output.txt, I found the name of the intent. It was as follows:

  * PendingIntentRecord{87b8050 com.whatsapp startService (whitelist: +30s0ms)}
    uid=10104 packageName=com.whatsapp type=startService flags=0x0
    requestIntent=act=com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE dat=content://com.whatsapp.provider.contact/contacts/2256 cmp=com.whatsapp/.notification.DirectReplyService (has extras)
    whitelistDuration=+30s0ms

Now I think that it may be possible to launch the intent com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE using adb shell am command, and passing the intent id and message as some parameters.

(Just like we can launch Whatsapp from adb with am command, it should be possible to launch the pendingIntent also.)


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.