Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa98986b authored by Shai Barack's avatar Shai Barack Committed by Android (Google) Code Review
Browse files

Merge "Delete MAX_CACHED_PROCESSES and associated constants" into main

parents d0507ffd c771b53a
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -6503,9 +6503,6 @@
    <string-array name="config_sharedLibrariesLoadedAfterApp" translatable="false">
    <string-array name="config_sharedLibrariesLoadedAfterApp" translatable="false">
    </string-array>
    </string-array>


    <!-- the number of the max cached processes in the system. -->
    <integer name="config_customizedMaxCachedProcesses">32</integer>

    <!-- Whether this device should support taking app snapshots on closure -->
    <!-- Whether this device should support taking app snapshots on closure -->
    <bool name="config_disableTaskSnapshots">false</bool>
    <bool name="config_disableTaskSnapshots">false</bool>


+0 −2
Original line number Original line Diff line number Diff line
@@ -5061,8 +5061,6 @@
       code and resources provided by applications. -->
       code and resources provided by applications. -->
  <java-symbol type="array" name="config_sharedLibrariesLoadedAfterApp" />
  <java-symbol type="array" name="config_sharedLibrariesLoadedAfterApp" />


  <java-symbol type="integer" name="config_customizedMaxCachedProcesses" />

  <java-symbol type="color" name="overview_background"/>
  <java-symbol type="color" name="overview_background"/>


  <java-symbol type="bool" name="config_disableTaskSnapshots" />
  <java-symbol type="bool" name="config_disableTaskSnapshots" />
+0 −20
Original line number Original line Diff line number Diff line
@@ -494,26 +494,6 @@
        <item>show_deuteranomaly</item>
        <item>show_deuteranomaly</item>
    </string-array>
    </string-array>


    <!-- Titles for app process limit preference. [CHAR LIMIT=35] -->
    <string-array name="app_process_limit_entries">
        <item>Standard limit</item>
        <item>No background processes</item>
        <item>At most 1 process</item>
        <item>At most 2 processes</item>
        <item>At most 3 processes</item>
        <item>At most 4 processes</item>
    </string-array>

    <!-- Values for app process limit preference. -->
    <string-array name="app_process_limit_values" translatable="false" >
        <item>-1</item>
        <item>0</item>
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
    </string-array>

    <!-- USB configuration names for Developer Settings.
    <!-- USB configuration names for Developer Settings.
         This can be overridden by devices with additional USB configurations. -->
         This can be overridden by devices with additional USB configurations. -->
    <string-array name="usb_configuration_titles">
    <string-array name="usb_configuration_titles">
+0 −3
Original line number Original line Diff line number Diff line
@@ -975,9 +975,6 @@
    <string name="immediately_destroy_activities_summary">Destroy every activity as soon as
    <string name="immediately_destroy_activities_summary">Destroy every activity as soon as
        the user leaves it</string>
        the user leaves it</string>


    <!-- UI debug setting: limit number of running background processes [CHAR LIMIT=25] -->
    <string name="app_process_limit_title">Background process limit</string>

    <!-- UI debug setting: show all ANRs? [CHAR LIMIT=25] -->
    <!-- UI debug setting: show all ANRs? [CHAR LIMIT=25] -->
    <string name="show_all_anrs">Show background ANRs</string>
    <string name="show_all_anrs">Show background ANRs</string>
    <!-- UI debug setting: show all ANRs summary [CHAR LIMIT=100] -->
    <!-- UI debug setting: show all ANRs summary [CHAR LIMIT=100] -->
