从 logcat Android-TV 中提取命令

Posted

技术标签:

【中文标题】从 logcat Android-TV 中提取命令【英文标题】:Extract command from logcat Android-TV 【发布时间】:2021-01-28 16:57:55 【问题描述】:

我正在尝试提取单击 android TV 上的特定按钮时调用的命令,最终我想将其添加到应用程序中,但现在我只是想通过 ADB 调用它进行测试。

10-14 10:18:16.654  5058  5058 D SourceElementCallback: onElementClick position:7
10-14 10:18:16.656  5058  5058 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1611 android.content.ContextWrapper.bindService:698 org.droidtv.channels.sources.SourcesUtils.bindToLoggingService:743 org.droidtv.channels.sources.SourcesUtils.switchTo:327 org.droidtv.channels.sources.SourceElementCallback.onElementClick:82
10-14 10:18:16.658  5058  5058 D SourcesUtils: PASSTHROUGH sourceUri:content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5
10-14 10:18:16.660  3878  3972 D org.droidtv.candeebug.Gateway: Returning successfully for event: "event-type":"unknown.28","boot-count":9,"standby-count":9,"kernel-time":4030979,"data":"original-event-type":28,"InputName":"Computer","uiname":"HDMI 1","ver":1
10-14 10:18:16.661  3878  5242 D org.droidtv.candeebug.h.a: Updated total event size to: 6815
10-14 10:18:16.670  2325  5682 I ActivityManager: START u0 act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 flg=0x10000000 cmp=org.droidtv.playtv/.PlayTvActivity (has extras) from uid 1000
10-14 10:18:16.673  3540  3540 D PlayTvActivity: onNewIntent Action android.intent.action.VIEW data content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5
10-14 10:18:16.673  3540  3540 D PlayTvActivity: device ID =5
10-14 10:18:16.673  3540  3540 D PlayTvActivity: onNewIntent: ACTION_VIEW fav_list_id -1
10-14 10:18:16.685  3540  3540 D PlayTvActivity: onResume STATE_STARTED
10-14 10:18:16.686  3540  3540 D TvSessionManager: setStreamType value true

看起来这是被调用的动作?怎么会通过亚行调用呢?

sourceUri:content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5

【问题讨论】:

【参考方案1】:
adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

它适用于 %2F :-)

【讨论】:

您可以格式化您的答案以使其更具可读性。现在答案和句子都混在一起了。【参考方案2】:

您必须通过以下方式致电活动经理am

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

考虑到意图包含额外信息(请参阅(has extras)),那么上面的命令可能会被扩展一点,以便也添加这些额外信息。

棘手的部分是要了解传递给活动管理器的密钥名称和类型(我指的是“设备 ID”,它似乎是作为额外数据提供的数据)。

假设这是一个 int 值,那么你必须追加:

--ei device-id-key 5

更多信息here

【讨论】:

谢谢,它越来越近了,它现在返回:“警告:活动未启动,意图已传递到当前运行的最顶层实例。” 这是因为 Activity 已经加载,系统只是将它带到了前台。

以上是关于从 logcat Android-TV 中提取命令的主要内容,如果未能解决你的问题,请参考以下文章

如何抓取android logcat日志

如何使一个apk既可以在移动端也可以在android-TV中使用?

Android 日志系统分析(三):logcat

Logcat命令详情

终端中查看某个app的logcat输出,支持关键字筛选,支持输出到文件

在命令行过滤 Logcat 日志