Reputation: 53
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:
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?
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.)
Upvotes: 4
Views: 3378
Reputation: 1914
There is no way to access not exported component from a non-root ADB.
In theory you can run this code to execute "Reply" action:
adb shell am startservice --user 10104 \
-a "com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE" \
-d "content://com.whatsapp.provider.contact/contacts/2256" \
-n "com.whatsapp/.notification.DirectReplyService" \
--es extra_key extra_string_value
com.whatsapp
--user
- user uid,
-a
- action from requestIntent.act
-d
- data_uri from requestIntent.dat
-n
- component from requestIntent.cmp
--es EXTRA_KEY extra_string_value
- extra keys/values, which application should accepts. It's optional, and defined in the application, actually this action accepts extra keys, see (has extras)
, it depends of application and could be in the application documentation
Intent documentation, commands, arguments and options
Whatsapp Android intent system
Upvotes: 1