Java Code Examples for android.os.CancellationSignal#createTransport()

The following examples show how to use android.os.CancellationSignal#createTransport() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 2
Source File: PrintManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 3
Source File: AutofillService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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())));
}
 
Example 4
Source File: ContentProvider.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public ICancellationSignal createCancellationSignal() {
    return CancellationSignal.createTransport();
}
 
Example 5
Source File: ContentProvider.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public ICancellationSignal createCancellationSignal() {
    return CancellationSignal.createTransport();
}