android 8.1添加开机启动服务
修改文件:
From 0ecbea62c6ceed9bc54a29524f04cd593e036eaa Mon Sep 17 00:00:00 2001
From: “xu.han747” [email protected]
Date: Wed, 25 Dec 2019 20:53:35 +0800
Subject: [PATCH] [Sim8950l_yunchongba]-system-[Add boot startup script]
…/device/qcom/msm8953_32/initlogkernel.sh | 84 ++++++++++++++++++++++
…/device/qcom/msm8953_32/msm8953_32.mk | 3 +
…/device/qcom/sepolicy/common/file_contexts | 1 +
…/system/core/libcutils/fs_config.cpp | 1 +
sim8950l_yunchong/system/core/rootdir/init.rc | 6 ++
…/prebuilts/api/26.0/private/initlogkernel.te | 4 ++
…/prebuilts/api/26.0/public/initlogkernel.te | 4 ++
…/system/sepolicy/private/initlogkernel.te | 4 ++
sim8950l_yunchong/system/sepolicy/public/domain.te | 1 +
sim8950l_yunchong/system/sepolicy/public/init.te | 14 ++±
…/system/sepolicy/public/initlogkernel.te | 4 ++
11 files changed, 124 insertions(+), 2 deletions(-)
create mode 100644 sim8950l_yunchong/device/qcom/msm8953_32/initlogkernel.sh
create mode 100644 sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/private/initlogkernel.te
create mode 100644 sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/public/initlogkernel.te
create mode 100644 sim8950l_yunchong/system/sepolicy/private/initlogkernel.te
create mode 100644 sim8950l_yunchong/system/sepolicy/public/initlogkernel.te
diff --git a/sim8950l_yunchong/device/qcom/msm8953_32/initlogkernel.sh b/sim8950l_yunchong/device/qcom/msm8953_32/initlogkernel.sh
new file mode 100644
index 0000000…f9a099b
— /dev/null
+++ b/sim8950l_yunchong/device/qcom/msm8953_32/initlogkernel.sh
@@ -0,0 +1,84 @@
+#!/vendor/bin/sh
+
+LOG_TAG=“logcat”
+LOG_NAME="${0}:"
+
+logcat_pid=""
+cp_pid=""
+
+sdcard_path="/sdcard"
+mount | grep “/sdcard ext4” > /dev/null
+
+#while [ $? == 1 ]
+#do
+# sleep 1
+# mount | grep “/sdcard ext4”
+#done
+
+loge ()
+{
+logi ()
+{
+failed ()
+{
/system/bin/mkdir ${sdcard_path}/log/
/system/bin/mkdir ${sdcard_path}/log/pstore/
#/system/bin/tar czf ${sdcard_path}/log/pstore/$(ls -l /sdcard/log/pstore/|grep "^-"|wc -l).tar.gz sys/fs/pstore/
#rm /sys/fs/pstore/dmesg-ramoops-0
/system/bin/mkdir /mnt/external_sd/
/system/bin/mkdir /mnt/external_sd/Log/
/system/bin/mkdir /mnt/external_sd/Log/drive/
+kill_logcat ()
+{
+}
+
+# init does SIGTERM on ctl.stop for service
+#trap “kill_logcat” TERM INT
+
+start_logcat
+
+#wait $cp_pid
+#busybox sync
+wait $logcat_pid
+
+logi “logcat service stopped”
+
+exit 0
diff --git a/sim8950l_yunchong/device/qcom/msm8953_32/msm8953_32.mk b/sim8950l_yunchong/device/qcom/msm8953_32/msm8953_32.mk
index ca4661a…af7572e 100644
— a/sim8950l_yunchong/device/qcom/msm8953_32/msm8953_32.mk
+++ b/sim8950l_yunchong/device/qcom/msm8953_32/msm8953_32.mk
@@ -233,6 +233,9 @@ PRODUCT_COPY_FILES += \
#fstab.qcom
PRODUCT_PACKAGES += fstab.qcom
+#initkernellog
+PRODUCT_COPY_FILES += \
#OEM Services library
PRODUCT_PACKAGES += oem-services
diff --git a/sim8950l_yunchong/device/qcom/sepolicy/common/file_contexts b/sim8950l_yunchong/device/qcom/sepolicy/common/file_contexts
index 4dbd2ea…2b1b815 100755
— a/sim8950l_yunchong/device/qcom/sepolicy/common/file_contexts
+++ b/sim8950l_yunchong/device/qcom/sepolicy/common/file_contexts
@@ -698,6 +698,7 @@
/firmware/image(/.*)? u:object_r:firmware_file:s0
/(vendor|system/vendor)/bin/grep u:object_r:vendor_toolbox_exec:s0
+/(vendor|system/vendor)/bin/initlogkernel.sh u:object_r:initlogkernel_exec:s0
##################################
#vendor toolbox
diff --git a/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/private/file_contexts b/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/private/file_contexts
index 4dbd2ea…2b1b815 100755
— a/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/private/file_contexts
+++ b/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/private/file_contexts
@@ -698,6 +698,7 @@
/firmware/image(/.*)? u:object_r:firmware_file:s0
/(vendor|system/vendor)/bin/grep u:object_r:vendor_toolbox_exec:s0
+/(vendor|system/vendor)/bin/initlogkernel.sh u:object_r:initlogkernel_exec:s0
##################################
#vendor toolbox
diff --git a/sim8950l_yunchong/system/core/libcutils/fs_config.cpp b/sim8950l_yunchong/system/core/libcutils/fs_config.cpp
index 2ec2283…e45d06f 100644
— a/sim8950l_yunchong/system/core/libcutils/fs_config.cpp
+++ b/sim8950l_yunchong/system/core/libcutils/fs_config.cpp
@@ -157,6 +157,7 @@ static const struct fs_path_config android_files[] = {
{ 00440, AID_ROOT, AID_SHELL, 0, “system/etc/init.goldfish.rc” },
{ 00550, AID_ROOT, AID_SHELL, 0, “system/etc/init.goldfish.sh” },
{ 00550, AID_ROOT, AID_SHELL, 0, “system/etc/init.ril” },
+service initlogkernel /verdor/bin/initlogkernel.sh
diff --git a/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/public/initlogkernel.te b/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/public/initlogkernel.te
new file mode 100644
index 0000000…a76d83d
— /dev/null
+++ b/sim8950l_yunchong/system/sepolicy/prebuilts/api/26.0/public/initlogkernel.te
@@ -0,0 +1,4 @@
+type initlogkernel, domain;
+type initlogkernel_exec, exec_type, vendor_file_type,file_type;
+
+
diff --git a/sim8950l_yunchong/system/sepolicy/private/initlogkernel.te b/sim8950l_yunchong/system/sepolicy/private/initlogkernel.te
new file mode 100644
index 0000000…55ce43b
— /dev/null
+++ b/sim8950l_yunchong/system/sepolicy/private/initlogkernel.te
@@ -0,0 +1,4 @@
+typeattribute yos coredomain;
+typeattribute yos mlstrustedsubject;
+init_daemon_domain(initlogkernel)
+
diff --git a/sim8950l_yunchong/system/sepolicy/public/domain.te b/sim8950l_yunchong/system/sepolicy/public/domain.te
index 69ea412…bd040f2 100644
— a/sim8950l_yunchong/system/sepolicy/public/domain.te
+++ b/sim8950l_yunchong/system/sepolicy/public/domain.te
@@ -407,6 +407,7 @@ neverallow {
vendor_file_type
exec_type
-yos_exec
neverallow { domain -recovery -kernel with_asan(`-asan_extract’) } { system_file vendor_file_type exec_type }:dir_file_class_set relabelto;
diff --git a/sim8950l_yunchong/system/sepolicy/public/init.te b/sim8950l_yunchong/system/sepolicy/public/init.te
index 5ef66e6…ad8ee40 100644
— a/sim8950l_yunchong/system/sepolicy/public/init.te
+++ b/sim8950l_yunchong/system/sepolicy/public/init.te
@@ -428,7 +428,7 @@ neverallow init shell_data_file:lnk_file read;
neverallow init app_data_file:lnk_file read;
-neverallow init { file_type fs_type -yos_exec }:file execute_no_trans;
+neverallow init { file_type fs_type -yos_exec -initlogkernel_exec}:file execute_no_trans;
neverallow init service_manager_type:service_manager { add find };
@@ -439,4 +439,14 @@ neverallow init shell_data_file:dir { write add_name remove_name };
diff --git a/sim8950l_yunchong/device/qcom/common/rootdir/etc/init.qcom.rc b/sim8950l_yunchong/device/qcom/common/rootdir/etc/init.qcom.rc
index 9214c4b…5fe13bc 100644
— a/sim8950l_yunchong/device/qcom/common/rootdir/etc/init.qcom.rc
+++ b/sim8950l_yunchong/device/qcom/common/rootdir/etc/init.qcom.rc
@@ -741,3 +741,9 @@ on property:ro.debuggable=1