diff options
Diffstat (limited to 'go/current/include/packages/modules')
6 files changed, 762 insertions, 0 deletions
diff --git a/go/current/include/packages/modules/StatsD/lib/libstatspull/include/stats_pull_atom_callback.h b/go/current/include/packages/modules/StatsD/lib/libstatspull/include/stats_pull_atom_callback.h new file mode 100644 index 0000000..17df584 --- /dev/null +++ b/go/current/include/packages/modules/StatsD/lib/libstatspull/include/stats_pull_atom_callback.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2019, 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 + +#include <stats_event.h> + +#include <stdbool.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Opaque struct representing the metadata for registering an AStatsManager_PullAtomCallback. + */ +struct AStatsManager_PullAtomMetadata; +typedef struct AStatsManager_PullAtomMetadata AStatsManager_PullAtomMetadata; + +/** + * Allocate and initialize new PullAtomMetadata. + * + * Must call AStatsManager_PullAtomMetadata_release to free the memory. + */ +AStatsManager_PullAtomMetadata* AStatsManager_PullAtomMetadata_obtain(); + +/** + * Frees the memory held by this PullAtomMetadata + * + * After calling this, the PullAtomMetadata must not be used or modified in any way. + */ +void AStatsManager_PullAtomMetadata_release(AStatsManager_PullAtomMetadata* metadata); + +/** + * Set the cool down time of the pull in milliseconds. If two successive pulls are issued + * within the cool down, a cached version of the first will be used for the second. The minimum + * allowed cool down is one second. + */ +void AStatsManager_PullAtomMetadata_setCoolDownMillis(AStatsManager_PullAtomMetadata* metadata, + int64_t cool_down_millis); + +/** + * Get the cool down time of the pull in milliseconds. + */ +int64_t AStatsManager_PullAtomMetadata_getCoolDownMillis(AStatsManager_PullAtomMetadata* metadata); + +/** + * Set the maximum time the pull can take in milliseconds. + * The maximum allowed timeout is 10 seconds. + */ +void AStatsManager_PullAtomMetadata_setTimeoutMillis(AStatsManager_PullAtomMetadata* metadata, + int64_t timeout_millis); + +/** + * Get the maximum time the pull can take in milliseconds. + */ +int64_t AStatsManager_PullAtomMetadata_getTimeoutMillis(AStatsManager_PullAtomMetadata* metadata); + +/** + * Set the additive fields of this pulled atom. + * + * This is only applicable for atoms which have a uid field. When tasks are run in + * isolated processes, the data will be attributed to the host uid. Additive fields + * will be combined when the non-additive fields are the same. + */ +void AStatsManager_PullAtomMetadata_setAdditiveFields(AStatsManager_PullAtomMetadata* metadata, + int32_t* additive_fields, int32_t num_fields); + +/** + * Get the number of additive fields for this pulled atom. This is intended to be called before + * AStatsManager_PullAtomMetadata_getAdditiveFields to determine the size of the array. + */ +int32_t AStatsManager_PullAtomMetadata_getNumAdditiveFields( + AStatsManager_PullAtomMetadata* metadata); + +/** + * Get the additive fields of this pulled atom. + * + * \param fields an output parameter containing the additive fields for this PullAtomMetadata. + * Fields is an array and it is assumed that it is at least as large as the number of + * additive fields, which can be obtained by calling + * AStatsManager_PullAtomMetadata_getNumAdditiveFields. + */ +void AStatsManager_PullAtomMetadata_getAdditiveFields(AStatsManager_PullAtomMetadata* metadata, + int32_t* fields); + +/** + * Return codes for the result of a pull. + */ +typedef int32_t AStatsManager_PullAtomCallbackReturn; +enum { + // Value indicating that this pull was successful and that the result should be used. + AStatsManager_PULL_SUCCESS = 0, + // Value indicating that this pull was unsuccessful and that the result should not be used. + AStatsManager_PULL_SKIP = 1, +}; + +/** + * Opaque struct representing a list of AStatsEvent objects. + */ +struct AStatsEventList; +typedef struct AStatsEventList AStatsEventList; + +/** + * Appends and returns an AStatsEvent to the end of the AStatsEventList. + * + * If an AStatsEvent is obtained in this manner, the memory is internally managed and + * AStatsEvent_release does not need to be called. The lifetime of the AStatsEvent is that of the + * AStatsEventList. + * + * The AStatsEvent does still need to be built by calling AStatsEvent_build. + */ +AStatsEvent* AStatsEventList_addStatsEvent(AStatsEventList* pull_data); + +/** + * Callback interface for pulling atoms requested by the stats service. + * + * \param atom_tag the tag of the atom to pull. + * \param data an output parameter in which the caller should fill the results of the pull. This + * param cannot be NULL and it's lifetime is as long as the execution of the callback. + * It must not be accessed or modified after returning from the callback. + * \param cookie the opaque pointer passed in AStatsManager_registerPullAtomCallback. + * \return AStatsManager_PULL_SUCCESS if the pull was successful, or AStatsManager_PULL_SKIP if not. + */ +typedef AStatsManager_PullAtomCallbackReturn (*AStatsManager_PullAtomCallback)( + int32_t atom_tag, AStatsEventList* data, void* cookie); +/** + * Sets a callback for an atom when that atom is to be pulled. The stats service will + * invoke the callback when the stats service determines that this atom needs to be + * pulled. + * + * Requires the REGISTER_STATS_PULL_ATOM permission. + * + * \param atom_tag The tag of the atom for this pull atom callback. + * \param metadata Optional metadata specifying the timeout, cool down time, and + * additive fields for mapping isolated to host uids. + * This param is nullable, in which case defaults will be used. + * \param callback The callback to be invoked when the stats service pulls the atom. + * \param cookie A pointer that will be passed back to the callback. + * It has no meaning to statsd. + */ +void AStatsManager_setPullAtomCallback(int32_t atom_tag, AStatsManager_PullAtomMetadata* metadata, + AStatsManager_PullAtomCallback callback, void* cookie); + +/** + * Clears a callback for an atom when that atom is to be pulled. Note that any ongoing + * pulls will still occur. + * + * Requires the REGISTER_STATS_PULL_ATOM permission. + * + * \param atomTag The tag of the atom of which to unregister + */ +void AStatsManager_clearPullAtomCallback(int32_t atom_tag); + +#ifdef __cplusplus +} +#endif diff --git a/go/current/include/packages/modules/StatsD/lib/libstatspull/include/stats_subscription.h b/go/current/include/packages/modules/StatsD/lib/libstatspull/include/stats_subscription.h new file mode 100644 index 0000000..6509c2b --- /dev/null +++ b/go/current/include/packages/modules/StatsD/lib/libstatspull/include/stats_subscription.h @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2023, 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 + +#include <stdint.h> +#include <sys/cdefs.h> + +#ifndef __STATSD_SUBS_MIN_API__ +#define __STATSD_SUBS_MIN_API__ __ANDROID_API_U__ +#endif + +__BEGIN_DECLS + +/** + * Reason codes for why subscription callback was triggered. + */ +typedef enum AStatsManager_SubscriptionCallbackReason : uint32_t { + /** + * SubscriptionCallbackReason constant for subscription data transfer initiated by stats + * service. + * + * Introduced in API 34. + */ + ASTATSMANAGER_SUBSCRIPTION_CALLBACK_REASON_STATSD_INITIATED = 1, + + /** + * SubscriptionCallbackReason constant for subscriber requesting flush of pending data. + * + * Introduced in API 34. + */ + ASTATSMANAGER_SUBSCRIPTION_CALLBACK_REASON_FLUSH_REQUESTED = 2, + + /** + * SubscriptionCallbackReason constant for final stream of data for a subscription. + * + * Introduced in API 34. + */ + ASTATSMANAGER_SUBSCRIPTION_CALLBACK_REASON_SUBSCRIPTION_ENDED = 3, +} AStatsManager_SubscriptionCallbackReason; + +/** + * Callback interface for receiving subscription data by the stats service. + * + * This will be called on an arbitrary binder thread. There is a pool of such threads and there is a + * no guarantee a single thread will be used even for the same subscription. Clients must ensure it + * is safe to call callback from arbitrary threads. + * + * \param subscription_id the subscription id for which the callback is triggered. + * \param reason code for why the callback is triggered. + * \param payload encoded SubscriptionResults proto containing subscription data. + * Cannot be null. + * \param num_bytes size in bytes of the payload. + * \param cookie the opaque pointer passed in AStatsManager_addSubscription. Can be null. + * + * Introduced in API 34. + */ +typedef void (*AStatsManager_SubscriptionCallback)(int32_t subscription_id, + AStatsManager_SubscriptionCallbackReason reason, + uint8_t* _Nonnull payload, size_t num_bytes, + void* _Nullable cookie); + +/** + * Adds a new subscription. + * + * Requires caller is in the traced_probes selinux domain. + * + * \param subscription_config encoded ShellSubscription proto containing parameters for a new + * subscription. Cannot be null. + * \param num_bytes size in bytes of the subscription_config. + * \param callback function called to deliver subscription data back to the subscriber. Each + * callback can be used for more than one subscription. Cannot be null. + * \param cookie opaque pointer to associate with the subscription. The provided callback will be + * invoked with this cookie as an argument when delivering data for this subscription. Can be + * null. + * \return subscription ID for the new subscription. Subscription ID is a positive integer. A + * negative value indicates an error. + * + * Introduced in API 34. + */ +int32_t AStatsManager_addSubscription(const uint8_t* _Nonnull subscription_config, size_t num_bytes, + const AStatsManager_SubscriptionCallback _Nonnull callback, + void* _Nullable cookie) + __INTRODUCED_IN(__STATSD_SUBS_MIN_API__); + +/** + * Removes an existing subscription. + * This will trigger a flush of the remaining subscription data through + * AStatsManager_SubscriptionCallback with the reason as + * ASTATSMANAGER_SUBSCRIPTION_CALLBACK_REASON_SUBSCRIPTION_ENDED. + * + * Requires caller is in the traced_probes selinux domain. + * + * \param subscription_id subscription id of the subscription to terminate. + * + * Introduced in API 34. + */ +void AStatsManager_removeSubscription(int32_t subscription_id) + __INTRODUCED_IN(__STATSD_SUBS_MIN_API__); + +/** + * Request stats service to flush a subscription. + * This will trigger AStatsManager_SubscriptionCallback with the reason as + * ASTATSMANAGER_SUBSCRIPTION_CALLBACK_REASON_FLUSH_REQUESTED. + * + * Requires caller is in the traced_probes selinux domain. + * + * \param subscription_id ID of the subscription to be flushed. + * + * Introduced in API 34. + */ +void AStatsManager_flushSubscription(int32_t subscription_id) + __INTRODUCED_IN(__STATSD_SUBS_MIN_API__); + +__END_DECLS diff --git a/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_annotations.h b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_annotations.h new file mode 100644 index 0000000..2963db9 --- /dev/null +++ b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_annotations.h @@ -0,0 +1,195 @@ +/* + * 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 + +#include <stddef.h> +#include <stdint.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +enum AnnotationIds : uint8_t { + /** + * Annotation ID constant for logging UID field. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_IS_UID = 1, + + /** + * Annotation ID constant to indicate logged atom event's timestamp should be truncated. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_TRUNCATE_TIMESTAMP = 2, + + /** + * Annotation ID constant for a state atom's primary field. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_PRIMARY_FIELD = 3, + + /** + * Annotation ID constant for state atom's state field. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_EXCLUSIVE_STATE = 4, + + /** + * Annotation ID constant to indicate the first UID in the attribution chain + * is a primary field. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_PRIMARY_FIELD_FIRST_UID = 5, + + /** + * Annotation ID constant to indicate which state is default for the state atom. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_DEFAULT_STATE = 6, + + /** + * Annotation ID constant to signal that all states should be reset to the default state. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_TRIGGER_STATE_RESET = 7, + + /** + * Annotation ID constant to indicate state changes need to account for nesting. + * This should only be used with binary state atoms. + * + * Introduced in API 31. + */ + ASTATSLOG_ANNOTATION_ID_STATE_NESTED = 8, + + /** + * Annotation ID constant to indicate the restriction category of an atom. + * This annotation must only be attached to the atom id. This is an int annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_RESTRICTION_CATEGORY = 9, + + /** + * Annotation ID to indicate that a field of an atom contains peripheral device info. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_PERIPHERAL_DEVICE_INFO = 10, + + /** + * Annotation ID to indicate that a field of an atom contains app usage information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_APP_USAGE = 11, + + /** + * Annotation ID to indicate that a field of an atom contains app activity information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_APP_ACTIVITY = 12, + + /** + * Annotation ID to indicate that a field of an atom contains health connect information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_HEALTH_CONNECT = 13, + + /** + * Annotation ID to indicate that a field of an atom contains accessibility information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_ACCESSIBILITY = 14, + + /** + * Annotation ID to indicate that a field of an atom contains system search information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_SYSTEM_SEARCH = 15, + + /** + * Annotation ID to indicate that a field of an atom contains user engagement information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_USER_ENGAGEMENT = 16, + + /** + * Annotation ID to indicate that a field of an atom contains ambient sensing information. + * This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_AMBIENT_SENSING = 17, + + /** + * Annotation ID to indicate that a field of an atom contains demographic classification + * information. This is a bool annotation. + * + * Introduced in API 34. + */ + ASTATSLOG_ANNOTATION_ID_FIELD_RESTRICTION_DEMOGRAPHIC_CLASSIFICATION = 18, +}; + +enum AStatsLogRestrictionCategory : uint32_t { + /** + * Restriction category for atoms about diagnostics. + * + * Introduced in API 34. + */ + ASTATSLOG_RESTRICTION_CATEGORY_DIAGNOSTIC = 1, + + /** + * Restriction category for atoms about system intelligence. + * + * Introduced in API 34. + */ + ASTATSLOG_RESTRICTION_CATEGORY_SYSTEM_INTELLIGENCE = 2, + + /** + * Restriction category for atoms about authentication. + * + * Introduced in API 34. + */ + ASTATSLOG_RESTRICTION_CATEGORY_AUTHENTICATION = 3, + + /** + * Restriction category for atoms about fraud and abuse. + * + * Introduced in API 34. + */ + ASTATSLOG_RESTRICTION_CATEGORY_FRAUD_AND_ABUSE = 4, + +}; +__END_DECLS diff --git a/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_buffer_writer.h b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_buffer_writer.h new file mode 100644 index 0000000..5b41f0e --- /dev/null +++ b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_buffer_writer.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 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 + +#include <stddef.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif // __CPLUSPLUS +void stats_log_close(); +int stats_log_is_closed(); +int write_buffer_to_statsd(void* buffer, size_t size, uint32_t atomId); +#ifdef __cplusplus +} +#endif // __CPLUSPLUS diff --git a/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_event.h b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_event.h new file mode 100644 index 0000000..23e1419 --- /dev/null +++ b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_event.h @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef ANDROID_STATS_LOG_STATS_EVENT_H +#define ANDROID_STATS_LOG_STATS_EVENT_H + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +/* + * Functionality to build and store the buffer sent over the statsd socket. + * This code defines and encapsulates the socket protocol. + * + * Usage: + * AStatsEvent* event = AStatsEvent_obtain(); + * + * AStatsEvent_setAtomId(event, atomId); + * AStatsEvent_addBoolAnnotation(event, 5, false); // atom-level annotation + * AStatsEvent_writeInt32(event, 24); + * AStatsEvent_addBoolAnnotation(event, 1, true); // annotation for preceding atom field + * AStatsEvent_addInt32Annotation(event, 2, 128); + * AStatsEvent_writeFloat(event, 2.0); + * + * AStatsEvent_write(event); + * AStatsEvent_release(event); + * + * Note that calls to add atom fields and annotations should be made in the + * order that they are defined in the atom. + */ + +#ifdef __cplusplus +extern "C" { +#endif // __CPLUSPLUS + +/** + * Opaque struct use to represent a StatsEvent. It builds and stores the data that is sent to + * statsd. + */ +struct AStatsEvent; +typedef struct AStatsEvent AStatsEvent; + +/** + * Returns a new AStatsEvent. If you call this function, you must call AStatsEvent_release to free + * the allocated memory. + */ +AStatsEvent* AStatsEvent_obtain(); + +/** + * Builds and finalizes the AStatsEvent for a pulled event. + * This should only be called for pulled AStatsEvents. + * + * After this function, the StatsEvent must not be modified in any way other than calling release or + * write. + * + * Build can be called multiple times without error. + * If the event has been built before, this function is a no-op. + */ +void AStatsEvent_build(AStatsEvent* event); + +/** + * Writes the StatsEvent to the stats log. + * + * After calling this, AStatsEvent_release must be called, + * and is the only function that can be safely called. + */ +int AStatsEvent_write(AStatsEvent* event); + +/** + * Frees the memory held by this StatsEvent. + * + * After calling this, the StatsEvent must not be used or modified in any way. + */ +void AStatsEvent_release(AStatsEvent* event); + +/** + * Sets the atom id for this StatsEvent. + * + * This function should be called immediately after AStatsEvent_obtain. It may + * be called additional times as well, but subsequent calls will have no effect. + **/ +void AStatsEvent_setAtomId(AStatsEvent* event, uint32_t atomId); + +/** + * Writes an int32_t field to this StatsEvent. + **/ +void AStatsEvent_writeInt32(AStatsEvent* event, int32_t value); + +/** + * Writes an int64_t field to this StatsEvent. + **/ +void AStatsEvent_writeInt64(AStatsEvent* event, int64_t value); + +/** + * Writes a float field to this StatsEvent. + **/ +void AStatsEvent_writeFloat(AStatsEvent* event, float value); + +/** + * Write a bool field to this StatsEvent. + **/ +void AStatsEvent_writeBool(AStatsEvent* event, bool value); + +/** + * Write a byte array field to this StatsEvent. + **/ +void AStatsEvent_writeByteArray(AStatsEvent* event, const uint8_t* buf, size_t numBytes); + +/** + * Write a string field to this StatsEvent. + * + * The string must be null-terminated. + **/ +void AStatsEvent_writeString(AStatsEvent* event, const char* value); + +/** + * Write an attribution chain field to this StatsEvent. + * + * The sizes of uids and tags must be equal. The AttributionNode at position i is + * made up of uids[i] and tags[i]. + * + * \param uids array of uids in the attribution chain. + * \param tags array of tags in the attribution chain. Each tag must be null-terminated. + * \param numNodes the number of AttributionNodes in the attribution chain. This is the length of + * the uids and the tags. + **/ +void AStatsEvent_writeAttributionChain(AStatsEvent* event, const uint32_t* uids, + const char* const* tags, uint8_t numNodes); + +/** + * Write a int32 array field to this StatsEvent. + * + * Max size of array is 127. If exceeded, array is not written and ERROR_LIST_TOO_LONG is appended + * to StatsEvent. + **/ +void AStatsEvent_writeInt32Array(AStatsEvent* event, const int32_t* elements, size_t numElements); + +/** + * Write a int64 array field to this StatsEvent. + * + * Max size of array is 127. If exceeded, array is not written and ERROR_LIST_TOO_LONG is appended + * to StatsEvent. + **/ +void AStatsEvent_writeInt64Array(AStatsEvent* event, const int64_t* elements, size_t numElements); + +/** + * Write a float array field to this StatsEvent. + * + * Max size of array is 127. If exceeded, array is not written and ERROR_LIST_TOO_LONG is appended + * to StatsEvent. + **/ +void AStatsEvent_writeFloatArray(AStatsEvent* event, const float* elements, size_t numElements); + +/** + * Write a bool array field to this StatsEvent. + * + * Max size of array is 127. If exceeded, array is not written and ERROR_LIST_TOO_LONG is appended + * to StatsEvent. + **/ +void AStatsEvent_writeBoolArray(AStatsEvent* event, const bool* elements, size_t numElements); + +/** + * Write a string array field to this StatsEvent. + * + * String array encoding is UTF8. + * + * Strings must be null terminated. Max size of array is 127. If exceeded, array is not written and + * ERROR_LIST_TOO_LONG is appended to StatsEvent. + **/ +void AStatsEvent_writeStringArray(AStatsEvent* event, const char* const* elements, + size_t numElements); + +/** + * Write a bool annotation for the previous field written. + **/ +void AStatsEvent_addBoolAnnotation(AStatsEvent* event, uint8_t annotationId, bool value); + +/** + * Write an integer annotation for the previous field written. + **/ +void AStatsEvent_addInt32Annotation(AStatsEvent* event, uint8_t annotationId, int32_t value); + +// Internal/test APIs. Should not be exposed outside of the APEX. +void AStatsEvent_overwriteTimestamp(AStatsEvent* event, uint64_t timestampNs); +uint32_t AStatsEvent_getAtomId(AStatsEvent* event); +// Size is an output parameter. +uint8_t* AStatsEvent_getBuffer(AStatsEvent* event, size_t* size); +uint32_t AStatsEvent_getErrors(AStatsEvent* event); + +#ifdef __cplusplus +} +#endif // __CPLUSPLUS + +#endif // ANDROID_STATS_LOG_STATS_EVENT_H diff --git a/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_socket.h b/go/current/include/packages/modules/StatsD/lib/libstatssocket/include/stats_socket.h new file mode 100644 index 0000000..5a75fc0 --- /dev/null +++ b/go/current/include/packages/modules/StatsD/lib/libstatssocket/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 |