From 62c220b20b3fc431c27feac29a71d040fc8e2626 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Sat, 18 Nov 2017 20:32:56 -0800 Subject: [PATCH] Fix how we build the statsd protos. This lets us include frameworks protos, and use the constants and messages from them. Change-Id: I609d6e524f780e6a5beea543a68561bede47813e Test: make --- Android.bp | 26 +- Android.mk | 13 +- cmds/incident_helper/Android.bp | 11 +- .../tests/CpuFreqParser_test.cpp | 11 +- .../tests/CpuInfoParser_test.cpp | 11 +- .../tests/KernelWakesParser_test.cpp | 13 +- .../tests/PageTypeInfoParser_test.cpp | 13 +- .../tests/ProcrankParser_test.cpp | 13 +- .../tests/SystemPropertiesParser_test.cpp | 11 +- cmds/statsd/Android.bp | 6 + cmds/statsd/Android.mk | 14 +- cmds/statsd/src/atoms.proto | 6 +- cmds/statsd/src/atoms_copy.proto | 1077 ----------------- cmds/statsd/src/stats_log.proto | 2 +- cmds/statsd/tools/dogfood/Android.mk | 24 +- cmds/statsd/tools/loadtest/Android.mk | 24 +- core/java/android/app/ActivityManager.java | 4 +- core/proto/android/app/activitymanager.proto | 110 +- .../android/server/powermanagerservice.proto | 2 +- libs/incident/Android.mk | 1 + 20 files changed, 146 insertions(+), 1246 deletions(-) delete mode 100644 cmds/statsd/src/atoms_copy.proto diff --git a/Android.bp b/Android.bp index 948b0a068215..86b82e52ad20 100644 --- a/Android.bp +++ b/Android.bp @@ -677,35 +677,23 @@ cc_library { "-Werror", "-Wno-unused-parameter", ], + + srcs: [ + "core/proto/**/*.proto", + "libs/incident/**/*.proto", + "tools/streaming_proto/stream.proto", + ], + target: { host: { proto: { type: "full", }, - srcs: [ - "core/proto/**/*.proto", - "libs/incident/**/*.proto", - "tools/streaming_proto/stream.proto", - ], }, android: { proto: { type: "lite", }, - // We only build the protos that are optimized for the lite - // runtime, as well as the only protos that are actually - // needed by the device. - srcs: [ - "core/proto/android/os/cpufreq.proto", - "core/proto/android/os/cpuinfo.proto", - "core/proto/android/os/kernelwake.proto", - "core/proto/android/os/pagetypeinfo.proto", - "core/proto/android/os/procrank.proto", - "core/proto/android/os/system_properties.proto", - "core/proto/android/service/graphicsstats.proto", - "libs/incident/proto/android/privacy.proto", - "tools/streaming_proto/stream.proto", - ], shared: { enabled: false, }, diff --git a/Android.mk b/Android.mk index ec5fb841131e..8cdd87eda58a 100644 --- a/Android.mk +++ b/Android.mk @@ -1008,7 +1008,7 @@ include $(BUILD_HOST_JAVA_LIBRARY) # ==== java proto device library (for test only) ============================== include $(CLEAR_VARS) LOCAL_MODULE := platformprotosnano -LOCAL_MODULE_TAGS := tests optional +LOCAL_MODULE_TAGS := tests LOCAL_PROTOC_OPTIMIZE_TYPE := nano LOCAL_PROTOC_FLAGS := \ -Iexternal/protobuf/src @@ -1020,6 +1020,17 @@ LOCAL_SRC_FILES := \ include $(BUILD_STATIC_JAVA_LIBRARY) +# ==== java proto device library (for test only) ============================== +include $(CLEAR_VARS) +LOCAL_MODULE := platformprotoslite +LOCAL_MODULE_TAGS := tests +LOCAL_PROTOC_OPTIMIZE_TYPE := lite +LOCAL_PROTOC_FLAGS := \ + -Iexternal/protobuf/src +LOCAL_SRC_FILES := \ + $(call all-proto-files-under, core/proto) +include $(BUILD_STATIC_JAVA_LIBRARY) + # Include subdirectory makefiles # ============================================================ diff --git a/cmds/incident_helper/Android.bp b/cmds/incident_helper/Android.bp index fc0bdccb268b..d7b6d69ade74 100644 --- a/cmds/incident_helper/Android.bp +++ b/cmds/incident_helper/Android.bp @@ -50,12 +50,15 @@ cc_test { "testdata/*", ], - shared_libs: [ - "libprotobuf-cpp-full", - ], - static_libs: [ "libgmock", "libplatformprotos" ], + + shared_libs: [ + "libprotobuf-cpp-full" + ], + proto: { + type: "full", + }, } diff --git a/cmds/incident_helper/tests/CpuFreqParser_test.cpp b/cmds/incident_helper/tests/CpuFreqParser_test.cpp index 1c2f9e59308d..82deee42687f 100644 --- a/cmds/incident_helper/tests/CpuFreqParser_test.cpp +++ b/cmds/incident_helper/tests/CpuFreqParser_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -125,6 +118,6 @@ TEST_F(CpuFreqParserTest, Success) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/CpuInfoParser_test.cpp b/cmds/incident_helper/tests/CpuInfoParser_test.cpp index bbc14bca3efc..8dce53e46492 100644 --- a/cmds/incident_helper/tests/CpuInfoParser_test.cpp +++ b/cmds/incident_helper/tests/CpuInfoParser_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -153,6 +146,6 @@ TEST_F(CpuInfoParserTest, Success) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/KernelWakesParser_test.cpp b/cmds/incident_helper/tests/KernelWakesParser_test.cpp index a8fa62088450..a98c62bd6024 100644 --- a/cmds/incident_helper/tests/KernelWakesParser_test.cpp +++ b/cmds/incident_helper/tests/KernelWakesParser_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -76,7 +69,7 @@ TEST_F(KernelWakesParserTest, Short) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } @@ -114,6 +107,6 @@ TEST_F(KernelWakesParserTest, Normal) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp index de64e70c80c7..a9e6e816c6c5 100644 --- a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp +++ b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -108,6 +101,6 @@ TEST_F(PageTypeInfoParserTest, Success) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); -} \ No newline at end of file +} diff --git a/cmds/incident_helper/tests/ProcrankParser_test.cpp b/cmds/incident_helper/tests/ProcrankParser_test.cpp index e86647ad479b..76b25d7f8f47 100644 --- a/cmds/incident_helper/tests/ProcrankParser_test.cpp +++ b/cmds/incident_helper/tests/ProcrankParser_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -104,7 +97,7 @@ TEST_F(ProcrankParserTest, HasSwapInfo) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } @@ -142,6 +135,6 @@ TEST_F(ProcrankParserTest, NoSwapInfo) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp b/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp index 98838e98d796..2fe2411e2017 100644 --- a/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp +++ b/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -99,6 +92,6 @@ TEST_F(SystemPropertiesParserTest, HasSwapInfo) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp index 5fcb8a1a0892..a5eae15b50da 100644 --- a/cmds/statsd/Android.bp +++ b/cmds/statsd/Android.bp @@ -31,5 +31,11 @@ cc_library_host_shared { type: "full", export_proto_headers: true, }, + + export_shared_lib_headers: [ + "libplatformprotos", + ] + } + diff --git a/cmds/statsd/Android.mk b/cmds/statsd/Android.mk index 337aeaaf37ab..859cb99f5c77 100644 --- a/cmds/statsd/Android.mk +++ b/cmds/statsd/Android.mk @@ -19,7 +19,7 @@ statsd_common_src := \ ../../core/java/android/os/IStatsManager.aidl \ src/stats_log.proto \ src/statsd_config.proto \ - src/atoms_copy.proto \ + src/atoms.proto \ src/anomaly/AnomalyMonitor.cpp \ src/anomaly/AnomalyTracker.cpp \ src/condition/CombinationConditionTracker.cpp \ @@ -67,6 +67,9 @@ statsd_common_c_includes := \ statsd_common_aidl_includes := \ $(LOCAL_PATH)/../../core/java +statsd_common_static_libraries := \ + libplatformprotos + statsd_common_shared_libraries := \ libbase \ libbinder \ @@ -121,6 +124,8 @@ LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static LOCAL_AIDL_INCLUDES := $(statsd_common_aidl_includes) LOCAL_C_INCLUDES += $(statsd_common_c_includes) +LOCAL_STATIC_LIBRARIES := $(statsd_common_static_libraries) + LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) \ libgtest_prod @@ -174,17 +179,22 @@ LOCAL_SRC_FILES := \ tests/guardrail/StatsdStats_test.cpp LOCAL_STATIC_LIBRARIES := \ + $(statsd_common_static_libraries) \ libgmock LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) LOCAL_PROTOC_OPTIMIZE_TYPE := lite +include $(BUILD_NATIVE_TEST) + + statsd_common_src:= statsd_common_aidl_includes:= statsd_common_c_includes:= +statsd_common_static_libraries:= +statsd_common_shared_libraries:= -include $(BUILD_NATIVE_TEST) ############################## diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index c81fc1dec7ab..716fee6bb1fb 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -21,6 +21,8 @@ package android.os.statsd; option java_package = "com.android.os"; option java_outer_classname = "AtomsProto"; +import "frameworks/base/core/proto/android/app/activitymanager.proto"; + /** * The master atom class. This message defines all of the available * raw stats log events from the Android system, also known as "atoms." @@ -168,7 +170,7 @@ message UidProcessStateChanged { // The state. // TODO: Use the real (mapped) process states. - optional int32 state = 2; + optional android.app.ProcessState state = 2; } /** @@ -1072,4 +1074,4 @@ message ModemActivityInfoPulled { optional uint64 controller_rx_time_ms = 9; // product of current(mA), voltage(V) and time(ms) optional uint64 energy_used = 10; -} \ No newline at end of file +} diff --git a/cmds/statsd/src/atoms_copy.proto b/cmds/statsd/src/atoms_copy.proto deleted file mode 100644 index 72bb38a394a7..000000000000 --- a/cmds/statsd/src/atoms_copy.proto +++ /dev/null @@ -1,1077 +0,0 @@ -/* - * 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"; -option optimize_for = LITE_RUNTIME; - - -// TODO: Not the right package and class name -package android.os.statsd; -option java_package = "com.android.os"; -option java_outer_classname = "AtomsProto"; - -/** - * The master atom 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 Atom 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 Atom { - // Pushed atoms start at 2. - oneof pushed { - // 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; - WakelockStateChanged wakelock_state_changed = 10; - LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 11; - MobileRadioPowerStateChanged mobile_radio_power_state_changed = 12; - WifiRadioPowerStateChanged wifi_radio_power_state_changed = 13; - // TODO: 14-19 are blank, but need not be - BatterySaverModeStateChanged battery_saver_mode_state_changed = 20; - DeviceIdleModeStateChanged device_idle_mode_state_changed = 21; - DeviceIdlingModeStateChanged device_idling_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; - BatteryLevelChanged battery_level_changed = 30; - ChargingStateChanged charging_state_changed = 31; - PluggedStateChanged plugged_state_changed = 32; - DeviceTemperatureReported device_temperature_reported = 33; - DeviceOnStatusChanged device_on_status_changed = 34; - WakeupAlarmOccurred wakeup_alarm_occurred = 35; - KernelWakeupReported kernel_wakeup_reported = 36; - WifiLockStateChanged wifi_lock_state_changed = 37; - WifiSignalStrengthChanged wifi_signal_strength_changed = 38; - WifiScanStateChanged wifi_scan_state_changed = 39; - PhoneSignalStrengthChanged phone_signal_strength_changed = 40; - SettingChanged setting_changed = 41; - ActivityForegroundStateChanged activity_foreground_state_changed = 42; - IsolatedUidChanged isolated_uid_changed = 43; - PacketWakeupOccurred packet_wakeup_occurred = 44; - DropboxErrorChanged dropbox_error_changed = 45; - // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15. - } - - // Pulled events will start at field 1000. - oneof pulled { - WifiBytesTransferred wifi_bytes_transferred = 1000; - WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001; - MobileBytesTransferred mobile_bytes_transferred = 1002; - MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003; - KernelWakelockPulled kernel_wakelock_pulled = 1004; - PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005; - PowerStateVoterPulled power_state_voter_pulled = 1006; - PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007; - CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008; - CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009; - CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010; - WifiActivityEnergyInfoPulled wifi_activity_energy_info_pulled = 1011; - ModemActivityInfoPulled modem_activity_info_pulled = 1012; - } -} - -/** - * A WorkSource represents the chained attribution of applications that - * resulted in a particular bit of work being done. - */ -message WorkSource { - // The uid for a given element in the attribution chain. - repeated int32 uid = 1; - // The (optional) string tag for an element in the attribution chain. If the - // element has no tag, it is encoded as an empty string. - repeated string tag = 2; -} - -/* - * ***************************************************************************** - * Below are all of the individual atoms that are logged by Android via statsd. - * - * 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 Atom. - * - 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; - STATE_ON_SUSPEND = 6; - } - // 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; - - // What lifecycle state the process changed to. - // This enum is specific to atoms.proto. - enum Event { - PROCESS_FINISHED = 0; - PROCESS_STARTED = 1; - PROCESS_CRASHED = 2; - PROCESS_ANRED = 3; - } - optional Event 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 WakelockStateChanged { - // TODO: Add attribution instead of uid. - optional int32 uid = 1; - - // Type of wakelock. - enum Type { - PARTIAL = 0; - FULL = 1; - WINDOW = 2; - } - optional Type type = 2; - - // The wakelock tag (Called tag in the Java API, sometimes name elsewhere). - optional string tag = 3; - - enum State { - RELEASE = 0; - ACQUIRE = 1; - CHANGE_RELEASE = 2; - CHANGE_ACQUIRE = 3; - } - optional State state = 4; -} - -/** - * 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/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message DeviceIdleModeStateChanged { - // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_. - enum State { - DEVICE_IDLE_MODE_OFF = 0; - DEVICE_IDLE_MODE_LIGHT = 1; - DEVICE_IDLE_MODE_DEEP = 2; - } - optional State state = 1; -} - - -/** - * Logs state change of Doze mode including maintenance windows. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message DeviceIdlingModeStateChanged { - // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_. - enum State { - DEVICE_IDLE_MODE_OFF = 0; - DEVICE_IDLE_MODE_LIGHT = 1; - DEVICE_IDLE_MODE_DEEP = 2; - } - optional State 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; -} - -/** - * Logs battery level (percent full, from 0 to 100). - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message BatteryLevelChanged { - // Battery level. Should be in [0, 100]. - optional int32 battery_level = 1; -} - -/** - * Logs change in charging status of the device. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message ChargingStateChanged { - // TODO: Link directly to BatteryManager.java's constants (via a proto). - enum State { - BATTERY_STATUS_UNKNOWN = 1; - BATTERY_STATUS_CHARGING = 2; - BATTERY_STATUS_DISCHARGING = 3; - BATTERY_STATUS_NOT_CHARGING = 4; - BATTERY_STATUS_FULL = 5; - } - optional State charging_state = 1; -} - -/** - * Logs whether the device is plugged in, and what power source it is using. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message PluggedStateChanged { - // TODO: Link directly to BatteryManager.java's constants (via a proto). - enum State { - // Note that NONE is not in BatteryManager.java's constants. - BATTERY_PLUGGED_NONE = 0; - // Power source is an AC charger. - BATTERY_PLUGGED_AC = 1; - // Power source is a USB port. - BATTERY_PLUGGED_USB = 2; - // Power source is wireless. - BATTERY_PLUGGED_WIRELESS = 4; - } - optional State plugged_state = 1; -} - -/** - * Logs the temperature of the device, in tenths of a degree Celsius. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message DeviceTemperatureReported { - // Temperature in tenths of a degree C. - optional int32 temperature = 1; -} - -// TODO: Define this more precisely. -// TODO: Log the ON state somewhere. It isn't currently logged anywhere. -/** - * Logs when the device turns off or on. - * - * Logged from: - * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java - */ -message DeviceOnStatusChanged { - enum State { - OFF = 0; - ON = 1; - } - optional State state = 1; -} - -/** - * Logs when an app's wakeup alarm fires. - * - * Logged from: - * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java - */ -message WakeupAlarmOccurred { - // TODO: Add attribution instead of uid? - optional int32 uid = 1; - - // Name of the wakeup alarm. - optional string tag = 2; -} - -/** - * Logs when an an app causes the mobile radio to change state. - * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message MobileRadioPowerStateChanged { - // TODO: Add attribution instead of uid? - optional int32 uid = 1; - - // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states. - enum PowerState { - DC_POWER_STATE_LOW = 1; - DC_POWER_STATE_MEDIUM = 2; - DC_POWER_STATE_HIGH = 3; - } - optional PowerState power_state = 2; -} - -/** - * Logs when an an app causes the wifi radio to change state. - * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message WifiRadioPowerStateChanged { - // TODO: Add attribution instead of uid? - optional int32 uid = 1; - - // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states. - enum PowerState { - DC_POWER_STATE_LOW = 1; - DC_POWER_STATE_MEDIUM = 2; - DC_POWER_STATE_HIGH = 3; - } - optional PowerState power_state = 2; -} - -/** - * Logs kernel wakeup reasons and aborts. - * - * Logged from: - * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java - */ -message KernelWakeupReported { - // Name of the kernel wakeup reason (or abort). - optional string wakeup_reason_name = 1; - - // Duration (in microseconds) for the wake-up interrupt to be serviced. - optional int64 duration_usec = 2; -} - -/** - * Logs wifi locks held by an app. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message WifiLockStateChanged { - // TODO: Add attribution instead of uid. - optional int32 uid = 1; - - enum State { - OFF = 0; - ON = 1; - } - optional State state = 2; -} - -/** - * Logs wifi signal strength changes. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message WifiSignalStrengthChanged { - // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states. - enum SignalStrength { - SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; - SIGNAL_STRENGTH_POOR = 1; - SIGNAL_STRENGTH_MODERATE = 2; - SIGNAL_STRENGTH_GOOD = 3; - SIGNAL_STRENGTH_GREAT = 4; - } - optional SignalStrength signal_strength = 1; -} - -/** - * Logs wifi scans performed by an app. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message WifiScanStateChanged { - // TODO: Add attribution instead of uid. - optional int32 uid = 1; - - enum State { - OFF = 0; - ON = 1; - } - optional State state = 2; -} - -/** - * Logs phone signal strength changes. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message PhoneSignalStrengthChanged { - // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states. - enum SignalStrength { - SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; - SIGNAL_STRENGTH_POOR = 1; - SIGNAL_STRENGTH_MODERATE = 2; - SIGNAL_STRENGTH_GOOD = 3; - SIGNAL_STRENGTH_GREAT = 4; - } - optional SignalStrength signal_strength = 1; -} - -/** - * Logs that a setting was updated. - * Logged from: - * frameworks/base/core/java/android/provider/Settings.java - * The tag and is_default allow resetting of settings to default values based on the specified - * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details. - */ -message SettingChanged { - // The name of the setting. - optional string setting = 1; - - // The change being imposed on this setting. May represent a number, eg "3". - optional string value = 2; - - // The new value of this setting. For most settings, this is same as value. For some settings, - // value is +X or -X where X represents an element in a set. For example, if the previous value - // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C. - // The +/- feature is currently only used for location_providers_allowed. - optional string new_value = 3; - - // The previous value of this setting. - optional string prev_value = 4; - - // The tag used with the is_default for resetting sets of settings. This is generally null. - optional string tag = 5; - - // 1 indicates that this setting with tag should be resettable. - optional int32 is_default = 6; - - // The user ID associated. Defined in android/os/UserHandle.java - optional int32 user = 7; -} - -/** - * Logs activity going to foreground or background - * - * Logged from: - * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java - */ -message ActivityForegroundStateChanged { - enum Activity { - MOVE_TO_BACKGROUND = 0; - MOVE_TO_FOREGROUND = 1; - } - optional int32 uid = 1; - optional string pkg_name = 2; - optional string class_name = 3; - optional Activity activity = 4; -} - -/** - * Logs when an error is written to dropbox. - * Logged from: - * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java - */ -message DropboxErrorChanged { - // The uid if available. -1 means not available. - optional int32 uid = 1; - - // Tag used when recording this error to dropbox. Contains data_ or system_ prefix. - optional string tag = 2; - - // The name of the process. - optional string process_name = 3; - - // The pid if available. -1 means not available. - optional int32 pid = 4; - - // 1 indicates is instant app. -1 indicates Not applicable. - optional int32 is_instant_app = 5; - - // The activity name if available. - optional string activity_name = 6; - - // 1 indicates in foreground. -1 indicates not available. - optional int32 is_foreground = 7; -} - -/** - * Pulls bytes transferred via wifi (Sum of foreground and background usage). - * - * Pulled from: - * StatsCompanionService (using BatteryStats to get which interfaces are wifi) - */ -message WifiBytesTransferred { - optional int32 uid = 1; - - optional int64 rx_bytes = 2; - - optional int64 rx_packets = 3; - - optional int64 tx_bytes = 4; - - optional int64 tx_packets = 5; -} - -/** - * Pulls bytes transferred via wifi (separated by foreground and background usage). - * - * Pulled from: - * StatsCompanionService (using BatteryStats to get which interfaces are wifi) - */ -message WifiBytesTransferredByFgBg { - optional int32 uid = 1; - - // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats. - optional int32 is_foreground = 2; - - optional int64 rx_bytes = 3; - - optional int64 rx_packets = 4; - - optional int64 tx_bytes = 5; - - optional int64 tx_packets = 6; -} - -/** - * Pulls bytes transferred via mobile networks (Sum of foreground and background usage). - * - * Pulled from: - * StatsCompanionService (using BatteryStats to get which interfaces are mobile data) - */ -message MobileBytesTransferred { - optional int32 uid = 1; - - optional int64 rx_bytes = 2; - - optional int64 rx_packets = 3; - - optional int64 tx_bytes = 4; - - optional int64 tx_packets = 5; -} - -/** - * Pulls bytes transferred via mobile networks (separated by foreground and background usage). - * - * Pulled from: - * StatsCompanionService (using BatteryStats to get which interfaces are mobile data) - */ -message MobileBytesTransferredByFgBg { - optional int32 uid = 1; - - // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats. - optional int32 is_foreground = 2; - - optional int64 rx_bytes = 3; - - optional int64 rx_packets = 4; - - optional int64 tx_bytes = 5; - - optional int64 tx_packets = 6; -} - -/** - * Pulls the kernel wakelock durations. This atom is adapted from - * android/internal/os/KernelWakelockStats.java - * - * Pulled from: - * StatsCompanionService using KernelWakelockReader. - */ -message KernelWakelockPulled { - optional string name = 1; - - optional int32 count = 2; - - optional int32 version = 3; - - optional int64 time = 4; -} - -/** - * Pulls PowerStatePlatformSleepState. - * - * Definition here: - * hardware/interfaces/power/1.0/types.hal - */ -message PowerStatePlatformSleepStatePulled { - optional string name = 1; - optional uint64 residency_in_msec_since_boot = 2; - optional uint64 total_transitions = 3; - optional bool supported_only_in_suspend = 4; -} - -/** - * Pulls PowerStateVoter. - * - * Definition here: - * hardware/interfaces/power/1.0/types.hal - */ -message PowerStateVoterPulled { - optional string power_state_platform_sleep_state_name = 1; - optional string power_state_voter_name = 2; - optional uint64 total_time_in_msec_voted_for_since_boot = 3; - optional uint64 total_number_of_times_voted_since_boot = 4; -} - -/** - * Pulls PowerStateSubsystemSleepState. - * - * Definition here: - * hardware/interfaces/power/1.1/types.hal - */ -message PowerStateSubsystemSleepStatePulled { - optional string power_state_subsystem_name = 1; - optional string power_state_subsystem_sleep_state_name = 2; - optional uint64 residency_in_msec_since_boot = 3; - optional uint64 total_transitions = 4; - optional uint64 last_entry_timestamp_ms = 5; - optional bool supported_only_in_suspend = 6; -} - -/** - * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky - * behavior in its own uid. However, the metrics of these isolated uid's almost always should be - * attributed back to the parent (host) uid. One example is Chrome. - * - * Logged from: - * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java - */ -message IsolatedUidChanged { - // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid. - optional int32 parent_uid = 1; - - optional int32 isolated_uid = 2; - - // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to - // be removed before if it's used for another parent uid. - optional int32 is_create = 3; -} - -/** - * Pulls Cpu time per frequency. - * Note: this should be pulled for gauge metric only, without condition. - * The puller keeps internal state of last values. It should not be pulled by - * different metrics. - * The pulled data is delta of cpu time from last pull, calculated as - * following: - * if current time is larger than last value, take delta between the two. - * if current time is smaller than last value, there must be a cpu - * hotplug event, and the current time is taken as delta. - */ -message CpuTimePerFreqPulled { - optional uint32 cluster = 1; - optional uint32 freq_index = 2; - optional uint64 time = 3; -} - -/** - * Pulls Cpu Time Per Uid. - * Note that isolated process uid time should be attributed to host uids. - */ -message CpuTimePerUidPulled { - optional uint64 uid = 1; - optional uint64 user_time_ms = 2; - optional uint64 sys_time_ms = 3; -} - -/** - * Pulls Cpu Time Per Uid per frequency. - * Note that isolated process uid time should be attributed to host uids. - * For each uid, we order the time by descending frequencies. - */ -message CpuTimePerUidFreqPulled { - optional uint64 uid = 1; - optional uint64 freq_idx = 2; - optional uint64 time_ms = 3; -} - -/* - * Logs the reception of an incoming network packet causing the main system to wake up for - * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd - * and processed by WakeupController.cpp. - */ -message PacketWakeupOccurred { - // The uid owning the socket into which the packet was delivered, or -1 if the packet was - // delivered nowhere. - optional int32 uid = 1; - // The interface name on which the packet was received. - optional string iface = 2; - // The ethertype value of the packet. - optional int32 ethertype = 3; - // String representation of the destination MAC address of the packet. - optional string destination_hardware_address = 4; - // String representation of the source address of the packet if this was an IP packet. - optional string source_ip = 5; - // String representation of the destination address of the packet if this was an IP packet. - optional string destination_ip = 6; - // The value of the protocol field if this was an IPv4 packet or the value of the Next Header - // field if this was an IPv6 packet. The range of possible values is the same for both IP - // families. - optional int32 ip_next_header = 7; - // The source port if this was a TCP or UDP packet. - optional int32 source_port = 8; - // The destination port if this was a TCP or UDP packet. - optional int32 destination_port = 9; -} - -/** - * Pulls Wifi Controller Activity Energy Info - */ -message WifiActivityEnergyInfoPulled { - // timestamp(wall clock) of record creation - optional uint64 timestamp_ms = 1; - // stack reported state - // TODO: replace this with proto enum - optional int32 stack_state = 2; - // tx time in ms - optional uint64 controller_tx_time_ms = 3; - // rx time in ms - optional uint64 controller_rx_time_ms = 4; - // idle time in ms - optional uint64 controller_idle_time_ms = 5; - // product of current(mA), voltage(V) and time(ms) - optional uint64 controller_energy_used = 6; -} - -/** - * Pulls Modem Activity Energy Info - */ -message ModemActivityInfoPulled { - // timestamp(wall clock) of record creation - optional uint64 timestamp_ms = 1; - // sleep time in ms. - optional uint64 sleep_time_ms = 2; - // idle time in ms - optional uint64 controller_idle_time_ms = 3; - /** - * Tx power index - * index 0 = tx_power < 0dBm - * index 1 = 0dBm < tx_power < 5dBm - * index 2 = 5dBm < tx_power < 15dBm - * index 3 = 15dBm < tx_power < 20dBm - * index 4 = tx_power > 20dBm - */ - // tx time in ms at power level 0 - optional uint64 controller_tx_time_pl0_ms = 4; - // tx time in ms at power level 1 - optional uint64 controller_tx_time_pl1_ms = 5; - // tx time in ms at power level 2 - optional uint64 controller_tx_time_pl2_ms = 6; - // tx time in ms at power level 3 - optional uint64 controller_tx_time_pl3_ms = 7; - // tx time in ms at power level 4 - optional uint64 controller_tx_time_pl4_ms = 8; - // rx time in ms at power level 5 - optional uint64 controller_rx_time_ms = 9; - // product of current(mA), voltage(V) and time(ms) - optional uint64 energy_used = 10; -} \ No newline at end of file diff --git a/cmds/statsd/src/stats_log.proto b/cmds/statsd/src/stats_log.proto index f8b91fe0ef0a..9301f2e1fa09 100644 --- a/cmds/statsd/src/stats_log.proto +++ b/cmds/statsd/src/stats_log.proto @@ -22,7 +22,7 @@ package android.os.statsd; option java_package = "com.android.os"; option java_outer_classname = "StatsLog"; -import "frameworks/base/cmds/statsd/src/atoms_copy.proto"; +import "frameworks/base/cmds/statsd/src/atoms.proto"; message KeyValuePair { optional int32 key = 1; diff --git a/cmds/statsd/tools/dogfood/Android.mk b/cmds/statsd/tools/dogfood/Android.mk index 1bd5f30b2f5c..6b0531d97c83 100644 --- a/cmds/statsd/tools/dogfood/Android.mk +++ b/cmds/statsd/tools/dogfood/Android.mk @@ -16,19 +16,19 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_SRC_FILES += ../../src/stats_log.proto \ - ../../src/atoms_copy.proto - -LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/../../src/ - -LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res - LOCAL_PACKAGE_NAME := StatsdDogfood + +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_SRC_FILES += ../../src/stats_log.proto \ + ../../src/atoms.proto +LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/../../src/ +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res +LOCAL_STATIC_JAVA_LIBRARIES := platformprotoslite + +LOCAL_PROTOC_OPTIMIZE_TYPE := lite LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_DEX_PREOPT := false -include $(BUILD_PACKAGE) \ No newline at end of file +LOCAL_PROGUARD_ENABLED := disabled + +include $(BUILD_PACKAGE) diff --git a/cmds/statsd/tools/loadtest/Android.mk b/cmds/statsd/tools/loadtest/Android.mk index f3f0a7c2128f..0a0fd6647fbb 100644 --- a/cmds/statsd/tools/loadtest/Android.mk +++ b/cmds/statsd/tools/loadtest/Android.mk @@ -16,20 +16,20 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_SRC_FILES += ../../src/stats_log.proto \ - ../../src/atoms_copy.proto \ - ../../src/statsd_config.proto - -LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/../../src/ - -LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res - LOCAL_PACKAGE_NAME := StatsdLoadtest + +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_SRC_FILES += ../../src/stats_log.proto \ + ../../src/atoms.proto \ + ../../src/statsd_config.proto +LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/../../src/ +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res +LOCAL_STATIC_JAVA_LIBRARIES := platformprotoslite + +LOCAL_PROTOC_OPTIMIZE_TYPE := lite LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_DEX_PREOPT := false +LOCAL_PROGUARD_ENABLED := disabled + include $(BUILD_PACKAGE) diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index e33b79e51fb6..3ca23f20a3e9 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -533,10 +533,10 @@ public class ActivityManager { // to frameworks/base/core/proto/android/app/activitymanager.proto and the following method must // be updated to correctly map between them. /** - * Maps ActivityManager.PROCESS_STATE_ values to ActivityManagerProto.ProcessState enum. + * Maps ActivityManager.PROCESS_STATE_ values to ProcessState enum. * * @param amInt a process state of the form ActivityManager.PROCESS_STATE_ - * @return the value of the corresponding android.app.ActivityManagerProto's ProcessState enum. + * @return the value of the corresponding ActivityManager's ProcessState enum. * @hide */ public static final int processStateAmToProto(int amInt) { diff --git a/core/proto/android/app/activitymanager.proto b/core/proto/android/app/activitymanager.proto index e87499ed2b83..73850509dfa8 100644 --- a/core/proto/android/app/activitymanager.proto +++ b/core/proto/android/app/activitymanager.proto @@ -20,61 +20,59 @@ package android.app; option java_multiple_files = true; -message ActivityManagerProto { +// ActivityManager.java PROCESS_STATEs +enum ProcessState { + // Order matters for process states, so values have been spaced to provide + // room for future additions. - // ActivityManager.java PROCESS_STATEs - enum ProcessState { - // Order matters for process states, so values have been spaced to provide - // room for future additions. - - // Not a real process state. - PROCESS_STATE_UNKNOWN = -100; - // Process is a persistent system process. - PROCESS_STATE_PERSISTENT = 0; - // Process is a persistent system process and is doing UI. - PROCESS_STATE_PERSISTENT_UI = 100; - // Process is hosting the current top activities. Note that this covers - // all activities that are visible to the user. - PROCESS_STATE_TOP = 200; - // Process is hosting a foreground service due to a system binding. - PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 300; - // Process is hosting a foreground service. - PROCESS_STATE_FOREGROUND_SERVICE = 400; - // Same as PROCESS_STATE_TOP but while device is sleeping. - PROCESS_STATE_TOP_SLEEPING = 500; - // Process is important to the user, and something they are aware of. - PROCESS_STATE_IMPORTANT_FOREGROUND = 600; - // Process is important to the user, but not something they are aware of. - PROCESS_STATE_IMPORTANT_BACKGROUND = 700; - // Process is in the background transient so we will try to keep running. - PROCESS_STATE_TRANSIENT_BACKGROUND = 800; - // Process is in the background running a backup/restore operation. - PROCESS_STATE_BACKUP = 900; - // Process is in the background, but it can't restore its state so we want - // to try to avoid killing it. - PROCESS_STATE_HEAVY_WEIGHT = 1000; - // Process is in the background running a service. Unlike oom_adj, this - // level is used for both the normal running in background state and the - // executing operations state. - PROCESS_STATE_SERVICE = 1100; - // Process is in the background running a receiver. Note that from the - // perspective of oom_adj, receivers run at a higher foreground level, but - // for our prioritization here that is not necessary and putting them - // below services means many fewer changes in some process states as they - // receive broadcasts. - PROCESS_STATE_RECEIVER = 1200; - // Process is in the background but hosts the home activity. - PROCESS_STATE_HOME = 1300; - // Process is in the background but hosts the last shown activity. - PROCESS_STATE_LAST_ACTIVITY = 1400; - // Process is being cached for later use and contains activities. - PROCESS_STATE_CACHED_ACTIVITY = 1500; - // Process is being cached for later use and is a client of another cached - // process that contains activities. - PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 1600; - // Process is being cached for later use and is empty. - PROCESS_STATE_CACHED_EMPTY = 1700; - // Process does not exist. - PROCESS_STATE_NONEXISTENT = 1800; - } + // Not a real process state. + PROCESS_STATE_UNKNOWN = -100; + // Process is a persistent system process. + PROCESS_STATE_PERSISTENT = 0; + // Process is a persistent system process and is doing UI. + PROCESS_STATE_PERSISTENT_UI = 100; + // Process is hosting the current top activities. Note that this covers + // all activities that are visible to the user. + PROCESS_STATE_TOP = 200; + // Process is hosting a foreground service due to a system binding. + PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 300; + // Process is hosting a foreground service. + PROCESS_STATE_FOREGROUND_SERVICE = 400; + // Same as PROCESS_STATE_TOP but while device is sleeping. + PROCESS_STATE_TOP_SLEEPING = 500; + // Process is important to the user, and something they are aware of. + PROCESS_STATE_IMPORTANT_FOREGROUND = 600; + // Process is important to the user, but not something they are aware of. + PROCESS_STATE_IMPORTANT_BACKGROUND = 700; + // Process is in the background transient so we will try to keep running. + PROCESS_STATE_TRANSIENT_BACKGROUND = 800; + // Process is in the background running a backup/restore operation. + PROCESS_STATE_BACKUP = 900; + // Process is in the background, but it can't restore its state so we want + // to try to avoid killing it. + PROCESS_STATE_HEAVY_WEIGHT = 1000; + // Process is in the background running a service. Unlike oom_adj, this + // level is used for both the normal running in background state and the + // executing operations state. + PROCESS_STATE_SERVICE = 1100; + // Process is in the background running a receiver. Note that from the + // perspective of oom_adj, receivers run at a higher foreground level, but + // for our prioritization here that is not necessary and putting them + // below services means many fewer changes in some process states as they + // receive broadcasts. + PROCESS_STATE_RECEIVER = 1200; + // Process is in the background but hosts the home activity. + PROCESS_STATE_HOME = 1300; + // Process is in the background but hosts the last shown activity. + PROCESS_STATE_LAST_ACTIVITY = 1400; + // Process is being cached for later use and contains activities. + PROCESS_STATE_CACHED_ACTIVITY = 1500; + // Process is being cached for later use and is a client of another cached + // process that contains activities. + PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 1600; + // Process is being cached for later use and is empty. + PROCESS_STATE_CACHED_EMPTY = 1700; + // Process does not exist. + PROCESS_STATE_NONEXISTENT = 1800; } + diff --git a/core/proto/android/server/powermanagerservice.proto b/core/proto/android/server/powermanagerservice.proto index d3b2cde01397..c1bd69218d64 100644 --- a/core/proto/android/server/powermanagerservice.proto +++ b/core/proto/android/server/powermanagerservice.proto @@ -57,7 +57,7 @@ message PowerManagerServiceDumpProto { optional bool is_active = 3; optional int32 num_wake_locks = 4; optional bool is_process_state_unknown = 5; - optional .android.app.ActivityManagerProto.ProcessState process_state = 6; + optional .android.app.ProcessState process_state = 6; } optional ConstantsProto constants = 1; diff --git a/libs/incident/Android.mk b/libs/incident/Android.mk index 439e86deba5d..8aa4b107c25e 100644 --- a/libs/incident/Android.mk +++ b/libs/incident/Android.mk @@ -36,6 +36,7 @@ LOCAL_SRC_FILES := \ src/IncidentReportArgs.cpp LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include +LOCAL_PROTO_OPTIMIZE_TYPE := lite include $(BUILD_SHARED_LIBRARY)