summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java2
-rw-r--r--services/core/java/com/android/server/am/OomAdjuster.java21
2 files changed, 16 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index ff8c3e954460..268e813c12dd 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -2399,7 +2399,7 @@ public class ActivityManagerService extends IActivityManager.Stub
final ActiveUids activeUids = new ActiveUids(this, false /* postChangesToAtm */);
mProcessList.init(this, activeUids);
mLowMemDetector = null;
- mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids);
+ mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids, handlerThread);
mIntentFirewall = hasHandlerThread
? new IntentFirewall(new IntentFirewallInterface(), mHandler) : null;
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index a2613d87d923..770cb3da3362 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -162,6 +162,21 @@ public final class OomAdjuster {
private final ProcessList mProcessList;
OomAdjuster(ActivityManagerService service, ProcessList processList, ActiveUids activeUids) {
+ this(service, processList, activeUids, createAdjusterThread());
+ }
+
+ private static ServiceThread createAdjusterThread() {
+ // The process group is usually critical to the response time of foreground app, so the
+ // setter should apply it as soon as possible.
+ final ServiceThread adjusterThread =
+ new ServiceThread(TAG, TOP_APP_PRIORITY_BOOST, false /* allowIo */);
+ adjusterThread.start();
+ Process.setThreadGroupAndCpuset(adjusterThread.getThreadId(), THREAD_GROUP_TOP_APP);
+ return adjusterThread;
+ }
+
+ OomAdjuster(ActivityManagerService service, ProcessList processList, ActiveUids activeUids,
+ ServiceThread adjusterThread) {
mService = service;
mProcessList = processList;
mActiveUids = activeUids;
@@ -170,12 +185,6 @@ public final class OomAdjuster {
mConstants = mService.mConstants;
mAppCompact = new AppCompactor(mService);
- // The process group is usually critical to the response time of foreground app, so the
- // setter should apply it as soon as possible.
- final ServiceThread adjusterThread = new ServiceThread(TAG, TOP_APP_PRIORITY_BOOST,
- false /* allowIo */);
- adjusterThread.start();
- Process.setThreadGroupAndCpuset(adjusterThread.getThreadId(), THREAD_GROUP_TOP_APP);
mProcessGroupHandler = new Handler(adjusterThread.getLooper(), msg -> {
final int pid = msg.arg1;
final int group = msg.arg2;