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

Commit 03966287 authored by Jing Ji's avatar Jing Ji
Browse files

Revert "Ignore BIND_ABOVE_CLIENT for same-process connections"

This reverts commit a18cd7c0.

Reason for revert: b/288824089

Bug: 288824089
Change-Id: Id5aee1323b9b3b254e19e8a4e189c1fa4f9d96ea
parent 11dcac2a
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -3701,9 +3701,7 @@ public final class ActiveServices {
            }
            }
            clientPsr.addConnection(c);
            clientPsr.addConnection(c);
            c.startAssociationIfNeeded();
            c.startAssociationIfNeeded();
            // Don't set hasAboveClient if binding to self to prevent modifyRawOomAdj() from
            if (c.hasFlag(Context.BIND_ABOVE_CLIENT)) {
            // dropping the process' adjustment level.
            if (b.client != s.app && c.hasFlag(Context.BIND_ABOVE_CLIENT)) {
                clientPsr.setHasAboveClient(true);
                clientPsr.setHasAboveClient(true);
            }
            }
            if (c.hasFlag(BIND_ALLOW_WHITELIST_MANAGEMENT)) {
            if (c.hasFlag(BIND_ALLOW_WHITELIST_MANAGEMENT)) {
+1 −2
Original line number Original line Diff line number Diff line
@@ -341,8 +341,7 @@ final class ProcessServiceRecord {
        mHasAboveClient = false;
        mHasAboveClient = false;
        for (int i = mConnections.size() - 1; i >= 0; i--) {
        for (int i = mConnections.size() - 1; i >= 0; i--) {
            ConnectionRecord cr = mConnections.valueAt(i);
            ConnectionRecord cr = mConnections.valueAt(i);
            if (cr.binding.service.app.mServices != this
            if (cr.hasFlag(Context.BIND_ABOVE_CLIENT)) {
                    && cr.hasFlag(Context.BIND_ABOVE_CLIENT)) {
                mHasAboveClient = true;
                mHasAboveClient = true;
                break;
                break;
            }
            }
+0 −23
Original line number Original line Diff line number Diff line
@@ -68,7 +68,6 @@ import static com.android.server.am.ProcessList.UNKNOWN_ADJ;
import static com.android.server.am.ProcessList.VISIBLE_APP_ADJ;
import static com.android.server.am.ProcessList.VISIBLE_APP_ADJ;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.AdditionalAnswers.answer;
import static org.mockito.AdditionalAnswers.answer;
@@ -2490,28 +2489,6 @@ public class MockingOomAdjusterTests {
        assertProcStates(app2, false, PROCESS_STATE_SERVICE, SERVICE_ADJ, "started-services");
        assertProcStates(app2, false, PROCESS_STATE_SERVICE, SERVICE_ADJ, "started-services");
    }
    }


    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_DoOne_AboveClient_SameProcess() {
        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).getTopApp();
        sService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
        sService.mOomAdjuster.updateOomAdjLocked(app, OOM_ADJ_REASON_NONE);

        assertEquals(FOREGROUND_APP_ADJ, app.mState.getSetAdj());

        // Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and
        // verify that its OOM adjustment level is unaffected.
        bindService(app, app, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
        app.mServices.updateHasAboveClientLocked();
        assertFalse(app.mServices.hasAboveClient());

        sService.mOomAdjuster.updateOomAdjLocked(app, OOM_ADJ_REASON_NONE);
        assertEquals(FOREGROUND_APP_ADJ, app.mState.getSetAdj());
    }

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