如何在Android Q中创建后台系统服务



我正在尝试创建一个系统服务,该服务在系统启动后运行,除了更新sepolicy文件外,我已经遵循了所需的步骤。我已经提到https://android.jlelse.eu/system-service-in-aosp-750007d39555.目前我的服务没有运行,因为avc拒绝错误即将到来。我在允许模式下运行。我已经尝试在/system/sepolicy/public/service.te中的service.te和conexts.te中添加所需的更改。我收到编译错误,如[6:49 PM]Kumar,Rathnakaram Anil(uic40644(

下午4:03 Kumar,Rathnakaram Anil(uic40644(

嗨,Ashwini,我正在尝试为我的测试服务添加selinux权限,遇到错误:[13%18579/140712]构建/target/product/caaf_denali_pegasus/obj/ETC/sepolicy_freeze_test_intermediates/sepolicy_freeze_test失败:输出/target/product/caaf_derali_pegasus/obj/ECT/sepolice_freeze_ttest_intermediates/sepolicx_freeze_testist/bin/bash-c〃;(diff-rq-x bug_map system/sepolicy/prebuilts/api/29/public-system/sepolice/public(&(diff-rq-x bug_map system/sepolicy/prebuilts/api/29/private system/sepulicy/private(&(触摸输出/target/product/caaf_denali_pegasus/obj/ETC/sepolicy_freeze_test_intermediates/sepolic_freeze_test(";文件system/spolicy/prepuilts/api/29/private/service.te和system/spolicy/parivate/service.te不同文件system/sepolicy/prepuints/api/29-0private/service和system/sepiciy/private/servections不同。

我找不到任何关于如何更新新服务的线索,请帮助我。

编辑文件/system/sepolicy/private/service_contexts并添加此行

service_name u:object_r:service_name:s0

重新编译AOSP。

  1. 给您的二进制文件一个selable,将其添加到"file_contexts">

/vvendor/bin/xxx u:object_r:xxx_exec:s0

  1. 创建te文件"xxx.te">
# xxx service
type xxx, domain;
type xxx_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(xxx)

最新更新