RK3288 + Android7.12
无法启动init.rc中新增的服务.
|–system/extras/info-service/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -std=c11 -Wall
#-Wmacro-redefined -Wunused-parameter -Wunused-variable
LOCAL_SRC_FILES:= infoservice.cpp
LOCAL_MODULE:= infoservice
LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \
libc \
libm
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := debug
include $(BUILD_EXECUTABLE)
|–system/extras/info-service/infoservice.cpp
#define LOG_TAG "InfoService"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
char configFile[] = "/data/system/device.cfg";
char profile[] = "/data/profile";
int main(int argc, char** argv) {
ALOGI("start Info Service");
}
在init.rc中添服务
|–device/rockchip/rk3288/init.rk3288.rc
on verity-logging
exec u:r:slideshow:s0 -- /sbin/slideshow warning/verity_red_1 warning/verity_red_2
+
+service infoservice /system/xbin/infoservice
+ class core
+ user root
+ group root system
+ disabled
+ oneshot
setprop ctl.start infoservice
服务无法启动!
[ 58.364922] init: ALog Starting 'infoservice'...
[ 58.365266] init: Service infoservice does not have a SELinux domain defined.
SELinux无法找到自定义服务的域定义.
参考bootanimation的源码:
|–system/sepolicy/infoservice.te
type infoservice, domain;
type infoservice_exec, exec_type, file_type;
init_daemon_domain(infoservice)
|–system/sepolicy/file_contexts
/system/bin/sh -- u:object_r:shell_exec:s0
/system/bin/run-as -- u:object_r:runas_exec:s0
/system/bin/bootanimation u:object_r:bootanim_exec:s0
+/system/xbin/infoservice u:object_r:infoservice_exec:s0
/system/bin/bootstat u:object_r:bootstat_exec:s0
/system/bin/app_process32 u:object_r:zygote_exec:s0
/system/bin/app_process64 u:object_r:zygote_exec:s0
|–system/sepolicy/property.te
type vold_prop, property_type, core_property_type;
type wifi_log_prop, property_type, log_property_type;
type ctl_bootanim_prop, property_type;
+type ctl_infoservice_prop, property_type;
type ctl_default_prop, property_type;
type ctl_dumpstate_prop, property_type;
type ctl_fuse_prop, property_type;
|–system/sepolicy/property_contexts
# ctl properties
ctl.bootanim u:object_r:ctl_bootanim_prop:s0
+ctl.infoservice u:object_r:ctl_infoservice_prop:s0
ctl.dumpstate u:object_r:ctl_dumpstate_prop:s0
ctl.fuse_ u:object_r:ctl_fuse_prop:s0
ctl.mdnsd u:object_r:ctl_mdnsd_prop:s0
编译system/sepolicy, 打包烧录, 问题解决!