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

Commit afe92474 authored by JW Wang's avatar JW Wang Committed by Android (Google) Code Review
Browse files

Merge "Don't extend Thread (1/n)"

parents 6826f471 fab5c95a
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ import java.util.HashSet;
import java.util.List;

/** This class calls its monitor every minute. Killing this process if they don't return **/
public class Watchdog extends Thread {
public class Watchdog {
    static final String TAG = "Watchdog";

    /** Debug flag. */
@@ -132,6 +132,8 @@ public class Watchdog extends Thread {

    private static Watchdog sWatchdog;

    private final Thread mThread;

    /* This handler will be used to post message back onto the main thread */
    private final ArrayList<HandlerChecker> mHandlerCheckers = new ArrayList<>();
    private final HandlerChecker mMonitorChecker;
@@ -311,7 +313,7 @@ public class Watchdog extends Thread {
    }

    private Watchdog() {
        super("watchdog");
        mThread = new Thread(this::run, "watchdog");
        // Initialize handler checkers for each common thread we want to check.  Note
        // that we are not currently checking the background thread, since it can
        // potentially hold longer running operations with no guarantees about the timeliness
@@ -354,6 +356,13 @@ public class Watchdog extends Thread {
                DEFAULT_TIMEOUT > ZygoteConnectionConstants.WRAPPED_PID_TIMEOUT_MILLIS;
    }

    /**
     * Called by SystemServer to cause the internal thread to begin execution.
     */
    public void start() {
        mThread.start();
    }

    /**
     * Registers a {@link BroadcastReceiver} to listen to reboot broadcasts and trigger reboot.
     * Should be called during boot after the ActivityManagerService is up and registered
@@ -550,8 +559,7 @@ public class Watchdog extends Thread {
        return pids;
    }

    @Override
    public void run() {
    private void run() {
        boolean waitedHalf = false;
        while (true) {
            final List<HandlerChecker> blockedCheckers;