summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/NetworkManagementService.java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-11-17 15:05:02 +0900
committerLorenzo Colitti <lorenzo@google.com>2013-11-26 21:55:15 +0900
commit5ad421a3d00c92c155d57af9d1a05d81cc2fa88f (patch)
tree68626927245cd2e5bbe42cddeff69b3199465e6a /services/java/com/android/server/NetworkManagementService.java
parent9d4ac9703657142b190d3c256de7c3329e5a4b29 (diff)
downloadframeworks_base-5ad421a3d00c92c155d57af9d1a05d81cc2fa88f.zip
frameworks_base-5ad421a3d00c92c155d57af9d1a05d81cc2fa88f.tar.gz
frameworks_base-5ad421a3d00c92c155d57af9d1a05d81cc2fa88f.tar.bz2
Use LinkAddress in address notifications.
Currently address{Updated,Removed} pass in the address as a string such as "fe80::1/64". Use LinkAddresses instead, since that's what it is. This makes the code more robust in the unlikely case that netd passes in an invalid string. In the future we can move flags and scope into the LinkAddress itself and simplify the code further. Bug: 9180552 Change-Id: I66599f9529cf421caa7676fdd0141bb110b8589e
Diffstat (limited to 'services/java/com/android/server/NetworkManagementService.java')
-rw-r--r--services/java/com/android/server/NetworkManagementService.java16
1 files changed, 10 insertions, 6 deletions
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;