1/* 2 * Copyright (C) 2022 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 android.os; 19 20option java_multiple_files = true; 21 22// This message is used for statsd logging and should be kept in sync with 23// frameworks/proto_logging/stats/atoms.proto 24/** 25 * Logs information about app background restrictions. 26 * 27 * Logged from: 28 * frameworks/base/services/core/java/com/android/server/am/AppRestrictionController.java 29 */ 30message AppBackgroundRestrictionsInfo { 31 // the uid of the app. 32 optional int32 uid = 1; 33 34 enum RestrictionLevel { 35 LEVEL_UNKNOWN = 0; 36 LEVEL_UNRESTRICTED = 1; 37 LEVEL_EXEMPTED = 2; 38 LEVEL_ADAPTIVE_BUCKET = 3; 39 LEVEL_RESTRICTED_BUCKET = 4; 40 LEVEL_BACKGROUND_RESTRICTED = 5; 41 LEVEL_HIBERNATION = 6; 42 } 43 // indicates the app background restriction level. 44 optional RestrictionLevel restriction_level = 2; 45 46 enum Threshold { 47 THRESHOLD_UNKNOWN = 0; 48 THRESHOLD_RESTRICTED = 1; // app was background restricted by the system. 49 THRESHOLD_USER = 2; // app was background restricted by user action. 50 } 51 // indicates which threshold caused the app to be put into bg restriction. 52 optional Threshold threshold = 3; 53 54 enum StateTracker { 55 UNKNOWN_TRACKER = 0; 56 BATTERY_TRACKER = 1; 57 BATTERY_EXEMPTION_TRACKER = 2; 58 FGS_TRACKER = 3; 59 MEDIA_SESSION_TRACKER = 4; 60 PERMISSION_TRACKER = 5; 61 BROADCAST_EVENTS_TRACKER = 6; 62 BIND_SERVICE_EVENTS_TRACKER = 7; 63 } 64 // indicates the reason/tracker which caused the app to hit the threshold. 65 optional StateTracker tracker = 4; 66 67 message FgsTrackerInfo { 68 // indicates whether an fgs notification was visible for this app or not. 69 optional bool fgs_notification_visible = 1; 70 // total FGS duration for this app. 71 optional int64 fgs_duration = 2; 72 } 73 optional FgsTrackerInfo fgs_tracker_info = 5; 74 75 message BatteryTrackerInfo { 76 // total battery usage within last 24h (1/10000th) 77 optional int32 battery_24h = 1; 78 // background battery usage (1/10000th) 79 optional int32 battery_usage_background = 2; 80 // FGS battery usage (1/10000th) 81 optional int32 battery_usage_fgs = 3; 82 // Foreground battery usage (1/10000th) 83 optional int32 battery_usage_foreground = 4; 84 // Cached battery usage (1/10000th) 85 optional int32 battery_usage_cached = 5; 86 87 } 88 optional BatteryTrackerInfo battery_tracker_info = 6; 89 90 message BroadcastEventsTrackerInfo { 91 // the number of broadcasts sent by this app. 92 optional int32 broadcasts_sent = 1; 93 } 94 optional BroadcastEventsTrackerInfo broadcast_events_tracker_info = 7; 95 96 message BindServiceEventsTrackerInfo { 97 // the number of bind service requests by this app. 98 optional int32 bind_service_requests = 1; 99 } 100 optional BindServiceEventsTrackerInfo bind_service_events_tracker_info = 101 8; 102 103 // The reasons listed below are defined in PowerExemptionManager.java 104 enum ExemptionReason { 105 // range 0-9 is reserved for default reasons 106 REASON_UNKNOWN = 0; 107 REASON_DENIED = 1; 108 REASON_OTHER = 2; 109 // range 10-49 is reserved for BG-FGS-launch allowed proc states 110 REASON_PROC_STATE_PERSISTENT = 10; 111 REASON_PROC_STATE_PERSISTENT_UI = 11; 112 REASON_PROC_STATE_TOP = 12; 113 REASON_PROC_STATE_BTOP = 13; 114 REASON_PROC_STATE_FGS = 14; 115 REASON_PROC_STATE_BFGS = 15; 116 // range 50-99 is reserved for BG-FGS-launch allowed reasons 117 REASON_UID_VISIBLE = 50; 118 REASON_SYSTEM_UID = 51; 119 REASON_ACTIVITY_STARTER = 52; 120 REASON_START_ACTIVITY_FLAG = 53; 121 REASON_FGS_BINDING = 54; 122 REASON_DEVICE_OWNER = 55; 123 REASON_PROFILE_OWNER = 56; 124 REASON_COMPANION_DEVICE_MANAGER = 57; 125 REASON_BACKGROUND_ACTIVITY_PERMISSION = 58; 126 REASON_BACKGROUND_FGS_PERMISSION = 59; 127 REASON_INSTR_BACKGROUND_ACTIVITY_PERMISSION = 60; 128 REASON_INSTR_BACKGROUND_FGS_PERMISSION = 61; 129 REASON_SYSTEM_ALERT_WINDOW_PERMISSION = 62; 130 REASON_DEVICE_DEMO_MODE = 63; 131 REASON_ALLOWLISTED_PACKAGE = 65; 132 REASON_APPOP = 66; 133 REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD = 67; 134 REASON_OP_ACTIVATE_VPN = 68; 135 REASON_OP_ACTIVATE_PLATFORM_VPN = 69; 136 REASON_TEMP_ALLOWED_WHILE_IN_USE = 70; 137 REASON_CURRENT_INPUT_METHOD = 71; 138 // range 100-199 is reserved for public reasons 139 REASON_GEOFENCING = 100; 140 REASON_PUSH_MESSAGING = 101; 141 REASON_PUSH_MESSAGING_OVER_QUOTA = 102; 142 REASON_ACTIVITY_RECOGNITION = 103; 143 REASON_ACCOUNT_TRANSFER = 104; 144 // range 200-299 is reserved for broadcast actions 145 REASON_BOOT_COMPLETED = 200; 146 REASON_PRE_BOOT_COMPLETED = 201; 147 REASON_LOCKED_BOOT_COMPLETED = 202; 148 REASON_BLUETOOTH_BROADCAST = 203; 149 REASON_TIMEZONE_CHANGED = 204; 150 REASON_TIME_CHANGED = 205; 151 REASON_LOCALE_CHANGED = 206; 152 REASON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED = 207; 153 REASON_REFRESH_SAFETY_SOURCES = 208; 154 // range 300-399 is reserved for other internal reasons 155 REASON_SYSTEM_ALLOW_LISTED = 300; 156 REASON_ALARM_MANAGER_ALARM_CLOCK = 301; 157 REASON_ALARM_MANAGER_WHILE_IDLE = 302; 158 REASON_SERVICE_LAUNCH = 303; 159 REASON_KEY_CHAIN = 304; 160 REASON_PACKAGE_VERIFIER = 305; 161 REASON_SYNC_MANAGER = 306; 162 REASON_DOMAIN_VERIFICATION_V1 = 307; 163 REASON_DOMAIN_VERIFICATION_V2 = 308; 164 REASON_VPN = 309; 165 REASON_NOTIFICATION_SERVICE = 310; 166 REASON_PACKAGE_REPLACED = 311; 167 REASON_LOCATION_PROVIDER = 312; 168 REASON_MEDIA_BUTTON = 313; 169 REASON_EVENT_SMS = 314; 170 REASON_EVENT_MMS = 315; 171 REASON_SHELL = 316; 172 REASON_MEDIA_SESSION_CALLBACK = 317; 173 REASON_ROLE_DIALER = 318; 174 REASON_ROLE_EMERGENCY = 319; 175 REASON_SYSTEM_MODULE = 320; 176 REASON_CARRIER_PRIVILEGED_APP = 321; 177 REASON_DPO_PROTECTED_APP = 322; 178 REASON_DISALLOW_APPS_CONTROL = 323; 179 REASON_ACTIVE_DEVICE_ADMIN = 324; 180 // app requested to be exempt 181 REASON_OPT_OUT_REQUESTED = 1000; 182 } 183 // indicates if the app is exempt from background restrictions and the reason if applicable. 184 optional ExemptionReason exemption_reason = 9; 185 186 enum OptimizationLevel { 187 UNKNOWN = 0; 188 OPTIMIZED = 1; 189 BACKGROUND_RESTRICTED = 2; 190 NOT_OPTIMIZED = 3; 191 } 192 // the user choice for the optimization level of the app. 193 optional OptimizationLevel opt_level = 10; 194 195 enum TargetSdk { 196 SDK_UNKNOWN = 0; 197 SDK_PRE_S = 1; 198 SDK_S = 2; 199 SDK_T = 3; 200 } 201 // indicates the target sdk level for this app. 202 optional TargetSdk target_sdk = 11; 203 204 // indicates if the current device is a low ram device. 205 optional bool low_mem_device = 12; 206 207 // indicates previous background restriction level. 208 optional RestrictionLevel previous_restriction_level = 13; 209} 210 211