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/cmds/surfacereplayer/proto/Android.mk b/cmds/surfacereplayer/proto/Android.mk
index b87d34f..3cf1148 100644
--- a/cmds/surfacereplayer/proto/Android.mk
+++ b/cmds/surfacereplayer/proto/Android.mk
@@ -18,10 +18,7 @@
LOCAL_SRC_FILES := $(call all-proto-files-under, src)
-LOCAL_SHARED_LIBRARIES := \
- libprotobuf-cpp-full
-
-LOCAL_PROTOC_OPTIMIZE_TYPE := full
+LOCAL_PROTOC_OPTIMIZE_TYPE := lite
LOCAL_MODULE := libtrace_proto
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
diff --git a/cmds/surfacereplayer/proto/src/trace.proto b/cmds/surfacereplayer/proto/src/trace.proto
index 45060af..0bc08a9 100644
--- a/cmds/surfacereplayer/proto/src/trace.proto
+++ b/cmds/surfacereplayer/proto/src/trace.proto
@@ -1,4 +1,5 @@
syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
message Trace {
repeated Increment increment = 1;
diff --git a/cmds/surfacereplayer/replayer/Android.mk b/cmds/surfacereplayer/replayer/Android.mk
index dac4314..3ec3178 100644
--- a/cmds/surfacereplayer/replayer/Android.mk
+++ b/cmds/surfacereplayer/replayer/Android.mk
@@ -40,7 +40,8 @@
libgui \
libui \
libutils \
- libprotobuf-cpp-full \
+ libprotobuf-cpp-lite \
+ libbase \
LOCAL_STATIC_LIBRARIES := \
libtrace_proto \
@@ -57,7 +58,7 @@
Main.cpp \
LOCAL_SHARED_LIBRARIES := \
- libprotobuf-cpp-full \
+ libprotobuf-cpp-lite \
libsurfacereplayer \
libutils \
diff --git a/cmds/surfacereplayer/replayer/Replayer.cpp b/cmds/surfacereplayer/replayer/Replayer.cpp
index ace10d1..a49da37 100644
--- a/cmds/surfacereplayer/replayer/Replayer.cpp
+++ b/cmds/surfacereplayer/replayer/Replayer.cpp
@@ -20,6 +20,8 @@
#include <android/native_window.h>
+#include <android-base/file.h>
+
#include <binder/IMemory.h>
#include <gui/BufferQueue.h>
@@ -61,14 +63,18 @@
mStopTimeStamp(stopHere) {
srand(RAND_COLOR_SEED);
- std::fstream input(filename, std::ios::in | std::ios::binary);
-
- mLoaded = mTrace.ParseFromIstream(&input);
- if (!mLoaded) {
+ std::string input;
+ if (!android::base::ReadFileToString(filename, &input, true)) {
std::cerr << "Trace did not load. Does " << filename << " exist?" << std::endl;
abort();
}
+ mLoaded = mTrace.ParseFromString(input);
+ if (!mLoaded) {
+ std::cerr << "Trace did not load." << std::endl;
+ abort();
+ }
+
mCurrentTime = mTrace.increment(0).time_stamp();
sReplayingManually.store(replayManually);