summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-08-21 17:47:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-21 17:47:13 +0000
commitfd589c1d946ca7633da43ae8e1b4989cb0a73043 (patch)
tree44ab684904a0e9afcc312c01a090d1b3cc04f9f1 /services
parent906da6bfe4092fda1daff63e00e9f2ce1daac00b (diff)
parent5c7daac2e3d9020185699ba554d763b825ab1778 (diff)
downloadframeworks_base-fd589c1d946ca7633da43ae8e1b4989cb0a73043.zip
frameworks_base-fd589c1d946ca7633da43ae8e1b4989cb0a73043.tar.gz
frameworks_base-fd589c1d946ca7633da43ae8e1b4989cb0a73043.tar.bz2
Merge "Notify IP address changes to interface observers." into klp-dev
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/NetworkManagementService.java57
-rw-r--r--services/java/com/android/server/connectivity/Tethering.java4
2 files changed, 61 insertions, 0 deletions
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 988b1f2..16cfa66 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -133,6 +133,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
public static final int InterfaceChange = 600;
public static final int BandwidthControl = 601;
public static final int InterfaceClassActivity = 613;
+ public static final int InterfaceAddressChange = 614;
}
/**
@@ -393,6 +394,36 @@ public class NetworkManagementService extends INetworkManagementService.Stub
setFirewallEnabled(mFirewallEnabled || LockdownVpnTracker.isEnabled());
}
+ /**
+ * Notify our observers of a new or updated interface address.
+ */
+ private void notifyAddressUpdated(String address, String iface, int flags, int scope) {
+ final int length = mObservers.beginBroadcast();
+ for (int i = 0; i < length; i++) {
+ try {
+ mObservers.getBroadcastItem(i).addressUpdated(address, iface, flags, scope);
+ } catch (RemoteException e) {
+ } catch (RuntimeException e) {
+ }
+ }
+ mObservers.finishBroadcast();
+ }
+
+ /**
+ * Notify our observers of a deleted interface address.
+ */
+ private void notifyAddressRemoved(String address, String iface, int flags, int scope) {
+ final int length = mObservers.beginBroadcast();
+ for (int i = 0; i < length; i++) {
+ try {
+ mObservers.getBroadcastItem(i).addressRemoved(address, iface, flags, scope);
+ } catch (RemoteException e) {
+ } catch (RuntimeException e) {
+ }
+ }
+ mObservers.finishBroadcast();
+ }
+
//
// Netd Callback handling
//
@@ -475,6 +506,32 @@ public class NetworkManagementService extends INetworkManagementService.Stub
notifyInterfaceClassActivity(cooked[3], isActive);
return true;
// break;
+ case NetdResponseCode.InterfaceAddressChange:
+ /*
+ * A network address change occurred
+ * Format: "NNN Address updated <addr> <iface> <flags> <scope>"
+ * "NNN Address removed <addr> <iface> <flags> <scope>"
+ */
+ String msg = String.format("Invalid event from daemon (%s)", raw);
+ if (cooked.length < 6 || !cooked[1].equals("Address")) {
+ throw new IllegalStateException(msg);
+ }
+
+ int flags, scope;
+ try {
+ flags = Integer.parseInt(cooked[5]);
+ scope = Integer.parseInt(cooked[6]);
+ } catch(NumberFormatException e) {
+ throw new IllegalStateException(msg);
+ }
+
+ if (cooked[2].equals("updated")) {
+ notifyAddressUpdated(cooked[3], cooked[4], flags, scope);
+ } else {
+ notifyAddressRemoved(cooked[3], cooked[4], flags, scope);
+ }
+ return true;
+ // break;
default: break;
}
return false;
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 22a7841..fb4c1cf 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -315,6 +315,10 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
}
}
+ public void addressUpdated(String address, String iface, int flags, int scope) {}
+
+ public void addressRemoved(String address, String iface, int flags, int scope) {}
+
public void limitReached(String limitName, String iface) {}
public void interfaceClassDataActivityChanged(String label, boolean active) {}