Add an API to release stats logger resources.
Test: tested with ag/5112579
Change-Id: I271b7574beab1baa9886d31bc1cf25c40c2fae23
Merged-In: I271b7574beab1baa9886d31bc1cf25c40c2fae23
(cherry picked from commit 5b63e2704a3d0dd23ff3ef9900639d5bb51aca61)
diff --git a/libstats/include/stats_event_list.h b/libstats/include/stats_event_list.h
index 28da270..a9832db 100644
--- a/libstats/include/stats_event_list.h
+++ b/libstats/include/stats_event_list.h
@@ -25,6 +25,7 @@
void reset_log_context(android_log_context ctx);
int write_to_logger(android_log_context context, log_id_t id);
void note_log_drop();
+void stats_log_close();
#ifdef __cplusplus
}
diff --git a/libstats/stats_event_list.c b/libstats/stats_event_list.c
index 51408e0..735088a 100644
--- a/libstats/stats_event_list.c
+++ b/libstats/stats_event_list.c
@@ -123,6 +123,14 @@
statsdLoggerWrite.noteDrop();
}
+void stats_log_close() {
+ statsd_writer_init_lock();
+ if (statsdLoggerWrite.close) {
+ (*statsdLoggerWrite.close)();
+ }
+ statsd_writer_init_unlock();
+}
+
/* log_init_lock assumed */
static int __write_to_statsd_initialize_locked() {
if (!statsdLoggerWrite.open || ((*statsdLoggerWrite.open)() < 0)) {