我有一部Android(7)手机和一台Linux pc。通过启用USB调试并使用我的pc终端,我可以使用命令adb shell dumpsys notification --noredact
来读取我的手机的通知。
现在,android中有一些通知,我们可以直接从通知中与应用程序进行交互。例如,在Whatsapp通知中,通常有两个按钮: Reply & Mark。在YouTube中,有一些选项,如播放、关闭、稍后监视。在上述命令的输出中,这些选项以下列形式可见:
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)}}
}
我有两个问题:
adb shell <SOME COMMAND> 'Message to be sent in whatsapp with reply option'
这样的命令可以在whatsapp中不打开应用程序就将文本作为回复发送?adb shell input swipe x0 y0 x1 y1
,它每次都需要解锁手机)提前谢谢你!
编辑:
以下是我发现的可能与这个问题相关的问题。
我认为我必须以某种方式启动与上述PendingIntent id链接的特定意图(在本例中为6becf48
或87b8050
)。
使用tthe命令adb shell dumpsys activity intents > output.txt
,然后在output.txt
中搜索87b8050
,我找到了意图的名称。其内容如下:
* 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
现在,我认为可以使用com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE
命令启动intent adb shell am
,并将意图id和消息作为一些参数传递。
(就像我们可以使用am
命令从亚行启动Whatsapp一样,也应该可以启动pendingIntent。)
发布于 2020-12-06 19:42:56
没有办法从非根ADB.访问未导出的组件。
理论上,您可以运行这段代码来执行“应答”操作:
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
-用户uid
-a
-来自requestIntent.act
的行动
-d
-来自requestIntent.dat
的data_uri
-n
-来自requestIntent.cmp
的组件
--es EXTRA_KEY extra_string_value
-额外的键/值,应用程序应该接受。它是可选的,并且是在应用程序中定义的,实际上这个操作接受额外的键,请参阅(has extras)
,它取决于应用程序,可能在应用程序文档中
https://stackoverflow.com/questions/64506380
复制相似问题