diff options
author | Robert Greenwalt <robdroid@android.com> | 2010-03-11 15:03:08 -0800 |
---|---|---|
committer | Robert Greenwalt <robdroid@android.com> | 2010-03-11 15:39:30 -0800 |
commit | dfadaeac088cabce854d8f476405cd412f82593a (patch) | |
tree | a6287b4546a7f8b60ea8a328cef45b40dd430a08 /services/java | |
parent | c1bcc9989cffa86780bdf1d797b080eea27e7194 (diff) | |
download | frameworks_base-dfadaeac088cabce854d8f476405cd412f82593a.zip frameworks_base-dfadaeac088cabce854d8f476405cd412f82593a.tar.gz frameworks_base-dfadaeac088cabce854d8f476405cd412f82593a.tar.bz2 |
Stop creating threads for tethering.
Use the passed in looper and save threads.
Change-Id: I6db04ef64e339a5fb2b71e9fb1da32e2d600447c
Diffstat (limited to 'services/java')
-rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 2 | ||||
-rw-r--r-- | services/java/com/android/server/connectivity/Tethering.java | 20 |
2 files changed, 13 insertions, 9 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index fa06244..fc20d96 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -320,7 +320,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - mTethering = new Tethering(mContext); + mTethering = new Tethering(mContext, mHandler.getLooper()); mTetheringConfigValid = (((mNetTrackers[ConnectivityManager.TYPE_MOBILE_DUN] != null) || !mTethering.isDunRequired()) && (mTethering.getTetherableUsbRegexs().length != 0 || diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index ebd3314..25f123c 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -36,6 +36,7 @@ import android.os.Binder; import android.os.Environment; import android.os.IBinder; import android.os.INetworkManagementService; +import android.os.Looper; import android.os.Message; import android.os.RemoteException; import android.os.ServiceManager; @@ -73,6 +74,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private String[] mTetherableWifiRegexs; private String[] mUpstreamIfaceRegexs; + private Looper mLooper; // given to us at construction time.. + private HashMap<String, TetherInterfaceSM> mIfaces; // all tethered/tetherable ifaces private BroadcastReceiver mStateReceiver; @@ -101,9 +104,10 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private boolean mUsbMassStorageOff; // track the status of USB Mass Storage private boolean mUsbConnected; // track the status of USB connection - public Tethering(Context context) { + public Tethering(Context context, Looper looper) { Log.d(TAG, "Tethering starting"); mContext = context; + mLooper = looper; // register for notifications from NetworkManagement Service IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); @@ -116,7 +120,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { mIfaces = new HashMap<String, TetherInterfaceSM>(); - mTetherMasterSM = new TetherMasterSM("TetherMaster"); + mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper); mTetherMasterSM.start(); // TODO - remove this hack after real USB connections are detected. @@ -175,7 +179,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { TetherInterfaceSM sm = mIfaces.get(iface); if (link) { if (sm == null) { - sm = new TetherInterfaceSM(iface, usb); + sm = new TetherInterfaceSM(iface, mLooper, usb); mIfaces.put(iface, sm); sm.start(); } @@ -225,7 +229,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { Log.e(TAG, "active iface (" + iface + ") reported as added, ignoring"); return; } - sm = new TetherInterfaceSM(iface, usb); + sm = new TetherInterfaceSM(iface, mLooper, usb); mIfaces.put(iface, sm); sm.start(); } @@ -639,8 +643,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub { String mIfaceName; boolean mUsb; - TetherInterfaceSM(String name, boolean usb) { - super(name); + TetherInterfaceSM(String name, Looper looper, boolean usb) { + super(name, looper); mIfaceName = name; mUsb = usb; setLastError(ConnectivityManager.TETHER_ERROR_NO_ERROR); @@ -1023,8 +1027,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private static final int CELL_DISABLE_DUN_TIMEOUT_MS = 3000; private static final int CELL_DUN_RENEW_MS = 40000; - TetherMasterSM(String name) { - super(name); + TetherMasterSM(String name, Looper looper) { + super(name, looper); //Add states mInitialState = new InitialState(); |