Update libstatssocket_lazy to support StringArray

Bug: 281162849
Test: LibstatssocketLazyTest

Change-Id: I917589e92db045f96daa9b191fadac50b01704c8
This commit is contained in:
Kenn Frankel 2024-02-01 11:48:38 -08:00
parent 13cb6f7b4b
commit 374c43e9b7
2 changed files with 10 additions and 2 deletions

View file

@ -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);
}
}

View file

@ -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);
}
}