本文整理汇总了Java中android.os.ParcelFileDescriptor.createPipe方法的典型用法代码示例。如果您正苦于以下问题:Java ParcelFileDescriptor.createPipe方法的具体用法?Java ParcelFileDescriptor.createPipe怎么用?Java ParcelFileDescriptor.createPipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.ParcelFileDescriptor
的用法示例。
在下文中一共展示了ParcelFileDescriptor.createPipe方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openFile
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
ParcelFileDescriptor[] pipe;
try {
pipe = ParcelFileDescriptor.createPipe();
String url = getFilePath(uri);
Log.d(TAG, "Retrieving " + url);
ByteArrayOutputStream stream = getDataForUrl(url);
new TransferThread(stream, new AutoCloseOutputStream(pipe[1])).start();
} catch (IOException e) {
e.printStackTrace();
throw new FileNotFoundException("Could not open pipe for: " + uri.toString());
}
return (pipe[0]);
}
示例2: testBadFileDescriptorProvider
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
public void testBadFileDescriptorProvider() throws Exception {
TestUrlRequestCallback callback = new TestUrlRequestCallback();
UrlRequest.Builder builder =
new UrlRequest.Builder(NativeTestServer.getRedirectToEchoBody(), callback,
callback.getExecutor(), mTestFramework.mCronetEngine);
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
try {
UploadDataProvider dataProvider = UploadDataProviders.create(pipe[0]);
builder.setUploadDataProvider(dataProvider, callback.getExecutor());
builder.addHeader("Content-Type", "useless/string");
builder.build().start();
callback.blockForDone();
assertTrue(callback.mError.getCause() instanceof IllegalArgumentException);
} finally {
pipe[1].close();
}
}
示例3: pipeFrom
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public static ParcelFileDescriptor pipeFrom(InputStream inputStream)
throws IOException {
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
final OutputStream output = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]);
new TransferThread(inputStream, output).start();
return pipe[0];
}
示例4: pipeFrom
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public static ParcelFileDescriptor pipeFrom(InputStream inputStream)
throws IOException {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
ParcelFileDescriptor readSide = pipe[0];
ParcelFileDescriptor writeSide = pipe[1];
new TransferThread(inputStream, new ParcelFileDescriptor.AutoCloseOutputStream(writeSide))
.start();
return readSide;
}
示例5: startPumpThread
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public ParcelFileDescriptor startPumpThread() throws IOException {
if (writeSidePfd != null) {
throw new IllegalStateException("startPumpThread() must only be called once!");
}
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
ParcelFileDescriptor readSidePfd = pipe[0];
writeSidePfd = pipe[1];
new DataSourceTransferThread(this, new ParcelFileDescriptor.AutoCloseOutputStream(writeSidePfd)).start();
return readSidePfd;
}
示例6: pipeTo
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public static ParcelFileDescriptor pipeTo(OutputStream outputStream)
throws IOException {
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
final InputStream input = new ParcelFileDescriptor.AutoCloseInputStream(pipe[0]);
new TransferThread(input, outputStream).start();
return pipe[1];
}
示例7: NativePipe
import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public NativePipe() {
try {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pipe[0]) {
private boolean closed = false;
@Override
public void close() throws IOException {
if (closed) return;
closed = true;
super.close();
outputStream.close();
}
};
outputStream = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]) {
private boolean closed = false;
@Override
public void close() throws IOException {
if (closed) return;
closed = true;
super.close();
inputStream.close();
}
};
} catch (IOException e) {
throw new RuntimeException(e);
}
}