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(); +}