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

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

Move LRU sequence to ProcessStateRecord

Move the `mLruSeq` field and its accessor methods from `ProcessRecord`
to `ProcessStateRecord`. This is a pure refactor that enhances
encapsulation and reduces `ProcessRecord`'s direct dependency on
LRU cycle details.

Bug: 425766486
Test: atest MockingOomAdjusterTests
Flag: EXEMPT pure refactor
Change-Id: Idb583186733820b8c64f2116a6129f5dd3d1731b
parent b7f85d5b
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3708,7 +3708,7 @@ public final class ProcessList {
            if (DEBUG_LRU) Slog.d(TAG_LRU, "Moving dep from " + lrui + " to " + index
                    + " in LRU list: " + app);
            mLruProcesses.add(index, app);
            app.setLruSeq(mLruSeq);
            app.mState.setLruSeq(mLruSeq);

            if (isActivity) {
                nextActivityIndex = index;
@@ -4114,7 +4114,7 @@ public final class ProcessList {
            }
        }

        app.setLruSeq(mLruSeq);
        app.mState.setLruSeq(mLruSeq);

        // Key of the indices array holds the current index of the process in the LRU list and the
        // value is a boolean indicating whether the process is an activity process or not.
@@ -4131,7 +4131,7 @@ public final class ProcessList {
            ConnectionRecord cr = psr.getConnectionAt(j);
            if (cr.binding != null && !cr.serviceDead && cr.binding.service != null
                    && cr.binding.service.app != null
                    && cr.binding.service.app.getLruSeq() != mLruSeq
                    && cr.binding.service.app.mState.getLruSeq() != mLruSeq
                    && cr.notHasFlag(Context.BIND_REDUCTION_FLAGS)
                    && !cr.binding.service.app.isPersistent()) {
                if (cr.binding.service.app.mServices.hasClientActivities()) {
@@ -4148,7 +4148,8 @@ public final class ProcessList {
        final ProcessProviderRecord ppr = app.mProviders;
        for (int j = ppr.numberOfProviderConnections() - 1; j >= 0; j--) {
            ContentProviderRecord cpr = ppr.getProviderConnectionAt(j).provider;
            if (cpr.proc != null && cpr.proc.getLruSeq() != mLruSeq && !cpr.proc.isPersistent()) {
            if (cpr.proc != null && cpr.proc.mState.getLruSeq() != mLruSeq
                    && !cpr.proc.isPersistent()) {
                indices.append(offerLruProcessInternalLSP(cpr.proc, now,
                        "provider reference", cpr, app), false);
            }
+3 −16
Original line number Diff line number Diff line
@@ -339,12 +339,6 @@ class ProcessRecord implements WindowProcessListener {
    @GuardedBy("mService")
    private boolean mUsingWrapper;

    /**
     * Sequence id for identifying LRU update cycles.
     */
    @GuardedBy("mService")
    private int mLruSeq;

    /**
     * Class to run on start if this is a special isolated process.
     */
@@ -562,6 +556,9 @@ class ProcessRecord implements WindowProcessListener {
        if (mState.getSetProcState() > ActivityManager.PROCESS_STATE_SERVICE) {
            mProfile.dumpCputime(pw, prefix);
        }
        if (mProfile.hasPendingUiClean()) {
            pw.print(prefix); pw.print("pendingUiClean="); pw.println(mProfile.hasPendingUiClean());
        }
        mProfile.dumpPss(pw, prefix, nowUptime);
        mState.dump(pw, prefix, nowUptime);
        mErrorState.dump(pw, prefix, nowUptime);
@@ -1138,16 +1135,6 @@ class ProcessRecord implements WindowProcessListener {
        mWindowProcessController.setUsingWrapper(usingWrapper);
    }

    @GuardedBy("mService")
    int getLruSeq() {
        return mLruSeq;
    }

    @GuardedBy("mService")
    void setLruSeq(int lruSeq) {
        mLruSeq = lruSeq;
    }

    @GuardedBy("mService")
    String getIsolatedEntryPoint() {
        return mIsolatedEntryPoint;
+19 −4
Original line number Diff line number Diff line
@@ -356,6 +356,12 @@ public final class ProcessStateRecord {
    @GuardedBy("mService")
    private int mCompletedAdjSeq;

    /**
     * Sequence id for identifying LRU update cycles.
     */
    @GuardedBy("mService")
    private int mLruSeq;

    /**
     * When (uptime) the process last became unimportant.
     */
@@ -928,6 +934,16 @@ public final class ProcessStateRecord {
        return mCompletedAdjSeq;
    }

    @GuardedBy("mService")
    int getLruSeq() {
        return mLruSeq;
    }

    @GuardedBy("mService")
    void setLruSeq(int lruSeq) {
        mLruSeq = lruSeq;
    }

    @GuardedBy({"mService", "mProcLock"})
    void setWhenUnimportant(long whenUnimportant) {
        mWhenUnimportant = whenUnimportant;
@@ -1440,7 +1456,7 @@ public final class ProcessStateRecord {
            pw.println();
        }
        pw.print(prefix); pw.print("adjSeq="); pw.print(mAdjSeq);
        pw.print(" lruSeq="); pw.println(mApp.getLruSeq());
        pw.print(" lruSeq="); pw.println(mLruSeq);
        pw.print(prefix); pw.print("oom adj: max="); pw.print(mMaxAdj);
        pw.print(" curRaw="); pw.print(mCurRawAdj);
        pw.print(" setRaw="); pw.print(mSetRawAdj);
@@ -1467,9 +1483,8 @@ public final class ProcessStateRecord {
            pw.print(mSetBoundByNonBgRestrictedApp);
        }
        pw.println();
        if (mHasShownUi || mApp.mProfile.hasPendingUiClean()) {
            pw.print(prefix); pw.print("hasShownUi="); pw.print(mHasShownUi);
            pw.print(" pendingUiClean="); pw.println(mApp.mProfile.hasPendingUiClean());
        if (mHasShownUi) {
            pw.print(prefix); pw.print("hasShownUi="); pw.println(mHasShownUi);
        }
        pw.print(prefix); pw.print("cached="); pw.print(isCached());
        pw.print(" empty="); pw.println(isEmpty());