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

Commit 87c96f5a authored by Michael Wachenschwanz's avatar Michael Wachenschwanz Committed by Android (Google) Code Review
Browse files

Merge "Cleanup unfreeze_bind_policy_fix flag" into main

parents 73698cce e0b2cbb0
Loading
Loading
Loading
Loading
+6 −18
Original line number Diff line number Diff line
@@ -2633,14 +2633,10 @@ public abstract class OomAdjuster {
                    & ALL_CPU_TIME_CAPABILITIES) != 0) {
            // The connection might grant CPU capability to the service.
            needDryRun = true;
        } else if (Flags.unfreezeBindPolicyFix()
                && cr.hasFlag(Context.BIND_WAIVE_PRIORITY
                            | Context.BIND_ALLOW_OOM_MANAGEMENT)) {
        } else if (cr.hasFlag(Context.BIND_WAIVE_PRIORITY | Context.BIND_ALLOW_OOM_MANAGEMENT)) {
            // These bind flags can grant the shouldNotFreeze state to the service.
            needDryRun = true;
        } else if (Flags.unfreezeBindPolicyFix()
                && client.mOptRecord.shouldNotFreeze()
                && !app.mOptRecord.shouldNotFreeze()) {
        } else if (client.mOptRecord.shouldNotFreeze() && !app.mOptRecord.shouldNotFreeze()) {
            // The shouldNotFreeze state can be propagated and needs to be checked.
            needDryRun = true;
        }
