Make NDC not block forever and handle restart.
Need changes in core. Still possible for netd to get wedged but system won't die because of it. Leads the way to having forking netd - then only individual commands would wedge, promoting stability. bug:5864209 Change-Id: Ifcd37511c8239fe3df7e9070869b63a9c5649bd2
This commit is contained in:
parent
25e3ec70aa
commit
5c7de0b4ec
1 changed files with 195 additions and 58 deletions
|
|
@ -28,16 +28,22 @@ public class NativeDaemonEvent {
|
|||
// TODO: keep class ranges in sync with ResponseCode.h
|
||||
// TODO: swap client and server error ranges to roughly mirror HTTP spec
|
||||
|
||||
private final int mCmdNumber;
|
||||
private final int mCode;
|
||||
private final String mMessage;
|
||||
private final String mRawEvent;
|
||||
|
||||
private NativeDaemonEvent(int code, String message, String rawEvent) {
|
||||
private NativeDaemonEvent(int cmdNumber, int code, String message, String rawEvent) {
|
||||
mCmdNumber = cmdNumber;
|
||||
mCode = code;
|
||||
mMessage = message;
|
||||
mRawEvent = rawEvent;
|
||||
}
|
||||
|
||||
public int getCmdNumber() {
|
||||
return mCmdNumber;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return mCode;
|
||||
}
|
||||
|
|
@ -110,20 +116,28 @@ public class NativeDaemonEvent {
|
|||
* from native side.
|
||||
*/
|
||||
public static NativeDaemonEvent parseRawEvent(String rawEvent) {
|
||||
final int splitIndex = rawEvent.indexOf(' ');
|
||||
if (splitIndex == -1) {
|
||||
final String[] parsed = rawEvent.split(" ");
|
||||
if (parsed.length < 3) {
|
||||
throw new IllegalArgumentException("unable to find ' ' separator");
|
||||
}
|
||||
|
||||
final int cmdNumber;
|
||||
try {
|
||||
cmdNumber = Integer.parseInt(parsed[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("problem parsing cmdNumber", e);
|
||||
}
|
||||
|
||||
final int code;
|
||||
try {
|
||||
code = Integer.parseInt(rawEvent.substring(0, splitIndex));
|
||||
code = Integer.parseInt(parsed[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("problem parsing code", e);
|
||||
}
|
||||
|
||||
final String message = rawEvent.substring(splitIndex + 1);
|
||||
return new NativeDaemonEvent(code, message, rawEvent);
|
||||
final String message = rawEvent.substring(parsed[0].length() + parsed[1].length() + 2);
|
||||
|
||||
return new NativeDaemonEvent(cmdNumber, code, message, rawEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue