List of usage examples for android.support.v4.os CancellationSignal CancellationSignal
public CancellationSignal()
From source file:eu.geopaparazzi.library.database.RawSqlCursorLoader.java
@Override public Cursor loadInBackground() { synchronized (this) { if (isLoadInBackgroundCanceled()) { throw new OperationCanceledException(); }/* w ww . jav a2 s .co m*/ mCancellationSignal = new CancellationSignal(); } try { Cursor cursor = mDatabase.rawQuery(mSql, null); if (cursor != null) { try { // Ensure the cursor window is filled. cursor.getCount(); cursor.registerContentObserver(mObserver); } catch (RuntimeException ex) { cursor.close(); throw ex; } } return cursor; } finally { synchronized (this) { mCancellationSignal = null; } } }
From source file:com.mtramin.rxfingerprint.FingerprintObservable.java
@Override public void call(AsyncEmitter<T> asyncEmitter) { if (!RxFingerprint.isAvailable(context)) { asyncEmitter.onError(new IllegalAccessException( "Fingerprint authentication is not available on this device! Ensure that the device has a Fingerprint sensor and enrolled Fingerprints by calling RxFingerprint#available(Context) first")); }// w ww . ja v a2s . co m AuthenticationCallback callback = createAuthenticationCallback(asyncEmitter); cancellationSignal = new CancellationSignal(); FingerprintManagerCompat.CryptoObject cryptoObject = initCryptoObject(asyncEmitter); FingerprintManagerCompat.from(context).authenticate(cryptoObject, 0, cancellationSignal, callback, null); asyncEmitter.setSubscription(Subscriptions.create(() -> { if (cancellationSignal != null && !cancellationSignal.isCanceled()) { cancellationSignal.cancel(); } })); }
From source file:cn.tangxb.imageselector.PhotoModelTaskLoader.java
@Override public ArrayList<PhotoModel> loadInBackground() { synchronized (this) { if (isLoadInBackgroundCanceled()) { throw new OperationCanceledException(); }// w ww . j a v a 2 s.co m mCancellationSignal = new CancellationSignal(); } try { Cursor cursor = ContentResolverCompat.query(getContext().getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.DATE_ADDED, MediaStore.Images.ImageColumns.SIZE }, null, null, MediaStore.Images.ImageColumns.DATE_ADDED, mCancellationSignal); if (cursor != null) { try { // Ensure the cursor window is filled. cursor.getCount(); cursor.registerContentObserver(mObserver); mData = new ArrayList<>(); if (cursor == null || !cursor.moveToNext()) return mData; cursor.moveToLast(); do { if (cursor.getLong(cursor.getColumnIndex(MediaStore.Images.ImageColumns.SIZE)) > 1024 * 10) { PhotoModel photoModel = new PhotoModel(); photoModel.setOriginalPath( cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA))); mData.add(photoModel); } } while (cursor.moveToPrevious()); } catch (RuntimeException ex) { cursor.close(); throw ex; } } return mData; } finally { synchronized (this) { mCancellationSignal = null; } } }
From source file:com.wei.android.lib.fingerprintidentify.impl.AndroidFingerprint.java
@Override protected void doIdentify() { try {/*from w ww .j ava2 s . c o m*/ mCancellationSignal = new CancellationSignal(); mFingerprintManagerCompat.authenticate(null, 0, mCancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { super.onAuthenticationSucceeded(result); onSucceed(); } @Override public void onAuthenticationFailed() { super.onAuthenticationFailed(); onNotMatch(); } @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { super.onAuthenticationError(errMsgId, errString); if (errMsgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED || errMsgId == FingerprintManager.FINGERPRINT_ERROR_USER_CANCELED) { return; } onFailed(errMsgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT || errMsgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT); } }, null); } catch (Throwable e) { onCatchException(e); onFailed(false); } }
From source file:com.grarak.kerneladiutor.utils.FingerprintUiHelper.java
public void startListening(FingerprintManagerCompat.CryptoObject cryptoObject) { if (!mListening) { mListening = true;// w w w. j a va 2 s .c o m mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; mFingerprintManagerCompat.authenticate(cryptoObject, 0, mCancellationSignal, this, null); mSwirlView.setState(SwirlView.State.ON); } }
From source file:com.keepassdroid.fingerprint.FingerPrintHelper.java
public void startListening() { // no need to start listening when not initialised if (!isFingerprintInitialized()) { if (fingerPrintCallback != null) { fingerPrintCallback.onException(); }//from w w w .j a va 2 s . com return; } if (!cryptoInitOk) { // Crypto key didn't initialize correctly, don't start listening return; } // starts listening for fingerprints with the initialised crypto object cancellationSignal = new CancellationSignal(); fingerprintManager.authenticate(cryptoObject, 0 /* flags */, cancellationSignal, authenticationCallback, null); }
From source file:com.example.android.fingerprintdialog.FingerprintUiHelper.java
public void startListening(CryptoObject cryptoObject) { if (!isFingerprintAuthAvailable()) { return;/*from w w w. j a v a 2 s.c om*/ } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; mFingerprintManager.authenticate(cryptoObject, 0 /* flags */, mCancellationSignal, this, null); mIcon.setImageResource(R.drawable.ic_fp_40px); }
From source file:com.cordova.plugin.android.fingerprintkey.FingerprintUiHelper.java
public void startListening(FingerprintManagerCompat.CryptoObject cryptoObject) { if (!isFingerprintAuthAvailable()) { return;/*from w w w .ja v a 2s . co m*/ } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; mFingerprintManager.authenticate(cryptoObject, 0 /* flags */, mCancellationSignal, this, null); int ic_fp_40px_id = mContext.getResources().getIdentifier("ic_fp_40px", "drawable", FingerprintScanner.packageName); mIcon.setImageResource(ic_fp_40px_id); }
From source file:alexander.martinz.fingerprintfuzzer.FingerPrinter.java
public void startListening() { if (hasFingerprintsSetup() != SETUP_OK) { return;/*ww w.j a va 2 s . co m*/ } cancellationSignal = new CancellationSignal(); selfCanceled = false; fingerprintManager.authenticate(cryptoObjectEnc, 0 /* flags */, cancellationSignal, fingerprinterCallback, null); }
From source file:de.schildbach.wallet.ui.EnableFingerprintDialog.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Activity activity = getActivity(); final View view = LayoutInflater.from(activity).inflate(R.layout.fingerprint_dialog, null); DialogBuilder builder = new DialogBuilder(activity); builder.setTitle(R.string.enable_fingerprint); builder.setView(view);/*from w w w . j a v a2 s . co m*/ builder.setPositiveButton(R.string.notification_inactivity_action_dismiss, null); builder.setNegativeButton(R.string.notification_inactivity_action_dismiss_forever, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { WalletApplication.getInstance().getConfiguration().setRemindEnableFingerprint(false); } }); builder.setCancelable(false); fingerprintView = view.findViewById(R.id.fingerprint_view); fingerprintView.setVisibility(View.VISIBLE); fingerprintView.hideSeparator(); fingerprintView.setText(R.string.touch_fingerprint_to_enable); FingerprintHelper fingerprintHelper = new FingerprintHelper(getActivity()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && fingerprintHelper.init()) { fingerprintCancellationSignal = new CancellationSignal(); fingerprintHelper.savePassword(getArguments().getString(PASSWORD_ARG), fingerprintCancellationSignal, new FingerprintHelper.Callback() { @Override public void onSuccess(String savedPass) { fingerprintCancellationSignal = null; if (activity != null && activity instanceof OnFingerprintEnabledListener) { ((OnFingerprintEnabledListener) activity).onFingerprintEnabled(); } dismiss(); } @Override public void onFailure(String message, boolean canceled, boolean exceededMaxAttempts) { if (!canceled) { fingerprintView.showError(exceededMaxAttempts); } } @Override public void onHelp(int helpCode, String helpString) { fingerprintView.showError(false); } }); } else { dismiss(); } return builder.create(); }