From 1f12775707350d805a520dc0dc8c68b77ce5d9ef Mon Sep 17 00:00:00 2001 From: Captain Throwback Date: Tue, 19 Jan 2016 17:30:20 -0500 Subject: Add TWRP flags to enable logd and/or logcat in recovery Developers and device maintainers may find it useful to have access to logcat in recovery. This patch set adds the following build flags: TARGET_USES_LOGD - This is an Android build flag that enables logd support. Devices that don't have built in kernel logging to dev/log/* will need this flag for logcat. We'll also use this to include the necessary support files for logd in TWRP. TWRP_INCLUDE_LOGCAT - This enables logcat support in recovery. I pulled the init entries from my HTC One M8 GPE boot.img, so I'm not certain whether these will work for all devices or if they're all necessary. Feedback is welcome. PS2: Use "TARGET_USES_LOGD" instead as this flag already exists, and previous flag was named incorrectly (logd isn't kernel logging) PS3: Start logd service on load_persist_props action, needed for 6.0+ PS4: More info on "TARGET_USES_LOGD" flag as related to liblog compilation can be found at the below links: https://android.googlesource.com/platform/system/core/+/android-6.0.1_r10/liblog/Android.mk#27 https://android.googlesource.com/platform/system/core/+/android-6.0.1_r10/liblog/Android.mk#50 Whether or not this flag is needed for logcat in TWRP is dependent on whether liblog was compiled with this flag. PS5: Update commit message to better describe "TARGET_USES_LOGD" flag PS6: Another commit message update Change-Id: Iaac6c6c822dc93fbe4b6eadcf24eef6995dd6b50 --- etc/Android.mk | 21 +++++++++++++++++++-- etc/init.rc | 1 + etc/init.recovery.logd.rc | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 etc/init.recovery.logd.rc (limited to 'etc') diff --git a/etc/Android.mk b/etc/Android.mk index 89ea0cc13..ac6f813bb 100644 --- a/etc/Android.mk +++ b/etc/Android.mk @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -ifneq ($(TW_EXCLUDE_DEFAULT_USB_INIT), true) - LOCAL_PATH := $(call my-dir) +ifneq ($(TW_EXCLUDE_DEFAULT_USB_INIT), true) + include $(CLEAR_VARS) LOCAL_MODULE := init.recovery.usb.rc LOCAL_MODULE_TAGS := eng @@ -30,3 +30,20 @@ LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) endif + +ifeq ($(TARGET_USES_LOGD), true) + +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) + +LOCAL_SRC_FILES := $(LOCAL_MODULE) +include $(BUILD_PREBUILT) + +endif diff --git a/etc/init.rc b/etc/init.rc index e6d8aec74..dc8b6e3f6 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -1,3 +1,4 @@ +import /init.recovery.logd.rc import /init.recovery.usb.rc import /init.recovery.${ro.hardware}.rc diff --git a/etc/init.recovery.logd.rc b/etc/init.recovery.logd.rc new file mode 100644 index 000000000..4bc21ad0c --- /dev/null +++ b/etc/init.recovery.logd.rc @@ -0,0 +1,28 @@ +on load_all_props_action + start logd + start logd-reinit + +on load_persist_props_action + start logd + start logd-reinit + +on post-fs + start logd + +on post-fs-data + start logd + +on property:vold.decrypt=trigger_load_persist_props + start logd + start logd-reinit + +service logd /sbin/logd + class core + socket logd stream 0666 logd logd + socket logdr seqpacket 0666 logd logd + socket logdw dgram 0222 logd logd + group root system + +service logd-reinit /sbin/logd --reinit + oneshot + disabled -- cgit v1.2.3