Search in sources :

Example 36 with ICancellationSignal

use of android.os.ICancellationSignal in project android_frameworks_base by AOSPA.

the class CancellationSignal method cancel.

/**
     * Cancels the operation and signals the cancellation listener.
     * If the operation has not yet started, then it will be canceled as soon as it does.
     */
public void cancel() {
    final OnCancelListener listener;
    final ICancellationSignal remote;
    synchronized (this) {
        if (mIsCanceled) {
            return;
        }
        mIsCanceled = true;
        mCancelInProgress = true;
        listener = mOnCancelListener;
        remote = mRemote;
    }
    try {
        if (listener != null) {
            listener.onCancel();
        }
        if (remote != null) {
            try {
                remote.cancel();
            } catch (RemoteException ex) {
            }
        }
    } finally {
        synchronized (this) {
            mCancelInProgress = false;
            notifyAll();
        }
    }
}
Also used : ICancellationSignal(android.os.ICancellationSignal)

Example 37 with ICancellationSignal

use of android.os.ICancellationSignal in project android_frameworks_base by ResurrectionRemix.

the class CancellationSignal method cancel.

/**
     * Cancels the operation and signals the cancellation listener.
     * If the operation has not yet started, then it will be canceled as soon as it does.
     */
public void cancel() {
    final OnCancelListener listener;
    final ICancellationSignal remote;
    synchronized (this) {
        if (mIsCanceled) {
            return;
        }
        mIsCanceled = true;
        mCancelInProgress = true;
        listener = mOnCancelListener;
        remote = mRemote;
    }
    try {
        if (listener != null) {
            listener.onCancel();
        }
        if (remote != null) {
            try {
                remote.cancel();
            } catch (RemoteException ex) {
            }
        }
    } finally {
        synchronized (this) {
            mCancelInProgress = false;
            notifyAll();
        }
    }
}
Also used : ICancellationSignal(android.os.ICancellationSignal)

Example 38 with ICancellationSignal

use of android.os.ICancellationSignal in project android_frameworks_base by ResurrectionRemix.

the class ContentProviderClient method query.

/** See {@link ContentProvider#query ContentProvider.query} */
@Nullable
public Cursor query(@NonNull Uri url, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder, @Nullable CancellationSignal cancellationSignal) throws RemoteException {
    Preconditions.checkNotNull(url, "url");
    beforeRemote();
    try {
        ICancellationSignal remoteCancellationSignal = null;
        if (cancellationSignal != null) {
            cancellationSignal.throwIfCanceled();
            remoteCancellationSignal = mContentProvider.createCancellationSignal();
            cancellationSignal.setRemote(remoteCancellationSignal);
        }
        final Cursor cursor = mContentProvider.query(mPackageName, url, projection, selection, selectionArgs, sortOrder, remoteCancellationSignal);
        if (cursor == null) {
            return null;
        }
        if ("com.google.android.gms".equals(mPackageName)) {
            // They're casting to a concrete subclass, sigh
            return cursor;
        } else {
            return new CursorWrapperInner(cursor);
        }
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
Also used : ICancellationSignal(android.os.ICancellationSignal) DeadObjectException(android.os.DeadObjectException) Cursor(android.database.Cursor) Nullable(android.annotation.Nullable)

Example 39 with ICancellationSignal

use of android.os.ICancellationSignal in project android_frameworks_base by ResurrectionRemix.

the class ContentProviderClient method openFile.

/**
     * See {@link ContentProvider#openFile ContentProvider.openFile}.  Note that
     * this <em>does not</em>
     * take care of non-content: URIs such as file:.  It is strongly recommended
     * you use the {@link ContentResolver#openFileDescriptor
     * ContentResolver.openFileDescriptor} API instead.
     */
@Nullable
public ParcelFileDescriptor openFile(@NonNull Uri url, @NonNull String mode, @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
    Preconditions.checkNotNull(url, "url");
    Preconditions.checkNotNull(mode, "mode");
    beforeRemote();
    try {
        ICancellationSignal remoteSignal = null;
        if (signal != null) {
            signal.throwIfCanceled();
            remoteSignal = mContentProvider.createCancellationSignal();
            signal.setRemote(remoteSignal);
        }
        return mContentProvider.openFile(mPackageName, url, mode, remoteSignal, null);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
Also used : ICancellationSignal(android.os.ICancellationSignal) DeadObjectException(android.os.DeadObjectException) Nullable(android.annotation.Nullable)

Example 40 with ICancellationSignal

use of android.os.ICancellationSignal in project android_frameworks_base by ResurrectionRemix.

the class ContentProviderClient method openAssetFile.

/**
     * See {@link ContentProvider#openAssetFile ContentProvider.openAssetFile}.
     * Note that this <em>does not</em>
     * take care of non-content: URIs such as file:.  It is strongly recommended
     * you use the {@link ContentResolver#openAssetFileDescriptor
     * ContentResolver.openAssetFileDescriptor} API instead.
     */
@Nullable
public AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode, @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
    Preconditions.checkNotNull(url, "url");
    Preconditions.checkNotNull(mode, "mode");
    beforeRemote();
    try {
        ICancellationSignal remoteSignal = null;
        if (signal != null) {
            signal.throwIfCanceled();
            remoteSignal = mContentProvider.createCancellationSignal();
            signal.setRemote(remoteSignal);
        }
        return mContentProvider.openAssetFile(mPackageName, url, mode, remoteSignal);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
Also used : ICancellationSignal(android.os.ICancellationSignal) DeadObjectException(android.os.DeadObjectException) Nullable(android.annotation.Nullable)

Aggregations

ICancellationSignal (android.os.ICancellationSignal)49 DeadObjectException (android.os.DeadObjectException)37 Nullable (android.annotation.Nullable)35 RemoteException (android.os.RemoteException)16 Cursor (android.database.Cursor)11 AssetFileDescriptor (android.content.res.AssetFileDescriptor)10 ParcelFileDescriptor (android.os.ParcelFileDescriptor)10 FileNotFoundException (java.io.FileNotFoundException)10 Parcel (android.os.Parcel)6 Resources (android.content.res.Resources)5 File (java.io.File)5