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

Commit 423f9c6f authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

Merge "Revert "Revert "Revert "Only promote remote animator to top sched group...

Merge "Revert "Revert "Revert "Only promote remote animator to top sched group during animation"""" into rvc-dev am: b3f5a7a9 am: 8d47933e am: e481cd81

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11987760

Change-Id: I8eb71092f0df42eda5448364a80811c5e04da367
parents 311bdac8 e481cd81
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -1667,12 +1667,6 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    @Nullable ContentCaptureManagerInternal mContentCaptureService;
    /**
     * Set of {@link ProcessRecord} that have either {@link ProcessRecord#hasTopUi()} or
     * {@link ProcessRecord#runningRemoteAnimation} set to {@code true}.
     */
    final ArraySet<ProcessRecord> mTopUiOrRunningRemoteAnimApps = new ArraySet<>();
    final class UiHandler extends Handler {
        public UiHandler() {
            super(com.android.server.UiThread.get().getLooper(), null, true);
@@ -14720,7 +14714,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mProcessesToGc.remove(app);
        mPendingPssProcesses.remove(app);
        mTopUiOrRunningRemoteAnimApps.remove(app);
        ProcessList.abortNextPssTime(app.procStateMemTracker);
        // Dismiss any open dialogs.
@@ -18521,22 +18514,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        return proc;
    }
    /**
     * @return {@code true} if {@link #mTopUiOrRunningRemoteAnimApps} set contains {@code app} or when there are no apps
     *         in this list, an false otherwise.
     */
    boolean containsTopUiOrRunningRemoteAnimOrEmptyLocked(ProcessRecord app) {
        return mTopUiOrRunningRemoteAnimApps.isEmpty() || mTopUiOrRunningRemoteAnimApps.contains(app);
    }
    void addTopUiOrRunningRemoteAnim(ProcessRecord app) {
        mTopUiOrRunningRemoteAnimApps.add(app);
    }
    void removeTopUiOrRunningRemoteAnim(ProcessRecord app) {
        mTopUiOrRunningRemoteAnimApps.remove(app);
    }
    @Override
    public boolean dumpHeap(String process, int userId, boolean managed, boolean mallocInfo,
            boolean runGc, String path, ParcelFileDescriptor fd, RemoteCallback finishCallback) {
+5 −24
Original line number Diff line number Diff line
@@ -1151,17 +1151,8 @@ public final class OomAdjuster {
            // is currently showing UI.
            app.systemNoUi = true;
            if (app == topApp) {
                // If specific system app has set ProcessRecord.mHasTopUi or is running a remote
                // animation (ProcessRecord.runningRemoteAnimation), this will prevent topApp
                // to use SCHED_GROUP_TOP_APP to ensure process with mHasTopUi will have exclusive
                // access to configured cores.
                if (mService.containsTopUiOrRunningRemoteAnimOrEmptyLocked(app)) {
                    app.setCurrentSchedulingGroup(ProcessList.SCHED_GROUP_TOP_APP);
                } else {
                    app.setCurrentSchedulingGroup(ProcessList.SCHED_GROUP_DEFAULT);
                }
                app.systemNoUi = false;

                app.setCurrentSchedulingGroup(ProcessList.SCHED_GROUP_TOP_APP);
                app.adjType = "pers-top-activity";
            } else if (app.hasTopUi()) {
                // sched group/proc state adjustment is below
@@ -1202,20 +1193,10 @@ public final class OomAdjuster {

        boolean foregroundActivities = false;
        if (PROCESS_STATE_CUR_TOP == PROCESS_STATE_TOP && app == topApp) {

            // If specific system app has set ProcessRecord.mHasTopUi or is running a remote
            // animation (ProcessRecord.runningRemoteAnimation), this will prevent topApp
            // to use SCHED_GROUP_TOP_APP to ensure process with mHasTopUi will have exclusive
            // access to configured cores.
            if (mService.containsTopUiOrRunningRemoteAnimOrEmptyLocked(app)) {
            // The last app on the list is the foreground app.
            adj = ProcessList.FOREGROUND_APP_ADJ;
            schedGroup = ProcessList.SCHED_GROUP_TOP_APP;
            app.adjType = "top-activity";
            } else {
                adj = ProcessList.FOREGROUND_APP_ADJ;
                schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
                app.adjType = "top-activity-behind-topui";
            }
            foregroundActivities = true;
            procState = PROCESS_STATE_CUR_TOP;
            if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
+0 −10
Original line number Diff line number Diff line
@@ -1268,7 +1268,6 @@ class ProcessRecord implements WindowProcessListener {
    void setHasTopUi(boolean hasTopUi) {
        mHasTopUi = hasTopUi;
        mWindowProcessController.setHasTopUi(hasTopUi);
        updateTopUiOrRunningRemoteAnim();
    }

    boolean hasTopUi() {
@@ -1519,19 +1518,10 @@ class ProcessRecord implements WindowProcessListener {
                Slog.i(TAG, "Setting runningRemoteAnimation=" + runningRemoteAnimation
                        + " for pid=" + pid);
            }
            updateTopUiOrRunningRemoteAnim();
            mService.updateOomAdjLocked(this, true, OomAdjuster.OOM_ADJ_REASON_UI_VISIBILITY);
        }
    }

    void updateTopUiOrRunningRemoteAnim() {
        if (runningRemoteAnimation || hasTopUi()) {
            mService.addTopUiOrRunningRemoteAnim(this);
        } else {
            mService.removeTopUiOrRunningRemoteAnim(this);
        }
    }

    public long getInputDispatchingTimeout() {
        return mWindowProcessController.getInputDispatchingTimeout();
    }
+0 −17
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ import static com.android.server.am.ProcessList.VISIBLE_APP_ADJ;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.AdditionalAnswers.answer;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyLong;
@@ -171,7 +170,6 @@ public class MockingOomAdjusterTests {
                mock(OomAdjProfiler.class));
        doReturn(new ActivityManagerService.ProcessChangeItem()).when(sService)
                .enqueueProcessChangeItemLocked(anyInt(), anyInt());
        doReturn(true).when(sService).containsTopUiOrRunningRemoteAnimOrEmptyLocked(any());
        sService.mOomAdjuster = new OomAdjuster(sService, sService.mProcessList,
                mock(ActiveUids.class));
        sService.mOomAdjuster.mAdjSeq = 10000;
@@ -266,21 +264,6 @@ public class MockingOomAdjusterTests {
        assertProcStates(app, PROCESS_STATE_TOP_SLEEPING, VISIBLE_APP_ADJ, SCHED_GROUP_TOP_APP);
    }

    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_DoOne_TopApp_PreemptedByTopUi() {
        ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
                MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
        doReturn(PROCESS_STATE_TOP).when(sService.mAtmInternal).getTopProcessState();
        doReturn(app).when(sService).getTopAppLocked();
        doReturn(false).when(sService).containsTopUiOrRunningRemoteAnimOrEmptyLocked(eq(app));
        sService.mWakefulness = PowerManagerInternal.WAKEFULNESS_AWAKE;
        sService.mOomAdjuster.updateOomAdjLocked(app, false, OomAdjuster.OOM_ADJ_REASON_NONE);
        doReturn(null).when(sService).getTopAppLocked();

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

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