Revert "Revert "Propagate new link-status-change message to any NetworkManagementService""
This reverts commit 1a7e67190228a8ff3b92e7e5496a8db8ff306cca.
Bring back the changes from Stan Chesnutt regarding link-status-change
notifications. The comment from the original patch was:
Propagate new link-status-change message to any NetworkManagementService
observers. Also fix the syntax of the "interface-status-change" message. Add
a null handler in the ThrottleService and Tethering classes (plus fix names).
Change-Id: I42cbed692024de32275cad234f42ff23ab7e9d8d
Signed-off-by: Mike J. Chen <mjchen@google.com>
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 2b01c5e..cd6ec33 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -141,12 +141,26 @@
}
/**
- * Notify our observers of an interface link status change
+ * Notify our observers of an interface status change
*/
- private void notifyInterfaceLinkStatusChanged(String iface, boolean link) {
+ private void notifyInterfaceStatusChanged(String iface, boolean up) {
for (INetworkManagementEventObserver obs : mObservers) {
try {
- obs.interfaceLinkStatusChanged(iface, link);
+ obs.interfaceStatusChanged(iface, up);
+ } catch (Exception ex) {
+ Slog.w(TAG, "Observer notifier failed", ex);
+ }
+ }
+ }
+
+ /**
+ * Notify our observers of an interface link status change.
+ * (typically, an Ethernet cable has been plugged-in or unplugged).
+ */
+ private void notifyInterfaceLinkStateChanged(String iface, boolean up) {
+ for (INetworkManagementEventObserver obs : mObservers) {
+ try {
+ obs.interfaceLinkStateChanged(iface, up);
} catch (Exception ex) {
Slog.w(TAG, "Observer notifier failed", ex);
}
@@ -207,6 +221,7 @@
* Format: "NNN Iface added <name>"
* "NNN Iface removed <name>"
* "NNN Iface changed <name> <up/down>"
+ * "NNN Iface linkstatus <name> <up/down>"
*/
if (cooked.length < 4 || !cooked[1].equals("Iface")) {
throw new IllegalStateException(
@@ -219,7 +234,10 @@
notifyInterfaceRemoved(cooked[3]);
return true;
} else if (cooked[2].equals("changed") && cooked.length == 5) {
- notifyInterfaceLinkStatusChanged(cooked[3], cooked[4].equals("up"));
+ notifyInterfaceStatusChanged(cooked[3], cooked[4].equals("up"));
+ return true;
+ } else if (cooked[2].equals("linkstatus") && cooked.length == 5) {
+ notifyInterfaceLinkStateChanged(cooked[3], cooked[4].equals("up"));
return true;
}
throw new IllegalStateException(