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

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

Merge changes Id751ea7c,Id9da2f66,I4ca546c5,I734e23fd,I6835aaaa, ... into main

* changes:
  am: Make computeOomAdjLSP() use ProcessRecordInternal
  am: Make unfreezeTemporarily() use ProcessRecordInternal
  am: Make OomAdjuster.evaluateConnectionPrelude to use internal classes
  am: Make maybeSetProcessFollowUpUpdateLocked use internal class
  am: Make setAttachingProcessStatesLSP use internal class
  am: Make forEachConnectionLSP use internal classes
parents 1f332672 a384a282
Loading
Loading
Loading
Loading
+108 −118

File changed.

Preview size limit exceeded, changes collapsed.

+178 −176

File changed.

Preview size limit exceeded, changes collapsed.

+83 −45
Original line number Diff line number Diff line
@@ -95,8 +95,6 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
    volatile ApplicationInfo info; // all about the first app in the process
    final ProcessInfo processInfo; // if non-null, process-specific manifest info
    final boolean appZygote;    // true if this is forked from the app zygote
    final int userId;           // user of process.
    final String processName;   // name of the process
    final String sdkSandboxClientAppPackage; // if this is an sdk sandbox process, name of the
                                             // app package for which it is running
    final String sdkSandboxClientAppVolumeUuid; // uuid of the app for which the sandbox is running
@@ -279,18 +277,6 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
    @CompositeRWLock({"mService", "mProcLock"})
    private ActiveInstrumentation mInstr;

    /**
     * True when proc has been killed by activity manager, not for RAM.
     */
    @CompositeRWLock({"mService", "mProcLock"})
    private boolean mKilledByAm;

    /**
     * True once we know the process has been killed.
     */
    @CompositeRWLock({"mService", "mProcLock"})
    private boolean mKilled;

    /**
     * The timestamp in uptime when this process was killed.
     */
