Revert "Revert "Remove a misleading "flush" function.""

This reverts commit 47da177405.

Reason for revert: Fixed the test broken by the original commit

Bug: 139192244
Bug: 140336855

Test: m -> flash -> boot
Test: atest CtsJvmtiAttachingHostTestCases

Change-Id: I4c67ad8709652c4710ef24564e0240f74f817f8c
This commit is contained in:
Christian Wailes
2019-09-04 23:35:54 +00:00
parent 47da177405
commit 647fee87dc
5 changed files with 0 additions and 65 deletions

View File

@@ -75,16 +75,4 @@ import java.io.OutputStream;
}
mSocket.write(b, offset, count);
}
/**
* Wait until the data in sending queue is emptied. A polling version
* for flush implementation. Use it to ensure the writing data afterwards will
* be packed in the new RFCOMM frame.
*
* @throws IOException if an i/o error occurs.
* @since Android 4.2.3
*/
public void flush() throws IOException {
mSocket.flush();
}
}

View File

@@ -515,20 +515,6 @@ public final class BluetoothSocket implements Closeable {
return mSocketIS.available();
}
/**
* Wait until the data in sending queue is emptied. A polling version
* for flush implementation. Used to ensure the writing data afterwards will
* be packed in new RFCOMM frame.
*
* @throws IOException if an i/o error occurs.
*/
@UnsupportedAppUsage
/*package*/ void flush() throws IOException {
if (mSocketOS == null) throw new IOException("flush is called on null OutputStream");
if (VDBG) Log.d(TAG, "flush: " + mSocketOS);
mSocketOS.flush();
}
/*package*/ int read(byte[] b, int offset, int length) throws IOException {
int ret = 0;
if (VDBG) Log.d(TAG, "read in: " + mSocketIS + " len: " + length);

View File

@@ -157,40 +157,6 @@ class LocalSocketImpl
write_native(b, myFd);
}
}
/**
* Wait until the data in sending queue is emptied. A polling version
* for flush implementation.
* @throws IOException
* if an i/o error occurs.
*/
@Override
public void flush() throws IOException {
FileDescriptor myFd = fd;
if (myFd == null) throw new IOException("socket closed");
// Loop until the output buffer is empty.
Int32Ref pending = new Int32Ref(0);
while (true) {
try {
// See linux/net/unix/af_unix.c
Os.ioctlInt(myFd, OsConstants.TIOCOUTQ, pending);
} catch (ErrnoException e) {
throw e.rethrowAsIOException();
}
if (pending.value <= 0) {
// The output buffer is empty.
break;
}
try {
Thread.sleep(10);
} catch (InterruptedException ie) {
break;
}
}
}
}
private native int read_native(FileDescriptor fd) throws IOException;