使用 HDMI CEC 命令关闭(待机)Android 电视不适用于 Amlogic MBOX

问题描述 投票:0回答:1

我正在尝试使用适用于 Android 的 HDMI CEC 通过 Android 应用程序关闭我的三星电视,我使用的是 Amlogic MBOX

  1. 三星电视 HDMI CEC 已开启。
  2. Amlogic MBOX HDMI CEC 也已打开。

我如何在 Android 中执行命令的代码片段

fun sudoForResult(vararg strings: String): String? {
    Log.e("TAG", "sudoForResult: executing ")
    var res: String? = ""
    var outputStream: DataOutputStream? = null
    var response: InputStream? = null
    try {
        val su = Runtime.getRuntime().exec("su")
        outputStream = DataOutputStream(su.outputStream)
        response = su.inputStream
        for (s in strings) {
            outputStream.writeBytes("$s\n")
            outputStream.flush()
        }
        outputStream.writeBytes("exit\n")
        outputStream.flush()
        try {
            su.waitFor()
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }
        res = readFully(response)
    } catch (e: IOException) {
        e.printStackTrace()
    } finally {
        outputStream?.close()
        response?.close()
    }
    Log.e("TAG", "sudoForResult: op = \n$res")
    return res
}

此命令用于在 Amlogic MBOX 中启用 HDMI CEC,并且它正在工作。

sudoForResult(
    "settings put global hdmi_control_enabled 1",
    "settings put global hdmi_control_auto_wakeup_enabled 1",
    "settings put global hdmi_control_auto_device_off_enabled 1"
)

这两个命令都尝试过,但电视没有关闭。

sudoForResult("echo 0x40 0x36 > /sys/class/cec/cmd")
sudoForResult("echo 0xF0 0x36 > /sys/class/cec/cmd")

我的 Amlogic MBOX 已经是 root 设备了。

我也尝试了与 Hdmi-cec 相关的问题的大部分答案和评论。

任何人都可以帮忙解决这个问题吗?

其他一些带有日志输出的命令(如果有人可以从中找到问题或解决方案)

1.   sudoForResult(
            "ls -l /dev/cec",
            "ls -l /sys/class/cec/",
            "cat /sys/class/cec/physical_addr",
            "cat /sys/class/cec/device_type",
            "cat /sys/class/cec/vendor_id"
        )
    
Log output :
crw-rw-rw- 1 root root 217,   0 2023-07-07 09:05 /dev/cec 
total 0
-r--r--r-- 1 root root 4096 2023-07-07 09:14 arc_port
lrwxrwxrwx 1 root root    0 2023-07-07 09:14 cec -> ../../devices/aocec/cec
-r--r--r-- 1 root root 4096 2023-07-07 09:14 cec_version
--w------- 1 root root 4096 2023-07-07 09:19 cmd
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 dbg_en
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 device_type
-r--r--r-- 1 root root 4096 2023-07-07 09:14 dump_reg
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 fun_cfg
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 menu_language
-r--r--r-- 1 root root 4096 2023-07-07 09:14 osd_name
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 physical_addr
-r--r--r-- 1 root root 4096 2023-07-07 09:14 pin_status
-r--r--r-- 1 root root 4096 2023-07-07 09:14 port_num
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 port_seq
-r--r--r-- 1 root root 4096 2023-07-07 09:14 port_status
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 vendor_id
-r--r--r-- 1 root root 4096 2023-07-07 09:14 wake_up
1000
4
0


2.  sudoForResult("echo 0xF0 0x36 > /sys/class/cec/cmd && sleep 0.1 && cat /sys/class/cec/dump_reg")

Log output :

TX buffer:
0: 0
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
CEC_TX_MSG_LENGTH: 0
CEC_TX_MSG_CMD: 0
CEC_TX_WRITE_BUF: 0
CEC_TX_CLEAR_BUF: 0
CEC_RX_MSG_CMD: 0
CEC_RX_CLEAR_BUF: 0
CEC_LOGICAL_ADDR0:14
CEC_LOGICAL_ADDR1: 0
CEC_LOGICAL_ADDR2: 0
CEC_LOGICAL_ADDR3: 0
CEC_LOGICAL_ADDR4: 0
CEC_CLOCK_DIV_H: 0
CEC_CLOCK_DIV_L: 0
RX buffer:
0: 0
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
CEC_RX_MSG_LENGTH: 0
CEC_RX_MSG_STATUS: 0
CEC_RX_NUM_MSG: 0
CEC_TX_MSG_STATUS: 0
CEC_TX_NUM_MSG: 0


android android-tv hdmi-cec
1个回答
0
投票

使用此命令

echo "0x40 0x36" > /sys/class/cec/cmd - 关闭电视

echo "0x40 0x04" > /sys/class/cec/cmd - 打开电视

© www.soinside.com 2019 - 2024. All rights reserved.