From 7eae25021d3aa71c7616ea766f9a4d5af3b1772b Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Tue, 20 Apr 2010 15:51:20 -0700 Subject: [PATCH] Move Tethering off the ServerThread. An ANR has been reported because somebody else was hogging the Netd link. We can't pause the server thread for that, so make a new thread. bug:2609904 Change-Id: I0430a08621da1cda0a0010ce15826cceee59a529 --- .../java/com/android/server/connectivity/Tethering.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index f335287412a09..b43b86c5abbac 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -35,6 +35,7 @@ import android.net.NetworkUtils; import android.os.BatteryManager; import android.os.Binder; import android.os.Environment; +import android.os.HandlerThread; import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Looper; @@ -75,7 +76,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private String[] mTetherableWifiRegexs; private String[] mUpstreamIfaceRegexs; - private Looper mLooper; // given to us at construction time.. + private Looper mLooper; + private HandlerThread mThread; private HashMap mIfaces; // all tethered/tetherable ifaces @@ -123,6 +125,10 @@ public class Tethering extends INetworkManagementEventObserver.Stub { mIfaces = new HashMap(); + // make our own thread so we don't anr the system + mThread = new HandlerThread("Tethering"); + mThread.start(); + mLooper = mThread.getLooper(); mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper); mTetherMasterSM.start();