Loading core/java/android/app/ActivityManager.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -1189,6 +1189,18 @@ public class ActivityManager { return procState == PROCESS_STATE_FOREGROUND_SERVICE; return procState == PROCESS_STATE_FOREGROUND_SERVICE; } } /** @hide Should this process state be considered jank perceptible? */ public static final boolean isProcStateJankPerceptible(int procState) { if (Flags.jankPerceptibleNarrow()) { return procState == PROCESS_STATE_PERSISTENT_UI || procState == PROCESS_STATE_TOP || procState == PROCESS_STATE_IMPORTANT_FOREGROUND || procState == PROCESS_STATE_TOP_SLEEPING; } else { return !isProcStateCached(procState); } } /** @hide requestType for assist context: only basic information. */ /** @hide requestType for assist context: only basic information. */ public static final int ASSIST_CONTEXT_BASIC = 0; public static final int ASSIST_CONTEXT_BASIC = 0; Loading core/java/android/app/ActivityThread.java +15 −17 Original line number Original line Diff line number Diff line Loading @@ -3945,12 +3945,7 @@ public final class ActivityThread extends ClientTransactionHandler if (mLastProcessState == processState) { if (mLastProcessState == processState) { return; return; } } // Do not issue a transitional GC if we are transitioning between 2 cached states. updateVmProcessState(mLastProcessState, processState); // Only update if the state flips between cached and uncached or vice versa if (ActivityManager.isProcStateCached(mLastProcessState) != ActivityManager.isProcStateCached(processState)) { updateVmProcessState(processState); } mLastProcessState = processState; mLastProcessState = processState; if (localLOGV) { if (localLOGV) { Slog.i(TAG, "******************* PROCESS STATE CHANGED TO: " + processState Slog.i(TAG, "******************* PROCESS STATE CHANGED TO: " + processState Loading @@ -3959,19 +3954,22 @@ public final class ActivityThread extends ClientTransactionHandler } } } } /** Converts a process state to a VM process state. */ private static int toVmProcessState(int processState) { final int state = ActivityManager.isProcStateJankPerceptible(processState) ? VM_PROCESS_STATE_JANK_PERCEPTIBLE : VM_PROCESS_STATE_JANK_IMPERCEPTIBLE; return state; } /** Update VM state based on ActivityManager.PROCESS_STATE_* constants. */ /** Update VM state based on ActivityManager.PROCESS_STATE_* constants. */ // Currently ART VM only uses state updates for Transitional GC, and thus private void updateVmProcessState(int lastProcessState, int newProcessState) { // this function initiates a Transitional GC for transitions into Cached apps states. final int state = toVmProcessState(newProcessState); private void updateVmProcessState(int processState) { if (lastProcessState == PROCESS_STATE_UNKNOWN // Only a transition into Cached state should result in a Transitional GC request || state != toVmProcessState(lastProcessState)) { // to the ART runtime. Update VM state to JANK_IMPERCEPTIBLE in that case. // Note that there are 4 possible cached states currently, all of which are // JANK_IMPERCEPTIBLE from GC point of view. final int state = ActivityManager.isProcStateCached(processState) ? VM_PROCESS_STATE_JANK_IMPERCEPTIBLE : VM_PROCESS_STATE_JANK_PERCEPTIBLE; VMRuntime.getRuntime().updateProcessState(state); VMRuntime.getRuntime().updateProcessState(state); } } } @Override @Override public void countLaunchingActivities(int num) { public void countLaunchingActivities(int num) { Loading core/java/android/app/activity_manager.aconfig +7 −0 Original line number Original line Diff line number Diff line Loading @@ -156,3 +156,10 @@ flag { bug: "362537357" bug: "362537357" is_exported: true is_exported: true } } flag { name: "jank_perceptible_narrow" namespace: "system_performance" description: "Narrow the scope of Jank Perceptible" bug: "304837972" } Loading
core/java/android/app/ActivityManager.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -1189,6 +1189,18 @@ public class ActivityManager { return procState == PROCESS_STATE_FOREGROUND_SERVICE; return procState == PROCESS_STATE_FOREGROUND_SERVICE; } } /** @hide Should this process state be considered jank perceptible? */ public static final boolean isProcStateJankPerceptible(int procState) { if (Flags.jankPerceptibleNarrow()) { return procState == PROCESS_STATE_PERSISTENT_UI || procState == PROCESS_STATE_TOP || procState == PROCESS_STATE_IMPORTANT_FOREGROUND || procState == PROCESS_STATE_TOP_SLEEPING; } else { return !isProcStateCached(procState); } } /** @hide requestType for assist context: only basic information. */ /** @hide requestType for assist context: only basic information. */ public static final int ASSIST_CONTEXT_BASIC = 0; public static final int ASSIST_CONTEXT_BASIC = 0; Loading
core/java/android/app/ActivityThread.java +15 −17 Original line number Original line Diff line number Diff line Loading @@ -3945,12 +3945,7 @@ public final class ActivityThread extends ClientTransactionHandler if (mLastProcessState == processState) { if (mLastProcessState == processState) { return; return; } } // Do not issue a transitional GC if we are transitioning between 2 cached states. updateVmProcessState(mLastProcessState, processState); // Only update if the state flips between cached and uncached or vice versa if (ActivityManager.isProcStateCached(mLastProcessState) != ActivityManager.isProcStateCached(processState)) { updateVmProcessState(processState); } mLastProcessState = processState; mLastProcessState = processState; if (localLOGV) { if (localLOGV) { Slog.i(TAG, "******************* PROCESS STATE CHANGED TO: " + processState Slog.i(TAG, "******************* PROCESS STATE CHANGED TO: " + processState Loading @@ -3959,19 +3954,22 @@ public final class ActivityThread extends ClientTransactionHandler } } } } /** Converts a process state to a VM process state. */ private static int toVmProcessState(int processState) { final int state = ActivityManager.isProcStateJankPerceptible(processState) ? VM_PROCESS_STATE_JANK_PERCEPTIBLE : VM_PROCESS_STATE_JANK_IMPERCEPTIBLE; return state; } /** Update VM state based on ActivityManager.PROCESS_STATE_* constants. */ /** Update VM state based on ActivityManager.PROCESS_STATE_* constants. */ // Currently ART VM only uses state updates for Transitional GC, and thus private void updateVmProcessState(int lastProcessState, int newProcessState) { // this function initiates a Transitional GC for transitions into Cached apps states. final int state = toVmProcessState(newProcessState); private void updateVmProcessState(int processState) { if (lastProcessState == PROCESS_STATE_UNKNOWN // Only a transition into Cached state should result in a Transitional GC request || state != toVmProcessState(lastProcessState)) { // to the ART runtime. Update VM state to JANK_IMPERCEPTIBLE in that case. // Note that there are 4 possible cached states currently, all of which are // JANK_IMPERCEPTIBLE from GC point of view. final int state = ActivityManager.isProcStateCached(processState) ? VM_PROCESS_STATE_JANK_IMPERCEPTIBLE : VM_PROCESS_STATE_JANK_PERCEPTIBLE; VMRuntime.getRuntime().updateProcessState(state); VMRuntime.getRuntime().updateProcessState(state); } } } @Override @Override public void countLaunchingActivities(int num) { public void countLaunchingActivities(int num) { Loading
core/java/android/app/activity_manager.aconfig +7 −0 Original line number Original line Diff line number Diff line Loading @@ -156,3 +156,10 @@ flag { bug: "362537357" bug: "362537357" is_exported: true is_exported: true } } flag { name: "jank_perceptible_narrow" namespace: "system_performance" description: "Narrow the scope of Jank Perceptible" bug: "304837972" }