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

Commit 7e3bcf31 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

[6/N] Delete OomAdjusterLegacyImpl and rename the Modern impl

Flag: EXEMPT pure refactor
Test: atest MockingOomAdjusterTests
Test: builds and flashes
Bug: 306731120
Change-Id: Iaec6ffe700448d5facb9e7d2ca8eaba6dddd2da3
parent f3f20514
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import java.io.PrintWriter;
/**
 * Description of a single binding to a service.
 */
final class ConnectionRecord implements OomAdjusterModernImpl.Connection{
final class ConnectionRecord implements OomAdjusterImpl.Connection{
    final AppBindRecord binding;    // The application/service binding.
    final ActivityServiceConnectionsHolder<ConnectionRecord> activity;  // If non-null, the owning activity.
    final IServiceConnection conn;  // The client connection.
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import com.android.internal.app.procstats.ProcessStats;
 * Represents a link between a content provider and client.
 */
public final class ContentProviderConnection extends Binder implements
        OomAdjusterModernImpl.Connection {
        OomAdjusterImpl.Connection {
    public final ContentProviderRecord provider;
    public final ProcessRecord client;
    public final String clientPackage;
+1 −42
Original line number Diff line number Diff line
@@ -1887,7 +1887,7 @@ public abstract class OomAdjuster {
    /**
     * @return the CPU capability from a client (of a service binding or provider).
     */
    protected static int getCpuCapabilityFromClient(OomAdjusterModernImpl.Connection conn,
    protected static int getCpuCapabilityFromClient(OomAdjusterImpl.Connection conn,
            ProcessRecord client) {
        if (conn == null || conn.transmitsCpuTime()) {
            return client.mState.getCurCapability() & ALL_CPU_TIME_CAPABILITIES;
@@ -1896,47 +1896,6 @@ public abstract class OomAdjuster {
        }
    }

    /**
     * Checks if for the given app and client, there's a cycle that should skip over the client
     * for now or use partial values to evaluate the effect of the client binding.
     * @param app
     * @param client
     * @param procState procstate evaluated so far for this app
     * @param adj oom_adj evaluated so far for this app
     * @param cycleReEval whether we're currently re-evaluating due to a cycle, and not the first
     *                    evaluation.
     * @return whether to skip using the client connection at this time
     */
    protected boolean shouldSkipDueToCycle(ProcessRecord app, ProcessStateRecord client,
            int procState, int adj, boolean cycleReEval) {
        if (client.containsCycle()) {
            // We've detected a cycle. We should retry computeOomAdjLSP later in
            // case a later-checked connection from a client  would raise its
            // priority legitimately.
            app.mState.setContainsCycle(true);
            mProcessesInCycle.add(app);
            // If the client has not been completely evaluated, check if it's worth
            // using the partial values.
            if (client.getCompletedAdjSeq() < mAdjSeq) {
                if (cycleReEval) {
                    // If the partial values are no better, skip until the next
                    // attempt
                    if (client.getCurRawProcState() >= procState
                            && client.getCurRawAdj() >= adj
                            && (client.getCurCapability() & app.mState.getCurCapability())
                            == client.getCurCapability()) {
                        return true;
                    }
                    // Else use the client's partial procstate and adj to adjust the
                    // effect of the binding
                } else {
                    return false;
                }
            }
        }
        return false;
    }

    /** Inform the oomadj observer of changes to oomadj. Used by tests. */
    @GuardedBy("mService")
    protected void reportOomAdjMessageLocked(String tag, String msg) {
+6 −6
Original line number Diff line number Diff line
@@ -114,10 +114,10 @@ import java.util.function.Consumer;
import java.util.function.ToIntFunction;

/**
 * A modern implementation of the oom adjuster.
 * The implementation of the oom adjuster traversal algorithm and policies.
 */
public class OomAdjusterModernImpl extends OomAdjuster {
    static final String TAG = "OomAdjusterModernImpl";
public class OomAdjusterImpl extends OomAdjuster {
    static final String TAG = "OomAdjusterImpl";

    // The ADJ_SLOT_INVALID is NOT an actual slot.
    static final int ADJ_SLOT_INVALID = -1;
@@ -727,7 +727,7 @@ public class OomAdjusterModernImpl extends OomAdjuster {
                return;
            }

            conn.computeHostOomAdjLSP(OomAdjusterModernImpl.this, host, client, now, topApp, false,
            conn.computeHostOomAdjLSP(OomAdjusterImpl.this, host, client, now, topApp, false,
                    oomAdjReason, UNKNOWN_ADJ);
        }
    }
@@ -758,7 +758,7 @@ public class OomAdjusterModernImpl extends OomAdjuster {
                return;
            }

            conn.computeHostOomAdjLSP(OomAdjusterModernImpl.this, host, client, now, topApp,
            conn.computeHostOomAdjLSP(OomAdjusterImpl.this, host, client, now, topApp,
                    fullUpdate, oomAdjReason, cachedAdj);

            updateProcStateSlotIfNecessary(host, prevProcState);
@@ -792,7 +792,7 @@ public class OomAdjusterModernImpl extends OomAdjuster {
    private final ComputeConnectionsConsumer mComputeConnectionsConsumer =
            new ComputeConnectionsConsumer();

    OomAdjusterModernImpl(ActivityManagerService service, ProcessList processList,
    OomAdjusterImpl(ActivityManagerService service, ProcessList processList,
            ActiveUids activeUids, ServiceThread adjusterThread, GlobalState globalState,
            CachedAppOptimizer cachedAppOptimizer, Injector injector) {
        super(service, processList, activeUids, adjusterThread, globalState, cachedAppOptimizer,
+0 −1771

File deleted.

Preview size limit exceeded, changes collapsed.

Loading