Replace surfaceflinger protobufs with protobuf-lite

Use lite protobufs for surfaceflinger to remove dependency on
libprotobuf-cpp-full, which will be removed from the platform.

Bug: 32417805
Test: builds
Change-Id: Ie27b253a2f6c1b296c4ae7c7cb056cd3c4c0dde6
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index f695edb..ba036dd 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -145,7 +145,7 @@
     libgui \
     libpowermanager \
     libvulkan \
-    libprotobuf-cpp-full \
+    libprotobuf-cpp-lite \
     libhidl \
     libhwbinder \
     libbase \
diff --git a/services/surfaceflinger/SurfaceInterceptor.cpp b/services/surfaceflinger/SurfaceInterceptor.cpp
index 4ae3580..a12276a 100644
--- a/services/surfaceflinger/SurfaceInterceptor.cpp
+++ b/services/surfaceflinger/SurfaceInterceptor.cpp
@@ -20,6 +20,9 @@
 #include "Layer.h"
 #include "SurfaceFlinger.h"
 #include "SurfaceInterceptor.h"
+
+#include <android-base/file.h>
+
 #include <cutils/log.h>
 
 #include <utils/Trace.h>
@@ -119,14 +122,18 @@
 
 status_t SurfaceInterceptor::writeProtoFileLocked() {
     ATRACE_CALL();
-    std::ofstream output(mOutputFileName, std::ios::out | std::ios::trunc | std::ios::binary);
-    // SerializeToOstream returns false when it's missing required data or when it could not write
+    std::string output;
+
     if (!mTrace.IsInitialized()) {
         return NOT_ENOUGH_DATA;
     }
-    if (!mTrace.SerializeToOstream(&output)) {
+    if (!mTrace.SerializeToString(&output)) {
         return PERMISSION_DENIED;
     }
+    if (!android::base::WriteStringToFile(output, mOutputFileName, true)) {
+        return PERMISSION_DENIED;
+    }
+
     return NO_ERROR;
 }