diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2012-05-07 13:39:34 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-07 13:39:34 -0700 |
commit | 2321301fe75f945b002372d6d35c597191564452 (patch) | |
tree | 9b989be5e3e3911aa2d23de17d0013b931d39c79 | |
parent | 7833e5f53228dd3f34c0f41550fea8564ed3222a (diff) | |
parent | 198bc11d099008531b7e445d9715698421d6e644 (diff) | |
download | frameworks_base-2321301fe75f945b002372d6d35c597191564452.zip frameworks_base-2321301fe75f945b002372d6d35c597191564452.tar.gz frameworks_base-2321301fe75f945b002372d6d35c597191564452.tar.bz2 |
Merge "Bring up the ethernet interface when detected" into jb-dev
-rw-r--r-- | core/java/android/net/EthernetDataTracker.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java index fb09ba5..28bd289 100644 --- a/core/java/android/net/EthernetDataTracker.java +++ b/core/java/android/net/EthernetDataTracker.java @@ -59,6 +59,8 @@ public class EthernetDataTracker implements NetworkStateTracker { private static String sIfaceMatch = ""; private static String mIface = ""; + private INetworkManagementService mNMService; + private static class InterfaceObserver extends INetworkManagementEventObserver.Stub { private EthernetDataTracker mTracker; @@ -117,6 +119,13 @@ public class EthernetDataTracker implements NetworkStateTracker { mIface = iface; } + // we don't get link status indications unless the iface is up - bring it up + try { + mNMService.setInterfaceUp(iface); + } catch (Exception e) { + Log.e(TAG, "Error upping interface " + iface + ": " + e); + } + mNetworkInfo.setIsAvailable(true); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); @@ -199,7 +208,7 @@ public class EthernetDataTracker implements NetworkStateTracker { // register for notifications from NetworkManagement Service IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); + mNMService = INetworkManagementService.Stub.asInterface(b); mInterfaceObserver = new InterfaceObserver(this); @@ -208,12 +217,12 @@ public class EthernetDataTracker implements NetworkStateTracker { sIfaceMatch = context.getResources().getString( com.android.internal.R.string.config_ethernet_iface_regex); try { - final String[] ifaces = service.listInterfaces(); + final String[] ifaces = mNMService.listInterfaces(); for (String iface : ifaces) { if (iface.matches(sIfaceMatch)) { mIface = iface; - service.setInterfaceUp(iface); - InterfaceConfiguration config = service.getInterfaceConfig(iface); + mNMService.setInterfaceUp(iface); + InterfaceConfiguration config = mNMService.getInterfaceConfig(iface); mLinkUp = config.isActive(); if (config != null && mHwAddr == null) { mHwAddr = config.getHardwareAddress(); @@ -230,7 +239,7 @@ public class EthernetDataTracker implements NetworkStateTracker { } try { - service.registerObserver(mInterfaceObserver); + mNMService.registerObserver(mInterfaceObserver); } catch (RemoteException e) { Log.e(TAG, "Could not register InterfaceObserver " + e); } |