android.support.v4.os.CancellationSignal Java Examples

The following examples show how to use android.support.v4.os.CancellationSignal. 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: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    FingerprintManagerCompatApi23.authenticate(context, wrapCryptoObject(crypto), flags,
            cancel != null ? cancel.getCancellationSignalObject() : null,
            wrapCallback(callback), handler);
}
 
Example #2
Source File: FingerprintUiHelper.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
public void startListening(FingerprintManagerCompat.CryptoObject cryptoObject) {
    if (!mListening) {
        mListening = true;
        mCancellationSignal = new CancellationSignal();
        mSelfCancelled = false;
        mFingerprintManagerCompat
                .authenticate(cryptoObject, 0, mCancellationSignal, this, null);
        mSwirlView.setState(SwirlView.State.ON);
    }
}
 
Example #3
Source File: CursorLoader.java    From letv with Apache License 2.0 5 votes vote down vote up
public Cursor loadInBackground() {
    Cursor cursor;
    synchronized (this) {
        if (isLoadInBackgroundCanceled()) {
            throw new OperationCanceledException();
        }
        this.mCancellationSignal = new CancellationSignal();
    }
    try {
        cursor = ContentResolverCompat.query(getContext().getContentResolver(), this.mUri, this.mProjection, this.mSelection, this.mSelectionArgs, this.mSortOrder, this.mCancellationSignal);
        if (cursor != null) {
            cursor.getCount();
            cursor.registerContentObserver(this.mObserver);
        }
        synchronized (this) {
            this.mCancellationSignal = null;
        }
        return cursor;
    } catch (RuntimeException ex) {
        cursor.close();
        throw ex;
    } catch (Throwable th) {
        synchronized (this) {
            this.mCancellationSignal = null;
        }
    }
}
 
Example #4
Source File: ContentResolverCompat.java    From letv with Apache License 2.0 5 votes vote down vote up
public Cursor query(ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
    Object cancellationSignalObject;
    if (cancellationSignal != null) {
        try {
            cancellationSignalObject = cancellationSignal.getCancellationSignalObject();
        } catch (Exception e) {
            if (ContentResolverCompatJellybean.isFrameworkOperationCanceledException(e)) {
                throw new OperationCanceledException();
            }
            throw e;
        }
    }
    cancellationSignalObject = null;
    return ContentResolverCompatJellybean.query(resolver, uri, projection, selection, selectionArgs, sortOrder, cancellationSignalObject);
}
 
Example #5
Source File: InteractionNavigationPopAnimationFactory.java    From scene with Apache License 2.0 5 votes vote down vote up
public void begin(NavigationScene navigationScene, Scene from, Scene to) {
    this.mStart = true;
    this.mNavigationScene = navigationScene;
    this.mFromScene = from;
    this.mToScene = to;
    this.mAnimationList = onPopInteraction(from, to);

    if (mCallback != null) {
        this.mAnimationList.add(new CallbackProgressProxyInteractionAnimation(1.0f));
    }

    this.mToScreenViewVisibility = this.mToScene.getView().getVisibility();
    this.mToScene.getView().setVisibility(View.VISIBLE);
    this.mFromSceneBackground = this.mFromScene.getView().getBackground();
    ViewCompat.setBackground(this.mFromScene.getView(), null);

    mCancellationSignal = new CancellationSignal();
    mCancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {
        @Override
        public void onCancel() {
            forceCancel();
        }
    });
    sCancellationSignal = mCancellationSignal;

    if (this.mCallback != null) {
        this.mCallback.onStart();
    }
}
 
Example #6
Source File: FingerAuth.java    From FingerAuth with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    failedCount = 0;

    authenticationCallback = new FingerprintManagerCompat.AuthenticationCallback() {
        @Override
        public void onAuthenticationFailed() {
            failedCount++;
            if (failedCount == maxFailedCount) {
                failedCount = 0;
                if (onFingerAuthListener != null) {
                    cancelSignal();
                    onFingerAuthListener.onError();
                }
            } else {
                onFingerAuthListener.onFailure();
            }
        }

        @Override
        public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) {
            if (onFingerAuthListener != null) {
                cancelSignal();
                onFingerAuthListener.onSuccess();
            }
        }
    };

    fingerprintManagerCompat = FingerprintManagerCompat.from(context);
    cancellationSignal = new CancellationSignal();

    fingerprintManagerCompat.authenticate(null, 0, cancellationSignal, authenticationCallback, null);
}
 
Example #7
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    FingerprintManagerCompatApi23.authenticate(context, wrapCryptoObject(crypto), flags,
            cancel != null ? cancel.getCancellationSignalObject() : null,
            wrapCallback(callback), handler);
}
 
Example #8
Source File: Utility.java    From scene with Apache License 2.0 5 votes vote down vote up
/**
 * This is especially error-prone, so the ViewTreeObserver parameter is mandatory.
 * <p>
 * If a View does not have attachedWindow(), the getViewTreeObserver is created internally by itself,
 * and ready to be merged into the system when attachedToWindow.
 * But if you need to remove this View in somewhere (such as Scene's own lifecycle)
 * Then there is no way to getViewTreeObserver.removeOnPreDrawListener(this)
 */
