Merge "[ipsec-doze] Add fchown to IpSecService to support doze" am: 4edb4c8ec4
am: 5949912523 Change-Id: I9036fc2768dd9664ab7407b359f3c689c7ce700e
This commit is contained in:
@@ -475,4 +475,26 @@ public class IpSecServiceTest {
|
|||||||
testIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId);
|
testIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId);
|
||||||
udpEncapResp.fileDescriptor.close();
|
udpEncapResp.fileDescriptor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOpenUdpEncapsulationSocketCallsSetEncapSocketOwner() throws Exception {
|
||||||
|
IpSecUdpEncapResponse udpEncapResp =
|
||||||
|
mIpSecService.openUdpEncapsulationSocket(0, new Binder());
|
||||||
|
|
||||||
|
FileDescriptor sockFd = udpEncapResp.fileDescriptor.getFileDescriptor();
|
||||||
|
ArgumentMatcher<FileDescriptor> fdMatcher = (arg) -> {
|
||||||
|
try {
|
||||||
|
StructStat sockStat = Os.fstat(sockFd);
|
||||||
|
StructStat argStat = Os.fstat(arg);
|
||||||
|
|
||||||
|
return sockStat.st_ino == argStat.st_ino
|
||||||
|
&& sockStat.st_dev == argStat.st_dev;
|
||||||
|
} catch (ErrnoException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
verify(mMockNetd).ipSecSetEncapSocketOwner(argThat(fdMatcher), eq(Os.getuid()));
|
||||||
|
mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user