Merge "Prevent Closure of Underlying Socket FDs" am: 3cff120fcb
am: 31f05d66ca Change-Id: I1ecac95dc1c4be573d5411a335f94c6a6511d4bd
This commit is contained in:
@@ -313,9 +313,7 @@ public final class IpSecManager {
|
|||||||
public void applyTransportModeTransform(
|
public void applyTransportModeTransform(
|
||||||
Socket socket, int direction, IpSecTransform transform)
|
Socket socket, int direction, IpSecTransform transform)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket)) {
|
applyTransportModeTransform(socket.getFileDescriptor$(), direction, transform);
|
||||||
applyTransportModeTransform(pfd, direction, transform);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -347,9 +345,7 @@ public final class IpSecManager {
|
|||||||
*/
|
*/
|
||||||
public void applyTransportModeTransform(
|
public void applyTransportModeTransform(
|
||||||
DatagramSocket socket, int direction, IpSecTransform transform) throws IOException {
|
DatagramSocket socket, int direction, IpSecTransform transform) throws IOException {
|
||||||
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.fromDatagramSocket(socket)) {
|
applyTransportModeTransform(socket.getFileDescriptor$(), direction, transform);
|
||||||
applyTransportModeTransform(pfd, direction, transform);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -383,18 +379,8 @@ public final class IpSecManager {
|
|||||||
FileDescriptor socket, int direction, IpSecTransform transform)
|
FileDescriptor socket, int direction, IpSecTransform transform)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// We dup() the FileDescriptor here because if we don't, then the ParcelFileDescriptor()
|
// We dup() the FileDescriptor here because if we don't, then the ParcelFileDescriptor()
|
||||||
// constructor takes control and closes the user's FD when we exit the method
|
// constructor takes control and closes the user's FD when we exit the method.
|
||||||
// This is behaviorally the same as the other versions, but the PFD constructor does not
|
|
||||||
// dup() automatically, whereas PFD.fromSocket() and PDF.fromDatagramSocket() do dup().
|
|
||||||
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(socket)) {
|
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(socket)) {
|
||||||
applyTransportModeTransform(pfd, direction, transform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Call down to activate a transform */
|
|
||||||
private void applyTransportModeTransform(
|
|
||||||
ParcelFileDescriptor pfd, int direction, IpSecTransform transform) throws IOException {
|
|
||||||
try {
|
|
||||||
mService.applyTransportModeTransform(pfd, direction, transform.getResourceId());
|
mService.applyTransportModeTransform(pfd, direction, transform.getResourceId());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
@@ -433,9 +419,7 @@ public final class IpSecManager {
|
|||||||
*/
|
*/
|
||||||
public void removeTransportModeTransforms(Socket socket, IpSecTransform transform)
|
public void removeTransportModeTransforms(Socket socket, IpSecTransform transform)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket)) {
|
removeTransportModeTransforms(socket.getFileDescriptor$(), transform);
|
||||||
removeTransportModeTransforms(pfd, transform);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,9 +439,7 @@ public final class IpSecManager {
|
|||||||
*/
|
*/
|
||||||
public void removeTransportModeTransforms(DatagramSocket socket, IpSecTransform transform)
|
public void removeTransportModeTransforms(DatagramSocket socket, IpSecTransform transform)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.fromDatagramSocket(socket)) {
|
removeTransportModeTransforms(socket.getFileDescriptor$(), transform);
|
||||||
removeTransportModeTransforms(pfd, transform);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,13 +460,6 @@ public final class IpSecManager {
|
|||||||
public void removeTransportModeTransforms(FileDescriptor socket, IpSecTransform transform)
|
public void removeTransportModeTransforms(FileDescriptor socket, IpSecTransform transform)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(socket)) {
|
try (ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(socket)) {
|
||||||
removeTransportModeTransforms(pfd, transform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Call down to remove a transform */
|
|
||||||
private void removeTransportModeTransforms(ParcelFileDescriptor pfd, IpSecTransform transform) {
|
|
||||||
try {
|
|
||||||
mService.removeTransportModeTransforms(pfd, transform.getResourceId());
|
mService.removeTransportModeTransforms(pfd, transform.getResourceId());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
|
|||||||
Reference in New Issue
Block a user