@@ -59,6 +59,8 @@ public class EthernetDataTracker implements NetworkStateTracker {
5959 private static String sIfaceMatch = "" ;
6060 private static String mIface = "" ;
6161
62+ private INetworkManagementService mNMService ;
63+
6264 private static class InterfaceObserver extends INetworkManagementEventObserver .Stub {
6365 private EthernetDataTracker mTracker ;
6466
@@ -117,6 +119,13 @@ private void interfaceAdded(String iface) {
117119 mIface = iface ;
118120 }
119121
122+ // we don't get link status indications unless the iface is up - bring it up
123+ try {
124+ mNMService .setInterfaceUp (iface );
125+ } catch (Exception e ) {
126+ Log .e (TAG , "Error upping interface " + iface + ": " + e );
127+ }
128+
120129 mNetworkInfo .setIsAvailable (true );
121130 Message msg = mCsHandler .obtainMessage (EVENT_CONFIGURATION_CHANGED , mNetworkInfo );
122131 msg .sendToTarget ();
@@ -199,7 +208,7 @@ public void startMonitoring(Context context, Handler target) {
199208
200209 // register for notifications from NetworkManagement Service
201210 IBinder b = ServiceManager .getService (Context .NETWORKMANAGEMENT_SERVICE );
202- INetworkManagementService service = INetworkManagementService .Stub .asInterface (b );
211+ mNMService = INetworkManagementService .Stub .asInterface (b );
203212
204213 mInterfaceObserver = new InterfaceObserver (this );
205214
@@ -208,12 +217,12 @@ public void startMonitoring(Context context, Handler target) {
208217 sIfaceMatch = context .getResources ().getString (
209218 com .android .internal .R .string .config_ethernet_iface_regex );
210219 try {
211- final String [] ifaces = service .listInterfaces ();
220+ final String [] ifaces = mNMService .listInterfaces ();
212221 for (String iface : ifaces ) {
213222 if (iface .matches (sIfaceMatch )) {
214223 mIface = iface ;
215- service .setInterfaceUp (iface );
216- InterfaceConfiguration config = service .getInterfaceConfig (iface );
224+ mNMService .setInterfaceUp (iface );
225+ InterfaceConfiguration config = mNMService .getInterfaceConfig (iface );
217226 mLinkUp = config .isActive ();
218227 if (config != null && mHwAddr == null ) {
219228 mHwAddr = config .getHardwareAddress ();
@@ -230,7 +239,7 @@ public void startMonitoring(Context context, Handler target) {
230239 }
231240
232241 try {
233- service .registerObserver (mInterfaceObserver );
242+ mNMService .registerObserver (mInterfaceObserver );
234243 } catch (RemoteException e ) {
235244 Log .e (TAG , "Could not register InterfaceObserver " + e );
236245 }
0 commit comments