diff --git a/core/java/android/os/health/HealthStats.java b/core/java/android/os/health/HealthStats.java index f0489e244750f..90d89c5ced8c1 100644 --- a/core/java/android/os/health/HealthStats.java +++ b/core/java/android/os/health/HealthStats.java @@ -83,6 +83,10 @@ import java.util.Map; * returned for UidHealthStats.STATS_PACKAGES, the keys come from the * {@link android.os.health.PackageHealthStats} class. * + *
+ * The keys that are available are subject to change, depending on what a particular + * device or software version is capable of recording. Applications must handle the absence of + * data without crashing. */ public class HealthStats { // Header fields diff --git a/core/java/android/os/health/PidHealthStats.java b/core/java/android/os/health/PidHealthStats.java index fe3c02cadcc7e..0d2a3f14fbb08 100644 --- a/core/java/android/os/health/PidHealthStats.java +++ b/core/java/android/os/health/PidHealthStats.java @@ -20,18 +20,56 @@ package android.os.health; * Keys for {@link HealthStats} returned from * {@link HealthStats#getStats(int) HealthStats.getStats(int)} with the * {@link UidHealthStats#STATS_PIDS UidHealthStats.STATS_PIDS} key. + *
+ * The values coming from PidHealthStats are a little bit different from + * the other HealthStats values. These values are not aggregate or historical + * values, but instead live values from when the snapshot is taken. These + * tend to be more useful in debugging rogue processes than in gathering + * aggregate metrics across the fleet of devices. */ public final class PidHealthStats { private PidHealthStats() { } + /** + * Key for a measurement of the current nesting depth of wakelocks for this process. + * That is to say, the number of times a nested wakelock has been started but not + * stopped. A high number here indicates an improperly paired wakelock acquire/release + * combination. + *
+ * More details on the individual wake locks is available + * by getting the {@link UidHealthStats#TIMERS_WAKELOCKS_FULL}, + * {@link UidHealthStats#TIMERS_WAKELOCKS_PARTIAL}, + * {@link UidHealthStats#TIMERS_WAKELOCKS_WINDOW} + * and {@link UidHealthStats#TIMERS_WAKELOCKS_DRAW} keys. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_WAKE_NESTING_COUNT = HealthKeys.BASE_PID + 1; + /** + * Key for a measurement of the total number of milleseconds that this process + * has held a wake lock. + *
+ * More details on the individual wake locks is available + * by getting the {@link UidHealthStats#TIMERS_WAKELOCKS_FULL}, + * {@link UidHealthStats#TIMERS_WAKELOCKS_PARTIAL}, + * {@link UidHealthStats#TIMERS_WAKELOCKS_WINDOW} + * and {@link UidHealthStats#TIMERS_WAKELOCKS_DRAW} keys. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_WAKE_SUM_MS = HealthKeys.BASE_PID + 2; + /** + * Key for a measurement of the time in the {@link android.os.SystemClock#elapsedRealtime} + * timebase that a wakelock was first acquired in this process. + *
+ * More details on the individual wake locks is available + * by getting the {@link UidHealthStats#TIMERS_WAKELOCKS_FULL}, + * {@link UidHealthStats#TIMERS_WAKELOCKS_PARTIAL}, + * {@link UidHealthStats#TIMERS_WAKELOCKS_WINDOW} + * and {@link UidHealthStats#TIMERS_WAKELOCKS_DRAW} keys. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_WAKE_START_MS = HealthKeys.BASE_PID + 3; diff --git a/core/java/android/os/health/ProcessHealthStats.java b/core/java/android/os/health/ProcessHealthStats.java index e004ecb27ad50..b3f0dfc50066d 100644 --- a/core/java/android/os/health/ProcessHealthStats.java +++ b/core/java/android/os/health/ProcessHealthStats.java @@ -26,21 +26,42 @@ public final class ProcessHealthStats { private ProcessHealthStats() { } + /** + * Key for a measurement of number of millseconds the CPU spent running in user space + * for this process. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_USER_TIME_MS = HealthKeys.BASE_PROCESS + 1; + /** + * Key for a measurement of number of millseconds the CPU spent running in kernel space + * for this process. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_SYSTEM_TIME_MS = HealthKeys.BASE_PROCESS + 2; + /** + * Key for a measurement of the number of times this process was started for any reason. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_STARTS_COUNT = HealthKeys.BASE_PROCESS + 3; + /** + * Key for a measurement of the number of crashes that happened in this process. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_CRASHES_COUNT = HealthKeys.BASE_PROCESS + 4; + /** + * Key for a measurement of the number of ANRs that happened in this process. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_ANR_COUNT = HealthKeys.BASE_PROCESS + 5; + /** + * Key for a measurement of the number of milliseconds this process spent with + * an activity in the foreground. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_FOREGROUND_MS = HealthKeys.BASE_PROCESS + 6; diff --git a/core/java/android/os/health/ServiceHealthStats.java b/core/java/android/os/health/ServiceHealthStats.java index 802ad31894b35..cc48b3eb9e14c 100644 --- a/core/java/android/os/health/ServiceHealthStats.java +++ b/core/java/android/os/health/ServiceHealthStats.java @@ -26,9 +26,20 @@ public final class ServiceHealthStats { private ServiceHealthStats() { } + /** + * Key for a measurement of the number of times this service was started due to calls to + * {@link android.content.Context#startService startService()}, including re-launches + * after crashes. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_START_SERVICE_COUNT = HealthKeys.BASE_SERVICE + 1; + /** + * Key for a measurement of the total number of times this service was started + * due to calls to {@link android.content.Context#startService startService()} + * or {@link android.content.Context#bindService bindService()} including re-launches + * after crashes. + */ @HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT) public static final int MEASUREMENT_LAUNCH_COUNT = HealthKeys.BASE_SERVICE + 2; diff --git a/core/java/android/os/health/SystemHealthManager.java b/core/java/android/os/health/SystemHealthManager.java index 520e84e0266ab..eff5c9a1b8990 100644 --- a/core/java/android/os/health/SystemHealthManager.java +++ b/core/java/android/os/health/SystemHealthManager.java @@ -27,6 +27,11 @@ import com.android.internal.app.IBatteryStats; /** * Provides access to data about how various system resources are used by applications. * @more + *
+ * If you are going to be using this class to log your application's resource usage, + * please consider the amount of resources (battery, network, etc) that will be used + * by the logging itself. It can be substantial. + *
* Battery Usage
* The statistics related to power (battery) usage are recorded since the device
* was last unplugged. It is expected that applications schedule more work to do
diff --git a/core/java/android/os/health/TimerStat.java b/core/java/android/os/health/TimerStat.java
index b9d8874e89385..6af1faf25107c 100644
--- a/core/java/android/os/health/TimerStat.java
+++ b/core/java/android/os/health/TimerStat.java
@@ -101,14 +101,14 @@ public final class TimerStat implements Parcelable {
}
/**
- * Set the time for this timer.
+ * Set the time for this timer in milliseconds.
*/
public void setTime(long time) {
mTime = time;
}
/**
- * Get the time for this timer.
+ * Get the time for this timer in milliseconds.
*/
public long getTime() {
return mTime;
diff --git a/core/java/android/os/health/UidHealthStats.java b/core/java/android/os/health/UidHealthStats.java
index 337235a38bdec..a702cdb6093cb 100644
--- a/core/java/android/os/health/UidHealthStats.java
+++ b/core/java/android/os/health/UidHealthStats.java
@@ -74,6 +74,11 @@ public final class UidHealthStats {
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMERS)
public static final int TIMERS_WAKELOCKS_WINDOW = HealthKeys.BASE_UID + 7;
+ /**
+ * Key for a TimerStat for the times a system-defined wakelock was acquired
+ * to allow the application to draw when it otherwise would not be able to
+ * (e.g. on the lock screen or doze screen).
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMERS)
public static final int TIMERS_WAKELOCKS_DRAW = HealthKeys.BASE_UID + 8;
@@ -125,144 +130,316 @@ public final class UidHealthStats {
@HealthKeys.Constant(type=HealthKeys.TYPE_STATS)
public static final int STATS_PACKAGES = HealthKeys.BASE_UID + 15;
+ /**
+ * Key for a measurement of number of millseconds the wifi controller was
+ * idle but turned on on behalf of this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_IDLE_MS = HealthKeys.BASE_UID + 16;
+ /**
+ * Key for a measurement of number of millseconds the wifi transmitter was
+ * receiving data for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_RX_MS = HealthKeys.BASE_UID + 17;
+ /**
+ * Key for a measurement of number of millseconds the wifi transmitter was
+ * transmitting data for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_TX_MS = HealthKeys.BASE_UID + 18;
+ /**
+ * Key for a measurement of the estimated number of mA*ms used by this uid
+ * for wifi, that is to say the number of milliseconds of wifi activity
+ * times the mA current during that period.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_POWER_MAMS = HealthKeys.BASE_UID + 19;
+ /**
+ * Key for a measurement of number of millseconds the bluetooth controller was
+ * idle but turned on on behalf of this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_IDLE_MS = HealthKeys.BASE_UID + 20;
+ /**
+ * Key for a measurement of number of millseconds the bluetooth transmitter was
+ * receiving data for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_RX_MS = HealthKeys.BASE_UID + 21;
+ /**
+ * Key for a measurement of number of millseconds the bluetooth transmitter was
+ * transmitting data for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_TX_MS = HealthKeys.BASE_UID + 22;
+ /**
+ * Key for a measurement of the estimated number of mA*ms used by this uid
+ * for bluetooth, that is to say the number of milliseconds of activity
+ * times the mA current during that period.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_POWER_MAMS = HealthKeys.BASE_UID + 23;
+ /**
+ * Key for a measurement of number of millseconds the mobile radio controller was
+ * idle but turned on on behalf of this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_IDLE_MS = HealthKeys.BASE_UID + 24;
+ /**
+ * Key for a measurement of number of millseconds the mobile radio transmitter was
+ * receiving data for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_RX_MS = HealthKeys.BASE_UID + 25;
+ /**
+ * Key for a measurement of number of millseconds the mobile radio transmitter was
+ * transmitting data for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_TX_MS = HealthKeys.BASE_UID + 26;
+ /**
+ * Key for a measurement of the estimated number of mA*ms used by this uid
+ * for mobile data, that is to say the number of milliseconds of activity
+ * times the mA current during that period.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_POWER_MAMS = HealthKeys.BASE_UID + 27;
+ /**
+ * Key for a measurement of number of millseconds the wifi controller was
+ * active on behalf of this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_RUNNING_MS = HealthKeys.BASE_UID + 28;
+ /**
+ * Key for a measurement of number of millseconds that this uid held a full wifi lock.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_FULL_LOCK_MS = HealthKeys.BASE_UID + 29;
+ /**
+ * Key for a timer for the count and duration of wifi scans done by this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_WIFI_SCAN = HealthKeys.BASE_UID + 30;
+ /**
+ * Key for a measurement of number of millseconds that this uid was performing
+ * multicast wifi traffic.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_MULTICAST_MS = HealthKeys.BASE_UID + 31;
+ /**
+ * Key for a timer for the count and duration of audio playback done by this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_AUDIO = HealthKeys.BASE_UID + 32;
+ /**
+ * Key for a timer for the count and duration of video playback done by this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_VIDEO = HealthKeys.BASE_UID + 33;
+ /**
+ * Key for a timer for the count and duration this uid had the flashlight turned on.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_FLASHLIGHT = HealthKeys.BASE_UID + 34;
+ /**
+ * Key for a timer for the count and duration this uid had the camera turned on.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_CAMERA = HealthKeys.BASE_UID + 35;
+ /**
+ * Key for a timer for the count and duration of when an activity from this uid
+ * was the foreground activitiy.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_FOREGROUND_ACTIVITY = HealthKeys.BASE_UID + 36;
+ /**
+ * Key for a timer for the count and duration of when this uid was doing bluetooth scans.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_BLUETOOTH_SCAN = HealthKeys.BASE_UID + 37;
+ /**
+ * Key for a timer for the count and duration of when this uid was in the "top" process state.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_PROCESS_STATE_TOP_MS = HealthKeys.BASE_UID + 38;
+ /**
+ * Key for a timer for the count and duration of when this uid was in the "foreground service"
+ * process state.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_PROCESS_STATE_FOREGROUND_SERVICE_MS = HealthKeys.BASE_UID + 39;
+ /**
+ * Key for a timer for the count and duration of when this uid was in the "top sleeping"
+ * process state.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_PROCESS_STATE_TOP_SLEEPING_MS = HealthKeys.BASE_UID + 40;
+ /**
+ * Key for a timer for the count and duration of when this uid was in the "foreground"
+ * process state.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_PROCESS_STATE_FOREGROUND_MS = HealthKeys.BASE_UID + 41;
+ /**
+ * Key for a timer for the count and duration of when this uid was in the "background"
+ * process state.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_PROCESS_STATE_BACKGROUND_MS = HealthKeys.BASE_UID + 42;
+ /**
+ * Key for a timer for the count and duration of when this uid was in the "cached" process
+ * state.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_PROCESS_STATE_CACHED_MS = HealthKeys.BASE_UID + 43;
+ /**
+ * Key for a timer for the count and duration this uid had the vibrator turned on.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_VIBRATOR = HealthKeys.BASE_UID + 44;
+ /**
+ * Key for a measurement of number of software-generated user activity events caused
+ * by the UID. Calls to userActivity() reset the user activity countdown timer and
+ * keep the screen on for the user's preferred screen-on setting.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_OTHER_USER_ACTIVITY_COUNT = HealthKeys.BASE_UID + 45;
+ /**
+ * Key for a measurement of number of user activity events due to physical button presses caused
+ * by the UID. Calls to userActivity() reset the user activity countdown timer and
+ * keep the screen on for the user's preferred screen-on setting.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BUTTON_USER_ACTIVITY_COUNT = HealthKeys.BASE_UID + 46;
+ /**
+ * Key for a measurement of number of user activity events due to touch events caused
+ * by the UID. Calls to userActivity() reset the user activity countdown timer and
+ * keep the screen on for the user's preferred screen-on setting.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_TOUCH_USER_ACTIVITY_COUNT = HealthKeys.BASE_UID + 47;
+ /**
+ * Key for a measurement of number of bytes received for this uid by the mobile radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_RX_BYTES = HealthKeys.BASE_UID + 48;
+ /**
+ * Key for a measurement of number of bytes transmitted for this uid by the mobile radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_TX_BYTES = HealthKeys.BASE_UID + 49;
+ /**
+ * Key for a measurement of number of bytes received for this uid by the wifi radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_RX_BYTES = HealthKeys.BASE_UID + 50;
+ /**
+ * Key for a measurement of number of bytes transmitted for this uid by the wifi radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_TX_BYTES = HealthKeys.BASE_UID + 51;
+ /**
+ * Key for a measurement of number of bytes received for this uid by the bluetooth radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_RX_BYTES = HealthKeys.BASE_UID + 52;
+ /**
+ * Key for a measurement of number of bytes transmitted for this uid by the bluetooth radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_TX_BYTES = HealthKeys.BASE_UID + 53;
+ /**
+ * Key for a measurement of number of packets received for this uid by the mobile radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_RX_PACKETS = HealthKeys.BASE_UID + 54;
+ /**
+ * Key for a measurement of number of packets transmitted for this uid by the mobile radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_MOBILE_TX_PACKETS = HealthKeys.BASE_UID + 55;
+ /**
+ * Key for a measurement of number of packets received for this uid by the wifi radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_RX_PACKETS = HealthKeys.BASE_UID + 56;
+ /**
+ * Key for a measurement of number of packets transmitted for this uid by the wifi radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_WIFI_TX_PACKETS = HealthKeys.BASE_UID + 57;
+ /**
+ * Key for a measurement of number of packets received for this uid by the bluetooth radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_RX_PACKETS = HealthKeys.BASE_UID + 58;
+ /**
+ * Key for a measurement of number of packets transmitted for this uid by the bluetooth radio.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_BLUETOOTH_TX_PACKETS = HealthKeys.BASE_UID + 59;
+ /**
+ * Key for a timer for the count and duration the mobile radio was turned on for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_TIMER)
public static final int TIMER_MOBILE_RADIO_ACTIVE = HealthKeys.BASE_UID + 61;
+ /**
+ * Key for a measurement of the number of milliseconds spent by the CPU running user space
+ * code for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_USER_CPU_TIME_MS = HealthKeys.BASE_UID + 62;
+ /**
+ * Key for a measurement of the number of milliseconds spent by the CPU running kernel
+ * code for this uid.
+ */
@HealthKeys.Constant(type=HealthKeys.TYPE_MEASUREMENT)
public static final int MEASUREMENT_SYSTEM_CPU_TIME_MS = HealthKeys.BASE_UID + 63;
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 7da247a453418..1edc9b18c697c 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -3067,7 +3067,7 @@ class AlarmManagerService extends SystemService {
}
} else {
ActivityManagerNative.noteWakeupAlarm(
- alarm.operation, -1, alarm.packageName, alarm.statsTag);
+ alarm.operation, alarm.uid, alarm.packageName, alarm.statsTag);
}
}
}