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

Commit e7fdf6b4 authored by Chih-Yu Huang's avatar Chih-Yu Huang
Browse files

psc: make ProcessRecordInternal access ProcessServiceRecordInternal

Previously, ProcessRecordInternal had direct accessors for
service-related fields like hasAboveClient and setTreatLikeActivity.

This change refactors these to be accessed via
ProcessServiceRecordInternal, which is now exposed through
ProcessRecordInternal.getServices().

Bug: 425766486
Test: m services.core
Test: atest MockingOomAdjusterTests OomAdjusterTests
Test: atest FrameworksServicesTestsRavenwood_ProcessStateController
Flag: EXEMPT pure refactor

Change-Id: I8999044bf8fbf93a541f72acaeb9d5d8239973b5
parent 6eeabb4b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1933,7 +1933,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) {
+1 −1
Original line number Diff line number Diff line
@@ -2216,7 +2216,7 @@ public class OomAdjusterImpl extends OomAdjuster {
        }
        if (cr.hasFlag(Context.BIND_TREAT_LIKE_ACTIVITY)) {
            if (!dryRun) {
                app.setTreatLikeActivity(true);
                app.getServices().setTreatLikeActivity(true);
            }
            if (clientProcState <= PROCESS_STATE_CACHED_ACTIVITY
                    && procState > PROCESS_STATE_CACHED_ACTIVITY) {
+2 −7
Original line number Diff line number Diff line
@@ -1170,13 +1170,8 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
    }

    @Override
    public boolean hasAboveClient() {
        return mServices.isHasAboveClient();
    }

    @Override
    public void setTreatLikeActivity(boolean treatLikeActivity) {
        mServices.setTreatLikeActivity(treatLikeActivity);
    public ProcessServiceRecord getServices() {
        return mServices;
    }

    @Override
+3 −13
Original line number Diff line number Diff line
@@ -188,19 +188,6 @@ public abstract class ProcessRecordInternal {
     */
    public abstract boolean hasCompatChange(@CachedCompatChangeId int cachedCompatChangeId);

    /**
     * Returns whether this process has bound to a service with
     * {@link android.content.Context#BIND_ABOVE_CLIENT}.
     * TODO(b/425766486): Remove it once ProcessRecordInternal could access ProcessServiceRecord.
     */
    public abstract boolean hasAboveClient();

    /**
     * Sets whether this process should be treated as if it has an activity.
     * TODO(b/425766486): Remove it once ProcessRecordInternal could access ProcessServiceRecord.
     */
    public abstract void setTreatLikeActivity(boolean treatLikeActivity);

    /** Returns true if there is an active instrumentation running in this process. */
    public abstract boolean hasActiveInstrumentation();

@@ -226,6 +213,9 @@ public abstract class ProcessRecordInternal {
    /** Returns the {@link UidRecordInternal} associated with this process. */
    public abstract UidRecordInternal getUidRecord();

    /** Returns the internal service-related record for this process. */
    public abstract ProcessServiceRecordInternal getServices();

    /** Returns the internal content provider related record for this process. */
    public abstract ProcessProviderRecordInternal getProviders();