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

Commit 8fc51bd1 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge changes from topic "revert-21648304-SKMVNCOMXL" into udc-dev am:...

Merge "Merge changes from topic "revert-21648304-SKMVNCOMXL" into udc-dev am: 99fac644 am: aa4722fa"
parents 09f67b5a 284a7f23
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -4943,8 +4943,14 @@ public class ActivityManagerService extends IActivityManager.Stub
        EventLogTags.writeAmProcBound(app.userId, pid, app.processName);
        synchronized (mProcLock) {
            mOomAdjuster.setAttachingProcessStatesLSP(app);
            app.mState.setCurAdj(ProcessList.INVALID_ADJ);
            app.mState.setSetAdj(ProcessList.INVALID_ADJ);
            app.mState.setVerifiedAdj(ProcessList.INVALID_ADJ);
            mOomAdjuster.setAttachingSchedGroupLSP(app);
            app.mState.setForcingToImportant(null);
            clearProcessForegroundLocked(app);
            app.mState.setHasShownUi(false);
            app.mState.setCached(false);
            app.setDebugging(false);
            app.setKilledByAm(false);
            app.setKilled(false);
@@ -5112,14 +5118,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                app.makeActive(thread, mProcessStats);
                checkTime(startTime, "attachApplicationLocked: immediately after bindApplication");
            }
            app.setPendingFinishAttach(true);
            updateLruProcessLocked(app, false, null);
            checkTime(startTime, "attachApplicationLocked: after updateLruProcessLocked");
            updateOomAdjLocked(app, OomAdjuster.OOM_ADJ_REASON_PROCESS_BEGIN);
            checkTime(startTime, "attachApplicationLocked: after updateOomAdjLocked");
            final long now = SystemClock.uptimeMillis();
            synchronized (mAppProfiler.mProfilerLock) {
                app.mProfile.setLastRequestedGc(now);
@@ -5135,6 +5135,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (!mConstants.mEnableWaitForFinishAttachApplication) {
                finishAttachApplicationInner(startSeq, callingUid, pid);
            } else {
                app.setPendingFinishAttach(true);
            }
        } catch (Exception e) {
            // We need kill the process group here. (b/148588589)
+2 −31
Original line number Diff line number Diff line
@@ -1260,19 +1260,12 @@ public class OomAdjuster {
        for (int i = numLru - 1; i >= 0; i--) {
            ProcessRecord app = lruList.get(i);
            final ProcessStateRecord state = app.mState;
            if (!app.isKilledByAm() && app.getThread() != null) {
            if (!app.isKilledByAm() && app.getThread() != null && !app.isPendingFinishAttach()) {
                // We don't need to apply the update for the process which didn't get computed
                if (state.getCompletedAdjSeq() == mAdjSeq) {
                    applyOomAdjLSP(app, true, now, nowElapsed, oomAdjReason);
                }

                if (app.isPendingFinishAttach()) {
                    // Avoid trimming processes that are still initializing. If they aren't
                    // hosting any components yet because they may be unfairly killed.
                    // We however apply any computed previously computed oom scores before skipping.
                    continue;
                }

                final ProcessServiceRecord psr = app.mServices;
                // Count the number of process types.
                switch (state.getCurProcState()) {
@@ -1706,19 +1699,6 @@ public class OomAdjuster {
            return false;
        }

        if (app.isPendingFinishAttach()) {
            state.setAdjSeq(mAdjSeq);
            state.setCompletedAdjSeq(mAdjSeq);
            // If the process is still initializing, we skip computing any states because we
            // don't want to override the special states that have been set at
            // AMS#attachApplication with OomAdjuster#setAttachingProcessStates.
            // In this limbo state, the app has |PROC_START_TIMEOUT| to finish attach application
            // and receive updated proc_state based on its importance.
            // Note that in this state, the oom_score is INVALID_ADJ which is outside the standard
            // oom score range and the app is safe from lmkd kills.
            return false;
        }

        state.setAdjTypeCode(ActivityManager.RunningAppProcessInfo.REASON_UNKNOWN);
        state.setAdjSource(null);
        state.setAdjTarget(null);
@@ -3239,7 +3219,7 @@ public class OomAdjuster {
    }

    @GuardedBy({"mService", "mProcLock"})
    void setAttachingProcessStatesLSP(ProcessRecord app) {
    void setAttachingSchedGroupLSP(ProcessRecord app) {
        int initialSchedGroup = SCHED_GROUP_DEFAULT;
        final ProcessStateRecord state = app.mState;
        // If the process has been marked as foreground, it is starting as the top app (with
@@ -3259,15 +3239,6 @@ public class OomAdjuster {

        state.setSetSchedGroup(initialSchedGroup);
        state.setCurrentSchedulingGroup(initialSchedGroup);
        state.setCurProcState(PROCESS_STATE_CACHED_EMPTY);
        state.setCurCapability(PROCESS_CAPABILITY_NONE);

        state.setCurAdj(ProcessList.FOREGROUND_APP_ADJ);
        state.setSetAdj(ProcessList.FOREGROUND_APP_ADJ);
        state.setVerifiedAdj(ProcessList.FOREGROUND_APP_ADJ);
        state.setForcingToImportant(null);
        state.setHasShownUi(false);
        state.setCached(true);
    }

    // ONLY used for unit testing in OomAdjusterTests.java
+0 −30
Original line number Diff line number Diff line
@@ -1966,36 +1966,6 @@ public class MockingOomAdjusterTests {
        assertBfsl(app1);
    }

    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_DoOne_PendingFinishAttach() {
        ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
                MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
        app.setPendingFinishAttach(true);
        app.mState.setHasForegroundActivities(false);

        sService.mOomAdjuster.setAttachingProcessStatesLSP(app);
        updateOomAdj(app);

        assertProcStates(app, PROCESS_STATE_CACHED_EMPTY, FOREGROUND_APP_ADJ,
                SCHED_GROUP_DEFAULT);
    }

    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_DoOne_TopApp_PendingFinishAttach() {
        ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
                MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
        app.setPendingFinishAttach(true);
        app.mState.setHasForegroundActivities(true);

        sService.mOomAdjuster.setAttachingProcessStatesLSP(app);
        updateOomAdj(app);

        assertProcStates(app, PROCESS_STATE_CACHED_EMPTY, FOREGROUND_APP_ADJ,
                SCHED_GROUP_TOP_APP);
    }

    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_UidIdle_StopService() {