summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-11-26 17:56:45 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-11-26 17:56:45 -0800
commit4806fdfbd0fecf91584396fc0f620c97a05ab837 (patch)
tree47521e7d98b953f0397c40d3f6791e9b1f73c6e0
parent37e4c405a6136f90e5a8d4fc512cf7f551eb0c56 (diff)
parentf226bc606af9ce5aceff6b05fc4b0200c94cb248 (diff)
downloadframeworks_base-4806fdfbd0fecf91584396fc0f620c97a05ab837.zip
frameworks_base-4806fdfbd0fecf91584396fc0f620c97a05ab837.tar.gz
frameworks_base-4806fdfbd0fecf91584396fc0f620c97a05ab837.tar.bz2
am f226bc60: Merge "Use LinkAddress in address notifications."
* commit 'f226bc606af9ce5aceff6b05fc4b0200c94cb248': Use LinkAddress in address notifications.
-rw-r--r--core/java/android/net/INetworkManagementEventObserver.aidl6
-rw-r--r--core/java/com/android/server/net/BaseNetworkObserver.java5
-rw-r--r--services/java/com/android/server/NetworkManagementService.java16
-rw-r--r--services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java14
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java8
5 files changed, 30 insertions, 19 deletions
diff --git a/core/java/android/net/INetworkManagementEventObserver.aidl b/core/java/android/net/INetworkManagementEventObserver.aidl
index c720c7b..405a897 100644
--- a/core/java/android/net/INetworkManagementEventObserver.aidl
+++ b/core/java/android/net/INetworkManagementEventObserver.aidl
@@ -16,6 +16,8 @@
package android.net;
+import android.net.LinkAddress;
+
/**
* Callback class for receiving events from an INetworkManagementService
*
@@ -62,7 +64,7 @@ interface INetworkManagementEventObserver {
* @param flags The address flags.
* @param scope The address scope.
*/
- void addressUpdated(String address, String iface, int flags, int scope);
+ void addressUpdated(in LinkAddress address, String iface, int flags, int scope);
/**
* An interface address has been removed
@@ -72,7 +74,7 @@ interface INetworkManagementEventObserver {
* @param flags The address flags.
* @param scope The address scope.
*/
- void addressRemoved(String address, String iface, int flags, int scope);
+ void addressRemoved(in LinkAddress address, String iface, int flags, int scope);
/**
* A networking quota limit has been reached. The quota might not
diff --git a/core/java/com/android/server/net/BaseNetworkObserver.java b/core/java/com/android/server/net/BaseNetworkObserver.java
index a02c602..1e80a21 100644
--- a/core/java/com/android/server/net/BaseNetworkObserver.java
+++ b/core/java/com/android/server/net/BaseNetworkObserver.java
@@ -17,6 +17,7 @@
package com.android.server.net;
import android.net.INetworkManagementEventObserver;
+import android.net.LinkAddress;
/**
* Base {@link INetworkManagementEventObserver} that provides no-op
@@ -36,12 +37,12 @@ public class BaseNetworkObserver extends INetworkManagementEventObserver.Stub {
}
@Override
- public void addressUpdated(String address, String iface, int flags, int scope) {
+ public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
// default no-op
}
@Override
- public void addressRemoved(String address, String iface, int flags, int scope) {
+ public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
// default no-op
}
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 8089fbc..40ea49e 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -405,7 +405,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
/**
* Notify our observers of a new or updated interface address.
*/
- private void notifyAddressUpdated(String address, String iface, int flags, int scope) {
+ private void notifyAddressUpdated(LinkAddress address, String iface, int flags, int scope) {
final int length = mObservers.beginBroadcast();
for (int i = 0; i < length; i++) {
try {
@@ -420,7 +420,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
/**
* Notify our observers of a deleted interface address.
*/
- private void notifyAddressRemoved(String address, String iface, int flags, int scope) {
+ private void notifyAddressRemoved(LinkAddress address, String iface, int flags, int scope) {
final int length = mObservers.beginBroadcast();
for (int i = 0; i < length; i++) {
try {
@@ -537,17 +537,21 @@ public class NetworkManagementService extends INetworkManagementService.Stub
int flags;
int scope;
+ LinkAddress address;
try {
flags = Integer.parseInt(cooked[5]);
scope = Integer.parseInt(cooked[6]);
- } catch(NumberFormatException e) {
- throw new IllegalStateException(errorMessage);
+ address = new LinkAddress(cooked[3]);
+ } catch(NumberFormatException e) { // Non-numeric lifetime or scope.
+ throw new IllegalStateException(errorMessage, e);
+ } catch(IllegalArgumentException e) { // Malformed IP address.
+ throw new IllegalStateException(errorMessage, e);
}
if (cooked[2].equals("updated")) {
- notifyAddressUpdated(cooked[3], cooked[4], flags, scope);
+ notifyAddressUpdated(address, cooked[4], flags, scope);
} else {
- notifyAddressRemoved(cooked[3], cooked[4], flags, scope);
+ notifyAddressRemoved(address, cooked[4], flags, scope);
}
return true;
// break;
diff --git a/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java
index 4385dcd..a78e7b6 100644
--- a/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java
@@ -17,6 +17,7 @@
package com.android.server;
import android.content.Context;
+import android.net.LinkAddress;
import android.net.LocalSocket;
import android.net.LocalServerSocket;
import android.os.Binder;
@@ -157,19 +158,22 @@ public class NetworkManagementServiceTest extends AndroidTestCase {
* IP address changes.
*/
sendMessage("614 Address updated fe80::1/64 wlan0 128 253");
- expectSoon(observer).addressUpdated("fe80::1/64", "wlan0", 128, 253);
+ expectSoon(observer).addressUpdated(
+ new LinkAddress("fe80::1/64"), "wlan0", 128, 253);
- // There is no "added".
+ // There is no "added", so we take this as "removed".
sendMessage("614 Address added fe80::1/64 wlan0 128 253");
- expectSoon(observer).addressRemoved("fe80::1/64", "wlan0", 128, 253);
+ expectSoon(observer).addressRemoved(
+ new LinkAddress("fe80::1/64"), "wlan0", 128, 253);
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1 0");
- expectSoon(observer).addressRemoved("2001:db8::1/64", "wlan0", 1, 0);
+ expectSoon(observer).addressRemoved(
+ new LinkAddress("2001:db8::1/64"), "wlan0", 1, 0);
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1");
// Not enough arguments.
- sendMessage("666 Address added 2001:db8::1/64 wlan0 1 0");
+ sendMessage("666 Address removed 2001:db8::1/64 wlan0 1 0");
// Invalid code.
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index eedd66f..d8ca6b0 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -242,24 +242,24 @@ public class WifiStateMachine extends StateMachine {
}
@Override
- public void addressUpdated(String address, String iface, int flags, int scope) {
+ public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
if (DBG) {
log("addressUpdated: " + address + " on " + iface +
" flags " + flags + " scope " + scope);
}
- mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, new LinkAddress(address));
+ mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, address);
}
}
@Override
- public void addressRemoved(String address, String iface, int flags, int scope) {
+ public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
if (DBG) {
log("addressRemoved: " + address + " on " + iface +
" flags " + flags + " scope " + scope);
}
- mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, new LinkAddress(address));
+ mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, address);
}
}
}