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

Commit 0654f47b authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Verify that setReportedProcState() has been called.

Currently, we check the reportedProcState directly but it
could have been updated since the broadcast delivery has
been finished.

Bug: 314181833
Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java
Change-Id: I8262ace3d004ffeb5fafca9de2764821cf0309c9
parent 90471152
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -401,7 +401,7 @@ class ProcessRecord implements WindowProcessListener {
    /**
     * All about the process state info (proc state, oom adj score) in this process.
     */
    final ProcessStateRecord mState;
    ProcessStateRecord mState;

    /**
     * All about the state info of the optimizer when the process is cached.
+3 −2
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ public class BroadcastQueueTest extends BaseBroadcastQueueTest {
        final boolean dead = (behavior == ProcessBehavior.DEAD);

        final ProcessRecord r = spy(new ProcessRecord(mAms, ai, processName, ai.uid));
        r.mState = spy(r.mState);
        r.setPid(mNextPid.getAndIncrement());
        mActiveProcesses.add(r);

@@ -788,8 +789,8 @@ public class BroadcastQueueTest extends BaseBroadcastQueueTest {
        }) {
            // Confirm expected OOM adjustments; we were invoked once to upgrade
            // and once to downgrade
            assertEquals(String.valueOf(receiverApp), ActivityManager.PROCESS_STATE_RECEIVER,
                    receiverApp.mState.getReportedProcState());
            verify(receiverApp.mState, times(1).description(String.valueOf(receiverApp)))
                    .setReportedProcState(ActivityManager.PROCESS_STATE_RECEIVER);
            verify(mAms, times(2)).enqueueOomAdjTargetLocked(eq(receiverApp));

            if ((mImpl == Impl.DEFAULT) && (receiverApp == receiverBlueApp)) {