From 2ebc2e3d8f64c7c0e26be9bb6203875f5b85ccc2 Mon Sep 17 00:00:00 2001 From: Muhammad Qureshi Date: Tue, 11 Feb 2020 14:12:59 -0800 Subject: [PATCH] Expose AStatsSocket_close() from the statsd apex As part of statsd becoming a Mainline module in R, we need to formalize the statsd APIs called from outside the statsd apex. Bug: 145923416 Test: m Change-Id: I296a018cc93d95bda77d95f8161acbbe983a5d51 --- libstats/socket/Android.bp | 1 + libstats/socket/include/stats_socket.h | 33 ++++++++++++++++++++++++++ libstats/socket/libstatssocket.map.txt | 1 + libstats/socket/stats_socket.c | 22 +++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 libstats/socket/include/stats_socket.h create mode 100644 libstats/socket/stats_socket.c diff --git a/libstats/socket/Android.bp b/libstats/socket/Android.bp index f36b214f5..a709961bc 100644 --- a/libstats/socket/Android.bp +++ b/libstats/socket/Android.bp @@ -25,6 +25,7 @@ cc_library { // TODO(b/145573568): Remove stats_event_list once stats_event // migration is complete. "stats_event_list.c", + "stats_socket.c", "statsd_writer.c", ], host_supported: true, diff --git a/libstats/socket/include/stats_socket.h b/libstats/socket/include/stats_socket.h new file mode 100644 index 000000000..5a75fc021 --- /dev/null +++ b/libstats/socket/include/stats_socket.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +/** + * Helpers to manage the statsd socket. + **/ + +#ifdef __cplusplus +extern "C" { +#endif // __CPLUSPLUS + +/** + * Closes the statsd socket file descriptor. + **/ +void AStatsSocket_close(); +#ifdef __cplusplus +} +#endif // __CPLUSPLUS diff --git a/libstats/socket/libstatssocket.map.txt b/libstats/socket/libstatssocket.map.txt index e2e7ae37e..5c1390419 100644 --- a/libstats/socket/libstatssocket.map.txt +++ b/libstats/socket/libstatssocket.map.txt @@ -14,6 +14,7 @@ LIBSTATSSOCKET { AStatsEvent_writeAttributionChain; # apex # introduced=30 AStatsEvent_addBoolAnnotation; # apex # introduced=30 AStatsEvent_addInt32Annotation; # apex # introduced=30 + AStatsSocket_close; # apex # introduced=30 local: *; }; diff --git a/libstats/socket/stats_socket.c b/libstats/socket/stats_socket.c new file mode 100644 index 000000000..09f8967b0 --- /dev/null +++ b/libstats/socket/stats_socket.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "include/stats_socket.h" +#include "stats_buffer_writer.h" + +void AStatsSocket_close() { + stats_log_close(); +}