gpt4 book ai didi

android - 如何在 Android init.rc 中读取和运行条件语句

转载 作者:行者123 更新时间:2023-11-30 04:11:52 25 4
gpt4 key购买 nike

我有一个要求,我需要读取一个接口(interface)(比如/sys/module/my_file/parameters/val),然后根据它的值在另一个接口(interface)上写入一些值。这必须在 Android 文件系统的 init.rc 中完成。

流程是这样的

if ( read /sys/module/my_file/parameters/val == "yes") then
write /sys/devices/platform/target_file/val 100

谁能帮我做同样的事情??可能吗??

最佳答案

您可以使用 exec 节来实现:

exec <path> [ <argument> ]*
Fork and execute a program (<path>). This will block until
the program completes execution. It is best to avoid exec
as unlike the builtin commands, it runs the risk of getting
init "stuck".

参见 https://github.com/android/platform_system_core/blob/master/init/readme.txt了解详情。

例子:将您的代码移动到脚本 (my_script.sh) 中。将此添加到您的 init.rc

on boot:
...
exec /path/to/my_script.sh

关于android - 如何在 Android init.rc 中读取和运行条件语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10734011/

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