MediaPlayer2: Remove hidden API usage, libcore.io.Streams

Test: build
Bug: 112767549
Change-Id: I7a23711660dab0a49a5d383f61f683283b592d0f
This commit is contained in:
Dongwon Kang
2018-10-01 10:13:45 -07:00
parent 58131839f0
commit a563eec2e7

View File

@@ -60,7 +60,6 @@ import com.android.internal.util.Preconditions;
import dalvik.system.CloseGuard;
import libcore.io.IoBridge;
import libcore.io.Streams;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -3954,7 +3953,7 @@ public final class MediaPlayer2Impl extends MediaPlayer2 {
connection.setReadTimeout(TIMEOUT_MS);
connection.connect();
response = Streams.readFully(connection.getInputStream());
response = readInputStreamFully(connection.getInputStream());
Log.v(TAG, "HandleProvisioninig: Thread run: response " +
response.length + " " + response);
@@ -4034,6 +4033,29 @@ public final class MediaPlayer2Impl extends MediaPlayer2 {
finished = true;
} // run()
/**
* Returns a byte[] containing the remainder of 'in', closing it when done.
*/
private byte[] readInputStreamFully(InputStream in) throws IOException {
try {
return readInputStreamFullyNoClose(in);
} finally {
in.close();
}
}
/**
* Returns a byte[] containing the remainder of 'in'.
*/
private byte[] readInputStreamFullyNoClose(InputStream in) throws IOException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int count;
while ((count = in.read(buffer)) != -1) {
bytes.write(buffer, 0, count);
}
return bytes.toByteArray();
}
} // ProvisioningThread
private int HandleProvisioninig(UUID uuid) {