Revert^2 Integrate transaction tracing with perfetto

Define the perfetto custom data source TransactionDataSource.
TransactionDataSource is registered with perfetto and is used
to listen to perfetto events (setup, start, stop, flush)
and to write trace packets to perfetto.

The user can configure/start/stop tracing via /system/bin/perfetto.

Tracing can operate in the following modes.

ACTIVE mode:
The transactions ring buffer (starting state + following committed
transactions) is written (only once) to perfetto when the 'start'
event is received.
Transactions are then written to perfetto each time they are committed.
On the receiver side, the data source is to be configured to periodically
flush data to disk providing a virtually infinite storage.

CONTINUOUS mode:
Listens to the perfetto 'flush' event (e.g. when a bugreport is taken).
When a 'flush' event is received, the ring buffer (starting state + following
committed transactions) hold by TransactionTracing is written to perfetto.
On the receiver side, the data source is to be configured with a dedicated
buffer large enough to store all the flushed data.

Bug: b/284424784
Test: atest libsurfaceflinger_unittest && atest transactiontrace_testsuite
Change-Id: I703ed53e71f442e2f6af7c4a638d2f847107167a
diff --git a/services/surfaceflinger/Tracing/TransactionRingBuffer.h b/services/surfaceflinger/Tracing/TransactionRingBuffer.h
index e6f85ca..7d1d3fd 100644
--- a/services/surfaceflinger/Tracing/TransactionRingBuffer.h
+++ b/services/surfaceflinger/Tracing/TransactionRingBuffer.h
@@ -47,7 +47,7 @@
         mUsedInBytes = 0U;
     }
 
-    void writeToProto(FileProto& fileProto) {
+    void writeToProto(FileProto& fileProto) const {
         fileProto.mutable_entry()->Reserve(static_cast<int>(mStorage.size()) +
                                            fileProto.entry().size());
         for (const std::string& entry : mStorage) {
@@ -56,24 +56,6 @@
         }
     }
 
-    status_t writeToFile(FileProto& fileProto, std::string filename) {
-        ATRACE_CALL();
-        writeToProto(fileProto);
-        std::string output;
-        if (!fileProto.SerializeToString(&output)) {
-            ALOGE("Could not serialize proto.");
-            return UNKNOWN_ERROR;
-        }
-
-        // -rw-r--r--
-        const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
-        if (!android::base::WriteStringToFile(output, filename, mode, getuid(), getgid(), true)) {
-            ALOGE("Could not save the proto file %s", filename.c_str());
-            return PERMISSION_DENIED;
-        }
-        return NO_ERROR;
-    }
-
     status_t appendToStream(FileProto& fileProto, std::ofstream& out) {
         ATRACE_CALL();
         writeToProto(fileProto);