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

Commit 69a0130d authored by Alex Klyubin's avatar Alex Klyubin Committed by Android (Google) Code Review
Browse files

Merge "Move EntropyMixer I/O from main thread to I/O thread"

parents 8cf5b695 44444444
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -70,7 +70,10 @@ public class EntropyMixer extends Binder {
    /**
     * Handler that periodically updates the entropy on disk.
     */
    private final Handler mHandler = new Handler() {
    private final Handler mHandler = new Handler(IoThread.getHandler().getLooper()) {
        // IMPLEMENTATION NOTE: This handler runs on the I/O thread to avoid I/O on the main thread.
        // The reason we're using our own Handler instead of IoThread.getHandler() is to create our
        // own ID space for the "what" parameter of messages seen by the handler.
        @Override
        public void handleMessage(Message msg) {
            if (msg.what != ENTROPY_WHAT) {
@@ -115,7 +118,12 @@ public class EntropyMixer extends Binder {
        IntentFilter broadcastFilter = new IntentFilter(Intent.ACTION_SHUTDOWN);
        broadcastFilter.addAction(Intent.ACTION_POWER_CONNECTED);
        broadcastFilter.addAction(Intent.ACTION_REBOOT);
        context.registerReceiver(mBroadcastReceiver, broadcastFilter);
        context.registerReceiver(
                mBroadcastReceiver,
                broadcastFilter,
                null, // do not require broadcaster to hold any permissions
                mHandler // process received broadcasts on the I/O thread instead of the main thread
                );
    }

    private void scheduleEntropyWriter() {