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

Commit b3be3d5b authored by Kalesh Singh's avatar Kalesh Singh
Browse files

AMS: Add Phenotype key for proactive kills



KEY_PROACTIVE_KILLS_ENABLED controls whether proactive kills
are enabled or not.

Bug: 249601646
Test: adb shell device_config put activity_manager proactive_kills_enabled true
Test: adb shell device_config get activity_manager proactive_kills_enabled
Change-Id: I173058d77e18294a882714591dcea96dae06c12f
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
parent 84d812ff
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -248,6 +248,11 @@ final class ActivityManagerConstants extends ContentObserver {
     */
    private static final String KEY_MAX_PHANTOM_PROCESSES = "max_phantom_processes";

    /**
     * Enables proactive killing of cached apps
     */
    private static final String KEY_PROACTIVE_KILLS_ENABLED = "proactive_kills_enabled";

    /**
     * Default value for mFlagBackgroundActivityStartsEnabled if not explicitly set in
     * Settings.Global. This allows it to be set experimentally unless it has been
@@ -874,6 +879,8 @@ final class ActivityManagerConstants extends ContentObserver {
     */
    private static final long DEFAULT_MIN_ASSOC_LOG_DURATION = 5 * 60 * 1000; // 5 mins

    private static final boolean DEFAULT_PROACTIVE_KILLS_ENABLED = false;

    private static final String KEY_MIN_ASSOC_LOG_DURATION = "min_assoc_log_duration";

    public static long MIN_ASSOC_LOG_DURATION = DEFAULT_MIN_ASSOC_LOG_DURATION;
@@ -904,6 +911,7 @@ final class ActivityManagerConstants extends ContentObserver {
    public static boolean BINDER_HEAVY_HITTER_AUTO_SAMPLER_ENABLED;
    public static int BINDER_HEAVY_HITTER_AUTO_SAMPLER_BATCHSIZE;
    public static float BINDER_HEAVY_HITTER_AUTO_SAMPLER_THRESHOLD;
    public static boolean PROACTIVE_KILLS_ENABLED = DEFAULT_PROACTIVE_KILLS_ENABLED;

    private final OnPropertiesChangedListener mOnDeviceConfigChangedListener =
            new OnPropertiesChangedListener() {
@@ -1040,6 +1048,9 @@ final class ActivityManagerConstants extends ContentObserver {
                            case KEY_MAX_SERVICE_CONNECTIONS_PER_PROCESS:
                                updateMaxServiceConnectionsPerProcess();
                                break;
                            case KEY_PROACTIVE_KILLS_ENABLED:
                                updateProactiveKillsEnabled();
                                break;
                            default:
                                break;
                        }
@@ -1660,6 +1671,13 @@ final class ActivityManagerConstants extends ContentObserver {
        CUR_TRIM_CACHED_PROCESSES = (MAX_CACHED_PROCESSES-rawMaxEmptyProcesses)/3;
    }

    private void updateProactiveKillsEnabled() {
        PROACTIVE_KILLS_ENABLED = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
                KEY_PROACTIVE_KILLS_ENABLED,
                DEFAULT_PROACTIVE_KILLS_ENABLED);
    }

    private void updateMinAssocLogDuration() {
        MIN_ASSOC_LOG_DURATION = DeviceConfig.getLong(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, KEY_MIN_ASSOC_LOG_DURATION,
@@ -1860,6 +1878,8 @@ final class ActivityManagerConstants extends ContentObserver {
        pw.print("="); pw.println(mNetworkAccessTimeoutMs);
        pw.print("  "); pw.print(KEY_MAX_SERVICE_CONNECTIONS_PER_PROCESS);
        pw.print("="); pw.println(mMaxServiceConnectionsPerProcess);
        pw.print("  "); pw.print(KEY_PROACTIVE_KILLS_ENABLED);
        pw.print("="); pw.println(PROACTIVE_KILLS_ENABLED);

        pw.println();
        if (mOverrideMaxCachedProcesses >= 0) {
+1 −1
Original line number Diff line number Diff line
@@ -1148,7 +1148,7 @@ public class OomAdjuster {
        int numEmpty = 0;
        int numTrimming = 0;

        boolean proactiveKillsEnabled = false;  // TODO: Configure from phenotype
        boolean proactiveKillsEnabled = mConstants.PROACTIVE_KILLS_ENABLED;
        double lowSwapThresholdPercent = 0.10;  // TODO: Configure from phenotype
        double freeSwapPercent =  proactiveKillsEnabled ? getFreeSwapPercent() : 1.00;
        ProcessRecord lruCachedApp = null;