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

Commit 194a77a0 authored by Aka (Chih-Yu) Huang's avatar Aka (Chih-Yu) Huang Committed by Android (Google) Code Review
Browse files

Merge changes I39bdb494,Id8926501,I7bccd1ce,I8999044b,I313288c0, ... into main

* changes:
  psc: Add ProcessReceiverRecordInternal
  psc: move linked list node to ProcessRecordInternal
  psc: Refactor ServiceRecord host process access
  psc: make ProcessRecordInternal access ProcessServiceRecordInternal
  psc: Add ProcessProviderRecordInternal
  psc: Add ContentProviderRecordInternal
  psc: Introduce ProcessServiceRecordInternal
parents 0b4e1d2f b2379a9c
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -5306,8 +5306,7 @@ public final class ActiveServices {
            if (r.app != null) {
                psr = r.app.mServices;
                mAm.mProcessStateController.startExecutingService(psr, r);
                mAm.mProcessStateController.setExecServicesFg(psr,
                        psr.shouldExecServicesFg() || fg);
                mAm.mProcessStateController.setExecServicesFg(psr, psr.isExecServicesFg() || fg);
                if (timeoutNeeded && psr.numberOfExecutingServices() == 1) {
                    if (!shouldSkipTimeout) {
                        scheduleServiceTimeoutLocked(r.app);
@@ -5318,7 +5317,7 @@ public final class ActiveServices {
            }
        } else if (r.app != null && fg) {
            psr = r.app.mServices;
            if (!psr.shouldExecServicesFg()) {
            if (!psr.isExecServicesFg()) {
                mAm.mProcessStateController.setExecServicesFg(psr, true);
                if (timeoutNeeded) {
                    if (!shouldSkipTimeout) {
@@ -7714,7 +7713,7 @@ public final class ActiveServices {
                }
                final long now = SystemClock.uptimeMillis();
                final long maxTime =  now
                        - (psr.shouldExecServicesFg()
                        - (psr.isExecServicesFg()
                        ? mAm.mConstants.SERVICE_TIMEOUT
                        : mAm.mConstants.SERVICE_BACKGROUND_TIMEOUT);
                ServiceRecord timeout = null;
@@ -7746,7 +7745,7 @@ public final class ActiveServices {
                    mActiveServiceAnrTimer.accept(proc, timeoutRecord);
                } else {
                    mActiveServiceAnrTimer.discard(proc);
                    final long delay = psr.shouldExecServicesFg()
                    final long delay = psr.isExecServicesFg()
                                       ? (nextTime + mAm.mConstants.SERVICE_TIMEOUT) :
                                       (nextTime + mAm.mConstants.SERVICE_BACKGROUND_TIMEOUT)
                                       - SystemClock.uptimeMillis();
@@ -7890,7 +7889,7 @@ public final class ActiveServices {
        if (proc.mServices.numberOfExecutingServices() == 0 || proc.getThread() == null) {
            return;
        }
        final long delay = proc.mServices.shouldExecServicesFg()
        final long delay = proc.mServices.isExecServicesFg()
                ? mAm.mConstants.SERVICE_TIMEOUT : mAm.mConstants.SERVICE_BACKGROUND_TIMEOUT;
        mActiveServiceAnrTimer.start(proc, delay);
        proc.mServices.noteScheduleServiceTimeoutPending(false);
+2 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PROVIDER;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;

import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.os.Binder;
import android.os.SystemClock;
import android.util.Slog;
@@ -117,8 +116,8 @@ public final class ContentProviderConnection extends Binder implements
    }

    @Override
    public ComponentName getProviderName() {
        return provider.name;
    public ContentProviderRecord getProvider() {
        return provider;
    }

    public void stopAssociation() {
+23 −4
Original line number Diff line number Diff line
@@ -37,11 +37,13 @@ import android.util.Slog;

import com.android.internal.app.procstats.AssociationState;
import com.android.internal.app.procstats.ProcessStats;
import com.android.server.am.psc.ContentProviderRecordInternal;

import java.io.PrintWriter;
import java.util.ArrayList;

final class ContentProviderRecord implements ComponentName.WithComponentName {
final class ContentProviderRecord extends ContentProviderRecordInternal
        implements ComponentName.WithComponentName {
    // Maximum attempts to bring up the content provider before giving up.
    static final int MAX_RETRY_COUNT = 3;

@@ -49,7 +51,6 @@ final class ContentProviderRecord implements ComponentName.WithComponentName {
    public final ProviderInfo info;
    final int uid;
    final ApplicationInfo appInfo;
    final ComponentName name;
    final boolean singleton;
    public IContentProvider provider;
    public boolean noReleaseNeeded;
@@ -69,22 +70,24 @@ final class ContentProviderRecord implements ComponentName.WithComponentName {

    public ContentProviderRecord(ActivityManagerService _service, ProviderInfo _info,
            ApplicationInfo ai, ComponentName _name, boolean _singleton) {
        super(_name);

        service = _service;
        info = _info;
        uid = ai.uid;
        appInfo = ai;
        name = _name;
        singleton = _singleton;
        noReleaseNeeded = (uid == 0 || uid == Process.SYSTEM_UID)
                && (_name == null || !"com.android.settings".equals(_name.getPackageName()));
    }

    public ContentProviderRecord(ContentProviderRecord cpr) {
        super(cpr.name);

        service = cpr.service;
        info = cpr.info;
        uid = cpr.uid;
        appInfo = cpr.appInfo;
        name = cpr.name;
        singleton = cpr.singleton;
        noReleaseNeeded = cpr.noReleaseNeeded;
    }
@@ -187,6 +190,7 @@ final class ContentProviderRecord implements ComponentName.WithComponentName {
        }
    }

    @Override
    public boolean hasExternalProcessHandles() {
        return (externalProcessTokenToHandle != null || externalProcessNoHandleCount > 0);
    }
@@ -239,6 +243,21 @@ final class ContentProviderRecord implements ComponentName.WithComponentName {
        }
    }

    @Override
    public ProcessRecord getHostProcess() {
        return proc;
    }

    @Override
    public int numberOfConnections() {
        return connections.size();
    }

    @Override
    public ContentProviderConnection getConnectionsAt(int index) {
        return connections.get(index);
    }

    void dump(PrintWriter pw, String prefix, boolean full) {
        if (full) {
            pw.print(prefix); pw.print("package=");
+20 −18
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ import com.android.server.am.psc.ContentProviderConnectionInternal;
import com.android.server.am.psc.PlatformCompatCache;
import com.android.server.am.psc.PlatformCompatCache.CachedCompatChangeId;
import com.android.server.am.psc.ProcessRecordInternal;
import com.android.server.am.psc.ProcessServiceRecordInternal;
import com.android.server.am.psc.ServiceRecordInternal;
import com.android.server.am.psc.UidRecordInternal;
import com.android.server.wm.WindowProcessController;
@@ -652,7 +653,7 @@ public abstract class OomAdjuster {
        if (!includeWarmPkg) {
            return;
        }
        final ProcessServiceRecord psr = app.mServices;
        final ProcessServiceRecordInternal psr = app.mServices;
        for (int j = psr.numberOfRunningServices() - 1; j >= 0; j--) {
            psr.getRunningServiceAt(j).updateKeepWarmLocked();
        }
@@ -782,7 +783,8 @@ public abstract class OomAdjuster {
            for (int i = psr.numberOfConnections() - 1; i >= 0; i--) {
                ConnectionRecord cr = psr.getConnectionAt(i);
                ProcessRecord service = cr.hasFlag(ServiceInfo.FLAG_ISOLATED_PROCESS)
                        ? cr.binding.service.isolationHostProc : cr.binding.service.app;
                        ? cr.binding.service.getIsolationHostProcess()
                        : cr.binding.service.getHostProcess();
                if (service == null || service == pr
                        || ((service.getMaxAdj() >= ProcessList.SYSTEM_ADJ)
                                && (service.getMaxAdj() < FOREGROUND_APP_ADJ))) {
@@ -800,10 +802,10 @@ public abstract class OomAdjuster {
                queue.offer(service);
                service.setReachable(true);
            }
            final ProcessProviderRecord ppr = pr.mProviders;
            final ProcessProviderRecord ppr = pr.getProviders();
            for (int i = ppr.numberOfProviderConnections() - 1; i >= 0; i--) {
                ContentProviderConnection cpc = ppr.getProviderConnectionAt(i);
                ProcessRecord provider = cpc.provider.proc;
                ProcessRecord provider = cpc.provider.getHostProcess();
                if (provider == null || provider == pr
                        || ((provider.getMaxAdj() >= ProcessList.SYSTEM_ADJ)
                                && (provider.getMaxAdj() < FOREGROUND_APP_ADJ))) {
@@ -1064,7 +1066,7 @@ public abstract class OomAdjuster {
                        targetAdj += 10 + mConstants.TIERED_CACHED_ADJ_UI_TIER_SIZE;
                    }
                    state.setCurRawAdj(targetAdj);
                    state.setCurAdj(applyBindAboveClientToAdj(psr.hasAboveClient(), targetAdj));
                    state.setCurAdj(applyBindAboveClientToAdj(psr.isHasAboveClient(), targetAdj));
                }
            }
        } else {
@@ -1121,7 +1123,7 @@ public abstract class OomAdjuster {
                } else if (!app.isKilledByAm() && app.getThread() != null
                               && curAdj >= UNKNOWN_ADJ) {
                    // If we haven't yet assigned the final cached adj to the process, do that now.
                    final ProcessServiceRecord psr = app.mServices;
                    final ProcessServiceRecordInternal psr = app.mServices;
                    switch (state.getCurProcState()) {
                        case PROCESS_STATE_LAST_ACTIVITY:
                        case PROCESS_STATE_CACHED_ACTIVITY:
@@ -1168,7 +1170,7 @@ public abstract class OomAdjuster {
                            final int rawAdj = curCachedAdj + curCachedImpAdj;
                            state.setCurRawAdj(rawAdj);
                            state.setCurAdj(
                                    applyBindAboveClientToAdj(psr.hasAboveClient(), rawAdj));
                                    applyBindAboveClientToAdj(psr.isHasAboveClient(), rawAdj));
                            if (DEBUG_LRU) {
                                Slog.d(TAG_LRU, "Assigning activity LRU #" + i
                                        + " adj: " + state.getCurAdj()
@@ -1195,8 +1197,8 @@ public abstract class OomAdjuster {
                            // cached level will be treated as empty (since their process
                            // state is still as a service), which is what we want.
                            state.setCurRawAdj(curEmptyAdj);
                            state.setCurAdj(
                                    applyBindAboveClientToAdj(psr.hasAboveClient(), curEmptyAdj));
                            state.setCurAdj(applyBindAboveClientToAdj(psr.isHasAboveClient(),
                                    curEmptyAdj));
                            if (DEBUG_LRU) {
                                Slog.d(TAG_LRU, "Assigning empty LRU #" + i
                                        + " adj: " + state.getCurAdj()
@@ -1853,9 +1855,9 @@ public abstract class OomAdjuster {
        }
    }

    protected boolean isReceivingBroadcast(ProcessRecord app) {
    protected boolean isReceivingBroadcast(ProcessRecordInternal app) {
        if (Flags.pushBroadcastStateToOomadjuster()) {
            return app.mReceivers.isReceivingBroadcast();
            return app.getReceivers().isReceivingBroadcast();
        } else {
            return app.getCachedIsReceivingBroadcast(mTmpSchedGroup);
        }
@@ -1932,7 +1934,7 @@ public abstract class OomAdjuster {
    protected int setIntermediateAdjLSP(ProcessRecordInternal app, int adj, int schedGroup) {
        app.setCurRawAdj(adj);

        adj = applyBindAboveClientToAdj(app.hasAboveClient(), adj);
        adj = applyBindAboveClientToAdj(app.getServices().isHasAboveClient(), adj);
        if (adj > app.getMaxAdj()) {
            adj = app.getMaxAdj();
            if (adj <= PERCEPTIBLE_LOW_APP_ADJ) {
@@ -2056,14 +2058,14 @@ public abstract class OomAdjuster {
            // Process has user perceptible activities.
            return CPU_TIME_REASON_OTHER;
        }
        if (app.mServices.numberOfExecutingServices() > 0) {
        if (app.mServices.hasExecutingServices()) {
            // Ensure that services get cpu time during start-up and tear-down.
            return CPU_TIME_REASON_OTHER;
        }
        if (app.mServices.hasForegroundServices()) {
            return CPU_TIME_REASON_OTHER;
        }
        if (app.mReceivers.isReceivingBroadcast()) {
        if (app.getReceivers().isReceivingBroadcast()) {
            return CPU_TIME_REASON_OTHER;
        }
        if (app.hasActiveInstrumentation()) {
@@ -2244,7 +2246,7 @@ public abstract class OomAdjuster {
        }

        final int curSchedGroup = state.getCurrentSchedulingGroup();
        if (app.getWaitingToKill() != null && !app.mReceivers.isReceivingBroadcast()
        if (app.getWaitingToKill() != null && !app.getReceivers().isReceivingBroadcast()
                && ActivityManager.isProcStateBackground(state.getCurProcState())
                && !state.getHasStartedServices()) {
            app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED,
@@ -2873,19 +2875,19 @@ public abstract class OomAdjuster {
    }

    @GuardedBy("mService")
    abstract void onProcessEndLocked(@NonNull ProcessRecord app);
    abstract void onProcessEndLocked(@NonNull ProcessRecordInternal app);

    /**
     * Called when the process state is changed outside of the OomAdjuster.
     */
    @GuardedBy("mService")
    abstract void onProcessStateChanged(@NonNull ProcessRecord app, int prevProcState);
    abstract void onProcessStateChanged(@NonNull ProcessRecordInternal app, int prevProcState);

    /**
     * Called when the oom adj is changed outside of the OomAdjuster.
     */
    @GuardedBy("mService")
    abstract void onProcessOomAdjChanged(@NonNull ProcessRecord app, int prevAdj);
    abstract void onProcessOomAdjChanged(@NonNull ProcessRecordInternal app, int prevAdj);

    @VisibleForTesting
    abstract void resetInternal();
+51 −46

File changed.

Preview size limit exceeded, changes collapsed.

Loading