Support stats log in lmkd.

This CL changes the relevant cpp files to c files. And added functionalities to reset the log
context for reuse.

Background:
+ lmkd doesn't use the generated statslog code because:
   1. lmkd doesn't want to create a 4K log context for each log. lmkd is single threaded and can
      reuse the same log context.
   2. lmkd is written in c, and the existing statslog.h/.cpp are not compatible

Bug: 78603347
Test: manually tested with alloc-stress
Change-Id: Ife6f5c69248ecf5af730269e67f229ba4c72f37f
diff --git a/tools/stats_log_api_gen/Android.bp b/tools/stats_log_api_gen/Android.bp
index 73b715a..026b54f 100644
--- a/tools/stats_log_api_gen/Android.bp
+++ b/tools/stats_log_api_gen/Android.bp
@@ -98,9 +98,23 @@
     name: "libstatslog",
     generated_sources: ["statslog.cpp"],
     generated_headers: ["statslog.h"],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    export_generated_headers: ["statslog.h"],
+    shared_libs: [
+        "liblog",
+        "libutils",
+    ],
+    static_libs: ["libstatssocket"],
+}
+
+cc_library_static {
+    name: "libstatssocket",
     srcs: [
-        "stats_event_list.cpp",
-        "statsd_writer.cpp",
+        "stats_event_list.c",
+        "statsd_writer.c",
     ],
     cflags: [
         "-Wall",
@@ -109,10 +123,9 @@
         "-DWRITE_TO_STATSD=1",
         "-DWRITE_TO_LOGD=0",
     ],
-    export_generated_headers: ["statslog.h"],
+    export_include_dirs: ["include"],
     shared_libs: [
         "liblog",
-        "libutils",
     ],
 }