diff options
-rw-r--r-- | services/java/com/android/server/Watchdog.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/java/com/android/server/Watchdog.java b/services/java/com/android/server/Watchdog.java index b2a8ad8..1663106 100644 --- a/services/java/com/android/server/Watchdog.java +++ b/services/java/com/android/server/Watchdog.java @@ -29,6 +29,7 @@ import android.content.IntentFilter; import android.os.BatteryManager; import android.os.Debug; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.ServiceManager; @@ -114,6 +115,10 @@ public class Watchdog extends Thread { * Used for scheduling monitor callbacks and checking memory usage. */ final class HeartbeatHandler extends Handler { + HeartbeatHandler(Looper looper) { + super(looper); + } + @Override public void handleMessage(Message msg) { switch (msg.what) { @@ -183,7 +188,9 @@ public class Watchdog extends Thread { private Watchdog() { super("watchdog"); - mHandler = new HeartbeatHandler(); + // Explicitly bind the HeartbeatHandler to run on the ServerThread, so + // that it can't get accidentally bound to another thread. + mHandler = new HeartbeatHandler(Looper.getMainLooper()); } public void init(Context context, BatteryService battery, |