@@ -530,9 +516,9 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        pw.print(prefix); pw.print("startSeq="); pw.println(mStartSeq);
        pw.print(prefix); pw.print("mountMode="); pw.println(
                DebugUtils.valueToString(Zygote.class, "MOUNT_EXTERNAL_", mMountMode));
        if (mKilled || mKilledByAm || mWaitingToKill != null) {
            pw.print(prefix); pw.print("killed="); pw.print(mKilled);
            pw.print(" killedByAm="); pw.print(mKilledByAm);
        if (isKilled() || isKilledByAm() || mWaitingToKill != null) {
            pw.print(prefix); pw.print("killed="); pw.print(isKilled());
            pw.print(" killedByAm="); pw.print(isKilledByAm());
            pw.print(" waitingToKill="); pw.println(mWaitingToKill);
        }
        if (mIsolatedEntryPoint != null || mIsolatedEntryPointArgs != null) {
@@ -593,8 +579,6 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        processInfo = procInfo;
        appZygote = (UserHandle.getAppId(_uid) >= Process.FIRST_APP_ZYGOTE_ISOLATED_UID
                && UserHandle.getAppId(_uid) <= Process.LAST_APP_ZYGOTE_ISOLATED_UID);
        userId = UserHandle.getUserId(_uid);
        processName = _processName;
        sdkSandboxClientAppPackage = _sdkSandboxClientAppPackage;
        if (isSdkSandbox) {
            final ApplicationInfo clientInfo = getClientInfoForSdkSandbox();
@@ -677,8 +661,9 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        mPkgDeps = pkgDeps;
    }

    @Override
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    int getPid() {
    public int getPid() {
        return mPid;
    }

@@ -703,6 +688,25 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        return mThread;
    }

    @Override
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    public boolean isProcessRunning() {
        return mThread != null;
    }

    @Override
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    public void setProcessStateToThread(int state) {
        if (mThread == null) {
            return;
        }

        try {
            mThread.setProcessState(state);
        } catch (RemoteException ignored) {
        }
    }

    @GuardedBy(anyOf = {"mService", "mProcLock"})
    IApplicationThread getOnewayThread() {
        return mOnewayThread;
@@ -735,13 +739,21 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        mProfile.onProcessInactive(tracker);
    }

    @Override
    @GuardedBy(anyOf = {"mService", "mProcLock"})
    boolean useFifoUiScheduling() {
    public boolean useFifoUiScheduling() {
        // TODO: b/439611239 - Migrate control of mAllowSpecifiedFifoScheduling to
        //  ProcessStateController.
        return mService.mUseFifoUiScheduling
                || (mService.mAllowSpecifiedFifoScheduling
                        && mWindowProcessController.useFifoUiScheduling());
    }

    @Override
    public void notifyTopProcChanged() {
        mWindowProcessController.onTopProcChanged();
    }

    @GuardedBy("mService")
    int getDyingPid() {
        return mDyingPid;
@@ -981,26 +993,6 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        return mInstr != null;
    }

    @GuardedBy(anyOf = {"mService", "mProcLock"})
    boolean isKilledByAm() {
        return mKilledByAm;
    }

    @GuardedBy({"mService", "mProcLock"})
    void setKilledByAm(boolean killedByAm) {
        mKilledByAm = killedByAm;
    }

    @GuardedBy(anyOf = {"mService", "mProcLock"})
    boolean isKilled() {
        return mKilled;
    }

    @GuardedBy({"mService", "mProcLock"})
    void setKilled(boolean killed) {
        mKilled = killed;
    }

    @GuardedBy(anyOf = {"mService", "mProcLock"})
    long getKillTime() {
        return mKillTime;
@@ -1155,6 +1147,22 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        return mWindowProcessController.hasRecentTasks();
    }

    @Override
    public boolean isShowingUiWhileDozing() {
        return mWindowProcessController.isShowingUiWhileDozing();
    }

    @Override
    public int getActivityStateFlagsLegacy() {
        return mWindowProcessController.getActivityStateFlags();
    }

    @Override
    public long getPerceptibleTaskStoppedTimeMillisLegacy() {
        return mWindowProcessController.getPerceptibleTaskStoppedTimeMillis();
    }


    @Override
    public boolean isReceivingBroadcast(int[] outSchedGroup) {
        return mService.isReceivingBroadcastLocked(this, outSchedGroup);
@@ -1181,6 +1189,21 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        return mReceivers;
    }

    @Override
    public boolean isFrozen() {
        return mOptRecord.isFrozen();
    }

    @Override
    public boolean isPendingFreeze() {
        return mOptRecord.isPendingFreeze();
    }

    @Override
    public boolean isFreezeExempt() {
        return mOptRecord.isFreezeExempt();
    }

    @Override
    public boolean shouldNotFreeze() {
        return mOptRecord.shouldNotFreeze();
@@ -1197,11 +1220,26 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        return mOptRecord.shouldNotFreezeReason();
    }

    @Override
    public int shouldNotFreezeAdjSeq() {
        return mOptRecord.shouldNotFreezeAdjSeq();
    }

    @Override
    public int getApplicationUid() {
        return info.uid;
    }

    @Override
    public long getLastPss() {
        return mProfile.getLastPss();
    }

    @Override
    public long getLastRss() {
        return mProfile.getLastRss();
    }

    boolean hasActivitiesOrRecentTasks() {
        return mWindowProcessController.hasActivitiesOrRecentTasks();
    }
@@ -1257,7 +1295,7 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
    void scheduleCrashLocked(String message, int exceptionTypeId, @Nullable Bundle extras) {
        // Checking killedbyAm should keep it from showing the crash dialog if the process
        // was already dead for a good / normal reason.
        if (!mKilledByAm) {
        if (!isKilledByAm()) {
            if (mThread != null) {
                if (mPid == Process.myPid()) {
                    Slog.w(TAG, "scheduleCrash: trying to crash system process!");
@@ -1309,7 +1347,7 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
    @GuardedBy("mService")
    void killLocked(String reason, String description, @Reason int reasonCode,
            @SubReason int subReason, boolean noisy, boolean asyncKPG) {
        if (!mKilledByAm) {
        if (!isKilledByAm()) {
            if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
                Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                        "kill/" + processName + "/" + reasonCode + "/" + subReason);
@@ -1337,8 +1375,8 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
            }
            if (!mPersistent) {
                synchronized (mProcLock) {
                    mKilled = true;
                    mKilledByAm = true;
                    setKilled(true);
                    setKilledByAm(true);
                    mKillTime = SystemClock.uptimeMillis();
                }
            }
+2 −4
Original line number Diff line number Diff line
@@ -154,10 +154,8 @@ final class ProcessServiceRecord extends ProcessServiceRecordInternal {
        }
    }

    /**
     * @return true if this process has any foreground services (even timed-out short-FGS)
     */
    boolean hasForegroundServices() {
    @Override
    public boolean hasForegroundServices() {
        return mHasForegroundServices;
    }

+5 −5
Original line number Diff line number Diff line
@@ -201,10 +201,10 @@ public class ProcessStateController {
        private volatile boolean mUnlockingStaged = false;
        private boolean mUnlocking = false;
        private boolean mExpandedNotificationShade = false;
        private ProcessRecord mTopProcess = null;
        private ProcessRecordInternal mTopProcess = null;
        private ProcessRecordInternal mHomeProcess = null;
        private ProcessRecordInternal mHeavyWeightProcess = null;
        private ProcessRecord mShowingUiWhileDozingProcess = null;
        private ProcessRecordInternal mShowingUiWhileDozingProcess = null;
        private ProcessRecordInternal mPreviousProcess = null;

        private void commitStagedState() {
@@ -237,7 +237,7 @@ public class ProcessStateController {
        }

        @Nullable
        public ProcessRecord getTopProcess() {
        public ProcessRecordInternal getTopProcess() {
            return mTopProcess;
        }

@@ -252,7 +252,7 @@ public class ProcessStateController {
        }

        @Nullable
        public ProcessRecord getShowingUiWhileDozingProcess() {
        public ProcessRecordInternal getShowingUiWhileDozingProcess() {
            return mShowingUiWhileDozingProcess;
        }

@@ -297,7 +297,7 @@ public class ProcessStateController {
    }

    @GuardedBy("mLock")
    private void setVisibleDozeUiProcess(@Nullable ProcessRecord proc) {
    private void setVisibleDozeUiProcess(@Nullable ProcessRecordInternal proc) {
        mGlobalState.mShowingUiWhileDozingProcess = proc;
    }

Loading