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

Commit 75ba827a authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Set isConnected, isBound, implCreated on server-side LocalSockets"

parents f33a71d0 b08c7bc0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public class LocalServerSocket {

        impl.accept(acceptedImpl);

        return new LocalSocket(acceptedImpl, LocalSocket.SOCKET_UNKNOWN);
        return LocalSocket.createLocalSocketForAccept(acceptedImpl, LocalSocket.SOCKET_UNKNOWN);
    }

    /**
+12 −5
Original line number Diff line number Diff line
@@ -75,17 +75,24 @@ public class LocalSocket implements Closeable {
        isConnected = true;
    }

    /**
     * for use with AndroidServerSocket
     * @param impl a SocketImpl
     */
    /*package*/ LocalSocket(LocalSocketImpl impl, int sockType) {
    private LocalSocket(LocalSocketImpl impl, int sockType) {
        this.impl = impl;
        this.sockType = sockType;
        this.isConnected = false;
        this.isBound = false;
    }

    /**
     * for use with LocalServerSocket.accept()
     */
    static LocalSocket createLocalSocketForAccept(LocalSocketImpl impl, int sockType) {
        LocalSocket socket = new LocalSocket(impl, sockType);
        socket.isConnected = true;
        socket.isBound = true;
        socket.implCreated = true;
        return socket;
    }

    /** {@inheritDoc} */
    @Override
    public String toString() {
+23 −23
Original line number Diff line number Diff line
@@ -235,9 +235,10 @@ class LocalSocketImpl
     * @throws IOException
     */
    public void create(int sockType) throws IOException {
        // no error if socket already created
        // need this for LocalServerSocket.accept()
        if (fd == null) {
        if (fd != null) {
            throw new IOException("LocalSocketImpl already has an fd");
        }

        int osType;
        switch (sockType) {
            case LocalSocket.SOCKET_DGRAM:
@@ -259,7 +260,6 @@ class LocalSocketImpl
            e.rethrowAsIOException();
        }
    }
    }

    /**
     * Closes the socket.