libbinder - split out libbatterystats_aidl

Moving this out of libbinder saves 4KB in 44 processes (on cuttlefish) =
176KB of private dirty memory (that is, this takes libbinder from 84 to
80 KB of private dirty memory). This also adds the cost of a new library
in 6 processes (6 * 12KB = 82 KB of additional private dirty memory).

Future considerations: once all these interfaces are moved, I'll file
bugs to have corresponding teams convert them to AIDL.

Bug: 183654927
Test: boot
Change-Id: Ic48f0ac8d5ebd27c76774f680b1891afcb1fa4c1
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index 49cb098..952a7a9 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -58,13 +58,13 @@
 // transport itself and should be moved to AIDL or in domain-specific libs.
 //
 // Currently, these are only on system android (not vendor, not host)
+// TODO(b/183654927) - move these into separate libraries
 libbinder_device_interface_sources = [
     "ActivityManager.cpp",
     "AppOpsManager.cpp",
     "IActivityManager.cpp",
     "IAppOpsCallback.cpp",
     "IAppOpsService.cpp",
-    "IBatteryStats.cpp",
     "IMediaResourceMonitor.cpp",
     "IPermissionController.cpp",
     "IProcessInfoService.cpp",
@@ -265,3 +265,23 @@
         },
     },
 }
+
+// libbinder historically contained additional interfaces that provided specific
+// functionality in the platform but have nothing to do with binder itself. These
+// are moved out of libbinder in order to avoid the overhead of their vtables.
+// If you are working on or own one of these interfaces, the responsible things
+// to would be:
+// - give them a new home
+// - convert them to AIDL instead of having manually written parceling code
+
+cc_library {
+    name: "libbatterystats_aidl",
+    srcs: [
+        "IBatteryStats.cpp",
+    ],
+    export_include_dirs: ["include_batterystats"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+    ],
+}