libandroid_runtime & libhwui: use libstats*_lazy

Update libandroid_runtime and libhwui, both of which are dependencies of
bootanimation, to use listatssocket_lazy and libstatspull_lazy, which
are new static versions of libstatssocket and libstatspull. This means
that bootanimation does not depend on these libraries, which are shipped
from the statsd apex.

The change enables removing the statsd apex from the bootstrap apexes.

Test: m
Test: boots
Test: no fatal linker errors after removing statsd from the bootstrap
apexes
Bug: 178480419

Change-Id: I78f4abe71f4b3718bbd97522c16f1c5ab88f77ae
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index d8715db..0a232d6 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -87,8 +87,8 @@
             cflags: [
                 "-Wno-unused-variable",
             ],
-        }
-    }
+        },
+    },
 }
 
 cc_defaults {
@@ -108,7 +108,6 @@
             shared_libs: [
                 "liblog",
                 "libcutils",
-                "libstatslog",
                 "libutils",
                 "libEGL",
                 "libGLESv1_CM",
@@ -122,12 +121,13 @@
                 "libandroidfw",
                 "libcrypto",
                 "libsync",
-                "libstatspull",
-                "libstatssocket",
             ],
             static_libs: [
                 "libEGL_blobCache",
                 "libprotoutil",
+                "libstatslog_hwui",
+                "libstatspull_lazy",
+                "libstatssocket_lazy",
             ],
         },
         host: {
@@ -135,8 +135,8 @@
                 "libandroidfw",
                 "libutils",
             ],
-        }
-    }
+        },
+    },
 }
 
 cc_defaults {
@@ -220,7 +220,7 @@
     srcs: [
         "apex/java/**/*.java",
     ],
-    path: "apex/java"
+    path: "apex/java",
 }
 
 // ------------------------
@@ -238,7 +238,7 @@
         windows: {
             enabled: true,
         },
-    }
+    },
 }
 
 cc_defaults {
@@ -263,7 +263,7 @@
         "apex/android_region.cpp",
     ],
 
-    header_libs: [ "android_graphics_apex_headers" ],
+    header_libs: ["android_graphics_apex_headers"],
 
     target: {
         android: {
@@ -278,7 +278,7 @@
             srcs: [
                 "apex/LayoutlibLoader.cpp",
             ],
-        }
+        },
     },
 }
 
@@ -297,7 +297,7 @@
         windows: {
             enabled: true,
         },
-    }
+    },
 }
 
 cc_defaults {
@@ -370,7 +370,7 @@
         "jni/text/TextShaper.cpp",
     ],
 
-    header_libs: [ "android_graphics_jni_headers" ],
+    header_libs: ["android_graphics_jni_headers"],
 
     include_dirs: [
         "external/skia/include/private",
@@ -391,7 +391,10 @@
         "libjpeg",
     ],
 
-    static_libs: ["libnativehelper_lazy", "libziparchive_for_incfs"],
+    static_libs: [
+        "libnativehelper_lazy",
+        "libziparchive_for_incfs",
+    ],
 
     target: {
         android: {
@@ -417,13 +420,13 @@
                 "libmediandk",
                 "libnativedisplay",
                 "libnativewindow",
-                "libstatspull",
-                "libstatssocket",
                 "libpdfium",
             ],
             static_libs: [
                 "libgif",
-                "libstatslog",
+                "libstatslog_hwui",
+                "libstatspull_lazy",
+                "libstatssocket_lazy",
             ],
         },
         host: {
@@ -434,10 +437,41 @@
             static_libs: [
                 "libandroidfw",
             ],
-        }
+        },
     },
 }
 
+cc_library_static {
+    name: "libstatslog_hwui",
+    generated_sources: ["statslog_hwui.cpp"],
+    generated_headers: ["statslog_hwui.h"],
+    export_generated_headers: ["statslog_hwui.h"],
+    static_libs: [
+        "libstatssocket_lazy",
+        "libstatspull_lazy",
+    ],
+}
+
+genrule {
+    name: "statslog_hwui.h",
+    tools: ["stats-log-api-gen"],
+    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_hwui.h --module hwui" +
+        " --namespace android,uirenderer,stats",
+    out: [
+        "statslog_hwui.h",
+    ],
+}
+
+genrule {
+    name: "statslog_hwui.cpp",
+    tools: ["stats-log-api-gen"],
+    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_hwui.cpp --module hwui" +
+        " --namespace android,uirenderer,stats --importHeader statslog_hwui.h",
+    out: [
+        "statslog_hwui.cpp",
+    ],
+}
+
 // ------------------------
 // library
 // ------------------------
@@ -449,8 +483,8 @@
     export_include_dirs: [
         ".",
     ],
-    header_libs: [ "android_graphics_jni_headers" ],
-    export_header_lib_headers: [ "android_graphics_jni_headers" ],
+    header_libs: ["android_graphics_jni_headers"],
+    export_header_lib_headers: ["android_graphics_jni_headers"],
 }
 
 cc_defaults {
@@ -514,7 +548,7 @@
 
     target: {
         android: {
-            header_libs: ["libandroid_headers_private" ],
+            header_libs: ["libandroid_headers_private"],
 
             srcs: [
                 "hwui/AnimatedImageThread.cpp",
@@ -572,8 +606,8 @@
             export_static_lib_headers: [
                 "libarect",
             ],
-        }
-    }
+        },
+    },
 }
 
 cc_library {
@@ -589,7 +623,7 @@
     target: {
         android: {
             version_script: "libhwui.map.txt",
-        }
+        },
     },
 }
 
@@ -608,10 +642,10 @@
     target: {
         android: {
             shared_libs: [
-	        "libgui",
-	        "libui",
-	    ],
-	}
+                "libgui",
+                "libui",
+            ],
+        },
     },
     srcs: [
         "tests/common/scenes/*.cpp",
@@ -732,5 +766,5 @@
     required: [
         "hwuimicro",
         "hwuimacro",
-    ]
+    ],
 }