Merge "Remove getProcessGroup usage in OomAdjuster" am: 720ea3a110

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1930823

Change-Id: I8bc76e7783cd11c3f8fbe372a83805a3924e2061
This commit is contained in:
Riddle Hsu
2021-12-22 10:39:58 +00:00
committed by Automerger Merge Worker

View File

@@ -2872,29 +2872,18 @@ public class OomAdjuster {
void setAttachingSchedGroupLSP(ProcessRecord app) { void setAttachingSchedGroupLSP(ProcessRecord app) {
int initialSchedGroup = ProcessList.SCHED_GROUP_DEFAULT; int initialSchedGroup = ProcessList.SCHED_GROUP_DEFAULT;
final ProcessStateRecord state = app.mState; final ProcessStateRecord state = app.mState;
// If the process has been marked as foreground via Zygote.START_FLAG_USE_TOP_APP_PRIORITY, // If the process has been marked as foreground, it is starting as the top app (with
// then verify that the top priority is actually is applied. // Zygote#START_AS_TOP_APP_ARG), so boost the thread priority of its default UI thread.
if (state.hasForegroundActivities()) { if (state.hasForegroundActivities()) {
String fallbackReason = null;
try { try {
// The priority must be the same as how does {@link #applyOomAdjLSP} set for // The priority must be the same as how does {@link #applyOomAdjLSP} set for
// {@link ProcessList.SCHED_GROUP_TOP_APP}. We don't check render thread because it // {@link ProcessList.SCHED_GROUP_TOP_APP}. We don't check render thread because it
// is not ready when attaching. // is not ready when attaching.
if (Process.getProcessGroup(app.getPid()) == THREAD_GROUP_TOP_APP) {
app.getWindowProcessController().onTopProcChanged(); app.getWindowProcessController().onTopProcChanged();
setThreadPriority(app.getPid(), THREAD_PRIORITY_TOP_APP_BOOST); setThreadPriority(app.getPid(), THREAD_PRIORITY_TOP_APP_BOOST);
} else {
fallbackReason = "not expected top priority";
}
} catch (Exception e) {
fallbackReason = e.toString();
}
if (fallbackReason == null) {
initialSchedGroup = ProcessList.SCHED_GROUP_TOP_APP; initialSchedGroup = ProcessList.SCHED_GROUP_TOP_APP;
} else { } catch (Exception e) {
// The real scheduling group will depend on if there is any component of the process Slog.w(TAG, "Failed to pre-set top priority to " + app + " " + e);
// did something during attaching.
Slog.w(TAG, "Fallback pre-set sched group to default: " + fallbackReason);
} }
} }