public static void executeImmediatelyOrOnPreDraw(@NonNull final View view, @NonNull final ViewTreeObserver viewTreeObserver, boolean force, @NonNull final CancellationSignal cancellationSignal, @NonNull final Runnable action) {
    if (view == null) {
        throw new NullPointerException("view can't be null");
    }
    if (viewTreeObserver == null) {
        throw new NullPointerException("viewTreeObserver can't be null");
    }
    if (action == null) {
        throw new NullPointerException("action can't be null");
    }
    if (force || view.getWidth() > 0 && view.getHeight() > 0) {
        action.run();
    } else {
        viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                viewTreeObserver.removeOnPreDrawListener(this);
                if (!cancellationSignal.isCanceled()) {
                    action.run();
                    return true;
                } else {
                    return false;
                }
            }
        });
        view.invalidate();
    }
}
 
Example #9
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
void authenticate(Context context, CryptoObject crypto, int flags,
CancellationSignal cancel, AuthenticationCallback callback, Handler handler);
 
Example #10
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    // TODO: Figure out behavior when there is no fingerprint hardware available
}
 
Example #11
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void authenticate(Context context, CryptoObject crypto, int flags,
                         CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    // TODO: Figure out behavior when there is no fingerprint hardware available
}
 
Example #12
Source File: ContentResolverCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public Cursor query(ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
    if (cancellationSignal != null) {
        cancellationSignal.throwIfCanceled();
    }
    return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
}
 
Example #13
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
void authenticate(Context context, CryptoObject crypto, int flags,
CancellationSignal cancel, AuthenticationCallback callback, Handler handler);
 
Example #14
Source File: ContentResolverCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public static Cursor query(ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
    return IMPL.query(resolver, uri, projection, selection, selectionArgs, sortOrder, cancellationSignal);
}
 
Example #15
Source File: FingerprintManagerCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public void authenticate(Context context, CryptoObject crypto, int flags, CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
    FingerprintManagerCompatApi23.authenticate(context, wrapCryptoObject(crypto), flags, cancel != null ? cancel.getCancellationSignalObject() : null, wrapCallback(callback), handler);
}
 
Example #16
Source File: FingerprintManagerCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public void authenticate(Context context, CryptoObject crypto, int flags, CancellationSignal cancel, AuthenticationCallback callback, Handler handler) {
}
 
Example #17
Source File: FingerprintManagerCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public void authenticate(@Nullable CryptoObject crypto, int flags, @Nullable CancellationSignal cancel, @NonNull AuthenticationCallback callback, @Nullable Handler handler) {
    IMPL.authenticate(this.mContext, crypto, flags, cancel, callback, handler);
}
 
Example #18
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Request authentication of a crypto object. This call warms up the fingerprint hardware
 * and starts scanning for a fingerprint. It terminates when
 * {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)} or
 * {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult) is called, at
 * which point the object is no longer valid. The operation can be canceled by using the
 * provided cancel object.
 *
 * @param crypto object associated with the call or null if none required.
 * @param flags optional flags; should be 0
 * @param cancel an object that can be used to cancel authentication
 * @param callback an object to receive authentication events
 * @param handler an optional handler for events
 */
public void authenticate(@Nullable CryptoObject crypto, int flags,
                         @Nullable CancellationSignal cancel, @NonNull AuthenticationCallback callback,
                         @Nullable Handler handler) {
    IMPL.authenticate(mContext, crypto, flags, cancel, callback, handler);
}
 
Example #19
Source File: FingerprintManagerCompat.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Request authentication of a crypto object. This call warms up the fingerprint hardware
 * and starts scanning for a fingerprint. It terminates when
 * {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)} or
 * {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult) is called, at
 * which point the object is no longer valid. The operation can be canceled by using the
 * provided cancel object.
 *
 * @param crypto object associated with the call or null if none required.
 * @param flags optional flags; should be 0
 * @param cancel an object that can be used to cancel authentication
 * @param callback an object to receive authentication events
 * @param handler an optional handler for events
 */
public void authenticate(@Nullable CryptoObject crypto, int flags,
                         @Nullable CancellationSignal cancel, @NonNull AuthenticationCallback callback,
                         @Nullable Handler handler) {
    IMPL.authenticate(mContext, crypto, flags, cancel, callback, handler);
}
 
Example #20
Source File: ContentResolverCompat.java    From letv with Apache License 2.0 votes vote down vote up
Cursor query(ContentResolver contentResolver, Uri uri, String[] strArr, String str, String[] strArr2, String str2, CancellationSignal cancellationSignal); 
Example #21
Source File: FingerprintManagerCompat.java    From letv with Apache License 2.0 votes vote down vote up
void authenticate(Context context, CryptoObject cryptoObject, int i, CancellationSignal cancellationSignal, AuthenticationCallback authenticationCallback, Handler handler);