diff --git a/Android.bp b/Android.bp
index 015e59fe9d08..773bf76da80d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -624,7 +624,7 @@ genrule {
name: "framework-statslog-gen",
tools: ["stats-log-api-gen"],
cmd: "$(location stats-log-api-gen) --java $(out)",
- out: ["android/util/StatsLog.java"],
+ out: ["android/util/StatsLogInternal.java"],
}
gensrcs {
diff --git a/api/current.txt b/api/current.txt
index 66a577c17de5..455cb7db1264 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -44575,6 +44575,12 @@ package android.util {
field public static final int[] WILD_CARD;
}
+ public final class StatsLog {
+ method public static boolean logEvent(int);
+ method public static boolean logStart(int);
+ method public static boolean logStop(int);
+ }
+
public class StringBuilderPrinter implements android.util.Printer {
ctor public StringBuilderPrinter(java.lang.StringBuilder);
method public void println(java.lang.String);
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 716fee6bb1fb..3471737e7dd9 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -79,6 +79,7 @@ message Atom {
IsolatedUidChanged isolated_uid_changed = 43;
PacketWakeupOccurred packet_wakeup_occurred = 44;
DropboxErrorChanged dropbox_error_changed = 45;
+ AppHook app_hook = 46;
// TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
}
@@ -801,6 +802,29 @@ message DropboxErrorChanged {
optional int32 is_foreground = 7;
}
+/*
+ * Allows other apps to push events into statsd.
+ * Logged from:
+ * frameworks/base/core/java/android/util/StatsLog.java
+ */
+message AppHook {
+ // The uid of the application that sent this custom atom.
+ optional int32 uid = 1;
+
+ // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
+ optional int32 label = 2;
+
+ // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
+ // predicates for the metrics).
+ enum State {
+ UNKNOWN = 0;
+ UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
+ STOP = 2;
+ START = 3;
+ }
+ optional State state = 3;
+}
+
/**
* Pulls bytes transferred via wifi (Sum of foreground and background usage).
*
diff --git a/cmds/statsd/tools/dogfood/res/layout/activity_main.xml b/cmds/statsd/tools/dogfood/res/layout/activity_main.xml
index 39978971d6b4..5d35c291f365 100644
--- a/cmds/statsd/tools/dogfood/res/layout/activity_main.xml
+++ b/cmds/statsd/tools/dogfood/res/layout/activity_main.xml
@@ -111,6 +111,23 @@
android:text="@string/screen_off"/>
+
+
+
+
+
+
+