+2 −96
Original line number Original line Diff line number Diff line
@@ -169,7 +169,6 @@ final class ActivityManagerConstants extends ContentObserver {
     */
     */
    static final String KEY_ENABLE_NEW_OOMADJ = "enable_new_oom_adj";
    static final String KEY_ENABLE_NEW_OOMADJ = "enable_new_oom_adj";


    private static final int DEFAULT_MAX_CACHED_PROCESSES = 1024;
    private static final boolean DEFAULT_PRIORITIZE_ALARM_BROADCASTS = true;
    private static final boolean DEFAULT_PRIORITIZE_ALARM_BROADCASTS = true;
    private static final long DEFAULT_FGSERVICE_MIN_SHOWN_TIME = 2*1000;
    private static final long DEFAULT_FGSERVICE_MIN_SHOWN_TIME = 2*1000;
    private static final long DEFAULT_FGSERVICE_MIN_REPORT_TIME = 3*1000;
    private static final long DEFAULT_FGSERVICE_MIN_REPORT_TIME = 3*1000;
@@ -294,12 +293,7 @@ final class ActivityManagerConstants extends ContentObserver {
    private static final long DEFAULT_SERVICE_BACKGROUND_TIMEOUT = DEFAULT_SERVICE_TIMEOUT * 10;
    private static final long DEFAULT_SERVICE_BACKGROUND_TIMEOUT = DEFAULT_SERVICE_TIMEOUT * 10;


    /**
    /**
     * Maximum number of cached processes.
     * Maximum number of phantom processes.
     */
    private static final String KEY_MAX_CACHED_PROCESSES = "max_cached_processes";

    /**
     * Maximum number of cached processes.
     */
     */
    private static final String KEY_MAX_PHANTOM_PROCESSES = "max_phantom_processes";
    private static final String KEY_MAX_PHANTOM_PROCESSES = "max_phantom_processes";


@@ -446,9 +440,6 @@ final class ActivityManagerConstants extends ContentObserver {
    volatile int mProcStateDebugSetProcStateDelay = 0;
    volatile int mProcStateDebugSetProcStateDelay = 0;
    volatile int mProcStateDebugSetUidStateDelay = 0;
    volatile int mProcStateDebugSetUidStateDelay = 0;


    // Maximum number of cached processes we will allow.
    public int MAX_CACHED_PROCESSES = DEFAULT_MAX_CACHED_PROCESSES;

    // This is the amount of time we allow an app to settle after it goes into the background,
    // This is the amount of time we allow an app to settle after it goes into the background,
    // before we start restricting what it can do.
    // before we start restricting what it can do.
    public long BACKGROUND_SETTLE_TIME = DEFAULT_BACKGROUND_SETTLE_TIME;
    public long BACKGROUND_SETTLE_TIME = DEFAULT_BACKGROUND_SETTLE_TIME;
@@ -857,24 +848,6 @@ final class ActivityManagerConstants extends ContentObserver {
    private ContentResolver mResolver;
    private ContentResolver mResolver;
    private final KeyValueListParser mParser = new KeyValueListParser(',');
    private final KeyValueListParser mParser = new KeyValueListParser(',');


    private int mOverrideMaxCachedProcesses = -1;
    private final int mCustomizedMaxCachedProcesses;

    // The maximum number of cached processes we will keep around before killing them.
    // NOTE: this constant is *only* a control to not let us go too crazy with
    // keeping around processes on devices with large amounts of RAM.  For devices that
    // are tighter on RAM, the out of memory killer is responsible for killing background
    // processes as RAM is needed, and we should *never* be relying on this limit to
    // kill them.  Also note that this limit only applies to cached background processes;
    // we have no limit on the number of service, visible, foreground, or other such
    // processes and the number of those processes does not count against the cached
    // process limit. This will be initialized in the constructor.
    public int CUR_MAX_CACHED_PROCESSES;

    // The maximum number of empty app processes we will let sit around.  This will be
    // initialized in the constructor.
    public int CUR_MAX_EMPTY_PROCESSES;

    /** @see #mNoKillCachedProcessesUntilBootCompleted */
    /** @see #mNoKillCachedProcessesUntilBootCompleted */
    private static final String KEY_NO_KILL_CACHED_PROCESSES_UNTIL_BOOT_COMPLETED =
    private static final String KEY_NO_KILL_CACHED_PROCESSES_UNTIL_BOOT_COMPLETED =
            "no_kill_cached_processes_until_boot_completed";
            "no_kill_cached_processes_until_boot_completed";
@@ -906,15 +879,6 @@ final class ActivityManagerConstants extends ContentObserver {
    volatile long mNoKillCachedProcessesPostBootCompletedDurationMillis =
    volatile long mNoKillCachedProcessesPostBootCompletedDurationMillis =
            DEFAULT_NO_KILL_CACHED_PROCESSES_POST_BOOT_COMPLETED_DURATION_MILLIS;
            DEFAULT_NO_KILL_CACHED_PROCESSES_POST_BOOT_COMPLETED_DURATION_MILLIS;


    // The number of empty apps at which we don't consider it necessary to do
    // memory trimming.
    public int CUR_TRIM_EMPTY_PROCESSES = computeEmptyProcessLimit(MAX_CACHED_PROCESSES) / 2;

    // The number of cached at which we don't consider it necessary to do
    // memory trimming.
    public int CUR_TRIM_CACHED_PROCESSES =
            (MAX_CACHED_PROCESSES - computeEmptyProcessLimit(MAX_CACHED_PROCESSES)) / 3;

    /** @see #mNoKillCachedProcessesUntilBootCompleted */
    /** @see #mNoKillCachedProcessesUntilBootCompleted */
    private static final String KEY_MAX_EMPTY_TIME_MILLIS =
    private static final String KEY_MAX_EMPTY_TIME_MILLIS =
            "max_empty_time_millis";
            "max_empty_time_millis";
@@ -1165,9 +1129,6 @@ final class ActivityManagerConstants extends ContentObserver {
                            return;
                            return;
                        }
                        }
                        switch (name) {
                        switch (name) {
                            case KEY_MAX_CACHED_PROCESSES:
                                updateMaxCachedProcesses();
                                break;
                            case KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED:
                            case KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED:
                                updateBackgroundActivityStarts();
                                updateBackgroundActivityStarts();
                                break;
                                break;
@@ -1417,16 +1378,7 @@ final class ActivityManagerConstants extends ContentObserver {
                context.getResources().getStringArray(
                context.getResources().getStringArray(
                        com.android.internal.R.array.config_keep_warming_services))
                        com.android.internal.R.array.config_keep_warming_services))
                .map(ComponentName::unflattenFromString).collect(Collectors.toSet()));
                .map(ComponentName::unflattenFromString).collect(Collectors.toSet()));
        mCustomizedMaxCachedProcesses = context.getResources().getInteger(

                com.android.internal.R.integer.config_customizedMaxCachedProcesses);
        CUR_MAX_CACHED_PROCESSES = mCustomizedMaxCachedProcesses;
        CUR_MAX_EMPTY_PROCESSES = computeEmptyProcessLimit(CUR_MAX_CACHED_PROCESSES);

        final int rawMaxEmptyProcesses = computeEmptyProcessLimit(
                Integer.min(CUR_MAX_CACHED_PROCESSES, MAX_CACHED_PROCESSES));
        CUR_TRIM_EMPTY_PROCESSES = rawMaxEmptyProcesses / 2;
        CUR_TRIM_CACHED_PROCESSES = (Integer.min(CUR_MAX_CACHED_PROCESSES, MAX_CACHED_PROCESSES)
                    - rawMaxEmptyProcesses) / 3;
        loadNativeBootDeviceConfigConstants();
        loadNativeBootDeviceConfigConstants();
        mDefaultDisableAppProfilerPssProfiling = context.getResources().getBoolean(
        mDefaultDisableAppProfilerPssProfiling = context.getResources().getBoolean(
                R.bool.config_am_disablePssProfiling);
                R.bool.config_am_disablePssProfiling);
@@ -1481,19 +1433,6 @@ final class ActivityManagerConstants extends ContentObserver {
                DEFAULT_ENABLE_NEW_OOM_ADJ);
                DEFAULT_ENABLE_NEW_OOM_ADJ);
    }
    }


    public void setOverrideMaxCachedProcesses(int value) {
        mOverrideMaxCachedProcesses = value;
        updateMaxCachedProcesses();
    }

    public int getOverrideMaxCachedProcesses() {
        return mOverrideMaxCachedProcesses;
    }

    public static int computeEmptyProcessLimit(int totalProcessLimit) {
        return totalProcessLimit/2;
    }

    @Override
    @Override
    public void onChange(boolean selfChange, Uri uri) {
    public void onChange(boolean selfChange, Uri uri) {
        if (uri == null) return;
        if (uri == null) return;
@@ -1994,29 +1933,6 @@ final class ActivityManagerConstants extends ContentObserver {
                mSystemServerAutomaticHeapDumpPackageName);
                mSystemServerAutomaticHeapDumpPackageName);
    }
    }


    private void updateMaxCachedProcesses() {
        String maxCachedProcessesFlag = DeviceConfig.getProperty(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, KEY_MAX_CACHED_PROCESSES);
        try {
            CUR_MAX_CACHED_PROCESSES = mOverrideMaxCachedProcesses < 0
                    ? (TextUtils.isEmpty(maxCachedProcessesFlag)
                    ? mCustomizedMaxCachedProcesses : Integer.parseInt(maxCachedProcessesFlag))
                    : mOverrideMaxCachedProcesses;
        } catch (NumberFormatException e) {
            // Bad flag value from Phenotype, revert to default.
            Slog.e(TAG,
                    "Unable to parse flag for max_cached_processes: " + maxCachedProcessesFlag, e);
            CUR_MAX_CACHED_PROCESSES = mCustomizedMaxCachedProcesses;
        }
        CUR_MAX_EMPTY_PROCESSES = computeEmptyProcessLimit(CUR_MAX_CACHED_PROCESSES);

        final int rawMaxEmptyProcesses = computeEmptyProcessLimit(
                Integer.min(CUR_MAX_CACHED_PROCESSES, MAX_CACHED_PROCESSES));
        CUR_TRIM_EMPTY_PROCESSES = rawMaxEmptyProcesses / 2;
        CUR_TRIM_CACHED_PROCESSES = (Integer.min(CUR_MAX_CACHED_PROCESSES, MAX_CACHED_PROCESSES)
                    - rawMaxEmptyProcesses) / 3;
    }

    private void updateProactiveKillsEnabled() {
    private void updateProactiveKillsEnabled() {
        PROACTIVE_KILLS_ENABLED = DeviceConfig.getBoolean(
        PROACTIVE_KILLS_ENABLED = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
@@ -2275,8 +2191,6 @@ final class ActivityManagerConstants extends ContentObserver {
        pw.println("ACTIVITY MANAGER SETTINGS (dumpsys activity settings) "
        pw.println("ACTIVITY MANAGER SETTINGS (dumpsys activity settings) "
                + Settings.Global.ACTIVITY_MANAGER_CONSTANTS + ":");
                + Settings.Global.ACTIVITY_MANAGER_CONSTANTS + ":");


        pw.print("  "); pw.print(KEY_MAX_CACHED_PROCESSES); pw.print("=");
        pw.println(MAX_CACHED_PROCESSES);
        pw.print("  "); pw.print(KEY_BACKGROUND_SETTLE_TIME); pw.print("=");
        pw.print("  "); pw.print(KEY_BACKGROUND_SETTLE_TIME); pw.print("=");
        pw.println(BACKGROUND_SETTLE_TIME);
        pw.println(BACKGROUND_SETTLE_TIME);
        pw.print("  "); pw.print(KEY_FGSERVICE_MIN_SHOWN_TIME); pw.print("=");
        pw.print("  "); pw.print(KEY_FGSERVICE_MIN_SHOWN_TIME); pw.print("=");
@@ -2477,14 +2391,6 @@ final class ActivityManagerConstants extends ContentObserver {
        pw.print("="); pw.println(MAX_PREVIOUS_TIME);
        pw.print("="); pw.println(MAX_PREVIOUS_TIME);


        pw.println();
        pw.println();
        if (mOverrideMaxCachedProcesses >= 0) {
            pw.print("  mOverrideMaxCachedProcesses="); pw.println(mOverrideMaxCachedProcesses);
        }
        pw.print("  mCustomizedMaxCachedProcesses="); pw.println(mCustomizedMaxCachedProcesses);
        pw.print("  CUR_MAX_CACHED_PROCESSES="); pw.println(CUR_MAX_CACHED_PROCESSES);
        pw.print("  CUR_MAX_EMPTY_PROCESSES="); pw.println(CUR_MAX_EMPTY_PROCESSES);
        pw.print("  CUR_TRIM_EMPTY_PROCESSES="); pw.println(CUR_TRIM_EMPTY_PROCESSES);
        pw.print("  CUR_TRIM_CACHED_PROCESSES="); pw.println(CUR_TRIM_CACHED_PROCESSES);
        pw.print("  OOMADJ_UPDATE_QUICK="); pw.println(OOMADJ_UPDATE_QUICK);
        pw.print("  OOMADJ_UPDATE_QUICK="); pw.println(OOMADJ_UPDATE_QUICK);
        pw.print("  ENABLE_WAIT_FOR_FINISH_ATTACH_APPLICATION=");
        pw.print("  ENABLE_WAIT_FOR_FINISH_ATTACH_APPLICATION=");
        pw.println(mEnableWaitForFinishAttachApplication);
        pw.println(mEnableWaitForFinishAttachApplication);
Loading