Home | History | Annotate | Download | only in service
      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 
     17 syntax = "proto2";
     18 option java_multiple_files = true;
     19 option java_outer_classname = "ProcessStatsServiceProto";
     20 
     21 import "frameworks/base/core/proto/android/util/common.proto";
     22 import "frameworks/base/libs/incident/proto/android/privacy.proto";
     23 
     24 package android.service.procstats;
     25 
     26 /**
     27  * Data from ProcStatsService Dumpsys
     28  *
     29  * Next Tag: 4
     30  */
     31 message ProcessStatsServiceDumpProto {
     32     option (android.msg_privacy).dest = DEST_AUTOMATIC;
     33 
     34     optional ProcessStatsSectionProto procstats_now = 1;
     35 
     36     optional ProcessStatsSectionProto procstats_over_3hrs = 2;
     37 
     38     optional ProcessStatsSectionProto procstats_over_24hrs = 3;
     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 {
     48     option (android.msg_privacy).dest = DEST_AUTOMATIC;
     49 
     50     // Elapsed realtime at start of report.
     51     optional int64 start_realtime_ms = 1;
     52 
     53     // Elapsed realtime at end of report.
     54     optional int64 end_realtime_ms = 2;
     55 
     56     // CPU uptime at start of report.
     57     optional int64 start_uptime_ms = 3;
     58 
     59     // CPU uptime at end of report.
     60     optional int64 end_uptime_ms = 4;
     61 
     62     // System runtime library. e.g. "libdvm.so", "libart.so".
     63     optional string runtime = 5;
     64 
     65     // whether kernel reports swapped pss.
     66     optional bool has_swapped_pss = 6;
     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 {
     84     option (android.msg_privacy).dest = DEST_AUTOMATIC;
     85 
     86     // Name of process.
     87     optional string process = 1;
     88 
     89     // Uid of the process.
     90     optional int32 uid = 2;
     91 
     92     // Information about how often kills occurred
     93     message Kill {
     94         option (android.msg_privacy).dest = DEST_AUTOMATIC;
     95 
     96       // Count of excessive CPU kills
     97       optional int32 cpu = 1;
     98 
     99       // Count of kills when cached
    100       optional int32 cached = 2;
    101 
    102       // PSS stats during cached kill
    103       optional android.util.AggStats cached_pss = 3;
    104     }
    105     optional Kill kill = 3;
    106 
    107     message State {
    108         option (android.msg_privacy).dest = DEST_AUTOMATIC;
    109 
    110         enum ScreenState {
    111             SCREEN_UNKNOWN = 0;
    112             OFF = 1;
    113             ON = 2;
    114         }
    115         optional ScreenState screen_state = 1;
    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         }
    124         optional MemoryState memory_state = 2;
    125 
    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
    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;
    140             // Background process running a service.
    141             SERVICE = 6;
    142             // Process not running, but would be if there was enough RAM.
    143             SERVICE_RESTARTING = 7;
    144             // Process running a receiver.
    145             RECEIVER = 8;
    146             // Heavy-weight process (currently not used).
    147             HEAVY_WEIGHT = 9;
    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         }
    159         optional ProcessState process_state = 3;
    160 
    161         // Millisecond duration spent in this state
    162         optional int64 duration_ms = 4;
    163 
    164         // # of samples taken
    165         optional int32 sample_size = 5;
    166 
    167         // PSS is memory reserved for this process
    168         optional android.util.AggStats pss = 6;
    169 
    170         // USS is memory shared between processes, divided evenly for accounting
    171         optional android.util.AggStats uss = 7;
    172 
    173         // RSS is memory resident for this process
    174         optional android.util.AggStats rss = 8;
    175     }
    176     repeated State states = 5;
    177 }
    178