* commit '6837f4a44235f96d410190806448ddf43d2fe696': 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.BatteryManager;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
@@ -114,6 +115,10 @@ public class Watchdog extends Thread {
|
|||||||
* Used for scheduling monitor callbacks and checking memory usage.
|
* Used for scheduling monitor callbacks and checking memory usage.
|
||||||
*/
|
*/
|
||||||
final class HeartbeatHandler extends Handler {
|
final class HeartbeatHandler extends Handler {
|
||||||
|
HeartbeatHandler(Looper looper) {
|
||||||
|
super(looper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
@@ -183,7 +188,9 @@ public class Watchdog extends Thread {
|
|||||||
|
|
||||||
private Watchdog() {
|
private Watchdog() {
|
||||||
super("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,
|
public void init(Context context, BatteryService battery,
|
||||||
|
|||||||
Reference in New Issue
Block a user