summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-10 22:41:08 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-10 22:41:08 +0000
commitccb530f58fd9d95b802b6f81817b928730e1d8c2 (patch)
tree19182e59a927385370b20d92a6ca4cc594e3d6cd /core/java/android
parentdf1499d027cc0d425b6c8eb4e83e219b71d2930d (diff)
parentfca0df0215520a6508fe08f5ee329f8c0a717f4e (diff)
Merge changes Ied6a13be,Ia4818f62,I660a4384 am: c7483ff8bf am: fca0df0215
Change-Id: I190062aae1e366f3e522ee01b5e6027a375074fd
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/util/StatsEvent.java223
1 files changed, 184 insertions, 39 deletions
diff --git a/core/java/android/util/StatsEvent.java b/core/java/android/util/StatsEvent.java
index a21f9e09ced5..cc32847834c0 100644
--- a/core/java/android/util/StatsEvent.java
+++ b/core/java/android/util/StatsEvent.java
@@ -43,6 +43,166 @@ import com.android.internal.annotations.VisibleForTesting;
* @hide
**/
public final class StatsEvent {
+ // Type Ids.
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_INT = 0x00;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_LONG = 0x01;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_STRING = 0x02;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_LIST = 0x03;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_FLOAT = 0x04;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_BOOLEAN = 0x05;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_BYTE_ARRAY = 0x06;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_OBJECT = 0x07;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_KEY_VALUE_PAIRS = 0x08;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_ATTRIBUTION_CHAIN = 0x09;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final byte TYPE_ERRORS = 0x0F;
+
+ // Error flags.
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_NO_TIMESTAMP = 0x1;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_NO_ATOM_ID = 0x2;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_OVERFLOW = 0x4;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_ATTRIBUTION_CHAIN_TOO_LONG = 0x8;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_TOO_MANY_KEY_VALUE_PAIRS = 0x10;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD = 0x20;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_INVALID_ANNOTATION_ID = 0x40;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_ANNOTATION_ID_TOO_LARGE = 0x80;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_TOO_MANY_ANNOTATIONS = 0x100;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_TOO_MANY_FIELDS = 0x200;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int ERROR_ATTRIBUTION_UIDS_TAGS_SIZES_NOT_EQUAL = 0x400;
+
+ // Size limits.
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int MAX_ANNOTATION_COUNT = 15;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int MAX_ATTRIBUTION_NODES = 127;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int MAX_NUM_ELEMENTS = 127;
+
+ /**
+ * @hide
+ **/
+ @VisibleForTesting
+ public static final int MAX_KEY_VALUE_PAIRS = 127;
+
private static final int LOGGER_ENTRY_MAX_PAYLOAD = 4068;
// Max payload size is 4 bytes less as 4 bytes are reserved for statsEventTag.
@@ -63,24 +223,42 @@ public final class StatsEvent {
* Returns a new StatsEvent.Builder for building StatsEvent object.
**/
@NonNull
- public StatsEvent.Builder newBuilder() {
+ public static StatsEvent.Builder newBuilder() {
return new StatsEvent.Builder(Buffer.obtain());
}
- int getAtomId() {
+ /**
+ * Get the atom Id of the atom encoded in this StatsEvent object.
+ *
+ * @hide
+ **/
+ public int getAtomId() {
return mAtomId;
}
+ /**
+ * Get the byte array that contains the encoded payload that can be sent to statsd.
+ *
+ * @hide
+ **/
@NonNull
- byte[] getBytes() {
+ public byte[] getBytes() {
return mBuffer.getBytes();
}
- int getNumBytes() {
+ /**
+ * Get the number of bytes used to encode the StatsEvent payload.
+ *
+ * @hide
+ **/
+ public int getNumBytes() {
return mNumBytes;
}
- void release() {
+ /**
+ * Recycle this StatsEvent object.
+ **/
+ public void release() {
mBuffer.release();
}
@@ -112,41 +290,8 @@ public final class StatsEvent {
* .addBooleanAnnotation(annotation1Id, true)
* .build();
* </pre>
- * @hide
**/
public static final class Builder {
- // Type Ids.
- private static final byte TYPE_INT = 0x00;
- private static final byte TYPE_LONG = 0x01;
- private static final byte TYPE_STRING = 0x02;
- private static final byte TYPE_LIST = 0x03;
- private static final byte TYPE_FLOAT = 0x04;
- private static final byte TYPE_BOOLEAN = 0x05;
- private static final byte TYPE_BYTE_ARRAY = 0x06;
- private static final byte TYPE_OBJECT = 0x07;
- private static final byte TYPE_KEY_VALUE_PAIRS = 0x08;
- private static final byte TYPE_ATTRIBUTION_CHAIN = 0x09;
- private static final byte TYPE_ERRORS = 0x0F;
-
- // Error flags.
- private static final int ERROR_NO_TIMESTAMP = 0x1;
- private static final int ERROR_NO_ATOM_ID = 0x2;
- private static final int ERROR_OVERFLOW = 0x4;
- private static final int ERROR_ATTRIBUTION_CHAIN_TOO_LONG = 0x8;
- private static final int ERROR_TOO_MANY_KEY_VALUE_PAIRS = 0x10;
- private static final int ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD = 0x20;
- private static final int ERROR_INVALID_ANNOTATION_ID = 0x40;
- private static final int ERROR_ANNOTATION_ID_TOO_LARGE = 0x80;
- private static final int ERROR_TOO_MANY_ANNOTATIONS = 0x100;
- private static final int ERROR_TOO_MANY_FIELDS = 0x200;
- private static final int ERROR_ATTRIBUTION_UIDS_TAGS_SIZES_NOT_EQUAL = 0x400;
-
- // Size limits.
- private static final int MAX_ANNOTATION_COUNT = 15;
- private static final int MAX_ATTRIBUTION_NODES = 127;
- private static final int MAX_NUM_ELEMENTS = 127;
- private static final int MAX_KEY_VALUE_PAIRS = 127;
-
// Fixed positions.
private static final int POS_NUM_ELEMENTS = 1;
private static final int POS_TIMESTAMP_NS = POS_NUM_ELEMENTS + Byte.BYTES;
@@ -288,7 +433,7 @@ public final class StatsEvent {
* @param tags array of tags in the attribution nodes.
**/
@NonNull
- public Builder writeAttributionNode(
+ public Builder writeAttributionChain(
@NonNull final int[] uids, @NonNull final String[] tags) {
final byte numUids = (byte) uids.length;
final byte numTags = (byte) tags.length;