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

Commit a3acbb82 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed thread leak in OomAdjuster during tests"

parents 8475d5e0 ce8db89c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+15 −6
Original line number Diff line number Diff line
@@ -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;