Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [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 | |
| 17 | package com.android.server.am; |
| 18 | |
| 19 | import android.content.ContentResolver; |
| 20 | import android.database.ContentObserver; |
| 21 | import android.net.Uri; |
| 22 | import android.os.Handler; |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 23 | import android.provider.Settings; |
| 24 | import android.util.KeyValueListParser; |
| 25 | import android.util.Slog; |
| 26 | |
| 27 | import java.io.PrintWriter; |
| 28 | |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 29 | import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_POWER_QUICK; |
| 30 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 31 | /** |
| 32 | * Settings constants that can modify the activity manager's behavior. |
| 33 | */ |
| 34 | final class ActivityManagerConstants extends ContentObserver { |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 35 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 36 | // Key names stored in the settings value. |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 37 | private static final String KEY_MAX_CACHED_PROCESSES = "max_cached_processes"; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 38 | private static final String KEY_BACKGROUND_SETTLE_TIME = "background_settle_time"; |
Dianne Hackborn | cb01563 | 2017-06-14 17:30:15 -0700 | [diff] [blame] | 39 | private static final String KEY_FGSERVICE_MIN_SHOWN_TIME |
| 40 | = "fgservice_min_shown_time"; |
| 41 | private static final String KEY_FGSERVICE_MIN_REPORT_TIME |
| 42 | = "fgservice_min_report_time"; |
| 43 | private static final String KEY_FGSERVICE_SCREEN_ON_BEFORE_TIME |
| 44 | = "fgservice_screen_on_before_time"; |
| 45 | private static final String KEY_FGSERVICE_SCREEN_ON_AFTER_TIME |
| 46 | = "fgservice_screen_on_after_time"; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 47 | private static final String KEY_CONTENT_PROVIDER_RETAIN_TIME = "content_provider_retain_time"; |
| 48 | private static final String KEY_GC_TIMEOUT = "gc_timeout"; |
| 49 | private static final String KEY_GC_MIN_INTERVAL = "gc_min_interval"; |
| 50 | private static final String KEY_FULL_PSS_MIN_INTERVAL = "full_pss_min_interval"; |
| 51 | private static final String KEY_FULL_PSS_LOWERED_INTERVAL = "full_pss_lowered_interval"; |
Dianne Hackborn | ffca58b | 2017-05-24 16:15:45 -0700 | [diff] [blame] | 52 | private static final String KEY_POWER_CHECK_INTERVAL = "power_check_interval"; |
| 53 | private static final String KEY_POWER_CHECK_MAX_CPU_1 = "power_check_max_cpu_1"; |
| 54 | private static final String KEY_POWER_CHECK_MAX_CPU_2 = "power_check_max_cpu_2"; |
| 55 | private static final String KEY_POWER_CHECK_MAX_CPU_3 = "power_check_max_cpu_3"; |
| 56 | private static final String KEY_POWER_CHECK_MAX_CPU_4 = "power_check_max_cpu_4"; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 57 | private static final String KEY_SERVICE_USAGE_INTERACTION_TIME |
| 58 | = "service_usage_interaction_time"; |
| 59 | private static final String KEY_USAGE_STATS_INTERACTION_INTERVAL |
| 60 | = "usage_stats_interaction_interval"; |
| 61 | static final String KEY_SERVICE_RESTART_DURATION = "service_restart_duration"; |
| 62 | static final String KEY_SERVICE_RESET_RUN_DURATION = "service_reset_run_duration"; |
| 63 | static final String KEY_SERVICE_RESTART_DURATION_FACTOR = "service_restart_duration_factor"; |
| 64 | static final String KEY_SERVICE_MIN_RESTART_TIME_BETWEEN = "service_min_restart_time_between"; |
| 65 | static final String KEY_MAX_SERVICE_INACTIVITY = "service_max_inactivity"; |
| 66 | static final String KEY_BG_START_TIMEOUT = "service_bg_start_timeout"; |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 67 | static final String KEY_BOUND_SERVICE_CRASH_RESTART_DURATION = "service_crash_restart_duration"; |
| 68 | static final String KEY_BOUND_SERVICE_CRASH_MAX_RETRY = "service_crash_max_retry"; |
Sudheer Shanka | f669010 | 2017-10-16 10:20:32 -0700 | [diff] [blame] | 69 | static final String KEY_PROCESS_START_ASYNC = "process_start_async"; |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 70 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 71 | private static final int DEFAULT_MAX_CACHED_PROCESSES = 32; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 72 | private static final long DEFAULT_BACKGROUND_SETTLE_TIME = 60*1000; |
Dianne Hackborn | cb01563 | 2017-06-14 17:30:15 -0700 | [diff] [blame] | 73 | private static final long DEFAULT_FGSERVICE_MIN_SHOWN_TIME = 2*1000; |
| 74 | private static final long DEFAULT_FGSERVICE_MIN_REPORT_TIME = 3*1000; |
| 75 | private static final long DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME = 1*1000; |
| 76 | private static final long DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME = 5*1000; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 77 | private static final long DEFAULT_CONTENT_PROVIDER_RETAIN_TIME = 20*1000; |
| 78 | private static final long DEFAULT_GC_TIMEOUT = 5*1000; |
| 79 | private static final long DEFAULT_GC_MIN_INTERVAL = 60*1000; |
Dianne Hackborn | 052e314 | 2017-12-19 16:08:30 -0800 | [diff] [blame] | 80 | private static final long DEFAULT_FULL_PSS_MIN_INTERVAL = 20*60*1000; |
| 81 | private static final long DEFAULT_FULL_PSS_LOWERED_INTERVAL = 5*60*1000; |
Dianne Hackborn | ffca58b | 2017-05-24 16:15:45 -0700 | [diff] [blame] | 82 | private static final long DEFAULT_POWER_CHECK_INTERVAL = (DEBUG_POWER_QUICK ? 1 : 5) * 60*1000; |
| 83 | private static final int DEFAULT_POWER_CHECK_MAX_CPU_1 = 25; |
| 84 | private static final int DEFAULT_POWER_CHECK_MAX_CPU_2 = 25; |
| 85 | private static final int DEFAULT_POWER_CHECK_MAX_CPU_3 = 10; |
| 86 | private static final int DEFAULT_POWER_CHECK_MAX_CPU_4 = 2; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 87 | private static final long DEFAULT_SERVICE_USAGE_INTERACTION_TIME = 30*60*1000; |
Amith Yamasani | 119be9a | 2018-02-18 22:23:00 -0800 | [diff] [blame] | 88 | private static final long DEFAULT_USAGE_STATS_INTERACTION_INTERVAL = 2*60*60*1000L; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 89 | private static final long DEFAULT_SERVICE_RESTART_DURATION = 1*1000; |
| 90 | private static final long DEFAULT_SERVICE_RESET_RUN_DURATION = 60*1000; |
| 91 | private static final int DEFAULT_SERVICE_RESTART_DURATION_FACTOR = 4; |
| 92 | private static final long DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN = 10*1000; |
| 93 | private static final long DEFAULT_MAX_SERVICE_INACTIVITY = 30*60*1000; |
| 94 | private static final long DEFAULT_BG_START_TIMEOUT = 15*1000; |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 95 | private static final long DEFAULT_BOUND_SERVICE_CRASH_RESTART_DURATION = 30*60_000; |
| 96 | private static final int DEFAULT_BOUND_SERVICE_CRASH_MAX_RETRY = 16; |
Sudheer Shanka | f669010 | 2017-10-16 10:20:32 -0700 | [diff] [blame] | 97 | private static final boolean DEFAULT_PROCESS_START_ASYNC = true; |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 98 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 99 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 100 | // Maximum number of cached processes we will allow. |
| 101 | public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES; |
| 102 | |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 103 | // This is the amount of time we allow an app to settle after it goes into the background, |
| 104 | // before we start restricting what it can do. |
| 105 | public long BACKGROUND_SETTLE_TIME = DEFAULT_BACKGROUND_SETTLE_TIME; |
| 106 | |
Dianne Hackborn | cb01563 | 2017-06-14 17:30:15 -0700 | [diff] [blame] | 107 | // The minimum time we allow a foreground service to run with a notification and the |
| 108 | // screen on without otherwise telling the user about it. (If it runs for less than this, |
| 109 | // it will still be reported to the user as a running app for at least this amount of time.) |
| 110 | public long FGSERVICE_MIN_SHOWN_TIME = DEFAULT_FGSERVICE_MIN_SHOWN_TIME; |
| 111 | |
| 112 | // If a foreground service is shown for less than FGSERVICE_MIN_SHOWN_TIME, we will display |
| 113 | // the background app running notification about it for at least this amount of time (if it |
| 114 | // is larger than the remaining shown time). |
| 115 | public long FGSERVICE_MIN_REPORT_TIME = DEFAULT_FGSERVICE_MIN_REPORT_TIME; |
| 116 | |
| 117 | // The minimum amount of time the foreground service needs to have remain being shown |
| 118 | // before the screen goes on for us to consider it not worth showing to the user. That is |
| 119 | // if an app has a foreground service that stops itself this amount of time or more before |
| 120 | // the user turns on the screen, we will just let it go without the user being told about it. |
| 121 | public long FGSERVICE_SCREEN_ON_BEFORE_TIME = DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME; |
| 122 | |
| 123 | // The minimum amount of time a foreground service should remain reported to the user if |
| 124 | // it is stopped when the screen turns on. This is the time from when the screen turns |
| 125 | // on until we will stop reporting it. |
| 126 | public long FGSERVICE_SCREEN_ON_AFTER_TIME = DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 127 | |
| 128 | // How long we will retain processes hosting content providers in the "last activity" |
| 129 | // state before allowing them to drop down to the regular cached LRU list. This is |
| 130 | // to avoid thrashing of provider processes under low memory situations. |
| 131 | long CONTENT_PROVIDER_RETAIN_TIME = DEFAULT_CONTENT_PROVIDER_RETAIN_TIME; |
| 132 | |
| 133 | // How long to wait after going idle before forcing apps to GC. |
| 134 | long GC_TIMEOUT = DEFAULT_GC_TIMEOUT; |
| 135 | |
| 136 | // The minimum amount of time between successive GC requests for a process. |
| 137 | long GC_MIN_INTERVAL = DEFAULT_GC_MIN_INTERVAL; |
| 138 | |
| 139 | // The minimum amount of time between successive PSS requests for a process. |
| 140 | long FULL_PSS_MIN_INTERVAL = DEFAULT_FULL_PSS_MIN_INTERVAL; |
| 141 | |
| 142 | // The minimum amount of time between successive PSS requests for a process |
| 143 | // when the request is due to the memory state being lowered. |
| 144 | long FULL_PSS_LOWERED_INTERVAL = DEFAULT_FULL_PSS_LOWERED_INTERVAL; |
| 145 | |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 146 | // The minimum sample duration we will allow before deciding we have |
| 147 | // enough data on CPU usage to start killing things. |
Dianne Hackborn | ffca58b | 2017-05-24 16:15:45 -0700 | [diff] [blame] | 148 | long POWER_CHECK_INTERVAL = DEFAULT_POWER_CHECK_INTERVAL; |
| 149 | |
| 150 | // The maximum CPU (as a percentage) a process is allowed to use over the first |
| 151 | // power check interval that it is cached. |
| 152 | int POWER_CHECK_MAX_CPU_1 = DEFAULT_POWER_CHECK_MAX_CPU_1; |
| 153 | |
| 154 | // The maximum CPU (as a percentage) a process is allowed to use over the second |
| 155 | // power check interval that it is cached. The home app will never check for less |
| 156 | // CPU than this (it will not test against the 3 or 4 levels). |
| 157 | int POWER_CHECK_MAX_CPU_2 = DEFAULT_POWER_CHECK_MAX_CPU_2; |
| 158 | |
| 159 | // The maximum CPU (as a percentage) a process is allowed to use over the third |
| 160 | // power check interval that it is cached. |
| 161 | int POWER_CHECK_MAX_CPU_3 = DEFAULT_POWER_CHECK_MAX_CPU_3; |
| 162 | |
| 163 | // The maximum CPU (as a percentage) a process is allowed to use over the fourth |
| 164 | // power check interval that it is cached. |
| 165 | int POWER_CHECK_MAX_CPU_4 = DEFAULT_POWER_CHECK_MAX_CPU_4; |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 166 | |
| 167 | // This is the amount of time an app needs to be running a foreground service before |
| 168 | // we will consider it to be doing interaction for usage stats. |
| 169 | long SERVICE_USAGE_INTERACTION_TIME = DEFAULT_SERVICE_USAGE_INTERACTION_TIME; |
| 170 | |
| 171 | // Maximum amount of time we will allow to elapse before re-reporting usage stats |
| 172 | // interaction with foreground processes. |
| 173 | long USAGE_STATS_INTERACTION_INTERVAL = DEFAULT_USAGE_STATS_INTERACTION_INTERVAL; |
| 174 | |
| 175 | // How long a service needs to be running until restarting its process |
| 176 | // is no longer considered to be a relaunch of the service. |
| 177 | public long SERVICE_RESTART_DURATION = DEFAULT_SERVICE_RESTART_DURATION; |
| 178 | |
| 179 | // How long a service needs to be running until it will start back at |
| 180 | // SERVICE_RESTART_DURATION after being killed. |
| 181 | public long SERVICE_RESET_RUN_DURATION = DEFAULT_SERVICE_RESET_RUN_DURATION; |
| 182 | |
| 183 | // Multiplying factor to increase restart duration time by, for each time |
| 184 | // a service is killed before it has run for SERVICE_RESET_RUN_DURATION. |
| 185 | public int SERVICE_RESTART_DURATION_FACTOR = DEFAULT_SERVICE_RESTART_DURATION_FACTOR; |
| 186 | |
| 187 | // The minimum amount of time between restarting services that we allow. |
| 188 | // That is, when multiple services are restarting, we won't allow each |
| 189 | // to restart less than this amount of time from the last one. |
| 190 | public long SERVICE_MIN_RESTART_TIME_BETWEEN = DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN; |
| 191 | |
| 192 | // Maximum amount of time for there to be no activity on a service before |
| 193 | // we consider it non-essential and allow its process to go on the |
| 194 | // LRU background list. |
| 195 | public long MAX_SERVICE_INACTIVITY = DEFAULT_MAX_SERVICE_INACTIVITY; |
| 196 | |
| 197 | // How long we wait for a background started service to stop itself before |
| 198 | // allowing the next pending start to run. |
| 199 | public long BG_START_TIMEOUT = DEFAULT_BG_START_TIMEOUT; |
| 200 | |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 201 | // Initial backoff delay for retrying bound foreground services |
| 202 | public long BOUND_SERVICE_CRASH_RESTART_DURATION = DEFAULT_BOUND_SERVICE_CRASH_RESTART_DURATION; |
| 203 | |
| 204 | // Maximum number of retries for bound foreground services that crash soon after start |
| 205 | public long BOUND_SERVICE_MAX_CRASH_RETRY = DEFAULT_BOUND_SERVICE_CRASH_MAX_RETRY; |
| 206 | |
Sudheer Shanka | f669010 | 2017-10-16 10:20:32 -0700 | [diff] [blame] | 207 | // Indicates if the processes need to be started asynchronously. |
| 208 | public boolean FLAG_PROCESS_START_ASYNC = DEFAULT_PROCESS_START_ASYNC; |
| 209 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 210 | private final ActivityManagerService mService; |
| 211 | private ContentResolver mResolver; |
| 212 | private final KeyValueListParser mParser = new KeyValueListParser(','); |
| 213 | |
| 214 | private int mOverrideMaxCachedProcesses = -1; |
| 215 | |
| 216 | // The maximum number of cached processes we will keep around before killing them. |
| 217 | // NOTE: this constant is *only* a control to not let us go too crazy with |
| 218 | // keeping around processes on devices with large amounts of RAM. For devices that |
| 219 | // are tighter on RAM, the out of memory killer is responsible for killing background |
| 220 | // processes as RAM is needed, and we should *never* be relying on this limit to |
| 221 | // kill them. Also note that this limit only applies to cached background processes; |
| 222 | // we have no limit on the number of service, visible, foreground, or other such |
| 223 | // processes and the number of those processes does not count against the cached |
| 224 | // process limit. |
| 225 | public int CUR_MAX_CACHED_PROCESSES; |
| 226 | |
| 227 | // The maximum number of empty app processes we will let sit around. |
| 228 | public int CUR_MAX_EMPTY_PROCESSES; |
| 229 | |
| 230 | // The number of empty apps at which we don't consider it necessary to do |
| 231 | // memory trimming. |
| 232 | public int CUR_TRIM_EMPTY_PROCESSES; |
| 233 | |
| 234 | // The number of cached at which we don't consider it necessary to do |
| 235 | // memory trimming. |
| 236 | public int CUR_TRIM_CACHED_PROCESSES; |
| 237 | |
| 238 | public ActivityManagerConstants(ActivityManagerService service, Handler handler) { |
| 239 | super(handler); |
| 240 | mService = service; |
| 241 | updateMaxCachedProcesses(); |
| 242 | } |
| 243 | |
| 244 | public void start(ContentResolver resolver) { |
| 245 | mResolver = resolver; |
| 246 | mResolver.registerContentObserver(Settings.Global.getUriFor( |
| 247 | Settings.Global.ACTIVITY_MANAGER_CONSTANTS), false, this); |
| 248 | updateConstants(); |
| 249 | } |
| 250 | |
| 251 | public void setOverrideMaxCachedProcesses(int value) { |
| 252 | mOverrideMaxCachedProcesses = value; |
| 253 | updateMaxCachedProcesses(); |
| 254 | } |
| 255 | |
| 256 | public int getOverrideMaxCachedProcesses() { |
| 257 | return mOverrideMaxCachedProcesses; |
| 258 | } |
| 259 | |
| 260 | public static int computeEmptyProcessLimit(int totalProcessLimit) { |
| 261 | return totalProcessLimit/2; |
| 262 | } |
| 263 | |
| 264 | @Override |
| 265 | public void onChange(boolean selfChange, Uri uri) { |
| 266 | updateConstants(); |
| 267 | } |
| 268 | |
| 269 | private void updateConstants() { |
Makoto Onuki | 73360ab | 2017-03-17 11:50:13 -0700 | [diff] [blame] | 270 | final String setting = Settings.Global.getString(mResolver, |
| 271 | Settings.Global.ACTIVITY_MANAGER_CONSTANTS); |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 272 | synchronized (mService) { |
| 273 | try { |
Makoto Onuki | 73360ab | 2017-03-17 11:50:13 -0700 | [diff] [blame] | 274 | mParser.setString(setting); |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 275 | } catch (IllegalArgumentException e) { |
| 276 | // Failed to parse the settings string, log this and move on |
| 277 | // with defaults. |
| 278 | Slog.e("ActivityManagerConstants", "Bad activity manager config settings", e); |
| 279 | } |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 280 | MAX_CACHED_PROCESSES = mParser.getInt(KEY_MAX_CACHED_PROCESSES, |
| 281 | DEFAULT_MAX_CACHED_PROCESSES); |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 282 | BACKGROUND_SETTLE_TIME = mParser.getLong(KEY_BACKGROUND_SETTLE_TIME, |
| 283 | DEFAULT_BACKGROUND_SETTLE_TIME); |
Dianne Hackborn | cb01563 | 2017-06-14 17:30:15 -0700 | [diff] [blame] | 284 | FGSERVICE_MIN_SHOWN_TIME = mParser.getLong(KEY_FGSERVICE_MIN_SHOWN_TIME, |
| 285 | DEFAULT_FGSERVICE_MIN_SHOWN_TIME); |
| 286 | FGSERVICE_MIN_REPORT_TIME = mParser.getLong(KEY_FGSERVICE_MIN_REPORT_TIME, |
| 287 | DEFAULT_FGSERVICE_MIN_REPORT_TIME); |
| 288 | FGSERVICE_SCREEN_ON_BEFORE_TIME = mParser.getLong(KEY_FGSERVICE_SCREEN_ON_BEFORE_TIME, |
| 289 | DEFAULT_FGSERVICE_SCREEN_ON_BEFORE_TIME); |
| 290 | FGSERVICE_SCREEN_ON_AFTER_TIME = mParser.getLong(KEY_FGSERVICE_SCREEN_ON_AFTER_TIME, |
| 291 | DEFAULT_FGSERVICE_SCREEN_ON_AFTER_TIME); |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 292 | CONTENT_PROVIDER_RETAIN_TIME = mParser.getLong(KEY_CONTENT_PROVIDER_RETAIN_TIME, |
| 293 | DEFAULT_CONTENT_PROVIDER_RETAIN_TIME); |
| 294 | GC_TIMEOUT = mParser.getLong(KEY_GC_TIMEOUT, |
| 295 | DEFAULT_GC_TIMEOUT); |
| 296 | GC_MIN_INTERVAL = mParser.getLong(KEY_GC_MIN_INTERVAL, |
| 297 | DEFAULT_GC_MIN_INTERVAL); |
| 298 | FULL_PSS_MIN_INTERVAL = mParser.getLong(KEY_FULL_PSS_MIN_INTERVAL, |
| 299 | DEFAULT_FULL_PSS_MIN_INTERVAL); |
| 300 | FULL_PSS_LOWERED_INTERVAL = mParser.getLong(KEY_FULL_PSS_LOWERED_INTERVAL, |
| 301 | DEFAULT_FULL_PSS_LOWERED_INTERVAL); |
Dianne Hackborn | ffca58b | 2017-05-24 16:15:45 -0700 | [diff] [blame] | 302 | POWER_CHECK_INTERVAL = mParser.getLong(KEY_POWER_CHECK_INTERVAL, |
| 303 | DEFAULT_POWER_CHECK_INTERVAL); |
| 304 | POWER_CHECK_MAX_CPU_1 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_1, |
| 305 | DEFAULT_POWER_CHECK_MAX_CPU_1); |
| 306 | POWER_CHECK_MAX_CPU_2 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_2, |
| 307 | DEFAULT_POWER_CHECK_MAX_CPU_2); |
| 308 | POWER_CHECK_MAX_CPU_3 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_3, |
| 309 | DEFAULT_POWER_CHECK_MAX_CPU_3); |
| 310 | POWER_CHECK_MAX_CPU_4 = mParser.getInt(KEY_POWER_CHECK_MAX_CPU_4, |
| 311 | DEFAULT_POWER_CHECK_MAX_CPU_4); |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 312 | SERVICE_USAGE_INTERACTION_TIME = mParser.getLong(KEY_SERVICE_USAGE_INTERACTION_TIME, |
| 313 | DEFAULT_SERVICE_USAGE_INTERACTION_TIME); |
| 314 | USAGE_STATS_INTERACTION_INTERVAL = mParser.getLong(KEY_USAGE_STATS_INTERACTION_INTERVAL, |
| 315 | DEFAULT_USAGE_STATS_INTERACTION_INTERVAL); |
| 316 | SERVICE_RESTART_DURATION = mParser.getLong(KEY_SERVICE_RESTART_DURATION, |
| 317 | DEFAULT_SERVICE_RESTART_DURATION); |
| 318 | SERVICE_RESET_RUN_DURATION = mParser.getLong(KEY_SERVICE_RESET_RUN_DURATION, |
| 319 | DEFAULT_SERVICE_RESET_RUN_DURATION); |
| 320 | SERVICE_RESTART_DURATION_FACTOR = mParser.getInt(KEY_SERVICE_RESTART_DURATION_FACTOR, |
| 321 | DEFAULT_SERVICE_RESTART_DURATION_FACTOR); |
| 322 | SERVICE_MIN_RESTART_TIME_BETWEEN = mParser.getLong(KEY_SERVICE_MIN_RESTART_TIME_BETWEEN, |
| 323 | DEFAULT_SERVICE_MIN_RESTART_TIME_BETWEEN); |
| 324 | MAX_SERVICE_INACTIVITY = mParser.getLong(KEY_MAX_SERVICE_INACTIVITY, |
| 325 | DEFAULT_MAX_SERVICE_INACTIVITY); |
| 326 | BG_START_TIMEOUT = mParser.getLong(KEY_BG_START_TIMEOUT, |
| 327 | DEFAULT_BG_START_TIMEOUT); |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 328 | BOUND_SERVICE_CRASH_RESTART_DURATION = mParser.getLong( |
| 329 | KEY_BOUND_SERVICE_CRASH_RESTART_DURATION, |
| 330 | DEFAULT_BOUND_SERVICE_CRASH_RESTART_DURATION); |
| 331 | BOUND_SERVICE_MAX_CRASH_RETRY = mParser.getInt(KEY_BOUND_SERVICE_CRASH_MAX_RETRY, |
| 332 | DEFAULT_BOUND_SERVICE_CRASH_MAX_RETRY); |
Sudheer Shanka | f669010 | 2017-10-16 10:20:32 -0700 | [diff] [blame] | 333 | FLAG_PROCESS_START_ASYNC = mParser.getBoolean(KEY_PROCESS_START_ASYNC, |
| 334 | DEFAULT_PROCESS_START_ASYNC); |
Amith Yamasani | b0c8a88 | 2017-08-28 09:36:42 -0700 | [diff] [blame] | 335 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 336 | updateMaxCachedProcesses(); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | private void updateMaxCachedProcesses() { |
| 341 | CUR_MAX_CACHED_PROCESSES = mOverrideMaxCachedProcesses < 0 |
| 342 | ? MAX_CACHED_PROCESSES : mOverrideMaxCachedProcesses; |
| 343 | CUR_MAX_EMPTY_PROCESSES = computeEmptyProcessLimit(CUR_MAX_CACHED_PROCESSES); |
| 344 | |
| 345 | // Note the trim levels do NOT depend on the override process limit, we want |
| 346 | // to consider the same level the point where we do trimming regardless of any |
| 347 | // additional enforced limit. |
| 348 | final int rawMaxEmptyProcesses = computeEmptyProcessLimit(MAX_CACHED_PROCESSES); |
| 349 | CUR_TRIM_EMPTY_PROCESSES = rawMaxEmptyProcesses/2; |
| 350 | CUR_TRIM_CACHED_PROCESSES = (MAX_CACHED_PROCESSES-rawMaxEmptyProcesses)/3; |
| 351 | } |
| 352 | |
| 353 | void dump(PrintWriter pw) { |
| 354 | pw.println("ACTIVITY MANAGER SETTINGS (dumpsys activity settings) " |
| 355 | + Settings.Global.ACTIVITY_MANAGER_CONSTANTS + ":"); |
| 356 | |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 357 | pw.print(" "); pw.print(KEY_MAX_CACHED_PROCESSES); pw.print("="); |
| 358 | pw.println(MAX_CACHED_PROCESSES); |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 359 | pw.print(" "); pw.print(KEY_BACKGROUND_SETTLE_TIME); pw.print("="); |
| 360 | pw.println(BACKGROUND_SETTLE_TIME); |
Dianne Hackborn | cb01563 | 2017-06-14 17:30:15 -0700 | [diff] [blame] | 361 | pw.print(" "); pw.print(KEY_FGSERVICE_MIN_SHOWN_TIME); pw.print("="); |
| 362 | pw.println(FGSERVICE_MIN_SHOWN_TIME); |
| 363 | pw.print(" "); pw.print(KEY_FGSERVICE_MIN_REPORT_TIME); pw.print("="); |
| 364 | pw.println(FGSERVICE_MIN_REPORT_TIME); |
| 365 | pw.print(" "); pw.print(KEY_FGSERVICE_SCREEN_ON_BEFORE_TIME); pw.print("="); |
| 366 | pw.println(FGSERVICE_SCREEN_ON_BEFORE_TIME); |
| 367 | pw.print(" "); pw.print(KEY_FGSERVICE_SCREEN_ON_AFTER_TIME); pw.print("="); |
| 368 | pw.println(FGSERVICE_SCREEN_ON_AFTER_TIME); |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 369 | pw.print(" "); pw.print(KEY_CONTENT_PROVIDER_RETAIN_TIME); pw.print("="); |
| 370 | pw.println(CONTENT_PROVIDER_RETAIN_TIME); |
| 371 | pw.print(" "); pw.print(KEY_GC_TIMEOUT); pw.print("="); |
| 372 | pw.println(GC_TIMEOUT); |
| 373 | pw.print(" "); pw.print(KEY_GC_MIN_INTERVAL); pw.print("="); |
| 374 | pw.println(GC_MIN_INTERVAL); |
| 375 | pw.print(" "); pw.print(KEY_FULL_PSS_MIN_INTERVAL); pw.print("="); |
| 376 | pw.println(FULL_PSS_MIN_INTERVAL); |
| 377 | pw.print(" "); pw.print(KEY_FULL_PSS_LOWERED_INTERVAL); pw.print("="); |
| 378 | pw.println(FULL_PSS_LOWERED_INTERVAL); |
Dianne Hackborn | ffca58b | 2017-05-24 16:15:45 -0700 | [diff] [blame] | 379 | pw.print(" "); pw.print(KEY_POWER_CHECK_INTERVAL); pw.print("="); |
| 380 | pw.println(POWER_CHECK_INTERVAL); |
| 381 | pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_1); pw.print("="); |
| 382 | pw.println(POWER_CHECK_MAX_CPU_1); |
| 383 | pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_2); pw.print("="); |
| 384 | pw.println(POWER_CHECK_MAX_CPU_2); |
| 385 | pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_3); pw.print("="); |
| 386 | pw.println(POWER_CHECK_MAX_CPU_3); |
| 387 | pw.print(" "); pw.print(KEY_POWER_CHECK_MAX_CPU_4); pw.print("="); |
| 388 | pw.println(POWER_CHECK_MAX_CPU_4); |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 389 | pw.print(" "); pw.print(KEY_SERVICE_USAGE_INTERACTION_TIME); pw.print("="); |
| 390 | pw.println(SERVICE_USAGE_INTERACTION_TIME); |
| 391 | pw.print(" "); pw.print(KEY_USAGE_STATS_INTERACTION_INTERVAL); pw.print("="); |
| 392 | pw.println(USAGE_STATS_INTERACTION_INTERVAL); |
| 393 | pw.print(" "); pw.print(KEY_SERVICE_RESTART_DURATION); pw.print("="); |
| 394 | pw.println(SERVICE_RESTART_DURATION); |
| 395 | pw.print(" "); pw.print(KEY_SERVICE_RESET_RUN_DURATION); pw.print("="); |
| 396 | pw.println(SERVICE_RESET_RUN_DURATION); |
| 397 | pw.print(" "); pw.print(KEY_SERVICE_RESTART_DURATION_FACTOR); pw.print("="); |
| 398 | pw.println(SERVICE_RESTART_DURATION_FACTOR); |
| 399 | pw.print(" "); pw.print(KEY_SERVICE_MIN_RESTART_TIME_BETWEEN); pw.print("="); |
| 400 | pw.println(SERVICE_MIN_RESTART_TIME_BETWEEN); |
| 401 | pw.print(" "); pw.print(KEY_MAX_SERVICE_INACTIVITY); pw.print("="); |
| 402 | pw.println(MAX_SERVICE_INACTIVITY); |
| 403 | pw.print(" "); pw.print(KEY_BG_START_TIMEOUT); pw.print("="); |
| 404 | pw.println(BG_START_TIMEOUT); |
Dianne Hackborn | 0ef403e | 2017-01-24 18:22:15 -0800 | [diff] [blame] | 405 | |
| 406 | pw.println(); |
| 407 | if (mOverrideMaxCachedProcesses >= 0) { |
| 408 | pw.print(" mOverrideMaxCachedProcesses="); pw.println(mOverrideMaxCachedProcesses); |
| 409 | } |
| 410 | pw.print(" CUR_MAX_CACHED_PROCESSES="); pw.println(CUR_MAX_CACHED_PROCESSES); |
| 411 | pw.print(" CUR_MAX_EMPTY_PROCESSES="); pw.println(CUR_MAX_EMPTY_PROCESSES); |
| 412 | pw.print(" CUR_TRIM_EMPTY_PROCESSES="); pw.println(CUR_TRIM_EMPTY_PROCESSES); |
| 413 | pw.print(" CUR_TRIM_CACHED_PROCESSES="); pw.println(CUR_TRIM_CACHED_PROCESSES); |
| 414 | } |
| 415 | } |