Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 17 | syntax = "proto2"; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 18 | option java_multiple_files = true; |
| 19 | option java_outer_classname = "ProcessStatsServiceProto"; |
| 20 | |
| 21 | import "frameworks/base/core/proto/android/util/common.proto"; |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 22 | import "frameworks/base/libs/incident/proto/android/privacy.proto"; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 23 | |
| 24 | package android.service.procstats; |
| 25 | |
| 26 | /** |
| 27 | * Data from ProcStatsService Dumpsys |
| 28 | * |
| 29 | * Next Tag: 4 |
| 30 | */ |
| 31 | message ProcessStatsServiceDumpProto { |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 32 | option (android.msg_privacy).dest = DEST_AUTOMATIC; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 33 | |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 34 | optional ProcessStatsSectionProto procstats_now = 1; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 35 | |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 36 | optional ProcessStatsSectionProto procstats_over_3hrs = 2; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 37 | |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 38 | optional ProcessStatsSectionProto procstats_over_24hrs = 3; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Data model from /frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java |
| 43 | * This proto is defined based on the writeToParcel method. |
| 44 | * |
| 45 | * Next Tag: 9 |
| 46 | */ |
| 47 | message ProcessStatsSectionProto { |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 48 | option (android.msg_privacy).dest = DEST_AUTOMATIC; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 49 | |
| 50 | // Elapsed realtime at start of report. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 51 | optional int64 start_realtime_ms = 1; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 52 | |
| 53 | // Elapsed realtime at end of report. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 54 | optional int64 end_realtime_ms = 2; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 55 | |
| 56 | // CPU uptime at start of report. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 57 | optional int64 start_uptime_ms = 3; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 58 | |
| 59 | // CPU uptime at end of report. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 60 | optional int64 end_uptime_ms = 4; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 61 | |
| 62 | // System runtime library. e.g. "libdvm.so", "libart.so". |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 63 | optional string runtime = 5; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 64 | |
| 65 | // whether kernel reports swapped pss. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 66 | optional bool has_swapped_pss = 6; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 67 | |
| 68 | // Data completeness. e.g. "complete", "partial", shutdown", or "sysprops". |
| 69 | enum Status { |
| 70 | STATUS_UNKNOWN = 0; |
| 71 | STATUS_COMPLETE = 1; |
| 72 | STATUS_PARTIAL = 2; |
| 73 | STATUS_SHUTDOWN = 3; |
| 74 | STATUS_SYSPROPS = 4; |
| 75 | } |
| 76 | repeated Status status = 7; |
| 77 | |
| 78 | // Stats for each process. |
| 79 | repeated ProcessStatsProto process_stats = 8; |
| 80 | } |
| 81 | |
| 82 | // Next Tag: 6 |
| 83 | message ProcessStatsProto { |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 84 | option (android.msg_privacy).dest = DEST_AUTOMATIC; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 85 | |
| 86 | // Name of process. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 87 | optional string process = 1; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 88 | |
| 89 | // Uid of the process. |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 90 | optional int32 uid = 2; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 91 | |
| 92 | // Information about how often kills occurred |
| 93 | message Kill { |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 94 | option (android.msg_privacy).dest = DEST_AUTOMATIC; |
| 95 | |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 96 | // Count of excessive CPU kills |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 97 | optional int32 cpu = 1; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 98 | |
| 99 | // Count of kills when cached |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 100 | optional int32 cached = 2; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 101 | |
| 102 | // PSS stats during cached kill |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 103 | optional android.util.AggStats cached_pss = 3; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 104 | } |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 105 | optional Kill kill = 3; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 106 | |
| 107 | message State { |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 108 | option (android.msg_privacy).dest = DEST_AUTOMATIC; |
| 109 | |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 110 | enum ScreenState { |
| 111 | SCREEN_UNKNOWN = 0; |
| 112 | OFF = 1; |
| 113 | ON = 2; |
| 114 | } |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 115 | optional ScreenState screen_state = 1; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 116 | |
| 117 | enum MemoryState { |
| 118 | MEMORY_UNKNOWN = 0; |
| 119 | NORMAL = 1; // normal. |
| 120 | MODERATE = 2; // moderate memory pressure. |
| 121 | LOW = 3; // low memory. |
| 122 | CRITICAL = 4; // critical memory. |
| 123 | } |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 124 | optional MemoryState memory_state = 2; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 125 | |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 126 | // this enum list is from frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java |
| 127 | // and not frameworks/base/core/java/android/app/ActivityManager.java |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 128 | enum ProcessState { |
| 129 | PROCESS_UNKNOWN = 0; |
| 130 | // Persistent system process. |
| 131 | PERSISTENT = 1; |
| 132 | // Top activity; actually any visible activity. |
| 133 | TOP = 2; |
| 134 | // Important foreground process (ime, wallpaper, etc). |
| 135 | IMPORTANT_FOREGROUND = 3; |
| 136 | // Important background process. |
| 137 | IMPORTANT_BACKGROUND = 4; |
| 138 | // Performing backup operation. |
| 139 | BACKUP = 5; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 140 | // Background process running a service. |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 141 | SERVICE = 6; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 142 | // Process not running, but would be if there was enough RAM. |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 143 | SERVICE_RESTARTING = 7; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 144 | // Process running a receiver. |
Yi Jin | 0d7bc2d1 | 2018-01-23 17:35:19 -0800 | [diff] [blame] | 145 | RECEIVER = 8; |
| 146 | // Heavy-weight process (currently not used). |
| 147 | HEAVY_WEIGHT = 9; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 148 | // Process hosting home/launcher app when not on top. |
| 149 | HOME = 10; |
| 150 | // Process hosting the last app the user was in. |
| 151 | LAST_ACTIVITY = 11; |
| 152 | // Cached process hosting a previous activity. |
| 153 | CACHED_ACTIVITY = 12; |
| 154 | // Cached process hosting a client activity. |
| 155 | CACHED_ACTIVITY_CLIENT = 13; |
| 156 | // Cached process that is empty. |
| 157 | CACHED_EMPTY = 14; |
| 158 | } |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 159 | optional ProcessState process_state = 3; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 160 | |
| 161 | // Millisecond duration spent in this state |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 162 | optional int64 duration_ms = 4; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 163 | |
| 164 | // # of samples taken |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 165 | optional int32 sample_size = 5; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 166 | |
| 167 | // PSS is memory reserved for this process |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 168 | optional android.util.AggStats pss = 6; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 169 | |
| 170 | // USS is memory shared between processes, divided evenly for accounting |
Yi Jin | c7f9307 | 2017-09-29 15:29:38 -0700 | [diff] [blame] | 171 | optional android.util.AggStats uss = 7; |
Yi Jin | 9680cfa | 2017-09-15 15:14:43 -0700 | [diff] [blame] | 172 | } |
| 173 | repeated State states = 5; |
| 174 | } |