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 package com.android.server.am; 18 19 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_POWER_QUICK; 20 21 import android.app.ActivityThread; 22 import android.content.ComponentName; 23 import android.content.ContentResolver; 24 import android.content.Context; 25 import android.database.ContentObserver; 26 import android.net.Uri; 27 import android.os.Build; 28 import android.os.Handler; 29 import android.provider.DeviceConfig; 30 import android.provider.DeviceConfig.OnPropertiesChangedListener; 31 import android.provider.DeviceConfig.Properties; 32 import android.provider.Settings; 33 import android.text.TextUtils; 34 import android.util.ArraySet; 35 import android.util.KeyValueListParser; 36 import android.util.Slog; 37 38 import java.io.PrintWriter; 39 import java.util.Arrays; 40 import java.util.List; 41 import java.util.stream.Collectors; 42 43 /** 44 * Settings constants that can modify the activity manager's behavior. 45 */ 46 final class ActivityManagerConstants extends ContentObserver { 47 private static final String TAG = "ActivityManagerConstants"; 48 49 // Key names stored in the settings value. 50 private static final String KEY_BACKGROUND_SETTLE_TIME = "background_settle_time"; 51 private static final String KEY_FGSERVICE_MIN_SHOWN_TIME 52 = "fgservice_min_shown_time"; 53 private static final String KEY_FGSERVICE_MIN_REPORT_TIME 54 = "fgservice_min_report_time"; 55 private static final String KEY_FGSERVICE_SCREEN_ON_BEFORE_TIME 56 = "fgservice_screen_on_before_time"; 57 private static final String KEY_FGSERVICE_SCREEN_ON_AFTER_TIME 58 = "fgservice_screen_on_after_time"; 59 private static final String KEY_CONTENT_PROVIDER_RETAIN_TIME = "content_provider_retain_time"; 60 private static final String KEY_GC_TIMEOUT = "gc_timeout"; 61 private static final String KEY_GC_MIN_INTERVAL = "gc_min_interval"; 62 private static final String KEY_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS = 63 "force_bg_check_on_restricted"; 64 private static final String KEY_FULL_PSS_MIN_INTERVAL = "full_pss_min_interval"; 65 private static final String KEY_FULL_PSS_LOWERED_INTERVAL = "full_pss_lowered_interval"; 66 private static final String KEY_POWER_CHECK_INTERVAL = "power_check_interval"; 67 private static final String KEY_POWER_CHECK_MAX_CPU_1 = "power_check_max_cpu_1"; 68 private static final String KEY_POWER_CHECK_MAX_CPU_2 = "power_check_max_cpu_2"; 69 private static final String KEY_POWER_CHECK_MAX_CPU_3 = "power_check_max_cpu_3"; 70 private static final String KEY_POWER_CHECK_MAX_CPU_4 = "power_check_max_cpu_4"; 71 private static final String KEY_SERVICE_USAGE_INTERACTION_TIME 72 = "service_usage_interaction_time"; 73 private static final String KEY_USAGE_STATS_INTERACTION_INTERVAL 74 = "usage_stats_interaction_interval"; 75 private static final String KEY_IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES = 76 "imperceptible_kill_exempt_packages"; 77 private static final String KEY_IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES = 78 "imperceptible_kill_exempt_proc_states"; 79 static final String KEY_SERVICE_RESTART_DURATION = "service_restart_duration"; 80 static final String KEY_SERVICE_RESET_RUN_DURATION = "service_reset_run_duration"; 81 static final String KEY_SERVICE_RESTART_DURATION_FACTOR = "service_restart_duration_factor"; 82 static final String KEY_SERVICE_MIN_RESTART_TIME_BETWEEN = "service_min_restart_time_between"; 83 static final String KEY_MAX_SERVICE_INACTIVITY = "service_max_inactivity"; 84 static final String KEY_BG_START_TIMEOUT = "service_bg_start_timeout"; 85 static final String KEY_SERVICE_BG_ACTIVITY_START_TIMEOUT = "service_bg_activity_start_timeout"; 86 static final String KEY_BOUND_SERVICE_CRASH_RESTART_DURATION = "service_crash_restart_duration"; 87 static final String KEY_BOUND_SERVICE_CRASH_MAX_RETRY = "service_crash_max_retry"; 88 static final String KEY_PROCESS_START_ASYNC = "process_start_async"; 89 static final String KEY_MEMORY_INFO_THROTTLE_TIME = "memory_info_throttle_time"; 90 static final String KEY_TOP_TO_FGS_GRACE_DURATION = "top_to_fgs_grace_duration"; 91 static final String KEY_FGS_START_FOREGROUND_TIMEOUT = "fgs_start_foreground_timeout"; 92 static final String KEY_PENDINGINTENT_WARNING_THRESHOLD = "pendingintent_warning_threshold"; 93 94 private static final int DEFAULT_MAX_CACHED_PROCESSES = 32; 95 private static final long DEFAULT_BACKGROUND_SETTLE_TIME = 60*1000; 96 private static final long DEFAULT_FGSERVICE_MIN_SHOWN_TIME = 2*1000; 97 private static final long DEFAULT_FGSERVICE_MIN_REPORT_TIME = 3*1000; 98 private static final long DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME = 1*1000; 99 private static final long DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME = 5*1000; 100 private static final long DEFAULT_CONTENT_PROVIDER_RETAIN_TIME = 20*1000; 101 private static final long DEFAULT_GC_TIMEOUT = 5*1000; 102 private static final long DEFAULT_GC_MIN_INTERVAL = 60*1000; 103 private static final long DEFAULT_FULL_PSS_MIN_INTERVAL = 20*60*1000; 104 private static final boolean DEFAULT_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS = true; 105 private static final long DEFAULT_FULL_PSS_LOWERED_INTERVAL = 5*60*1000; 106 private static final long DEFAULT_POWER_CHECK_INTERVAL = (DEBUG_POWER_QUICK ? 1 : 5) * 60*1000; 107 private static final int DEFAULT_POWER_CHECK_MAX_CPU_1 = 25; 108 private static final int DEFAULT_POWER_CHECK_MAX_CPU_2 = 25; 109 private static final int DEFAULT_POWER_CHECK_MAX_CPU_3 = 10; 110 private static final int DEFAULT_POWER_CHECK_MAX_CPU_4 = 2; 111 private static final long DEFAULT_SERVICE_USAGE_INTERACTION_TIME = 30*60*1000; 112 private static final long DEFAULT_USAGE_STATS_INTERACTION_INTERVAL = 2*60*60*1000L; 113 private static final long DEFAULT_SERVICE_RESTART_DURATION = 1*1000; 114 private static final long DEFAULT_SERVICE_RESET_RUN_DURATION = 60*1000; 115 private static final int DEFAULT_SERVICE_RESTART_DURATION_FACTOR = 4; 116 private static final long DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN = 10*1000; 117 private static final long DEFAULT_MAX_SERVICE_INACTIVITY = 30*60*1000; 118 private static final long DEFAULT_BG_START_TIMEOUT = 15*1000; 119 private static final long DEFAULT_SERVICE_BG_ACTIVITY_START_TIMEOUT = 10_000; 120 private static final long DEFAULT_BOUND_SERVICE_CRASH_RESTART_DURATION = 30*60_000; 121 private static final int DEFAULT_BOUND_SERVICE_CRASH_MAX_RETRY = 16; 122 private static final boolean DEFAULT_PROCESS_START_ASYNC = true; 123 private static final long DEFAULT_MEMORY_INFO_THROTTLE_TIME = 5*60*1000; 124 private static final long DEFAULT_TOP_TO_FGS_GRACE_DURATION = 15 * 1000; 125 private static final int DEFAULT_FGS_START_FOREGROUND_TIMEOUT_MS = 10 * 1000; 126 private static final int DEFAULT_PENDINGINTENT_WARNING_THRESHOLD = 2000; 127 128 // Flag stored in the DeviceConfig API. 129 /** 130 * Maximum number of cached processes. 131 */ 132 private static final String KEY_MAX_CACHED_PROCESSES = "max_cached_processes"; 133 134 /** 135 * Default value for mFlagBackgroundActivityStartsEnabled if not explicitly set in 136 * Settings.Global. This allows it to be set experimentally unless it has been 137 * enabled/disabled in developer options. Defaults to false. 138 */ 139 private static final String KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED = 140 "default_background_activity_starts_enabled"; 141 142 /** 143 * Default value for mFlagBackgroundFgsStartRestrictionEnabled if not explicitly set in 144 * Settings.Global. 145 */ 146 private static final String KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED = 147 "default_background_fgs_starts_restriction_enabled"; 148 149 // Maximum number of cached processes we will allow. 150 public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES; 151 152 // This is the amount of time we allow an app to settle after it goes into the background, 153 // before we start restricting what it can do. 154 public long BACKGROUND_SETTLE_TIME = DEFAULT_BACKGROUND_SETTLE_TIME; 155 156 // The minimum time we allow a foreground service to run with a notification and the 157 // screen on without otherwise telling the user about it. (If it runs for less than this, 158 // it will still be reported to the user as a running app for at least this amount of time.) 159 public long FGSERVICE_MIN_SHOWN_TIME = DEFAULT_FGSERVICE_MIN_SHOWN_TIME; 160 161 // If a foreground service is shown for less than FGSERVICE_MIN_SHOWN_TIME, we will display 162 // the background app running notification about it for at least this amount of time (if it 163 // is larger than the remaining shown time). 164 public long FGSERVICE_MIN_REPORT_TIME = DEFAULT_FGSERVICE_MIN_REPORT_TIME; 165 166 // The minimum amount of time the foreground service needs to have remain being shown 167 // before the screen goes on for us to consider it not worth showing to the user. That is 168 // if an app has a foreground service that stops itself this amount of time or more before 169 // the user turns on the screen, we will just let it go without the user being told about it. 170 public long FGSERVICE_SCREEN_ON_BEFORE_TIME = DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME; 171 172 // The minimum amount of time a foreground service should remain reported to the user if 173 // it is stopped when the screen turns on. This is the time from when the screen turns 174 // on until we will stop reporting it. 175 public long FGSERVICE_SCREEN_ON_AFTER_TIME = DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME; 176 177 // How long we will retain processes hosting content providers in the "last activity" 178 // state before allowing them to drop down to the regular cached LRU list. This is 179 // to avoid thrashing of provider processes under low memory situations. 180 long CONTENT_PROVIDER_RETAIN_TIME = DEFAULT_CONTENT_PROVIDER_RETAIN_TIME; 181 182 // How long to wait after going idle before forcing apps to GC. 183 long GC_TIMEOUT = DEFAULT_GC_TIMEOUT; 184 185 // The minimum amount of time between successive GC requests for a process. 186 long GC_MIN_INTERVAL = DEFAULT_GC_MIN_INTERVAL; 187 188 /** 189 * Whether or not Background Check should be forced on any apps in the 190 * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket, 191 * regardless of target SDK version. 192 */ 193 boolean FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS = 194 DEFAULT_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS; 195 196 // The minimum amount of time between successive PSS requests for a process. 197 long FULL_PSS_MIN_INTERVAL = DEFAULT_FULL_PSS_MIN_INTERVAL; 198 199 // The minimum amount of time between successive PSS requests for a process 200 // when the request is due to the memory state being lowered. 201 long FULL_PSS_LOWERED_INTERVAL = DEFAULT_FULL_PSS_LOWERED_INTERVAL; 202 203 // The minimum sample duration we will allow before deciding we have 204 // enough data on CPU usage to start killing things. 205 long POWER_CHECK_INTERVAL = DEFAULT_POWER_CHECK_INTERVAL; 206 207 // The maximum CPU (as a percentage) a process is allowed to use over the first 208 // power check interval that it is cached. 209 int POWER_CHECK_MAX_CPU_1 = DEFAULT_POWER_CHECK_MAX_CPU_1; 210 211 // The maximum CPU (as a percentage) a process is allowed to use over the second 212 // power check interval that it is cached. The home app will never check for less 213 // CPU than this (it will not test against the 3 or 4 levels). 214 int POWER_CHECK_MAX_CPU_2 = DEFAULT_POWER_CHECK_MAX_CPU_2; 215 216 // The maximum CPU (as a percentage) a process is allowed to use over the third 217 // power check interval that it is cached. 218 int POWER_CHECK_MAX_CPU_3 = DEFAULT_POWER_CHECK_MAX_CPU_3; 219 220 // The maximum CPU (as a percentage) a process is allowed to use over the fourth 221 // power check interval that it is cached. 222 int POWER_CHECK_MAX_CPU_4 = DEFAULT_POWER_CHECK_MAX_CPU_4; 223 224 // This is the amount of time an app needs to be running a foreground service before 225 // we will consider it to be doing interaction for usage stats. 226 long SERVICE_USAGE_INTERACTION_TIME = DEFAULT_SERVICE_USAGE_INTERACTION_TIME; 227 228 // Maximum amount of time we will allow to elapse before re-reporting usage stats 229 // interaction with foreground processes. 230 long USAGE_STATS_INTERACTION_INTERVAL = DEFAULT_USAGE_STATS_INTERACTION_INTERVAL; 231 232 // How long a service needs to be running until restarting its process 233 // is no longer considered to be a relaunch of the service. 234 public long SERVICE_RESTART_DURATION = DEFAULT_SERVICE_RESTART_DURATION; 235 236 // How long a service needs to be running until it will start back at 237 // SERVICE_RESTART_DURATION after being killed. 238 public long SERVICE_RESET_RUN_DURATION = DEFAULT_SERVICE_RESET_RUN_DURATION; 239 240 // Multiplying factor to increase restart duration time by, for each time 241 // a service is killed before it has run for SERVICE_RESET_RUN_DURATION. 242 public int SERVICE_RESTART_DURATION_FACTOR = DEFAULT_SERVICE_RESTART_DURATION_FACTOR; 243 244 // The minimum amount of time between restarting services that we allow. 245 // That is, when multiple services are restarting, we won't allow each 246 // to restart less than this amount of time from the last one. 247 public long SERVICE_MIN_RESTART_TIME_BETWEEN = DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN; 248 249 // Maximum amount of time for there to be no activity on a service before 250 // we consider it non-essential and allow its process to go on the 251 // LRU background list. 252 public long MAX_SERVICE_INACTIVITY = DEFAULT_MAX_SERVICE_INACTIVITY; 253 254 // How long we wait for a background started service to stop itself before 255 // allowing the next pending start to run. 256 public long BG_START_TIMEOUT = DEFAULT_BG_START_TIMEOUT; 257 258 // For how long after a whitelisted service's start its process can start a background activity 259 public long SERVICE_BG_ACTIVITY_START_TIMEOUT = DEFAULT_SERVICE_BG_ACTIVITY_START_TIMEOUT; 260 261 // Initial backoff delay for retrying bound foreground services 262 public long BOUND_SERVICE_CRASH_RESTART_DURATION = DEFAULT_BOUND_SERVICE_CRASH_RESTART_DURATION; 263 264 // Maximum number of retries for bound foreground services that crash soon after start 265 public long BOUND_SERVICE_MAX_CRASH_RETRY = DEFAULT_BOUND_SERVICE_CRASH_MAX_RETRY; 266 267 // Indicates if the processes need to be started asynchronously. 268 public boolean FLAG_PROCESS_START_ASYNC = DEFAULT_PROCESS_START_ASYNC; 269 270 // The minimum time we allow between requests for the MemoryInfo of a process to 271 // throttle requests from apps. 272 public long MEMORY_INFO_THROTTLE_TIME = DEFAULT_MEMORY_INFO_THROTTLE_TIME; 273 274 // Allow app just moving from TOP to FOREGROUND_SERVICE to stay in a higher adj value for 275 // this long. 276 public long TOP_TO_FGS_GRACE_DURATION = DEFAULT_TOP_TO_FGS_GRACE_DURATION; 277 278 /** 279 * When service started from background, before the timeout it can be promoted to FGS by calling 280 * Service.startForeground(). 281 */ 282 volatile long mFgsStartForegroundTimeoutMs = DEFAULT_FGS_START_FOREGROUND_TIMEOUT_MS; 283 284 // Indicates whether the activity starts logging is enabled. 285 // Controlled by Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED 286 volatile boolean mFlagActivityStartsLoggingEnabled; 287 288 // Indicates whether the background activity starts is enabled. 289 // Controlled by Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED. 290 // If not set explicitly the default is controlled by DeviceConfig. 291 volatile boolean mFlagBackgroundActivityStartsEnabled; 292 293 // Indicates whether foreground service starts logging is enabled. 294 // Controlled by Settings.Global.FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED 295 volatile boolean mFlagForegroundServiceStartsLoggingEnabled; 296 297 // Indicates whether the foreground service background start restriction is enabled. 298 // When the restriction is enabled, foreground service started from background will not have 299 // while-in-use permissions like location, camera and microphone. (The foreground service can be 300 // started, the restriction is on while-in-use permissions.) 301 volatile boolean mFlagBackgroundFgsStartRestrictionEnabled = true; 302 303 private final ActivityManagerService mService; 304 private ContentResolver mResolver; 305 private final KeyValueListParser mParser = new KeyValueListParser(','); 306 307 private int mOverrideMaxCachedProcesses = -1; 308 309 // The maximum number of cached processes we will keep around before killing them. 310 // NOTE: this constant is *only* a control to not let us go too crazy with 311 // keeping around processes on devices with large amounts of RAM. For devices that 312 // are tighter on RAM, the out of memory killer is responsible for killing background 313 // processes as RAM is needed, and we should *never* be relying on this limit to 314 // kill them. Also note that this limit only applies to cached background processes; 315 // we have no limit on the number of service, visible, foreground, or other such 316 // processes and the number of those processes does not count against the cached 317 // process limit. 318 public int CUR_MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES; 319 320 // The maximum number of empty app processes we will let sit around. 321 public int CUR_MAX_EMPTY_PROCESSES = computeEmptyProcessLimit(CUR_MAX_CACHED_PROCESSES); 322 323 // The number of empty apps at which we don't consider it necessary to do 324 // memory trimming. 325 public int CUR_TRIM_EMPTY_PROCESSES = computeEmptyProcessLimit(MAX_CACHED_PROCESSES) / 2; 326 327 // The number of cached at which we don't consider it necessary to do 328 // memory trimming. 329 public int CUR_TRIM_CACHED_PROCESSES = 330 (MAX_CACHED_PROCESSES - computeEmptyProcessLimit(MAX_CACHED_PROCESSES)) / 3; 331 332 /** 333 * Packages that can't be killed even if it's requested to be killed on imperceptible. 334 */ 335 public ArraySet<String> IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES = new ArraySet<String>(); 336 337 /** 338 * Proc State that can't be killed even if it's requested to be killed on imperceptible. 339 */ 340 public ArraySet<Integer> IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES = new ArraySet<Integer>(); 341 342 /** 343 * The threshold for the amount of PendingIntent for each UID, there will be 344 * warning logs if the number goes beyond this threshold. 345 */ 346 public int PENDINGINTENT_WARNING_THRESHOLD = DEFAULT_PENDINGINTENT_WARNING_THRESHOLD; 347 348 /** 349 * Component names of the services which will keep critical code path of the host warm 350 */ 351 public final ArraySet<ComponentName> KEEP_WARMING_SERVICES = new ArraySet<ComponentName>(); 352 353 private List<String> mDefaultImperceptibleKillExemptPackages; 354 private List<Integer> mDefaultImperceptibleKillExemptProcStates; 355 356 @SuppressWarnings("unused") 357 private static final int OOMADJ_UPDATE_POLICY_SLOW = 0; 358 private static final int OOMADJ_UPDATE_POLICY_QUICK = 1; 359 private static final int DEFAULT_OOMADJ_UPDATE_POLICY = OOMADJ_UPDATE_POLICY_QUICK; 360 361 private static final String KEY_OOMADJ_UPDATE_POLICY = "oomadj_update_policy"; 362 363 // Indicate if the oom adjuster should take the quick path to update the oom adj scores, 364 // in which no futher actions will be performed if there are no significant adj/proc state 365 // changes for the specific process; otherwise, use the traditonal slow path which would 366 // keep updating all processes in the LRU list. 367 public boolean OOMADJ_UPDATE_QUICK = DEFAULT_OOMADJ_UPDATE_POLICY == OOMADJ_UPDATE_POLICY_QUICK; 368 369 private static final long MIN_AUTOMATIC_HEAP_DUMP_PSS_THRESHOLD_BYTES = 100 * 1024; // 100 KB 370 371 private final boolean mSystemServerAutomaticHeapDumpEnabled; 372 373 /** Package to report to when the memory usage exceeds the limit. */ 374 private final String mSystemServerAutomaticHeapDumpPackageName; 375 376 /** Byte limit for dump heap monitoring. */ 377 private long mSystemServerAutomaticHeapDumpPssThresholdBytes; 378 379 private static final Uri ACTIVITY_MANAGER_CONSTANTS_URI = Settings.Global.getUriFor( 380 Settings.Global.ACTIVITY_MANAGER_CONSTANTS); 381 382 private static final Uri ACTIVITY_STARTS_LOGGING_ENABLED_URI = Settings.Global.getUriFor( 383 Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED); 384 385 private static final Uri FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED_URI = 386 Settings.Global.getUriFor( 387 Settings.Global.FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED); 388 389 private static final Uri ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI = 390 Settings.Global.getUriFor(Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS); 391 392 /** 393 * The threshold to decide if a given association should be dumped into metrics. 394 */ 395 private static final long DEFAULT_MIN_ASSOC_LOG_DURATION = 5 * 60 * 1000; // 5 mins 396 397 private static final String KEY_MIN_ASSOC_LOG_DURATION = "min_assoc_log_duration"; 398 399 public static long MIN_ASSOC_LOG_DURATION = DEFAULT_MIN_ASSOC_LOG_DURATION; 400 401 private final OnPropertiesChangedListener mOnDeviceConfigChangedListener = 402 new OnPropertiesChangedListener() { 403 @Override 404 public void onPropertiesChanged(Properties properties) { 405 for (String name : properties.getKeyset()) { 406 if (name == null) { 407 return; 408 } 409 switch (name) { 410 case KEY_MAX_CACHED_PROCESSES: 411 updateMaxCachedProcesses(); 412 break; 413 case KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED: 414 updateBackgroundActivityStarts(); 415 break; 416 case KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED: 417 updateBackgroundFgsStartsRestriction(); 418 break; 419 case KEY_OOMADJ_UPDATE_POLICY: 420 updateOomAdjUpdatePolicy(); 421 break; 422 case KEY_IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES: 423 case KEY_IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES: 424 updateImperceptibleKillExemptions(); 425 break; 426 case KEY_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS: 427 updateForceRestrictedBackgroundCheck(); 428 break; 429 case KEY_MIN_ASSOC_LOG_DURATION: 430 updateMinAssocLogDuration(); 431 break; 432 case KEY_FGS_START_FOREGROUND_TIMEOUT: 433 updateFgsStartForegroundTimeout(); 434 break; 435 default: 436 break; 437 } 438 } 439 } 440 }; 441 ActivityManagerConstants(Context context, ActivityManagerService service, Handler handler)442 ActivityManagerConstants(Context context, ActivityManagerService service, Handler handler) { 443 super(handler); 444 mService = service; 445 mSystemServerAutomaticHeapDumpEnabled = Build.IS_DEBUGGABLE 446 && context.getResources().getBoolean( 447 com.android.internal.R.bool.config_debugEnableAutomaticSystemServerHeapDumps); 448 mSystemServerAutomaticHeapDumpPackageName = context.getPackageName(); 449 mSystemServerAutomaticHeapDumpPssThresholdBytes = Math.max( 450 MIN_AUTOMATIC_HEAP_DUMP_PSS_THRESHOLD_BYTES, 451 context.getResources().getInteger( 452 com.android.internal.R.integer.config_debugSystemServerPssThresholdBytes)); 453 mDefaultImperceptibleKillExemptPackages = Arrays.asList( 454 context.getResources().getStringArray( 455 com.android.internal.R.array.config_defaultImperceptibleKillingExemptionPkgs)); 456 mDefaultImperceptibleKillExemptProcStates = Arrays.stream( 457 context.getResources().getIntArray( 458 com.android.internal.R.array.config_defaultImperceptibleKillingExemptionProcStates)) 459 .boxed().collect(Collectors.toList()); 460 IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.addAll(mDefaultImperceptibleKillExemptPackages); 461 IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES.addAll(mDefaultImperceptibleKillExemptProcStates); 462 KEEP_WARMING_SERVICES.addAll(Arrays.stream( 463 context.getResources().getStringArray( 464 com.android.internal.R.array.config_keep_warming_services)) 465 .map(ComponentName::unflattenFromString).collect(Collectors.toSet())); 466 } 467 start(ContentResolver resolver)468 public void start(ContentResolver resolver) { 469 mResolver = resolver; 470 mResolver.registerContentObserver(ACTIVITY_MANAGER_CONSTANTS_URI, false, this); 471 mResolver.registerContentObserver(ACTIVITY_STARTS_LOGGING_ENABLED_URI, false, this); 472 mResolver.registerContentObserver(FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED_URI, 473 false, this); 474 if (mSystemServerAutomaticHeapDumpEnabled) { 475 mResolver.registerContentObserver(ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI, 476 false, this); 477 } 478 updateConstants(); 479 if (mSystemServerAutomaticHeapDumpEnabled) { 480 updateEnableAutomaticSystemServerHeapDumps(); 481 } 482 DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 483 ActivityThread.currentApplication().getMainExecutor(), 484 mOnDeviceConfigChangedListener); 485 loadDeviceConfigConstants(); 486 // The following read from Settings. 487 updateActivityStartsLoggingEnabled(); 488 updateForegroundServiceStartsLoggingEnabled(); 489 } 490 loadDeviceConfigConstants()491 private void loadDeviceConfigConstants() { 492 mOnDeviceConfigChangedListener.onPropertiesChanged( 493 DeviceConfig.getProperties(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER)); 494 } 495 setOverrideMaxCachedProcesses(int value)496 public void setOverrideMaxCachedProcesses(int value) { 497 mOverrideMaxCachedProcesses = value; 498 updateMaxCachedProcesses(); 499 } 500 getOverrideMaxCachedProcesses()501 public int getOverrideMaxCachedProcesses() { 502 return mOverrideMaxCachedProcesses; 503 } 504 computeEmptyProcessLimit(int totalProcessLimit)505 public static int computeEmptyProcessLimit(int totalProcessLimit) { 506 return totalProcessLimit/2; 507 } 508 509 @Override onChange(boolean selfChange, Uri uri)510 public void onChange(boolean selfChange, Uri uri) { 511 if (uri == null) return; 512 if (ACTIVITY_MANAGER_CONSTANTS_URI.equals(uri)) { 513 updateConstants(); 514 } else if (ACTIVITY_STARTS_LOGGING_ENABLED_URI.equals(uri)) { 515 updateActivityStartsLoggingEnabled(); 516 } else if (FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED_URI.equals(uri)) { 517 updateForegroundServiceStartsLoggingEnabled(); 518 } else if (ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI.equals(uri)) { 519 updateEnableAutomaticSystemServerHeapDumps(); 520 } 521 } 522 updateConstants()523 private void updateConstants() { 524 final String setting = Settings.Global.getString(mResolver, 525 Settings.Global.ACTIVITY_MANAGER_CONSTANTS); 526 synchronized (mService) { 527 try { 528 mParser.setString(setting); 529 } catch (IllegalArgumentException e) { 530 // Failed to parse the settings string, log this and move on 531 // with defaults. 532 Slog.e("ActivityManagerConstants", "Bad activity manager config settings", e); 533 } 534 BACKGROUND_SETTLE_TIME = mParser.getLong(KEY_BACKGROUND_SETTLE_TIME, 535 DEFAULT_BACKGROUND_SETTLE_TIME); 536 FGSERVICE_MIN_SHOWN_TIME = mParser.getLong(KEY_FGSERVICE_MIN_SHOWN_TIME, 537 DEFAULT_FGSERVICE_MIN_SHOWN_TIME); 538 FGSERVICE_MIN_REPORT_TIME = mParser.getLong(KEY_FGSERVICE_MIN_REPORT_TIME, 539 DEFAULT_FGSERVICE_MIN_REPORT_TIME); 540 FGSERVICE_SCREEN_ON_BEFORE_TIME = mParser.getLong(KEY_FGSERVICE_SCREEN_ON_BEFORE_TIME, 541 DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME); 542 FGSERVICE_SCREEN_ON_AFTER_TIME = mParser.getLong(KEY_FGSERVICE_SCREEN_ON_AFTER_TIME, 543 DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME); 544 CONTENT_PROVIDER_RETAIN_TIME = mParser.getLong(KEY_CONTENT_PROVIDER_RETAIN_TIME, 545 DEFAULT_CONTENT_PROVIDER_RETAIN_TIME); 546 GC_TIMEOUT = mParser.getLong(KEY_GC_TIMEOUT, 547 DEFAULT_GC_TIMEOUT); 548 GC_MIN_INTERVAL = mParser.getLong(KEY_GC_MIN_INTERVAL, 549 DEFAULT_GC_MIN_INTERVAL); 550 FULL_PSS_MIN_INTERVAL = mParser.getLong(KEY_FULL_PSS_MIN_INTERVAL, 551 DEFAULT_FULL_PSS_MIN_INTERVAL); 552 FULL_PSS_LOWERED_INTERVAL = mParser.getLong(KEY_FULL_PSS_LOWERED_INTERVAL, 553 DEFAULT_FULL_PSS_LOWERED_INTERVAL); 554 POWER_CHECK_INTERVAL = mParser.getLong(KEY_POWER_CHECK_INTERVAL, 555 DEFAULT_POWER_CHECK_INTERVAL); 556 POWER_CHECK_MAX_CPU_1 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_1, 557 DEFAULT_POWER_CHECK_MAX_CPU_1); 558 POWER_CHECK_MAX_CPU_2 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_2, 559 DEFAULT_POWER_CHECK_MAX_CPU_2); 560 POWER_CHECK_MAX_CPU_3 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_3, 561 DEFAULT_POWER_CHECK_MAX_CPU_3); 562 POWER_CHECK_MAX_CPU_4 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_4, 563 DEFAULT_POWER_CHECK_MAX_CPU_4); 564 SERVICE_USAGE_INTERACTION_TIME = mParser.getLong(KEY_SERVICE_USAGE_INTERACTION_TIME, 565 DEFAULT_SERVICE_USAGE_INTERACTION_TIME); 566 USAGE_STATS_INTERACTION_INTERVAL = mParser.getLong(KEY_USAGE_STATS_INTERACTION_INTERVAL, 567 DEFAULT_USAGE_STATS_INTERACTION_INTERVAL); 568 SERVICE_RESTART_DURATION = mParser.getLong(KEY_SERVICE_RESTART_DURATION, 569 DEFAULT_SERVICE_RESTART_DURATION); 570 SERVICE_RESET_RUN_DURATION = mParser.getLong(KEY_SERVICE_RESET_RUN_DURATION, 571 DEFAULT_SERVICE_RESET_RUN_DURATION); 572 SERVICE_RESTART_DURATION_FACTOR = mParser.getInt(KEY_SERVICE_RESTART_DURATION_FACTOR, 573 DEFAULT_SERVICE_RESTART_DURATION_FACTOR); 574 SERVICE_MIN_RESTART_TIME_BETWEEN = mParser.getLong(KEY_SERVICE_MIN_RESTART_TIME_BETWEEN, 575 DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN); 576 MAX_SERVICE_INACTIVITY = mParser.getLong(KEY_MAX_SERVICE_INACTIVITY, 577 DEFAULT_MAX_SERVICE_INACTIVITY); 578 BG_START_TIMEOUT = mParser.getLong(KEY_BG_START_TIMEOUT, 579 DEFAULT_BG_START_TIMEOUT); 580 SERVICE_BG_ACTIVITY_START_TIMEOUT = mParser.getLong( 581 KEY_SERVICE_BG_ACTIVITY_START_TIMEOUT, 582 DEFAULT_SERVICE_BG_ACTIVITY_START_TIMEOUT); 583 BOUND_SERVICE_CRASH_RESTART_DURATION = mParser.getLong( 584 KEY_BOUND_SERVICE_CRASH_RESTART_DURATION, 585 DEFAULT_BOUND_SERVICE_CRASH_RESTART_DURATION); 586 BOUND_SERVICE_MAX_CRASH_RETRY = mParser.getInt(KEY_BOUND_SERVICE_CRASH_MAX_RETRY, 587 DEFAULT_BOUND_SERVICE_CRASH_MAX_RETRY); 588 FLAG_PROCESS_START_ASYNC = mParser.getBoolean(KEY_PROCESS_START_ASYNC, 589 DEFAULT_PROCESS_START_ASYNC); 590 MEMORY_INFO_THROTTLE_TIME = mParser.getLong(KEY_MEMORY_INFO_THROTTLE_TIME, 591 DEFAULT_MEMORY_INFO_THROTTLE_TIME); 592 TOP_TO_FGS_GRACE_DURATION = mParser.getDurationMillis(KEY_TOP_TO_FGS_GRACE_DURATION, 593 DEFAULT_TOP_TO_FGS_GRACE_DURATION); 594 PENDINGINTENT_WARNING_THRESHOLD = mParser.getInt(KEY_PENDINGINTENT_WARNING_THRESHOLD, 595 DEFAULT_PENDINGINTENT_WARNING_THRESHOLD); 596 597 // For new flags that are intended for server-side experiments, please use the new 598 // DeviceConfig package. 599 } 600 } 601 updateActivityStartsLoggingEnabled()602 private void updateActivityStartsLoggingEnabled() { 603 mFlagActivityStartsLoggingEnabled = Settings.Global.getInt(mResolver, 604 Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED, 1) == 1; 605 } 606 updateBackgroundActivityStarts()607 private void updateBackgroundActivityStarts() { 608 mFlagBackgroundActivityStartsEnabled = DeviceConfig.getBoolean( 609 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 610 KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED, 611 /*defaultValue*/ false); 612 } 613 updateForegroundServiceStartsLoggingEnabled()614 private void updateForegroundServiceStartsLoggingEnabled() { 615 mFlagForegroundServiceStartsLoggingEnabled = Settings.Global.getInt(mResolver, 616 Settings.Global.FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED, 1) == 1; 617 } updateBackgroundFgsStartsRestriction()618 private void updateBackgroundFgsStartsRestriction() { 619 mFlagBackgroundFgsStartRestrictionEnabled = DeviceConfig.getBoolean( 620 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 621 KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED, 622 /*defaultValue*/ true); 623 } 624 updateOomAdjUpdatePolicy()625 private void updateOomAdjUpdatePolicy() { 626 OOMADJ_UPDATE_QUICK = DeviceConfig.getInt( 627 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 628 KEY_OOMADJ_UPDATE_POLICY, 629 /* defaultValue */ DEFAULT_OOMADJ_UPDATE_POLICY) 630 == OOMADJ_UPDATE_POLICY_QUICK; 631 } 632 updateForceRestrictedBackgroundCheck()633 private void updateForceRestrictedBackgroundCheck() { 634 FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS = DeviceConfig.getBoolean( 635 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 636 KEY_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS, 637 DEFAULT_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS); 638 } 639 updateImperceptibleKillExemptions()640 private void updateImperceptibleKillExemptions() { 641 IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.clear(); 642 IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.addAll(mDefaultImperceptibleKillExemptPackages); 643 String val = DeviceConfig.getString(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 644 KEY_IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES, null); 645 if (!TextUtils.isEmpty(val)) { 646 IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.addAll(Arrays.asList(val.split(","))); 647 } 648 649 IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES.clear(); 650 IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES.addAll(mDefaultImperceptibleKillExemptProcStates); 651 val = DeviceConfig.getString(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 652 KEY_IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES, null); 653 if (!TextUtils.isEmpty(val)) { 654 Arrays.asList(val.split(",")).stream().forEach((v) -> { 655 try { 656 IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES.add(Integer.parseInt(v)); 657 } catch (NumberFormatException e) { 658 } 659 }); 660 } 661 } 662 updateEnableAutomaticSystemServerHeapDumps()663 private void updateEnableAutomaticSystemServerHeapDumps() { 664 if (!mSystemServerAutomaticHeapDumpEnabled) { 665 Slog.wtf(TAG, 666 "updateEnableAutomaticSystemServerHeapDumps called when leak detection " 667 + "disabled"); 668 return; 669 } 670 // Monitoring is on by default, so if the setting hasn't been set by the user, 671 // monitoring should be on. 672 final boolean enabled = Settings.Global.getInt(mResolver, 673 Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, 1) == 1; 674 675 // Setting the threshold to 0 stops the checking. 676 final long threshold = enabled ? mSystemServerAutomaticHeapDumpPssThresholdBytes : 0; 677 mService.setDumpHeapDebugLimit(null, 0, threshold, 678 mSystemServerAutomaticHeapDumpPackageName); 679 } 680 updateMaxCachedProcesses()681 private void updateMaxCachedProcesses() { 682 String maxCachedProcessesFlag = DeviceConfig.getProperty( 683 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, KEY_MAX_CACHED_PROCESSES); 684 try { 685 CUR_MAX_CACHED_PROCESSES = mOverrideMaxCachedProcesses < 0 686 ? (TextUtils.isEmpty(maxCachedProcessesFlag) 687 ? DEFAULT_MAX_CACHED_PROCESSES : Integer.parseInt(maxCachedProcessesFlag)) 688 : mOverrideMaxCachedProcesses; 689 } catch (NumberFormatException e) { 690 // Bad flag value from Phenotype, revert to default. 691 Slog.e(TAG, 692 "Unable to parse flag for max_cached_processes: " + maxCachedProcessesFlag, e); 693 CUR_MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES; 694 } 695 CUR_MAX_EMPTY_PROCESSES = computeEmptyProcessLimit(CUR_MAX_CACHED_PROCESSES); 696 697 // Note the trim levels do NOT depend on the override process limit, we want 698 // to consider the same level the point where we do trimming regardless of any 699 // additional enforced limit. 700 final int rawMaxEmptyProcesses = computeEmptyProcessLimit(MAX_CACHED_PROCESSES); 701 CUR_TRIM_EMPTY_PROCESSES = rawMaxEmptyProcesses/2; 702 CUR_TRIM_CACHED_PROCESSES = (MAX_CACHED_PROCESSES-rawMaxEmptyProcesses)/3; 703 } 704 705 private void updateMinAssocLogDuration() { 706 MIN_ASSOC_LOG_DURATION = DeviceConfig.getLong( 707 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, KEY_MIN_ASSOC_LOG_DURATION, 708 /* defaultValue */ DEFAULT_MIN_ASSOC_LOG_DURATION); 709 } 710 711 private void updateFgsStartForegroundTimeout() { 712 mFgsStartForegroundTimeoutMs = DeviceConfig.getLong( 713 DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, 714 KEY_FGS_START_FOREGROUND_TIMEOUT, 715 DEFAULT_FGS_START_FOREGROUND_TIMEOUT_MS); 716 } 717 718 void dump(PrintWriter pw) { 719 pw.println("ACTIVITY MANAGER SETTINGS (dumpsys activity settings) " 720 + Settings.Global.ACTIVITY_MANAGER_CONSTANTS + ":"); 721 722 pw.print(" "); pw.print(KEY_MAX_CACHED_PROCESSES); pw.print("="); 723 pw.println(MAX_CACHED_PROCESSES); 724 pw.print(" "); pw.print(KEY_BACKGROUND_SETTLE_TIME); pw.print("="); 725 pw.println(BACKGROUND_SETTLE_TIME); 726 pw.print(" "); pw.print(KEY_FGSERVICE_MIN_SHOWN_TIME); pw.print("="); 727 pw.println(FGSERVICE_MIN_SHOWN_TIME); 728 pw.print(" "); pw.print(KEY_FGSERVICE_MIN_REPORT_TIME); pw.print("="); 729 pw.println(FGSERVICE_MIN_REPORT_TIME); 730 pw.print(" "); pw.print(KEY_FGSERVICE_SCREEN_ON_BEFORE_TIME); pw.print("="); 731 pw.println(FGSERVICE_SCREEN_ON_BEFORE_TIME); 732 pw.print(" "); pw.print(KEY_FGSERVICE_SCREEN_ON_AFTER_TIME); pw.print("="); 733 pw.println(FGSERVICE_SCREEN_ON_AFTER_TIME); 734 pw.print(" "); pw.print(KEY_CONTENT_PROVIDER_RETAIN_TIME); pw.print("="); 735 pw.println(CONTENT_PROVIDER_RETAIN_TIME); 736 pw.print(" "); pw.print(KEY_GC_TIMEOUT); pw.print("="); 737 pw.println(GC_TIMEOUT); 738 pw.print(" "); pw.print(KEY_GC_MIN_INTERVAL); pw.print("="); 739 pw.println(GC_MIN_INTERVAL); 740 pw.print(" "); pw.print(KEY_FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS); pw.print("="); 741 pw.println(FORCE_BACKGROUND_CHECK_ON_RESTRICTED_APPS); 742 pw.print(" "); pw.print(KEY_FULL_PSS_MIN_INTERVAL); pw.print("="); 743 pw.println(FULL_PSS_MIN_INTERVAL); 744 pw.print(" "); pw.print(KEY_FULL_PSS_LOWERED_INTERVAL); pw.print("="); 745 pw.println(FULL_PSS_LOWERED_INTERVAL); 746 pw.print(" "); pw.print(KEY_POWER_CHECK_INTERVAL); pw.print("="); 747 pw.println(POWER_CHECK_INTERVAL); 748 pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_1); pw.print("="); 749 pw.println(POWER_CHECK_MAX_CPU_1); 750 pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_2); pw.print("="); 751 pw.println(POWER_CHECK_MAX_CPU_2); 752 pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_3); pw.print("="); 753 pw.println(POWER_CHECK_MAX_CPU_3); 754 pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_4); pw.print("="); 755 pw.println(POWER_CHECK_MAX_CPU_4); 756 pw.print(" "); pw.print(KEY_SERVICE_USAGE_INTERACTION_TIME); pw.print("="); 757 pw.println(SERVICE_USAGE_INTERACTION_TIME); 758 pw.print(" "); pw.print(KEY_USAGE_STATS_INTERACTION_INTERVAL); pw.print("="); 759 pw.println(USAGE_STATS_INTERACTION_INTERVAL); 760 pw.print(" "); pw.print(KEY_SERVICE_RESTART_DURATION); pw.print("="); 761 pw.println(SERVICE_RESTART_DURATION); 762 pw.print(" "); pw.print(KEY_SERVICE_RESET_RUN_DURATION); pw.print("="); 763 pw.println(SERVICE_RESET_RUN_DURATION); 764 pw.print(" "); pw.print(KEY_SERVICE_RESTART_DURATION_FACTOR); pw.print("="); 765 pw.println(SERVICE_RESTART_DURATION_FACTOR); 766 pw.print(" "); pw.print(KEY_SERVICE_MIN_RESTART_TIME_BETWEEN); pw.print("="); 767 pw.println(SERVICE_MIN_RESTART_TIME_BETWEEN); 768 pw.print(" "); pw.print(KEY_MAX_SERVICE_INACTIVITY); pw.print("="); 769 pw.println(MAX_SERVICE_INACTIVITY); 770 pw.print(" "); pw.print(KEY_BG_START_TIMEOUT); pw.print("="); 771 pw.println(BG_START_TIMEOUT); 772 pw.print(" "); pw.print(KEY_SERVICE_BG_ACTIVITY_START_TIMEOUT); pw.print("="); 773 pw.println(SERVICE_BG_ACTIVITY_START_TIMEOUT); 774 pw.print(" "); pw.print(KEY_BOUND_SERVICE_CRASH_RESTART_DURATION); pw.print("="); 775 pw.println(BOUND_SERVICE_CRASH_RESTART_DURATION); 776 pw.print(" "); pw.print(KEY_BOUND_SERVICE_CRASH_MAX_RETRY); pw.print("="); 777 pw.println(BOUND_SERVICE_MAX_CRASH_RETRY); 778 pw.print(" "); pw.print(KEY_PROCESS_START_ASYNC); pw.print("="); 779 pw.println(FLAG_PROCESS_START_ASYNC); 780 pw.print(" "); pw.print(KEY_MEMORY_INFO_THROTTLE_TIME); pw.print("="); 781 pw.println(MEMORY_INFO_THROTTLE_TIME); 782 pw.print(" "); pw.print(KEY_TOP_TO_FGS_GRACE_DURATION); pw.print("="); 783 pw.println(TOP_TO_FGS_GRACE_DURATION); 784 pw.print(" "); pw.print(KEY_IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES); pw.print("="); 785 pw.println(Arrays.toString(IMPERCEPTIBLE_KILL_EXEMPT_PROC_STATES.toArray())); 786 pw.print(" "); pw.print(KEY_IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES); pw.print("="); 787 pw.println(Arrays.toString(IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.toArray())); 788 pw.print(" "); pw.print(KEY_MIN_ASSOC_LOG_DURATION); pw.print("="); 789 pw.println(MIN_ASSOC_LOG_DURATION); 790 pw.print(" "); pw.print(KEY_FGS_START_FOREGROUND_TIMEOUT); pw.print("="); 791 pw.println(mFgsStartForegroundTimeoutMs); 792 793 pw.println(); 794 if (mOverrideMaxCachedProcesses >= 0) { 795 pw.print(" mOverrideMaxCachedProcesses="); pw.println(mOverrideMaxCachedProcesses); 796 } 797 pw.print(" CUR_MAX_CACHED_PROCESSES="); pw.println(CUR_MAX_CACHED_PROCESSES); 798 pw.print(" CUR_MAX_EMPTY_PROCESSES="); pw.println(CUR_MAX_EMPTY_PROCESSES); 799 pw.print(" CUR_TRIM_EMPTY_PROCESSES="); pw.println(CUR_TRIM_EMPTY_PROCESSES); 800 pw.print(" CUR_TRIM_CACHED_PROCESSES="); pw.println(CUR_TRIM_CACHED_PROCESSES); 801 pw.print(" OOMADJ_UPDATE_QUICK="); pw.println(OOMADJ_UPDATE_QUICK); 802 } 803 } 804