blob: 39621406222e6693e22ad24b5cde6fa8585e6039 [file] [log] [blame]
/*
* Copyright (C) 2017 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.
*/
syntax = "proto2";
// TODO: Not the right package and class name
package android.os.statsd;
option java_package = "com.android.os";
option java_outer_classname = "StatsEventProto";
/**
* The master event class. This message defines all of the available
* raw stats log events from the Android system, also known as "atoms."
*
* This field contains a single oneof with all of the available messages.
* The stats-log-api-gen tool runs as part of the Android build and
* generates the android.util.StatsLog class, which contains the constants
* and methods that Android uses to log.
*
* This StatsEvent class is not actually built into the Android system.
* Instead, statsd on Android constructs these messages synthetically,
* in the format defined here and in stats_log.proto.
*/
message StatsEvent {
oneof event {
// For StatsLog reasons, 1 is illegal and will not work. Must start at 2.
BleScanStateChanged ble_scan_state_changed = 2;
BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
BleScanResultReceived ble_scan_result_received = 4;
SensorStateChanged sensor_state_changed = 5;
GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested
SyncStateChanged sync_state_changed = 7;
ScheduledJobStateChanged scheduled_job_state_changed = 8;
ScreenBrightnessChanged screen_brightness_changed = 9;
// 10-20 are temporarily reserved for wakelocks etc.
UidWakelockStateChanged uid_wakelock_state_changed = 11;
LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 12;
BatterySaverModeStateChanged battery_saver_mode_state_changed = 21;
DeviceIdleModeStateChanged device_idle_mode_state_changed = 22;
AudioStateChanged audio_state_changed = 23;
MediaCodecActivityChanged media_codec_activity_changed = 24;
CameraStateChanged camera_state_changed = 25;
FlashlightStateChanged flashlight_state_changed = 26;
UidProcessStateChanged uid_process_state_changed = 27;
ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
ScreenStateChanged screen_state_changed = 29;
// TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
}
}
/**
* A WorkSource represents the chained attribution of applications that
* resulted in a particular bit of work being done.
*/
message WorkSource {
// TODO
}
/*
* *****************************************************************************
* Below are all of the individual atoms that are logged by Android via statsd
* and Westworld.
*
* RULES:
* - The field ids for each atom must start at 1, and count upwards by 1.
* Skipping field ids is not allowed.
* - These form an API, so renaming, renumbering or removing fields is
* not allowed between android releases. (This is not currently enforced,
* but there will be a tool to enforce this restriction).
* - The types must be built-in protocol buffer types, namely, no sub-messages
* are allowed (yet). The bytes type is also not allowed.
* - The CamelCase name of the message type should match the
* underscore_separated name as defined in StatsEvent.
* - If an atom represents work that can be attributed to an app, there can
* be exactly one WorkSource field. It must be field number 1.
* - A field that is a uid should be a string field, tagged with the [xxx]
* annotation. The generated code on android will be represented by UIDs,
* and those UIDs will be translated in xxx to those strings.
*
* CONVENTIONS:
* - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
* - If there is a UID, it goes first. Think in an object-oriented fashion.
* *****************************************************************************
*/
/**
* Logs when the screen state changes.
*
* Logged from:
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message ScreenStateChanged {
// TODO: Use the real screen state.
enum State {
STATE_UNKNOWN = 0;
STATE_OFF = 1;
STATE_ON = 2;
STATE_DOZE = 3;
STATE_DOZE_SUSPEND = 4;
STATE_VR = 5;
}
// New screen state.
optional State display_state = 1;
}
/**
* Logs that the state of a process state, as per the activity manager, has changed.
*
* Logged from:
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message UidProcessStateChanged {
optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
// The state.
// TODO: Use the real (mapped) process states.
optional int32 state = 2;
}
/**
* Logs that a process started, finished, crashed, or ANRed.
*
* Logged from:
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message ProcessLifeCycleStateChanged {
// TODO: Use the real (mapped) process states.
optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
// TODO: What is this?
optional string name = 2;
// The state.
// TODO: Use an enum.
optional int32 event = 3;
}
/**
* Logs when the ble scan state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message BleScanStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs when an unoptimized ble scan state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
message BleUnoptimizedScanStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs reporting of a ble scan finding results.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
message BleScanResultReceived {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
// Number of ble scan results returned.
optional int32 num_of_results = 2;
}
/**
* Logs when a sensor state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message SensorStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
// TODO: Is there a way to get the actual name of the sensor?
// The id (int) of the sensor.
optional int32 sensor_id = 2;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 3;
}
/**
* Logs when GPS state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message GpsScanStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs when a sync manager sync state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message SyncStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
// Name of the sync (as named in the app)
optional string name = 2;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 3;
}
/**
* Logs when a job scheduler job state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message ScheduledJobStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
// Name of the job (as named in the app)
optional string name = 2;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 3;
// TODO: Consider adding the stopReason (int)
}
/**
* Logs when the audio state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message AudioStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs when the video codec state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message MediaCodecActivityChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs when the flashlight state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message FlashlightStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs when the camera state changes.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message CameraStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 2;
}
/**
* Logs that the state of a wakelock (per app and per wakelock name) has changed.
*
* Logged from:
* TODO
*/
message WakelockChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
// Type of wakelock.
enum Type {
PARTIAL = 0;
FULL = 1;
WINDOW = 2;
}
optional int32 type = 2;
// The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
optional string tag = 3;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 4;
}
/**
* Logs when an app is holding a wakelock, regardless of the wakelock's name.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message UidWakelockStateChanged {
// TODO: Add attribution instead of uid.
optional int32 uid = 1;
// Type of wakelock.
enum Type {
PARTIAL = 0;
FULL = 1;
WINDOW = 2;
}
optional int32 type = 2;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 3;
}
/**
* Logs when a partial wakelock is considered 'long' (over 1 min).
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message LongPartialWakelockStateChanged {
// TODO: Add attribution instead of uid?
optional int32 uid = 1;
// The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
optional string tag = 2;
// TODO: I have no idea what this is.
optional string history_tag = 3;
enum State {
OFF = 0;
ON = 1;
}
optional State state = 4;
}
/**
* Logs Battery Saver state change.
*
* Logged from:
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message BatterySaverModeStateChanged {
enum State {
OFF = 0;
ON = 1;
}
optional State state = 1;
}
/**
* Logs Doze mode state change.
*
* Logged from:
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message DeviceIdleModeStateChanged {
// TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
optional int32 state = 1;
}
/**
* Logs screen brightness level.
*
* Logged from:
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message ScreenBrightnessChanged {
// Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
optional int32 level = 1;
}