@@ -2670,13 +2666,9 @@ public abstract class OomAdjuster {
                && (app.getSetCapability() & client.getSetCapability())
                            != PROCESS_CAPABILITY_NONE) {
            return true;
        } else if (Flags.unfreezeBindPolicyFix()
                && cr.hasFlag(Context.BIND_WAIVE_PRIORITY
                            | Context.BIND_ALLOW_OOM_MANAGEMENT)) {
        } else if (cr.hasFlag(Context.BIND_WAIVE_PRIORITY | Context.BIND_ALLOW_OOM_MANAGEMENT)) {
            return true;
        } else if (Flags.unfreezeBindPolicyFix()
                && app.mOptRecord.shouldNotFreeze()
                && client.mOptRecord.shouldNotFreeze()) {
        } else if (app.mOptRecord.shouldNotFreeze() && client.mOptRecord.shouldNotFreeze()) {
            // Process has shouldNotFreeze and it could have gotten it from the client.
            return true;
        } else if (Flags.cpuTimeCapabilityBasedFreezePolicy()
@@ -2698,9 +2690,7 @@ public abstract class OomAdjuster {
            needDryRun = true;
        } else if (app.getSetProcState() > client.getSetProcState()) {
            needDryRun = true;
        } else if (Flags.unfreezeBindPolicyFix()
                && client.mOptRecord.shouldNotFreeze()
                && !app.mOptRecord.shouldNotFreeze()) {
        } else if (client.mOptRecord.shouldNotFreeze() && !app.mOptRecord.shouldNotFreeze()) {
            needDryRun = true;
        } else if (Flags.cpuTimeCapabilityBasedFreezePolicy()
                && (client.getSetCapability() & ~app.getSetCapability()
@@ -2725,9 +2715,7 @@ public abstract class OomAdjuster {
            return true;
        } else if (app.getSetProcState() >= client.getSetProcState()) {
            return true;
        } else if (Flags.unfreezeBindPolicyFix()
                && app.mOptRecord.shouldNotFreeze()
                && client.mOptRecord.shouldNotFreeze()) {
        } else if (app.mOptRecord.shouldNotFreeze() && client.mOptRecord.shouldNotFreeze()) {
            // Process has shouldNotFreeze and it could have gotten it from the client.
            return true;
        } else if (Flags.cpuTimeCapabilityBasedFreezePolicy()
+1 −5
Original line number Diff line number Diff line
@@ -338,11 +338,7 @@ final class ProcessCachedOptimizerRecord {
    boolean setShouldNotFreeze(boolean shouldNotFreeze, boolean dryRun,
            @ShouldNotFreezeReason int reason, int adjSeq) {
        if (dryRun) {
            if (Flags.unfreezeBindPolicyFix()) {
            return mShouldNotFreeze != shouldNotFreeze;
            } else {
                return mFrozen && !shouldNotFreeze;
            }
        }
        if (Flags.traceUpdateAppFreezeStateLsp()) {
            if (shouldNotFreeze) {
+0 −10
Original line number Diff line number Diff line
@@ -201,16 +201,6 @@ flag {
    bug: "369893532"
}

flag {
    name: "unfreeze_bind_policy_fix"
    namespace: "backstage_power"
    description: "Make sure shouldNotFreeze state change correctly triggers updates."
    bug: "375691778"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "oomadjuster_prev_laddering"
    namespace: "system_performance"
+2 −56
Original line number Diff line number Diff line
@@ -69,8 +69,6 @@ import android.os.IBinder;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.platform.test.flag.junit.SetFlagsRule;
@@ -328,7 +326,6 @@ public final class ServiceBindingOomAdjPolicyTest {
    }

    @Test
    @RequiresFlagsEnabled(com.android.server.am.Flags.FLAG_UNFREEZE_BIND_POLICY_FIX)
    @DisableFlags(Flags.FLAG_CPU_TIME_CAPABILITY_BASED_FREEZE_POLICY)
    public void testServiceDistinctBindingOomAdjShouldNotFreeze() throws Exception {
        // Enable the flags.
@@ -421,7 +418,6 @@ public final class ServiceBindingOomAdjPolicyTest {
    }

    @Test
    @RequiresFlagsEnabled(com.android.server.am.Flags.FLAG_UNFREEZE_BIND_POLICY_FIX)
    @DisableFlags(Flags.FLAG_CPU_TIME_CAPABILITY_BASED_FREEZE_POLICY)
    public void testServiceDistinctBindingOomAdjAllowOomManagement() throws Exception {
        // Enable the flags.
@@ -501,7 +497,6 @@ public final class ServiceBindingOomAdjPolicyTest {
    }

    @Test
    @RequiresFlagsEnabled(com.android.server.am.Flags.FLAG_UNFREEZE_BIND_POLICY_FIX)
    @DisableFlags(Flags.FLAG_CPU_TIME_CAPABILITY_BASED_FREEZE_POLICY)
    public void testServiceDistinctBindingOomAdjWaivePriority_propagateUnfreeze() throws Exception {
        // Enable the flags.
@@ -580,11 +575,8 @@ public final class ServiceBindingOomAdjPolicyTest {
    }

    @Test
    @RequiresFlagsEnabled({
            Flags.FLAG_UNFREEZE_BIND_POLICY_FIX,
            Flags.FLAG_SERVICE_BINDING_OOM_ADJ_POLICY
    })
    @EnableFlags(Flags.FLAG_CPU_TIME_CAPABILITY_BASED_FREEZE_POLICY)
    @EnableFlags({Flags.FLAG_SERVICE_BINDING_OOM_ADJ_POLICY,
            Flags.FLAG_CPU_TIME_CAPABILITY_BASED_FREEZE_POLICY})
    public void testServiceDistinctBindingOomAdj_propagateCpuTimeCapability() throws Exception {
        // Note that PROCESS_CAPABILITY_CPU_TIME is special and should be propagated even when
        // BIND_INCLUDE_CAPABILITIES is not present.
@@ -623,52 +615,6 @@ public final class ServiceBindingOomAdjPolicyTest {
                never(), atLeastOnce());
    }

    @Test
    @RequiresFlagsDisabled(com.android.server.am.Flags.FLAG_UNFREEZE_BIND_POLICY_FIX)
    public void testServiceDistinctBindingOomAdjWaivePriority() throws Exception {
        // Enable the flags.
        mSetFlagsRule.enableFlags(Flags.FLAG_SERVICE_BINDING_OOM_ADJ_POLICY);

        // Verify that there should be 0 oom adj update for binding
        // because we're using the BIND_WAIVE_PRIORITY;
        // but for the unbinding, because client is better than service, we can't skip it safely.
        performTestServiceDistinctBindingOomAdj(TEST_APP1_PID, TEST_APP1_UID,
                PROCESS_STATE_FOREGROUND_SERVICE, PERCEPTIBLE_APP_ADJ,
                PROCESS_CAPABILITY_NONE, TEST_APP1_NAME,
                this::setHasForegroundServices,
                TEST_APP2_PID, TEST_APP2_UID, PROCESS_STATE_HOME,
                HOME_APP_ADJ, PROCESS_CAPABILITY_NONE, TEST_APP2_NAME, TEST_SERVICE2_NAME,
                this::setHomeProcess,
                BIND_AUTO_CREATE | BIND_WAIVE_PRIORITY,
                never(), atLeastOnce());

        // Verify that there should be 0 oom adj update
        // because we're using the BIND_WAIVE_PRIORITY;
        performTestServiceDistinctBindingOomAdj(TEST_APP1_PID, TEST_APP1_UID,
                PROCESS_STATE_HOME, HOME_APP_ADJ, PROCESS_CAPABILITY_NONE, TEST_APP1_NAME,
                this::setHomeProcess,
                TEST_APP2_PID, TEST_APP2_UID, PROCESS_STATE_FOREGROUND_SERVICE,
                PERCEPTIBLE_APP_ADJ, PROCESS_CAPABILITY_NONE, TEST_APP2_NAME, TEST_SERVICE2_NAME,
                this::setHasForegroundServices,
                BIND_AUTO_CREATE | BIND_WAIVE_PRIORITY,
                never(), never());

        // Disable the flags.
        mSetFlagsRule.disableFlags(Flags.FLAG_SERVICE_BINDING_OOM_ADJ_POLICY);

        // Verify that there should be at least 1 oom adj update
        // because the client is more important.
        performTestServiceDistinctBindingOomAdj(TEST_APP1_PID, TEST_APP1_UID,
                PROCESS_STATE_FOREGROUND_SERVICE, PERCEPTIBLE_APP_ADJ,
                PROCESS_CAPABILITY_NONE, TEST_APP1_NAME,
                this::setHasForegroundServices,
                TEST_APP2_PID, TEST_APP2_UID, PROCESS_STATE_HOME,
                HOME_APP_ADJ, PROCESS_CAPABILITY_NONE, TEST_APP2_NAME, TEST_SERVICE2_NAME,
                this::setHomeProcess,
                BIND_AUTO_CREATE,
                atLeastOnce(), atLeastOnce());
    }

    @Test
    public void testServiceDistinctBindingOomAdjNoIncludeCapabilities() throws Exception {
        // Enable the flags.