From 374c43e9b7cc2c2a2e26a3ba088679f03f680437 Mon Sep 17 00:00:00 2001 From: Kenn Frankel Date: Thu, 1 Feb 2024 11:48:38 -0800 Subject: [PATCH] Update libstatssocket_lazy to support StringArray Bug: 281162849 Test: LibstatssocketLazyTest Change-Id: I917589e92db045f96daa9b191fadac50b01704c8 --- libstats/socket_lazy/libstatssocket_lazy.cpp | 9 ++++++++- libstats/socket_lazy/tests/libstatssocket_lazy_test.cpp | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libstats/socket_lazy/libstatssocket_lazy.cpp b/libstats/socket_lazy/libstatssocket_lazy.cpp index dd93eebf0..fe94ef2d8 100644 --- a/libstats/socket_lazy/libstatssocket_lazy.cpp +++ b/libstats/socket_lazy/libstatssocket_lazy.cpp @@ -45,6 +45,7 @@ enum MethodIndex { k_AStatsEvent_writeBool, k_AStatsEvent_writeByteArray, k_AStatsEvent_writeString, + k_AStatsEvent_writeStringArray, k_AStatsEvent_writeAttributionChain, k_AStatsEvent_addBoolAnnotation, k_AStatsEvent_addInt32Annotation, @@ -104,6 +105,7 @@ static void InitializeOnce() { BIND_SYMBOL(AStatsEvent_writeBool); BIND_SYMBOL(AStatsEvent_writeByteArray); BIND_SYMBOL(AStatsEvent_writeString); + BIND_SYMBOL(AStatsEvent_writeStringArray); BIND_SYMBOL(AStatsEvent_writeAttributionChain); BIND_SYMBOL(AStatsEvent_addBoolAnnotation); BIND_SYMBOL(AStatsEvent_addInt32Annotation); @@ -179,6 +181,11 @@ void AStatsEvent_writeString(AStatsEvent* event, const char* value) { INVOKE_METHOD(AStatsEvent_writeString, event, value); } +void AStatsEvent_writeStringArray(AStatsEvent* event, const char* const* elements, + size_t numElements) { + INVOKE_METHOD(AStatsEvent_writeStringArray, event, elements, numElements); +} + void AStatsEvent_writeAttributionChain(AStatsEvent* event, const uint32_t* uids, const char* const* tags, uint8_t numNodes) { INVOKE_METHOD(AStatsEvent_writeAttributionChain, event, uids, tags, numNodes); @@ -198,4 +205,4 @@ void AStatsEvent_addInt32Annotation(AStatsEvent* event, uint8_t annotationId, in void AStatsSocket_close() { INVOKE_METHOD(AStatsSocket_close); -} \ No newline at end of file +} diff --git a/libstats/socket_lazy/tests/libstatssocket_lazy_test.cpp b/libstats/socket_lazy/tests/libstatssocket_lazy_test.cpp index fe1359860..3de6cd762 100644 --- a/libstats/socket_lazy/tests/libstatssocket_lazy_test.cpp +++ b/libstats/socket_lazy/tests/libstatssocket_lazy_test.cpp @@ -47,6 +47,7 @@ TEST_F(LibstatssocketLazyTest, NoLibstatssocketForStatsEvent) { EXPECT_DEATH(AStatsEvent_writeBool(event, false), kLoadFailed); EXPECT_DEATH(AStatsEvent_writeByteArray(event, NULL, 0), kLoadFailed); EXPECT_DEATH(AStatsEvent_writeString(event, NULL), kLoadFailed); + EXPECT_DEATH(AStatsEvent_writeStringArray(event, NULL, 0), kLoadFailed); EXPECT_DEATH(AStatsEvent_writeAttributionChain(event, NULL, NULL, 0), kLoadFailed); EXPECT_DEATH(AStatsEvent_addBoolAnnotation(event, 0, false), kLoadFailed); @@ -55,4 +56,4 @@ TEST_F(LibstatssocketLazyTest, NoLibstatssocketForStatsEvent) { TEST_F(LibstatssocketLazyTest, NoLibstatssocketForStatsSocket) { EXPECT_DEATH(AStatsSocket_close(), kLoadFailed); -} \ No newline at end of file +}