summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/EthernetManager.java49
-rw-r--r--core/java/android/net/IEthernetManager.aidl7
-rw-r--r--core/java/android/net/IEthernetServiceListener.aidl2
3 files changed, 38 insertions, 20 deletions
diff --git a/core/java/android/net/EthernetManager.java b/core/java/android/net/EthernetManager.java
index 31a30968cbcd..ecccda588aec 100644
--- a/core/java/android/net/EthernetManager.java
+++ b/core/java/android/net/EthernetManager.java
@@ -18,9 +18,6 @@ package android.net;
import android.annotation.SystemService;
import android.content.Context;
-import android.net.IEthernetManager;
-import android.net.IEthernetServiceListener;
-import android.net.IpConfiguration;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
@@ -45,18 +42,18 @@ public class EthernetManager {
if (msg.what == MSG_AVAILABILITY_CHANGED) {
boolean isAvailable = (msg.arg1 == 1);
for (Listener listener : mListeners) {
- listener.onAvailabilityChanged(isAvailable);
+ listener.onAvailabilityChanged((String) msg.obj, isAvailable);
}
}
}
};
- private final ArrayList<Listener> mListeners = new ArrayList<Listener>();
+ private final ArrayList<Listener> mListeners = new ArrayList<>();
private final IEthernetServiceListener.Stub mServiceListener =
new IEthernetServiceListener.Stub() {
@Override
- public void onAvailabilityChanged(boolean isAvailable) {
+ public void onAvailabilityChanged(String iface, boolean isAvailable) {
mHandler.obtainMessage(
- MSG_AVAILABILITY_CHANGED, isAvailable ? 1 : 0, 0, null).sendToTarget();
+ MSG_AVAILABILITY_CHANGED, isAvailable ? 1 : 0, 0, iface).sendToTarget();
}
};
@@ -66,9 +63,10 @@ public class EthernetManager {
public interface Listener {
/**
* Called when Ethernet port's availability is changed.
- * @param isAvailable {@code true} if one or more Ethernet port exists.
+ * @param iface Ethernet interface name
+ * @param isAvailable {@code true} if Ethernet port exists.
*/
- public void onAvailabilityChanged(boolean isAvailable);
+ void onAvailabilityChanged(String iface, boolean isAvailable);
}
/**
@@ -86,9 +84,9 @@ public class EthernetManager {
* Get Ethernet configuration.
* @return the Ethernet Configuration, contained in {@link IpConfiguration}.
*/
- public IpConfiguration getConfiguration() {
+ public IpConfiguration getConfiguration(String iface) {
try {
- return mService.getConfiguration();
+ return mService.getConfiguration(iface);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -97,21 +95,29 @@ public class EthernetManager {
/**
* Set Ethernet configuration.
*/
- public void setConfiguration(IpConfiguration config) {
+ public void setConfiguration(String iface, IpConfiguration config) {
try {
- mService.setConfiguration(config);
+ mService.setConfiguration(iface, config);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
- * Indicates whether the system currently has one or more
- * Ethernet interfaces.
+ * Indicates whether the system currently has one or more Ethernet interfaces.
*/
public boolean isAvailable() {
+ return getAvailableInterfaces().length > 0;
+ }
+
+ /**
+ * Indicates whether the system has given interface.
+ *
+ * @param iface Ethernet interface name
+ */
+ public boolean isAvailable(String iface) {
try {
- return mService.isAvailable();
+ return mService.isAvailable(iface);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -137,6 +143,17 @@ public class EthernetManager {
}
/**
+ * Returns an array of available Ethernet interface names.
+ */
+ public String[] getAvailableInterfaces() {
+ try {
+ return mService.getAvailableInterfaces();
+ } catch (RemoteException e) {
+ throw e.rethrowAsRuntimeException();
+ }
+ }
+
+ /**
* Removes a listener.
* @param listener A {@link Listener} to remove.
* @throws IllegalArgumentException If the listener is null.
diff --git a/core/java/android/net/IEthernetManager.aidl b/core/java/android/net/IEthernetManager.aidl
index 7a92eb955ace..94960b51d329 100644
--- a/core/java/android/net/IEthernetManager.aidl
+++ b/core/java/android/net/IEthernetManager.aidl
@@ -26,9 +26,10 @@ import android.net.IEthernetServiceListener;
/** {@hide} */
interface IEthernetManager
{
- IpConfiguration getConfiguration();
- void setConfiguration(in IpConfiguration config);
- boolean isAvailable();
+ String[] getAvailableInterfaces();
+ IpConfiguration getConfiguration(String iface);
+ void setConfiguration(String iface, in IpConfiguration config);
+ boolean isAvailable(String iface);
void addListener(in IEthernetServiceListener listener);
void removeListener(in IEthernetServiceListener listener);
}
diff --git a/core/java/android/net/IEthernetServiceListener.aidl b/core/java/android/net/IEthernetServiceListener.aidl
index 356690e8f7a6..782fa19d9df7 100644
--- a/core/java/android/net/IEthernetServiceListener.aidl
+++ b/core/java/android/net/IEthernetServiceListener.aidl
@@ -19,5 +19,5 @@ package android.net;
/** @hide */
oneway interface IEthernetServiceListener
{
- void onAvailabilityChanged(boolean isAvailable);
+ void onAvailabilityChanged(String iface, boolean isAvailable);
}