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

Commit 832bfbdb authored by Eric Lok's avatar Eric Lok
Browse files

[Reland] Fix failed MockingOomAdjusterTests when Perceptible Tasks is Enabled

The `WindowProcessController.getPerceptibleTaskStoppedTimeMillis()` is
mocked and returns 0 by default which is wrong. Need to update to behave
similarly to the real method, where tasks that are not enabled for
perceptible tasks should return Long.MIN_VALUE by default.

Original change did not work because the doReturn() was defined prior to adding WPC as a mock (my bad when rebasing).

Test: atest com.android.server.am.MockingOomAdjusterTests
BUG: 370890207
Flag: com.android.server.am.perceptible_tasks
Change-Id: I7855fb86c5897164fcd14bf21b7cce87f32a3d18
parent 2fecc801
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3963,6 +3963,9 @@ public class MockingOomAdjusterTests {
            app.setIsolatedEntryPoint(mIsolatedEntryPoint);
            setFieldValue(ProcessRecord.class, app, "mWindowProcessController",
                    mock(WindowProcessController.class));
            doReturn(Long.MIN_VALUE)
                .when(app.getWindowProcessController())
                .getPerceptibleTaskStoppedTimeMillis();
            profile.setLastPssTime(mLastPssTime);
            profile.setNextPssTime(mNextPssTime);
            profile.setLastPss(mLastPss);