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