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

Commit 0cf08da2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "psc: ConnectionRecordInternal accesses ServiceRecordInternal" into main

parents 206589a3 c82d0007
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.util.proto.ProtoUtils;
import com.android.internal.app.procstats.AssociationState;
import com.android.internal.app.procstats.ProcessStats;
import com.android.server.am.psc.ConnectionRecordInternal;
import com.android.server.am.psc.ServiceRecordInternal;
import com.android.server.wm.ActivityServiceConnectionsHolder;

import java.io.PrintWriter;
@@ -145,13 +146,8 @@ final class ConnectionRecord extends ConnectionRecordInternal {
    }

    @Override
    public long getServiceLastActivityTimeMillis() {
        return binding.service.getLastActivity();
    }

    @Override
    public ComponentName getServiceInstanceName() {
        return binding.service.instanceName;
    public ServiceRecordInternal getService() {
        return binding.service;
    }

    public void startAssociationIfNeeded() {
+3 −3
Original line number Diff line number Diff line
@@ -1989,7 +1989,7 @@ public class OomAdjusterImpl extends OomAdjuster {
                    clientAdj = adj;
                    clientProcState = procState;
                } else {
                    if (now >= (cr.getServiceLastActivityTimeMillis()
                    if (now >= (cr.getService().getLastActivity()
                            + mConstants.MAX_SERVICE_INACTIVITY)) {
                        // This service has not seen activity within
                        // recent memory, so allow it to drop to the
@@ -2183,7 +2183,7 @@ public class OomAdjusterImpl extends OomAdjuster {
                app.setAdjTypeCode(ActivityManager.RunningAppProcessInfo.REASON_SERVICE_IN_USE);
                app.setAdjSource(client);
                app.setAdjSourceProcState(clientProcState);
                app.setAdjTarget(cr.getServiceInstanceName());
                app.setAdjTarget(cr.getService().instanceName);
                if (reportDebugMsgs) {
                    reportOomAdjMessageLocked(TAG_OOM_ADJ, "Raise to " + adjType
                            + ": " + app + ", due to " + client
@@ -2248,7 +2248,7 @@ public class OomAdjusterImpl extends OomAdjuster {
                    app.setAdjTypeCode(ActivityManager.RunningAppProcessInfo.REASON_SERVICE_IN_USE);
                    app.setAdjSource(a);
                    app.setAdjSourceProcState(procState);
                    app.setAdjTarget(cr.getServiceInstanceName());
                    app.setAdjTarget(cr.getService().instanceName);
                    if (reportDebugMsgs) {
                        reportOomAdjMessageLocked(TAG_OOM_ADJ,
                                "Raise to service w/activity: " + app);
+2 −5
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@ final class ServiceRecord extends ServiceRecordInternal implements ComponentName

    final ActivityManagerService ams;
    final ComponentName name; // service component.
    final ComponentName instanceName; // service component's per-instance name.
    final String shortInstanceName; // instanceName.flattenToShortString().
    final String definingPackageName;
                            // Can be different from appInfo.packageName for external services
@@ -1100,11 +1099,10 @@ final class ServiceRecord extends ServiceRecordInternal implements ComponentName

    /** Used only for tests */
    private ServiceRecord(ActivityManagerService ams) {
        super(0);
        super(null, 0);

        this.ams = ams;
        name = null;
        instanceName = null;
        shortInstanceName = null;
        definingPackageName = null;
        definingUid = 0;
@@ -1140,11 +1138,10 @@ final class ServiceRecord extends ServiceRecordInternal implements ComponentName
            Intent.FilterComparison intent, ServiceInfo sInfo, boolean callerIsFg,
            Runnable restarter, String processName, int sdkSandboxClientAppUid,
            String sdkSandboxClientAppPackage, boolean inSharedIsolatedProcess) {
        super(SystemClock.uptimeMillis());
        super(instanceName, SystemClock.uptimeMillis());

        this.ams = ams;
        this.name = name;
        this.instanceName = instanceName;
        shortInstanceName = instanceName.flattenToShortString();
        this.definingPackageName = definingPackageName;
        this.definingUid = definingUid;
+2 −13
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.am.psc;

import android.content.ComponentName;
import android.content.Context;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;

@@ -38,18 +37,8 @@ public abstract class ConnectionRecordInternal implements OomAdjusterImpl.Connec
    /** Returns the {@link ActivityServiceConnectionsHolder} associated with this connection. */
    public abstract ActivityServiceConnectionsHolder getActivity();

    /**
     * Returns the last activity time of the service associated with this connection,
     * in milliseconds.
     * TODO(b/425766486): Remove it once ConnectionRecordInternal could access ServiceRecord.
     */
    public abstract long getServiceLastActivityTimeMillis();

    /**
     * Returns the {@link ComponentName} of the service instance that this connection is bound to.
     * TODO(b/425766486): Remove it once ConnectionRecordInternal could access ServiceRecord.
     */
    public abstract ComponentName getServiceInstanceName();
    /** Returns the service associated with this connection. */
    public abstract ServiceRecordInternal getService();

    /** Tracks the current process state and sequence number for association management. */
    public abstract void trackProcState(int procState, int seq);
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.am.psc;

import android.content.ComponentName;
import android.os.Binder;

/**
@@ -25,6 +26,9 @@ import android.os.Binder;
 * TODO(b/425766486): Make setter methods package-private once OomAdjuster is migrated to psc.
 */
public abstract class ServiceRecordInternal extends Binder {
    /** The service component's per-instance name. */
    public final ComponentName instanceName;

    /** Whether the service has been explicitly requested to start by an application. */
    private boolean mStartRequested;
    /** Whether the service is currently running in foreground mode. */
@@ -39,7 +43,8 @@ public abstract class ServiceRecordInternal extends Binder {
    /** The bitmask of foreground service types declared for this service. */
    private int mForegroundServiceType;

    public ServiceRecordInternal(long lastActivity) {
    public ServiceRecordInternal(ComponentName instanceName, long lastActivity) {
        this.instanceName = instanceName;
        mLastActivity = lastActivity;
    }