am e4679750: Merge "Fix Watchdog HeartbeatHandler to run on correct thread"
* commit 'e4679750c538e982bb81f4eea2343e8bede3e118': Fix Watchdog HeartbeatHandler to run on correct thread
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user