gpt4 book ai didi

android - 与来自 ADB Shell 的 android 通知操作进行交互

转载 作者:行者123 更新时间:2023-12-04 03:50:20 46 4
gpt4 key购买 nike

我有一部 Android(7) 手机和一台 Linux 电脑。通过启用 USB 调试并使用我的电脑终端,我可以使用以下命令读取手机的通知:adb shell dumpsys notification --noredact现在,在 android 中有一些通知,我们可以直接从通知中与应用程序进行交互。例如,在 Whatsapp 通知中,通常有两个按钮:回复和标记为已读。在 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 与这些选项进行交互吗?例如,有没有类似 adb shell <SOME COMMAND> 'Message to be sent in whatsapp with reply option' 的命令?哪个会在whatsapp中发送文本作为回复而不打开应用程序?
  • 是否可以使用任何 adb 命令滑动通知? (不是adb shell input swipe x0 y0 x1 y1,每次都需要解锁手机)

  • 先感谢您!
    编辑:
    这是我发现的可能与这个问题有关的内容。
    我认为我必须以某种方式启动与提到的 PendingIntent id 相关联的特定 Intent (在本例中为 6becf4887b8050 )
    使用命令 adb shell dumpsys activity intents > output.txt然后搜索 87b8050output.txt ,我找到了 Intent 的名称。情况如下:
      * 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
    现在我认为有可能启动 Intent com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE使用 adb shell am命令,并将 Intent ID 和消息作为一些参数传递。
    (就像我们可以使用 am 命令从 adb 启动 Whatsapp 一样,应该也可以启动 pendingIntent。)

    最佳答案

    无法从非根 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 - data_uri 来自 requestIntent.dat -n - 来自 requestIntent.cmp 的组件 --es EXTRA_KEY extra_string_value - 应用程序应接受的额外键/值。它是可选的,在应用程序中定义,实际上这个 Action 接受额外的键,见 (has extras) ,它取决于应用程序,可能在应用程序文档中
    Intent documentation, commands, arguments and options
    Whatsapp Android intent system

    关于android - 与来自 ADB Shell 的 android 通知操作进行交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64506380/

    46 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com