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

Commit 118c8515 authored by Zhihai Xu's avatar Zhihai Xu
Browse files

Bluetooth stopped working in master - "bad file descriptor"

only close file descriptor which is created internally for LocalSocketImpl

bug:9960585
Change-Id: I79492a05cc7c81ae6e134058840d5ca0b7663795
parent df3cedab
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ class LocalSocketImpl

    /** null if closed or not yet created */
    private FileDescriptor fd;
    /** whether fd is created internally */
    private boolean mFdCreatedInternally;

    // These fields are accessed by native code;
    /** file descriptor array received during a previous read */
@@ -247,6 +249,7 @@ class LocalSocketImpl
            }
            try {
                fd = Libcore.os.socket(OsConstants.AF_UNIX, osType, 0);
                mFdCreatedInternally = true;
            } catch (ErrnoException e) {
                e.rethrowAsIOException();
            }
@@ -260,7 +263,10 @@ class LocalSocketImpl
     */
    public void close() throws IOException {
        synchronized (LocalSocketImpl.this) {
            if (fd == null) return;
            if ((fd == null) || (mFdCreatedInternally == false)) {
                fd = null;
                return;
            }
            try {
                Libcore.os.close(fd);
            } catch (ErrnoException e) {