OSDN Git Service

Small fixes to StatsManager API.
authorDavid Chen <dwchen@google.com>
Thu, 22 Feb 2018 02:58:23 +0000 (18:58 -0800)
committerDavid Chen <dwchen@google.com>
Mon, 19 Mar 2018 17:26:51 +0000 (10:26 -0700)
Adds some annotations, deletes an unused API method, and adds some
comments.

Test: Flashed onto marlin-eng and verified there are no crashes.
Bug: 72562867
Change-Id: I6c93ee4aeeacf6842795256c76551cfb1c28888d

api/system-current.txt
core/java/android/app/StatsManager.java
core/java/android/util/StatsLog.java

index 1080669..14137f6 100644 (file)
@@ -373,7 +373,6 @@ package android.app {
   }
 
   public final class StatsManager {
-    method public boolean addConfiguration(long, byte[], java.lang.String, java.lang.String);
     method public boolean addConfiguration(long, byte[]);
     method public byte[] getData(long);
     method public byte[] getMetadata();
index 7325daa..4a6fa8c 100644 (file)
@@ -16,6 +16,7 @@
 package android.app;
 
 import android.Manifest;
+import android.annotation.Nullable;
 import android.annotation.RequiresPermission;
 import android.annotation.SystemApi;
 import android.os.IBinder;
@@ -81,14 +82,6 @@ public final class StatsManager {
     }
 
     /**
-     * Temporary. Will be deleted.
-     */
-    @RequiresPermission(Manifest.permission.DUMP)
-    public boolean addConfiguration(long configKey, byte[] config, String a, String b) {
-        return addConfiguration(configKey, config);
-    }
-
-    /**
      * Clients can send a configuration and simultaneously registers the name of a broadcast
      * receiver that listens for when it should request data.
      *
@@ -233,10 +226,11 @@ public final class StatsManager {
      * the retrieved metrics from statsd memory.
      *
      * @param configKey Configuration key to retrieve data from.
-     * @return Serialized ConfigMetricsReportList proto. Returns null on failure.
+     * @return Serialized ConfigMetricsReportList proto. Returns null on failure (eg, if statsd
+     * crashed).
      */
     @RequiresPermission(Manifest.permission.DUMP)
-    public byte[] getData(long configKey) {
+    public @Nullable byte[] getData(long configKey) {
         synchronized (this) {
             try {
                 IStatsManager service = getIStatsManagerLocked();
@@ -257,10 +251,10 @@ public final class StatsManager {
      * the actual metrics themselves (metrics must be collected via {@link #getData(String)}.
      * This getter is not destructive and will not reset any metrics/counters.
      *
-     * @return Serialized StatsdStatsReport proto. Returns null on failure.
+     * @return Serialized StatsdStatsReport proto. Returns null on failure (eg, if statsd crashed).
      */
     @RequiresPermission(Manifest.permission.DUMP)
-    public byte[] getMetadata() {
+    public @Nullable byte[] getMetadata() {
         synchronized (this) {
             try {
                 IStatsManager service = getIStatsManagerLocked();
index 789131c..e8b4197 100644 (file)
@@ -20,8 +20,7 @@ import android.os.Process;
 
 /**
  * StatsLog provides an API for developers to send events to statsd. The events can be used to
- * define custom metrics inside statsd. We will rate-limit how often the calls can be made inside
- * statsd.
+ * define custom metrics inside statsd.
  */
 public final class StatsLog extends StatsLogInternal {
     private static final String TAG = "StatsManager";