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

Commit 1f8455d4 authored by Brett Chabot's avatar Brett Chabot
Browse files

Fix race condition in OomAdjuster.

OomAdjuster accesses the not-thread-safe HandlerThread.getThreadId from
outside the thread.
Modify so it posts a message to thread instead.

See bug 22476742

Bug: 151407445
Test: See repro instructions in bug
Change-Id: Iae03d46896561f0442af6595a8d0bdf617ccd61e
parent a8375cc9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -227,7 +227,8 @@ public final class OomAdjuster {
        final ServiceThread adjusterThread =
                new ServiceThread(TAG, TOP_APP_PRIORITY_BOOST, false /* allowIo */);
        adjusterThread.start();
        Process.setThreadGroupAndCpuset(adjusterThread.getThreadId(), THREAD_GROUP_TOP_APP);
        adjusterThread.getThreadHandler().post(() -> Process.setThreadGroupAndCpuset(
                adjusterThread.getThreadId(), THREAD_GROUP_TOP_APP));
        return adjusterThread;
    }