Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8e522bb authored by Luke Huang's avatar Luke Huang
Browse files

Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl

Stable aidl won't support FileDescriptor but ParcelFileDescriptor.
In order to migrate to stable aidl, replace all FileDescriptor in
INdetd.aidl.

Test: runtest frameworks-net passes
Change-Id: Icdf37aed0e0cce0352070a437066e77c0f2fd85a
parent 372fa2ed
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1236,7 +1236,8 @@ public class IpSecService extends IIpSecService.Stub {
                    OsConstants.UDP_ENCAP,
                    OsConstants.UDP_ENCAP_ESPINUDP);

            mSrvConfig.getNetdInstance().ipSecSetEncapSocketOwner(sockFd, callingUid);
            mSrvConfig.getNetdInstance().ipSecSetEncapSocketOwner(
                        new ParcelFileDescriptor(sockFd), callingUid);
            if (port != 0) {
                Log.v(TAG, "Binding to port " + port);
                Os.bind(sockFd, INADDR_ANY, port);
@@ -1696,7 +1697,7 @@ public class IpSecService extends IIpSecService.Stub {
        mSrvConfig
                .getNetdInstance()
                .ipSecApplyTransportModeTransform(
                        socket.getFileDescriptor(),
                        socket,
                        callingUid,
                        direction,
                        c.getSourceAddress(),
@@ -1715,7 +1716,7 @@ public class IpSecService extends IIpSecService.Stub {
            throws RemoteException {
        mSrvConfig
                .getNetdInstance()
                .ipSecRemoveTransportModeTransform(socket.getFileDescriptor());
                .ipSecRemoveTransportModeTransform(socket);
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -542,7 +542,7 @@ public class IpSecServiceParameterizedTest {

        verify(mMockNetd)
                .ipSecApplyTransportModeTransform(
                        eq(pfd.getFileDescriptor()),
                        eq(pfd),
                        eq(mUid),
                        eq(IpSecManager.DIRECTION_OUT),
                        anyString(),
@@ -555,7 +555,7 @@ public class IpSecServiceParameterizedTest {
        ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket());
        mIpSecService.removeTransportModeTransforms(pfd);

        verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd.getFileDescriptor());
        verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd);
    }

    private IpSecTunnelInterfaceResponse createAndValidateTunnel(
+3 −3
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ public class IpSecServiceTest {
        ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket());
        mIpSecService.removeTransportModeTransforms(pfd);

        verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd.getFileDescriptor());
        verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd);
    }

    @Test
@@ -620,10 +620,10 @@ public class IpSecServiceTest {
                mIpSecService.openUdpEncapsulationSocket(0, new Binder());

        FileDescriptor sockFd = udpEncapResp.fileDescriptor.getFileDescriptor();
        ArgumentMatcher<FileDescriptor> fdMatcher = (arg) -> {
        ArgumentMatcher<ParcelFileDescriptor> fdMatcher = (arg) -> {
                    try {
                        StructStat sockStat = Os.fstat(sockFd);
                        StructStat argStat = Os.fstat(arg);
                        StructStat argStat = Os.fstat(arg.getFileDescriptor());

                        return sockStat.st_ino == argStat.st_ino
                                && sockStat.st_dev == argStat.st_dev;