logd: only copy event-log-tags on sdk < 28

File not present in 9.0 tree

Change-Id: I54c5321813ddabbf11082fffc093efd4a829c185
diff --git a/etc/Android.mk b/etc/Android.mk
index ca549ea..f7bb3d8 100644
--- a/etc/Android.mk
+++ b/etc/Android.mk
@@ -82,19 +82,33 @@
 
 ifeq ($(TWRP_INCLUDE_LOGCAT), true)
     ifeq ($(TARGET_USES_LOGD), true)
+        ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 28; echo $$?),0)
+            include $(CLEAR_VARS)
+            LOCAL_MODULE := init.recovery.logd.rc
+            LOCAL_MODULE_TAGS := eng
+            LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
 
-        include $(CLEAR_VARS)
-        LOCAL_MODULE := init.recovery.logd.rc
-        LOCAL_MODULE_TAGS := eng
-        LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
+            # Cannot send to TARGET_RECOVERY_ROOT_OUT since build system wipes init*.rc
+            # during ramdisk creation and only allows init.recovery.*.rc files to be copied
+            # from TARGET_ROOT_OUT thereafter
+            LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
 
-        # Cannot send to TARGET_RECOVERY_ROOT_OUT since build system wipes init*.rc
-        # during ramdisk creation and only allows init.recovery.*.rc files to be copied
-        # from TARGET_ROOT_OUT thereafter
-        LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+            LOCAL_SRC_FILES := init.recovery.logd27.rc
+            include $(BUILD_PREBUILT)
+        else
+            include $(CLEAR_VARS)
+            LOCAL_MODULE := init.recovery.logd.rc
+            LOCAL_MODULE_TAGS := eng
+            LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
 
-        LOCAL_SRC_FILES := $(LOCAL_MODULE)
-        include $(BUILD_PREBUILT)
+            # Cannot send to TARGET_RECOVERY_ROOT_OUT since build system wipes init*.rc
+            # during ramdisk creation and only allows init.recovery.*.rc files to be copied
+            # from TARGET_ROOT_OUT thereafter
+            LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+
+            LOCAL_SRC_FILES := init.recovery.logd28.rc
+            include $(BUILD_PREBUILT)
+        endif
     endif
 endif
 
diff --git a/etc/init.recovery.logd.rc b/etc/init.recovery.logd27.rc
similarity index 60%
rename from etc/init.recovery.logd.rc
rename to etc/init.recovery.logd27.rc
index 423039c..0454a7a 100644
--- a/etc/init.recovery.logd.rc
+++ b/etc/init.recovery.logd27.rc
@@ -3,6 +3,7 @@
 
 on load_persist_props_action
     start logd
+    start logd-reinit
 
 service logd /sbin/logd
     class core
@@ -11,3 +12,11 @@
     socket logdw dgram 0222 logd logd
     group root system
     seclabel u:r:logd:s0
+
+service logd-reinit /sbin/logd --reinit
+    oneshot
+    disabled
+    user logd
+    group logd
+    writepid /dev/cpuset/system-background/tasks
+    seclabel u:r:logd:s0
diff --git a/etc/init.recovery.logd28.rc b/etc/init.recovery.logd28.rc
new file mode 100644
index 0000000..673df77
--- /dev/null
+++ b/etc/init.recovery.logd28.rc
@@ -0,0 +1,31 @@
+on init
+    start logd
+
+on fs
+    write /dev/event-log-tags "# content owned by logd
+"
+    chown logd logd /dev/event-log-tags
+    chmod 0644 /dev/event-log-tags
+
+on load_persist_props_action
+    start logd
+    start logd-reinit
+
+service logd /sbin/logd
+    socket logd stream 0666 logd logd
+    socket logdr seqpacket 0666 logd logd
+    socket logdw dgram+passcred 0222 logd logd
+    file /proc/kmsg r
+    file /dev/kmsg w
+    user logd
+    group logd system package_info readproc
+    writepid /dev/cpuset/system-background/tasks
+    seclabel u:r:logd:s0
+
+service logd-reinit /sbin/logd --reinit
+    oneshot
+    disabled
+    user logd
+    group logd
+    writepid /dev/cpuset/system-background/tasks
+    seclabel u:r:logd:s0