am 2321301f: Merge "Bring up the ethernet interface when detected" into jb-dev
* commit '2321301fe75f945b002372d6d35c597191564452': Bring up the ethernet interface when detected
This commit is contained in:
@@ -59,6 +59,8 @@ public class EthernetDataTracker implements NetworkStateTracker {
|
|||||||
private static String sIfaceMatch = "";
|
private static String sIfaceMatch = "";
|
||||||
private static String mIface = "";
|
private static String mIface = "";
|
||||||
|
|
||||||
|
private INetworkManagementService mNMService;
|
||||||
|
|
||||||
private static class InterfaceObserver extends INetworkManagementEventObserver.Stub {
|
private static class InterfaceObserver extends INetworkManagementEventObserver.Stub {
|
||||||
private EthernetDataTracker mTracker;
|
private EthernetDataTracker mTracker;
|
||||||
|
|
||||||
@@ -117,6 +119,13 @@ public class EthernetDataTracker implements NetworkStateTracker {
|
|||||||
mIface = iface;
|
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);
|
mNetworkInfo.setIsAvailable(true);
|
||||||
Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
|
Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
|
||||||
msg.sendToTarget();
|
msg.sendToTarget();
|
||||||
@@ -199,7 +208,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
|
|||||||
|
|
||||||
// register for notifications from NetworkManagement Service
|
// register for notifications from NetworkManagement Service
|
||||||
IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
|
IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
|
||||||
INetworkManagementService service = INetworkManagementService.Stub.asInterface(b);
|
mNMService = INetworkManagementService.Stub.asInterface(b);
|
||||||
|
|
||||||
mInterfaceObserver = new InterfaceObserver(this);
|
mInterfaceObserver = new InterfaceObserver(this);
|
||||||
|
|
||||||
@@ -208,12 +217,12 @@ public class EthernetDataTracker implements NetworkStateTracker {
|
|||||||
sIfaceMatch = context.getResources().getString(
|
sIfaceMatch = context.getResources().getString(
|
||||||
com.android.internal.R.string.config_ethernet_iface_regex);
|
com.android.internal.R.string.config_ethernet_iface_regex);
|
||||||
try {
|
try {
|
||||||
final String[] ifaces = service.listInterfaces();
|
final String[] ifaces = mNMService.listInterfaces();
|
||||||
for (String iface : ifaces) {
|
for (String iface : ifaces) {
|
||||||
if (iface.matches(sIfaceMatch)) {
|
if (iface.matches(sIfaceMatch)) {
|
||||||
mIface = iface;
|
mIface = iface;
|
||||||
service.setInterfaceUp(iface);
|
mNMService.setInterfaceUp(iface);
|
||||||
InterfaceConfiguration config = service.getInterfaceConfig(iface);
|
InterfaceConfiguration config = mNMService.getInterfaceConfig(iface);
|
||||||
mLinkUp = config.isActive();
|
mLinkUp = config.isActive();
|
||||||
if (config != null && mHwAddr == null) {
|
if (config != null && mHwAddr == null) {
|
||||||
mHwAddr = config.getHardwareAddress();
|
mHwAddr = config.getHardwareAddress();
|
||||||
@@ -230,7 +239,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
service.registerObserver(mInterfaceObserver);
|
mNMService.registerObserver(mInterfaceObserver);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Could not register InterfaceObserver " + e);
|
Log.e(TAG, "Could not register InterfaceObserver " + e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user