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

Commit e0058e6c authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

[7/N] Simplify Service/Provider policy method signatures

Now that the Legacy OomAdjuster is gone, many of the arguments are no
longer needed.

Flag: EXEMPT pure refactor
Test: atest MockingOomAdjusterTests
Test: builds and flashes
Bug: 306731120
Change-Id: I7940d56bed08a6857b9e953697ed5594b8b47f8d
parent 7e3bcf31
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.am;

import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ProcessList.UNKNOWN_ADJ;

import android.annotation.Nullable;
import android.app.IServiceConnection;
@@ -132,8 +131,7 @@ final class ConnectionRecord implements OomAdjusterImpl.Connection{
    public void computeHostOomAdjLSP(OomAdjuster oomAdjuster, ProcessRecord host,
            ProcessRecord client, long now, ProcessRecord topApp, boolean doingAll,
            int oomAdjReason, int cachedAdj) {
        oomAdjuster.computeServiceHostOomAdjLSP(this, host, client, now, topApp, doingAll, false,
                false, oomAdjReason, UNKNOWN_ADJ, false, false);
        oomAdjuster.computeServiceHostOomAdjLSP(this, host, client, now, false);
    }

    @Override
+1 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.server.am;

import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROVIDER;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ProcessList.UNKNOWN_ADJ;

import android.annotation.UserIdInt;
import android.os.Binder;
@@ -78,8 +77,7 @@ public final class ContentProviderConnection extends Binder implements
    public void computeHostOomAdjLSP(OomAdjuster oomAdjuster, ProcessRecord host,
            ProcessRecord client, long now, ProcessRecord topApp, boolean doingAll,
            int oomAdjReason, int cachedAdj) {
        oomAdjuster.computeProviderHostOomAdjLSP(this, host, client, now, topApp, doingAll, false,
                false, oomAdjReason, UNKNOWN_ADJ, false, false);
        oomAdjuster.computeProviderHostOomAdjLSP(this, host, client, false);
    }

    @Override
+4 −12
Original line number Diff line number Diff line
@@ -1745,18 +1745,14 @@ public abstract class OomAdjuster {
     */
    @GuardedBy({"mService", "mProcLock"})
    public abstract boolean computeServiceHostOomAdjLSP(ConnectionRecord cr, ProcessRecord app,
            ProcessRecord client, long now, ProcessRecord topApp, boolean doingAll,
            boolean cycleReEval, boolean computeClients, int oomAdjReason, int cachedAdj,
            boolean couldRecurse, boolean dryRun);
            ProcessRecord client, long now, boolean dryRun);

    /**
     * Computes the impact on {@code app} the provider connections from {@code client} has.
     */
    @GuardedBy({"mService", "mProcLock"})
    public abstract boolean computeProviderHostOomAdjLSP(ContentProviderConnection conn,
            ProcessRecord app, ProcessRecord client, long now, ProcessRecord topApp,
            boolean doingAll, boolean cycleReEval, boolean computeClients, int oomAdjReason,
            int cachedAdj, boolean couldRecurse, boolean dryRun);
            ProcessRecord app, ProcessRecord client, boolean dryRun);

    protected int getDefaultCapability(ProcessRecord app, int procState) {
        final int networkCapabilities =
@@ -2644,8 +2640,7 @@ public abstract class OomAdjuster {
            // Take a dry run of the computeServiceHostOomAdjLSP, this would't be expensive
            // since it's only evaluating one service connection.
            return computeServiceHostOomAdjLSP(cr, app, client, mInjector.getUptimeMillis(),
                    mService.getTopApp(), false, false, false, OOM_ADJ_REASON_NONE,
                    CACHED_APP_MIN_ADJ, false, true /* dryRun */);
                    true /* dryRun */);
        }
        return false;
    }
@@ -2706,10 +2701,7 @@ public abstract class OomAdjuster {
        }

        if (needDryRun) {
            return computeProviderHostOomAdjLSP(null, app, client, mInjector.getUptimeMillis(),
                    mService.getTopApp(), false, false, false, OOM_ADJ_REASON_NONE,
                    CACHED_APP_MIN_ADJ,
                    false, true /* dryRun */);
            return computeProviderHostOomAdjLSP(null, app, client, true /* dryRun */);
        }
        return false;
    }
+1 −18
Original line number Diff line number Diff line
@@ -1995,15 +1995,6 @@ public class OomAdjusterImpl extends OomAdjuster {
    @GuardedBy({"mService", "mProcLock"})
    @Override
    public boolean computeServiceHostOomAdjLSP(ConnectionRecord cr, ProcessRecord app,
            ProcessRecord client, long now, ProcessRecord topApp, boolean doingAll,
            boolean cycleReEval, boolean computeClients, int oomAdjReason, int cachedAdj,
            boolean couldRecurse, boolean dryRun) {
        return computeServiceHostOomAdjLSP(cr, app, client, now, dryRun);
    }


    @GuardedBy({"mService", "mProcLock"})
    private boolean computeServiceHostOomAdjLSP(ConnectionRecord cr, ProcessRecord app,
            ProcessRecord client, long now, boolean dryRun) {
        if (app.isPendingFinishAttach()) {
            // We've set the attaching process state in the computeInitialOomAdjLSP. Skip it here.
@@ -2460,15 +2451,7 @@ public class OomAdjusterImpl extends OomAdjuster {

    @GuardedBy({"mService", "mProcLock"})
    @Override
    public boolean computeProviderHostOomAdjLSP(ContentProviderConnection conn,
            ProcessRecord app, ProcessRecord client, long now, ProcessRecord topApp,
            boolean doingAll, boolean cycleReEval, boolean computeClients, int oomAdjReason,
            int cachedAdj, boolean couldRecurse, boolean dryRun) {
        return computeProviderHostOomAdjLSP(conn, app, client, dryRun);
    }

    @GuardedBy({"mService", "mProcLock"})
    private boolean computeProviderHostOomAdjLSP(ContentProviderConnection conn, ProcessRecord app,
    public boolean computeProviderHostOomAdjLSP(ContentProviderConnection conn, ProcessRecord app,
            ProcessRecord client, boolean dryRun) {
        if (app.isPendingFinishAttach()) {
            // We've set the attaching process state in the computeInitialOomAdjLSP. Skip it here.