summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/NetworkManagementService.java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-11-04 17:44:09 +0900
committerLorenzo Colitti <lorenzo@google.com>2013-11-25 17:25:45 +0900
commita9626c1c956f51e7b4cb783d70b75abc3b180a00 (patch)
tree1c1bef2ecca682d5d55176b3956bf4c611febbbf /services/java/com/android/server/NetworkManagementService.java
parent132fe8d27dcb45b363dff3eeb347ff2f4cf60901 (diff)
downloadframeworks_base-a9626c1c956f51e7b4cb783d70b75abc3b180a00.zip
frameworks_base-a9626c1c956f51e7b4cb783d70b75abc3b180a00.tar.gz
frameworks_base-a9626c1c956f51e7b4cb783d70b75abc3b180a00.tar.bz2
Minor cleanups to NetdCallbackReceiver.onEvent.
- Clean up identical error messages. - Fix the array length check for InterfaceAddressChange. [Cherry-pick of 59be800e7fe81842aa8c77b91319f58ab165983d] Bug: 9180552 Change-Id: Id871f481445b530c3ad749725f1548df0e3a1228
Diffstat (limited to 'services/java/com/android/server/NetworkManagementService.java')
-rw-r--r--services/java/com/android/server/NetworkManagementService.java23
1 files changed, 9 insertions, 14 deletions
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 92f99c2..9a0d648 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -455,6 +455,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
@Override
public boolean onEvent(int code, String raw, String[] cooked) {
+ String errorMessage = String.format("Invalid event from daemon (%s)", raw);
switch (code) {
case NetdResponseCode.InterfaceChange:
/*
@@ -465,8 +466,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
* "NNN Iface linkstatus <name> <up/down>"
*/
if (cooked.length < 4 || !cooked[1].equals("Iface")) {
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
}
if (cooked[2].equals("added")) {
notifyInterfaceAdded(cooked[3]);
@@ -481,8 +481,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
notifyInterfaceLinkStateChanged(cooked[3], cooked[4].equals("up"));
return true;
}
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
// break;
case NetdResponseCode.BandwidthControl:
/*
@@ -490,15 +489,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub
* Format: "NNN limit alert <alertName> <ifaceName>"
*/
if (cooked.length < 5 || !cooked[1].equals("limit")) {
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
}
if (cooked[2].equals("alert")) {
notifyLimitReached(cooked[3], cooked[4]);
return true;
}
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
// break;
case NetdResponseCode.InterfaceClassActivity:
/*
@@ -506,8 +503,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
* Format: "NNN IfaceClass <active/idle> <label>"
*/
if (cooked.length < 4 || !cooked[1].equals("IfaceClass")) {
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
}
boolean isActive = cooked[2].equals("active");
notifyInterfaceClassActivity(cooked[3], isActive);
@@ -519,9 +515,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub
* 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);
+ if (cooked.length < 7 || !cooked[1].equals("Address")) {
+ throw new IllegalStateException(errorMessage);
}
int flags;
@@ -530,7 +525,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
flags = Integer.parseInt(cooked[5]);
scope = Integer.parseInt(cooked[6]);
} catch(NumberFormatException e) {
- throw new IllegalStateException(msg);
+ throw new IllegalStateException(errorMessage);
}
if (cooked[2].equals("updated")) {