1/* 2 * Copyright (C) 2021 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 17syntax = "proto2"; 18package com.android.server.criticalevents; 19 20option java_multiple_files = true; 21 22// Output proto containing recent critical events for inclusion in logs such as ANR files. 23// Do not change the field names since this data is dumped to ANR files in textproto format. 24message CriticalEventLogProto { 25 // Timestamp when the log snapshot was generated. 26 // Required. 27 optional int64 timestamp_ms = 1; 28 29 // Max age of events that are included in this proto. 30 // Required. 31 optional int32 window_ms = 2; 32 33 // Max number of events in the log. 34 // Note: if the number of events is equal to the capacity then it is likely the actual time range 35 // covered by the log is shorter than window_ms. 36 // Required. 37 optional int32 capacity = 3; 38 39 // Recent critical events. 40 repeated CriticalEventProto events = 4; 41} 42 43// On-disk storage of events. 44message CriticalEventLogStorageProto { 45 repeated CriticalEventProto events = 1; 46} 47 48// A "critical" event such as an ANR or watchdog. 49// Do not change the field names since this data is dumped to ANR files in textproto format. 50message CriticalEventProto { 51 // Timestamp of the event. 52 // Required. 53 optional int64 timestamp_ms = 1; 54 55 // Required. 56 oneof event { 57 Watchdog watchdog = 2; 58 HalfWatchdog half_watchdog = 3; 59 AppNotResponding anr = 4; 60 JavaCrash java_crash = 5; 61 NativeCrash native_crash = 6; 62 } 63 64 message Watchdog { 65 // The watchdog subject. 66 // Required. 67 optional string subject = 1; 68 69 // Unique identifier of the watchdog. 70 // Can be used to join with other data for this watchdog such as stack dumps & perfetto traces. 71 // Generated in {@link com.android.server.Watchdog#run}. 72 // Required. 73 optional string uuid = 2; 74 } 75 76 message HalfWatchdog { 77 // The half-watchdog subject. 78 // Required. 79 optional string subject = 1; 80 } 81 82 message AppNotResponding { 83 // The ANR subject. 84 // Optional, may be redacted for privacy. 85 optional string subject = 1; 86 87 // Name of the ANRing process. 88 // Optional, may be redacted for privacy. 89 optional string process = 2; 90 91 // PID of the ANRing process. 92 // Required. 93 optional int32 pid = 3; 94 95 // UID of the ANRing process. 96 // Required. 97 optional int32 uid = 4; 98 99 // Category of the ANRing process (DATA_APP, SYSTEM_APP, etc). 100 // Required. 101 optional ProcessClass process_class = 5; 102 } 103 104 message JavaCrash { 105 // The crash exception class. 106 // Optional, may be redacted for privacy. 107 optional string exception_class = 1; 108 109 // Name of the crashed process. 110 // Optional, may be redacted for privacy. 111 optional string process = 2; 112 113 // PID of the crashed process. 114 // Required. 115 optional int32 pid = 3; 116 117 // UID of the crashed process. 118 // Required. 119 optional int32 uid = 4; 120 121 // Category of the crashed process (DATA_APP, SYSTEM_APP, etc). 122 // Required. 123 optional ProcessClass process_class = 5; 124 } 125 126 message NativeCrash { 127 // Name of the crashed process. 128 // Optional, may be redacted for privacy. 129 optional string process = 1; 130 131 // PID of the crashed process. 132 // Required. 133 optional int32 pid = 2; 134 135 // UID of the crashed process. 136 // Required. 137 optional int32 uid = 3; 138 139 // Category of the crashed process (DATA_APP, SYSTEM_APP, etc). 140 // Required. 141 optional ProcessClass process_class = 4; 142 } 143 144 145 // Mirrors definition & values in {@link android.server.ServerProtoEnums}. 146 enum ProcessClass { 147 PROCESS_CLASS_UNKNOWN = 0; 148 DATA_APP = 1; 149 SYSTEM_APP = 2; 150 SYSTEM_SERVER = 3; 151 } 152}