给的自启动示例应该要在rk588 Android12里面添加的
时间: 2024-02-09 20:10:28 浏览: 30
非常抱歉,我之前给你的自启动示例是基于 Android 10 的,可能不适用于 Android 12。对于 Android 12,你可以尝试使用以下方法来实现自启动。
首先,在 `/vendor/etc/init/hw/init.rc` 文件中添加以下内容,实现在系统启动时自动执行 `/vendor/bin/switch_screen` 脚本:
```bash
service switch_screen /vendor/bin/switch_screen
class main
user root
group root
oneshot
```
接下来,在 `/vendor/bin` 目录下创建一个名为 `switch_screen` 的符号链接,指向 `/system/bin/switch_screen.sh` 文件,并赋予可执行权限:
```bash
ln -s /system/bin/switch_screen.sh /vendor/bin/switch_screen
chmod +x /vendor/bin/switch_screen
```
最后,在 `/vendor/etc/selinux/plat_sepolicy.cil` 文件中添加以下内容,以允许 `/vendor/bin/switch_screen` 脚本在系统启动时自动运行:
```
(type vendor_exec_file (file_type)
(executable
(user root)
(group root)
(allow any)) ;允许任何进程执行
)
(type switch_screen_exec (domain)
(process (execmem (file (allow vendor_exec_file)))) ;允许执行 vendor_exec_file
)
(domain (switch_screen_exec)
(type switch_screen_exec)
(allow switch_screen_exec vendor_exec_file (file (read open getattr execute))) ;允许 switch_screen_exec 进程执行 vendor_exec_file
)
```
需要注意的是,修改 `/vendor/etc/selinux/plat_sepolicy.cil` 文件可能会影响系统的安全性和稳定性,因此在修改前请备份该文件,并谨慎操作。
希望这个修改后的示例对你有所帮助。