下面列出了android.os.CancellationSignal#createTransport ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void layout(PrintAttributes oldAttributes, PrintAttributes newAttributes,
ILayoutResultCallback callback, Bundle metadata, int sequence) {
ICancellationSignal cancellationTransport = CancellationSignal.createTransport();
try {
callback.onLayoutStarted(cancellationTransport, sequence);
} catch (RemoteException re) {
// The spooler is dead - can't recover.
Log.e(LOG_TAG, "Error notifying for layout start", re);
return;
}
synchronized (mLock) {
// If destroyed the handler is null.
if (isDestroyedLocked()) {
return;
}
CancellationSignal cancellationSignal = CancellationSignal.fromTransport(
cancellationTransport);
SomeArgs args = SomeArgs.obtain();
args.arg1 = mDocumentAdapter;
args.arg2 = oldAttributes;
args.arg3 = newAttributes;
args.arg4 = cancellationSignal;
args.arg5 = new MyLayoutResultCallback(callback, sequence);
args.arg6 = metadata;
mHandler.obtainMessage(MyHandler.MSG_ON_LAYOUT, args).sendToTarget();
}
}
@Override
public void write(PageRange[] pages, ParcelFileDescriptor fd,
IWriteResultCallback callback, int sequence) {
ICancellationSignal cancellationTransport = CancellationSignal.createTransport();
try {
callback.onWriteStarted(cancellationTransport, sequence);
} catch (RemoteException re) {
// The spooler is dead - can't recover.
Log.e(LOG_TAG, "Error notifying for write start", re);
return;
}
synchronized (mLock) {
// If destroyed the handler is null.
if (isDestroyedLocked()) {
return;
}
CancellationSignal cancellationSignal = CancellationSignal.fromTransport(
cancellationTransport);
SomeArgs args = SomeArgs.obtain();
args.arg1 = mDocumentAdapter;
args.arg2 = pages;
args.arg3 = fd;
args.arg4 = cancellationSignal;
args.arg5 = new MyWriteResultCallback(callback, fd, sequence);
mHandler.obtainMessage(MyHandler.MSG_ON_WRITE, args).sendToTarget();
}
}
@Override
public void onFillRequest(FillRequest request, IFillCallback callback) {
ICancellationSignal transport = CancellationSignal.createTransport();
try {
callback.onCancellable(transport);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
mHandler.sendMessage(obtainMessage(
AutofillService::onFillRequest,
AutofillService.this, request, CancellationSignal.fromTransport(transport),
new FillCallback(callback, request.getId())));
}
@Override
public ICancellationSignal createCancellationSignal() {
return CancellationSignal.createTransport();
}
@Override
public ICancellationSignal createCancellationSignal() {
return CancellationSignal.createTransport();
}