Merge "Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl" am: d6c2dc5908
am: db15177cf7
Change-Id: I8b89e88d1db96581ab91d649e5af621c499669ed
This commit is contained in:
@@ -1236,7 +1236,8 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
OsConstants.UDP_ENCAP,
|
OsConstants.UDP_ENCAP,
|
||||||
OsConstants.UDP_ENCAP_ESPINUDP);
|
OsConstants.UDP_ENCAP_ESPINUDP);
|
||||||
|
|
||||||
mSrvConfig.getNetdInstance().ipSecSetEncapSocketOwner(sockFd, callingUid);
|
mSrvConfig.getNetdInstance().ipSecSetEncapSocketOwner(
|
||||||
|
new ParcelFileDescriptor(sockFd), callingUid);
|
||||||
if (port != 0) {
|
if (port != 0) {
|
||||||
Log.v(TAG, "Binding to port " + port);
|
Log.v(TAG, "Binding to port " + port);
|
||||||
Os.bind(sockFd, INADDR_ANY, port);
|
Os.bind(sockFd, INADDR_ANY, port);
|
||||||
@@ -1696,7 +1697,7 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
mSrvConfig
|
mSrvConfig
|
||||||
.getNetdInstance()
|
.getNetdInstance()
|
||||||
.ipSecApplyTransportModeTransform(
|
.ipSecApplyTransportModeTransform(
|
||||||
socket.getFileDescriptor(),
|
socket,
|
||||||
callingUid,
|
callingUid,
|
||||||
direction,
|
direction,
|
||||||
c.getSourceAddress(),
|
c.getSourceAddress(),
|
||||||
@@ -1715,7 +1716,7 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
mSrvConfig
|
mSrvConfig
|
||||||
.getNetdInstance()
|
.getNetdInstance()
|
||||||
.ipSecRemoveTransportModeTransform(socket.getFileDescriptor());
|
.ipSecRemoveTransportModeTransform(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ public class IpSecServiceParameterizedTest {
|
|||||||
|
|
||||||
verify(mMockNetd)
|
verify(mMockNetd)
|
||||||
.ipSecApplyTransportModeTransform(
|
.ipSecApplyTransportModeTransform(
|
||||||
eq(pfd.getFileDescriptor()),
|
eq(pfd),
|
||||||
eq(mUid),
|
eq(mUid),
|
||||||
eq(IpSecManager.DIRECTION_OUT),
|
eq(IpSecManager.DIRECTION_OUT),
|
||||||
anyString(),
|
anyString(),
|
||||||
@@ -555,7 +555,7 @@ public class IpSecServiceParameterizedTest {
|
|||||||
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket());
|
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket());
|
||||||
mIpSecService.removeTransportModeTransforms(pfd);
|
mIpSecService.removeTransportModeTransforms(pfd);
|
||||||
|
|
||||||
verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd.getFileDescriptor());
|
verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IpSecTunnelInterfaceResponse createAndValidateTunnel(
|
private IpSecTunnelInterfaceResponse createAndValidateTunnel(
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ public class IpSecServiceTest {
|
|||||||
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket());
|
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket());
|
||||||
mIpSecService.removeTransportModeTransforms(pfd);
|
mIpSecService.removeTransportModeTransforms(pfd);
|
||||||
|
|
||||||
verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd.getFileDescriptor());
|
verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -620,10 +620,10 @@ public class IpSecServiceTest {
|
|||||||
mIpSecService.openUdpEncapsulationSocket(0, new Binder());
|
mIpSecService.openUdpEncapsulationSocket(0, new Binder());
|
||||||
|
|
||||||
FileDescriptor sockFd = udpEncapResp.fileDescriptor.getFileDescriptor();
|
FileDescriptor sockFd = udpEncapResp.fileDescriptor.getFileDescriptor();
|
||||||
ArgumentMatcher<FileDescriptor> fdMatcher = (arg) -> {
|
ArgumentMatcher<ParcelFileDescriptor> fdMatcher = (arg) -> {
|
||||||
try {
|
try {
|
||||||
StructStat sockStat = Os.fstat(sockFd);
|
StructStat sockStat = Os.fstat(sockFd);
|
||||||
StructStat argStat = Os.fstat(arg);
|
StructStat argStat = Os.fstat(arg.getFileDescriptor());
|
||||||
|
|
||||||
return sockStat.st_ino == argStat.st_ino
|
return sockStat.st_ino == argStat.st_ino
|
||||||
&& sockStat.st_dev == argStat.st_dev;
|
&& sockStat.st_dev == argStat.st_dev;
|
||||||
|
|||||||
Reference in New Issue
Block a user