Remove logd from Microdroid

Logs are now sent directly to /dev/hvc2, instead of being sent to logd
and then forwarded by logcat.

ro.log.file_logger.enabled is statically set to 1 so that the liblog
library doesn't attempt to send logs to logd which doesn't exist.

ro.log.file_logger.path is dynamically set to either /dev/hvc2 or
/dev/stderr depending on whether the VM is debuggable or not.

Bug: 222592894
Test: run Microdroid using the VM tool and see if logs are still shown
Test: logd process doesn't exist
Change-Id: I3412d4f853f2def8ca1e22fece8b6bf1debc3e92
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index 65aeb07..5f1414a 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -57,8 +57,6 @@
         "libbinder",
         "libbinder_ndk",
         "libstdc++",
-        "logcat.microdroid",
-        "logd.microdroid",
         "secilc",
 
         // "com.android.adbd" requires these,
diff --git a/microdroid/bootconfig.app_debuggable b/microdroid/bootconfig.app_debuggable
index 0d85186..6e66371 100644
--- a/microdroid/bootconfig.app_debuggable
+++ b/microdroid/bootconfig.app_debuggable
@@ -13,7 +13,3 @@
 
 # ADB is supported but rooting is prohibited.
 androidboot.adb.enabled=1
-
-# logd is enabled
-# TODO(b/200914564) Filter only the log from the app
-androidboot.logd.enabled=1
diff --git a/microdroid/bootconfig.full_debuggable b/microdroid/bootconfig.full_debuggable
index 0bdd810..583060b 100644
--- a/microdroid/bootconfig.full_debuggable
+++ b/microdroid/bootconfig.full_debuggable
@@ -12,6 +12,3 @@
 # ro.adb.secure is still 0 (see build.prop) which means that adbd is started
 # unrooted by default. To root, developer should explicitly execute `adb root`.
 androidboot.adb.enabled=1
-
-# logd is enabled
-androidboot.logd.enabled=1
diff --git a/microdroid/bootconfig.normal b/microdroid/bootconfig.normal
index ea83287..ec85f0d 100644
--- a/microdroid/bootconfig.normal
+++ b/microdroid/bootconfig.normal
@@ -12,6 +12,3 @@
 
 # ADB is not enabled.
 androidboot.adb.enabled=0
-
-# logd is not enabled
-androidboot.logd.enabled=0
diff --git a/microdroid/init.rc b/microdroid/init.rc
index 42aa983..cd7332b 100644
--- a/microdroid/init.rc
+++ b/microdroid/init.rc
@@ -17,6 +17,14 @@
 
     start ueventd
 
+# If VM is debuggable, send logs to outside ot the VM via the serial console.
+# If non-debuggable, logs are internally consumed at /dev/null
+on early-init && property:ro.boot.microdroid.app_debuggable=1
+    setprop ro.log.file_logger.path /dev/hvc2
+
+on early-init && property:ro.boot.microdroid.app_debuggable=0
+    setprop ro.log.file_logger.path /dev/null
+
 on init
     # Mount binderfs
     mkdir /dev/binderfs
@@ -62,12 +70,6 @@
     start vendor.dice-microdroid
     start diced
 
-on init && property:ro.boot.logd.enabled=1
-    # Start logd before any other services run to ensure we capture all of their logs.
-    # TODO(b/217796229) set filterspec if debug_level is app_only
-    start logd
-    start seriallogging
-
 on init
     mkdir /mnt/apk 0755 system system
     mkdir /mnt/extra-apk 0755 root root
@@ -99,10 +101,6 @@
 on init && property:ro.boot.adb.enabled=1
     start adbd
 
-on load_persist_props_action && property:ro.boot.logd.enabled=1
-    start logd
-    start logd-reinit
-
 # Mount filesystems and start core system services.
 on late-init
     trigger early-fs
@@ -206,13 +204,3 @@
     seclabel u:r:shell:s0
     setenv HOSTNAME console
 
-service seriallogging /system/bin/logcat -b all -v threadtime -f /dev/hvc2 *:V
-    disabled
-    user logd
-    group root 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
diff --git a/microdroid/ueventd.rc b/microdroid/ueventd.rc
index 340a1f7..fc165c8 100644
--- a/microdroid/ueventd.rc
+++ b/microdroid/ueventd.rc
@@ -26,6 +26,6 @@
 /dev/tty0                 0660   root       system
 
 # Virtual console for logcat
-/dev/hvc2                 0660   logd       logd
+/dev/hvc2                 0666   system     system
 
 /dev/open-dice0           0660   diced      diced