StatsEventParcel impl.; move AIDL files

This implementation continue to uses libbinder, as opposed to
libbinder_ndk.

We also move many (but not all) statsd aidl files from
frameworks/base/core into the apex.

Test: m -j128 && bit statsd_test:*
Change-Id: I95f06e937e50c1e2a638163b13587682402956a7
diff --git a/cmds/statsd/src/external/PullResultReceiver.cpp b/cmds/statsd/src/external/PullResultReceiver.cpp
index 6bd0545..6b6fe7d 100644
--- a/cmds/statsd/src/external/PullResultReceiver.cpp
+++ b/cmds/statsd/src/external/PullResultReceiver.cpp
@@ -25,12 +25,13 @@
 namespace statsd {
 
 PullResultReceiver::PullResultReceiver(
-        std::function<void(int32_t, bool, const vector<android::util::StatsEvent>&)> pullFinishCb)
+        std::function<void(int32_t, bool, const vector<android::util::StatsEventParcel>&)>
+             pullFinishCb)
     : pullFinishCallback(std::move(pullFinishCb)) {
 }
 
 Status PullResultReceiver::pullFinished(int32_t atomTag, bool success,
-                                        const vector<StatsEvent>& output) {
+                                        const vector<StatsEventParcel>& output) {
     pullFinishCallback(atomTag, success, output);
     return Status::ok();
 }
@@ -40,4 +41,4 @@
 
 }  // namespace statsd
 }  // namespace os
-}  // namespace android
\ No newline at end of file
+}  // namespace android
diff --git a/cmds/statsd/src/external/PullResultReceiver.h b/cmds/statsd/src/external/PullResultReceiver.h
index f731f77..17d06e4 100644
--- a/cmds/statsd/src/external/PullResultReceiver.h
+++ b/cmds/statsd/src/external/PullResultReceiver.h
@@ -24,7 +24,7 @@
 
 class PullResultReceiver : public BnPullAtomResultReceiver {
 public:
-    PullResultReceiver(function<void(int32_t, bool, const vector<android::util::StatsEvent>&)>
+    PullResultReceiver(function<void(int32_t, bool, const vector<android::util::StatsEventParcel>&)>
                                pullFinishCallback);
     ~PullResultReceiver();
 
@@ -32,10 +32,11 @@
      * Binder call for finishing a pull.
      */
     binder::Status pullFinished(int32_t atomTag, bool success,
-                                        const vector<android::util::StatsEvent>& output) override;
+                                const vector<android::util::StatsEventParcel>& output) override;
 
 private:
-    function<void(int32_t, bool, const vector<android::util::StatsEvent>&)> pullFinishCallback;
+    function<void(int32_t, bool, const vector<android::util::StatsEventParcel>&)>
+            pullFinishCallback;
 };
 
 }  // namespace statsd
diff --git a/cmds/statsd/src/external/StatsCallbackPuller.cpp b/cmds/statsd/src/external/StatsCallbackPuller.cpp
index 92db684..f5b1e7f 100644
--- a/cmds/statsd/src/external/StatsCallbackPuller.cpp
+++ b/cmds/statsd/src/external/StatsCallbackPuller.cpp
@@ -20,7 +20,7 @@
 #include "StatsCallbackPuller.h"
 
 #include <android/os/IPullAtomCallback.h>
-#include <android/util/StatsEvent.h>
+#include <android/util/StatsEventParcel.h>
 
 #include "PullResultReceiver.h"
 #include "StatsPullerManager.h"
@@ -57,13 +57,19 @@
 
     sp<PullResultReceiver> resultReceiver = new PullResultReceiver(
             [cv_mutex, cv, pullFinish, pullSuccess, sharedData](
-                    int32_t atomTag, bool success, const vector<StatsEvent>& output) {
+                    int32_t atomTag, bool success, const vector<StatsEventParcel>& output) {
                 // This is the result of the pull, executing in a statsd binder thread.
                 // The pull could have taken a long time, and we should only modify
                 // data (the output param) if the pointer is in scope and the pull did not time out.
                 {
                     lock_guard<mutex> lk(*cv_mutex);
-                    // TODO: fill the shared vector of LogEvents once StatsEvent is complete.
+                    for (const StatsEventParcel& parcel: output) {
+                        shared_ptr<LogEvent> event =
+                              make_shared<LogEvent>(const_cast<uint8_t*>(parcel.buffer.data()),
+                                                    parcel.buffer.size(),
+                                                    /*uid=*/ -1);
+                        sharedData->push_back(event);
+                    }
                     *pullSuccess = success;
                     *pullFinish = true;
                 }