Loading services/core/java/com/android/server/am/ProcessServiceRecord.java +2 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,8 @@ final class ProcessServiceRecord { adj = ProcessList.PERCEPTIBLE_APP_ADJ; } else if (adj < ProcessList.PERCEPTIBLE_LOW_APP_ADJ) { adj = ProcessList.PERCEPTIBLE_LOW_APP_ADJ; } else if (Flags.addModifyRawOomAdjServiceLevel() && adj < ProcessList.SERVICE_ADJ) { adj = ProcessList.SERVICE_ADJ; } else if (adj < ProcessList.CACHED_APP_MIN_ADJ) { adj = ProcessList.CACHED_APP_MIN_ADJ; } else if (adj < ProcessList.CACHED_APP_MAX_ADJ) { Loading services/core/java/com/android/server/am/flags.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -260,3 +260,13 @@ flag { description: "Use PROCESS_CAPABILITY_CPU_TIME to control unfreeze state." bug: "370817323" } flag { name: "add_modify_raw_oom_adj_service_level" namespace: "backstage_power" description: "Add a SERVICE_ADJ level to the modifyRawOomAdj method" bug: "374810368" metadata { purpose: PURPOSE_BUGFIX } } services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +28 −3 Original line number Diff line number Diff line Loading @@ -1425,6 +1425,31 @@ public class MockingOomAdjusterTests { assertEquals(PERCEPTIBLE_LOW_APP_ADJ, app.mState.getSetAdj()); } @SuppressWarnings("GuardedBy") @Test public void testUpdateOomAdj_DoOne_Service_NotPerceptible_AboveClient() { ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID, MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false)); ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID, MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false)); ProcessRecord service = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID, MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false)); bindService(app, client, null, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class)); bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class)); mProcessStateController.setRunningRemoteAnimation(client, true); mProcessStateController.updateHasAboveClientLocked(app.mServices); setWakefulness(PowerManagerInternal.WAKEFULNESS_AWAKE); updateOomAdj(client, app, service); final int expectedAdj; if (Flags.addModifyRawOomAdjServiceLevel()) { expectedAdj = SERVICE_ADJ; } else { expectedAdj = CACHED_APP_MIN_ADJ; } assertEquals(expectedAdj, app.mState.getSetAdj()); } @SuppressWarnings("GuardedBy") @Test public void testUpdateOomAdj_DoOne_Service_NotVisible() { Loading Loading @@ -2906,7 +2931,7 @@ public class MockingOomAdjusterTests { // Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and // verify that its OOM adjustment level is unaffected. bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class)); app.mServices.updateHasAboveClientLocked(); mProcessStateController.updateHasAboveClientLocked(app.mServices); assertTrue(app.mServices.hasAboveClient()); updateOomAdj(app); Loading @@ -2928,7 +2953,7 @@ public class MockingOomAdjusterTests { // 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, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class)); app.mServices.updateHasAboveClientLocked(); mProcessStateController.updateHasAboveClientLocked(app.mServices); assertFalse(app.mServices.hasAboveClient()); updateOomAdj(app); Loading Loading @@ -2983,7 +3008,7 @@ public class MockingOomAdjusterTests { // Since sr.app is null, this service cannot be in the same process as the // client so we expect the BIND_ABOVE_CLIENT adjustment to take effect. app.mServices.updateHasAboveClientLocked(); mProcessStateController.updateHasAboveClientLocked(app.mServices); updateOomAdj(app); assertTrue(app.mServices.hasAboveClient()); assertNotEquals(FOREGROUND_APP_ADJ, app.mState.getSetAdj()); Loading Loading
services/core/java/com/android/server/am/ProcessServiceRecord.java +2 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,8 @@ final class ProcessServiceRecord { adj = ProcessList.PERCEPTIBLE_APP_ADJ; } else if (adj < ProcessList.PERCEPTIBLE_LOW_APP_ADJ) { adj = ProcessList.PERCEPTIBLE_LOW_APP_ADJ; } else if (Flags.addModifyRawOomAdjServiceLevel() && adj < ProcessList.SERVICE_ADJ) { adj = ProcessList.SERVICE_ADJ; } else if (adj < ProcessList.CACHED_APP_MIN_ADJ) { adj = ProcessList.CACHED_APP_MIN_ADJ; } else if (adj < ProcessList.CACHED_APP_MAX_ADJ) { Loading
services/core/java/com/android/server/am/flags.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -260,3 +260,13 @@ flag { description: "Use PROCESS_CAPABILITY_CPU_TIME to control unfreeze state." bug: "370817323" } flag { name: "add_modify_raw_oom_adj_service_level" namespace: "backstage_power" description: "Add a SERVICE_ADJ level to the modifyRawOomAdj method" bug: "374810368" metadata { purpose: PURPOSE_BUGFIX } }
services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +28 −3 Original line number Diff line number Diff line Loading @@ -1425,6 +1425,31 @@ public class MockingOomAdjusterTests { assertEquals(PERCEPTIBLE_LOW_APP_ADJ, app.mState.getSetAdj()); } @SuppressWarnings("GuardedBy") @Test public void testUpdateOomAdj_DoOne_Service_NotPerceptible_AboveClient() { ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID, MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false)); ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID, MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false)); ProcessRecord service = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID, MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false)); bindService(app, client, null, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class)); bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class)); mProcessStateController.setRunningRemoteAnimation(client, true); mProcessStateController.updateHasAboveClientLocked(app.mServices); setWakefulness(PowerManagerInternal.WAKEFULNESS_AWAKE); updateOomAdj(client, app, service); final int expectedAdj; if (Flags.addModifyRawOomAdjServiceLevel()) { expectedAdj = SERVICE_ADJ; } else { expectedAdj = CACHED_APP_MIN_ADJ; } assertEquals(expectedAdj, app.mState.getSetAdj()); } @SuppressWarnings("GuardedBy") @Test public void testUpdateOomAdj_DoOne_Service_NotVisible() { Loading Loading @@ -2906,7 +2931,7 @@ public class MockingOomAdjusterTests { // Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and // verify that its OOM adjustment level is unaffected. bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class)); app.mServices.updateHasAboveClientLocked(); mProcessStateController.updateHasAboveClientLocked(app.mServices); assertTrue(app.mServices.hasAboveClient()); updateOomAdj(app); Loading @@ -2928,7 +2953,7 @@ public class MockingOomAdjusterTests { // 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, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class)); app.mServices.updateHasAboveClientLocked(); mProcessStateController.updateHasAboveClientLocked(app.mServices); assertFalse(app.mServices.hasAboveClient()); updateOomAdj(app); Loading Loading @@ -2983,7 +3008,7 @@ public class MockingOomAdjusterTests { // Since sr.app is null, this service cannot be in the same process as the // client so we expect the BIND_ABOVE_CLIENT adjustment to take effect. app.mServices.updateHasAboveClientLocked(); mProcessStateController.updateHasAboveClientLocked(app.mServices); updateOomAdj(app); assertTrue(app.mServices.hasAboveClient()); assertNotEquals(FOREGROUND_APP_ADJ, app.mState.getSetAdj()); Loading