Add capability to receive FD with NativeDaemonConnector.
BUG=25755372 Change-Id: I2888219b77cf04f4bf749d5518ff62ba16258f2d
This commit is contained in:
@@ -177,6 +177,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
|
|
||||||
mCallbacks.onDaemonConnected();
|
mCallbacks.onDaemonConnected();
|
||||||
|
|
||||||
|
FileDescriptor[] fdList = null;
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
int start = 0;
|
int start = 0;
|
||||||
|
|
||||||
@@ -186,6 +187,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
loge("got " + count + " reading with start = " + start);
|
loge("got " + count + " reading with start = " + start);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
fdList = socket.getAncillaryFileDescriptors();
|
||||||
|
|
||||||
// Add our starting point to the count and reset the start.
|
// Add our starting point to the count and reset the start.
|
||||||
count += start;
|
count += start;
|
||||||
@@ -200,8 +202,8 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
|
|
||||||
boolean releaseWl = false;
|
boolean releaseWl = false;
|
||||||
try {
|
try {
|
||||||
final NativeDaemonEvent event = NativeDaemonEvent.parseRawEvent(
|
final NativeDaemonEvent event =
|
||||||
rawEvent);
|
NativeDaemonEvent.parseRawEvent(rawEvent, fdList);
|
||||||
|
|
||||||
log("RCV <- {" + event + "}");
|
log("RCV <- {" + event + "}");
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.server;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
|
|
||||||
|
import java.io.FileDescriptor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,15 +36,17 @@ public class NativeDaemonEvent {
|
|||||||
private final String mRawEvent;
|
private final String mRawEvent;
|
||||||
private final String mLogMessage;
|
private final String mLogMessage;
|
||||||
private String[] mParsed;
|
private String[] mParsed;
|
||||||
|
private FileDescriptor[] mFdList;
|
||||||
|
|
||||||
private NativeDaemonEvent(int cmdNumber, int code, String message,
|
private NativeDaemonEvent(int cmdNumber, int code, String message,
|
||||||
String rawEvent, String logMessage) {
|
String rawEvent, String logMessage, FileDescriptor[] fdList) {
|
||||||
mCmdNumber = cmdNumber;
|
mCmdNumber = cmdNumber;
|
||||||
mCode = code;
|
mCode = code;
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
mRawEvent = rawEvent;
|
mRawEvent = rawEvent;
|
||||||
mLogMessage = logMessage;
|
mLogMessage = logMessage;
|
||||||
mParsed = null;
|
mParsed = null;
|
||||||
|
mFdList = fdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public final String SENSITIVE_MARKER = "{{sensitive}}";
|
static public final String SENSITIVE_MARKER = "{{sensitive}}";
|
||||||
@@ -60,6 +63,10 @@ public class NativeDaemonEvent {
|
|||||||
return mMessage;
|
return mMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileDescriptor[] getFileDescriptors() {
|
||||||
|
return mFdList;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getRawEvent() {
|
public String getRawEvent() {
|
||||||
return mRawEvent;
|
return mRawEvent;
|
||||||
@@ -127,7 +134,7 @@ public class NativeDaemonEvent {
|
|||||||
* @throws IllegalArgumentException when line doesn't match format expected
|
* @throws IllegalArgumentException when line doesn't match format expected
|
||||||
* from native side.
|
* from native side.
|
||||||
*/
|
*/
|
||||||
public static NativeDaemonEvent parseRawEvent(String rawEvent) {
|
public static NativeDaemonEvent parseRawEvent(String rawEvent, FileDescriptor[] fdList) {
|
||||||
final String[] parsed = rawEvent.split(" ");
|
final String[] parsed = rawEvent.split(" ");
|
||||||
if (parsed.length < 2) {
|
if (parsed.length < 2) {
|
||||||
throw new IllegalArgumentException("Insufficient arguments");
|
throw new IllegalArgumentException("Insufficient arguments");
|
||||||
@@ -164,7 +171,7 @@ public class NativeDaemonEvent {
|
|||||||
|
|
||||||
final String message = rawEvent.substring(skiplength);
|
final String message = rawEvent.substring(skiplength);
|
||||||
|
|
||||||
return new NativeDaemonEvent(cmdNumber, code, message, rawEvent, logMessage);
|
return new NativeDaemonEvent(cmdNumber, code, message, rawEvent, logMessage, fdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user