List of usage examples for android.os CancellationSignal CancellationSignal
public CancellationSignal()
From source file:com.nyelito.fingerprintcam.FingerprintUiHelper.java
public void startListening(Context context, FingerprintManager.CryptoObject cryptoObject) { if (!isFingerprintAuthAvailable(context)) { return;//from ww w .j a v a2 s .co m } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; if (ContextCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // public void requestPermissions(@NonNull String[] permissions, int requestCode) // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for Activity#requestPermissions for more details. return; } mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null); // mIcon.setImageResource(R.drawable.ic_fp_40px); }
From source file:se.chalmers.watchme.database.GenericCursorLoader.java
@Override public Cursor loadInBackground() { synchronized (this) { mCancellationSignal = new CancellationSignal(); }//from w w w . jav a 2 s. c om try { Cursor cursor = mCursorHelper.getCursor(); if (cursor != null) { // Ensure the cursor window is filled cursor.getCount(); registerContentObserver(cursor, mObserver); } return cursor; } finally { synchronized (this) { mCancellationSignal = null; } } }
From source file:com.github.brandon.fingerprintauthenticationdialog.FingerprintUiHelper.java
public void startListening(FingerprintManager.CryptoObject cryptoObject) { if (cryptoObject == null) return;/* w w w .jav a2 s . c o m*/ mCancellationSignal = new CancellationSignal(); if (ContextCompat.checkSelfPermission(mActivity, Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED) { mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null); } mIcon.setImageResource(R.drawable.ic_fp_40px); }
From source file:com.elkriefy.android.apps.authenticationexample.fingerprintdialog.FingerprintUiHelper.java
public void startListening(FingerprintManager.CryptoObject cryptoObject) { if (!isFingerprintAuthAvailable()) { return;//from w ww .ja v a 2 s.co m } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null); mIcon.setImageResource(R.drawable.ic_fp_40px); }
From source file:rmatze.com.fingerprint.FingerprintUiHelper.java
public void startListening(FingerprintManager.CryptoObject cryptoObject) { if (!isFingerprintAuthAvailable()) { return;//from www. j a v a2s . c om } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null); mIcon.setImageResource(R.drawable.ic_fp_40px); }
From source file:gov.cdc.everydose.utils.uiUtils.FingerprintUiHelper.java
public void startListening(FingerprintManager.CryptoObject cryptoObject) { if (!isFingerprintAuthAvailable()) { return;//w w w. j a v a2 s .c o m } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null); mIcon.setImageResource(R.drawable.fingerprint); }
From source file:cn.edu.wyu.documentviewer.DirectoryResult.java
@Override public final DirectoryResult loadInBackground() { synchronized (this) { if (isLoadInBackgroundCanceled()) { throw new OperationCanceledException(); }/*from ww w . jav a 2s . c o m*/ mSignal = new CancellationSignal(); } final ContentResolver resolver = getContext().getContentResolver(); final String authority = mUri.getAuthority(); final DirectoryResult result = new DirectoryResult(); int userMode = State.MODE_UNKNOWN; // Use default document when searching if (mType == DirectoryFragment.TYPE_SEARCH) { final Uri docUri = DocumentsContract.buildDocumentUri(mRoot.authority, mRoot.documentId); try { mDoc = DocumentInfo.fromUri(resolver, docUri); } catch (FileNotFoundException e) { Log.w(TAG, "Failed to query", e); result.exception = e; return result; } } // Pick up any custom modes requested by user Cursor cursor = null; try { final Uri stateUri = RecentsProvider.buildState(mRoot.authority, mRoot.rootId, mDoc.documentId); cursor = resolver.query(stateUri, null, null, null, null); if (cursor.moveToFirst()) { userMode = getCursorInt(cursor, StateColumns.MODE); } } finally { IOUtils.closeQuietly(cursor); } if (userMode != State.MODE_UNKNOWN) { result.mode = userMode; } else { if ((mDoc.flags & Document.FLAG_DIR_PREFERS_GRID) != 0) { result.mode = State.MODE_GRID; } else { result.mode = State.MODE_LIST; } } if (mUserSortOrder != State.SORT_ORDER_UNKNOWN) { result.sortOrder = mUserSortOrder; } else { if ((mDoc.flags & Document.FLAG_DIR_PREFERS_LAST_MODIFIED) != 0) { result.sortOrder = State.SORT_ORDER_LAST_MODIFIED; } else { result.sortOrder = State.SORT_ORDER_DISPLAY_NAME; } } // Search always uses ranking from provider if (mType == DirectoryFragment.TYPE_SEARCH) { result.sortOrder = State.SORT_ORDER_UNKNOWN; } Log.d(TAG, "userMode=" + userMode + ", userSortOrder=" + mUserSortOrder + " --> mode=" + result.mode + ", sortOrder=" + result.sortOrder); ContentProviderClient client = null; try { client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, authority); cursor = client.query(mUri, null, null, null, getQuerySortOrder(result.sortOrder), mSignal); cursor.registerContentObserver(mObserver); cursor = new RootCursorWrapper(mUri.getAuthority(), mRoot.rootId, cursor, -1); if (mType == DirectoryFragment.TYPE_SEARCH) { // Filter directories out of search results, for now cursor = new FilteringCursorWrapper(cursor, null, SEARCH_REJECT_MIMES); } else { // Normal directories should have sorting applied cursor = new SortingCursorWrapper(cursor, result.sortOrder); } result.client = client; result.cursor = cursor; } catch (Exception e) { Log.w(TAG, "Failed to query", e); result.exception = e; ContentProviderClient.releaseQuietly(client); } finally { synchronized (this) { mSignal = null; } } return result; }
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
private void startFingerprint() { TextView fingerprintTextView = (TextView) findViewById(R.id.scanfingerprinttext); FingerprintManager fingerprintManager = (FingerprintManager) MainApp.getAppContext() .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return;//from ww w . ja v a2s.c om } KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (!keyguardManager.isKeyguardSecure()) { return; } else { generateKey(); if (cipherInit()) { cryptoObject = new FingerprintManager.CryptoObject(cipher); FingerprintHandler.Callback callback = new FingerprintHandler.Callback() { @Override public void onAuthenticated() { fingerprintResult(true); } @Override public void onFailed(String error) { Toast.makeText(MainApp.getAppContext(), error, Toast.LENGTH_LONG).show(); ImageView imageView = (ImageView) findViewById(R.id.fingerprinticon); int[][] states = new int[][] { new int[] { android.R.attr.state_activated }, new int[] { -android.R.attr.state_activated } }; int[] colors = new int[] { Color.parseColor("#FF0000"), Color.RED }; ColorStateList csl = new ColorStateList(states, colors); Drawable drawable = DrawableCompat.wrap(imageView.getDrawable()); DrawableCompat.setTintList(drawable, csl); imageView.setImageDrawable(drawable); } }; helper = new FingerprintHandler(fingerprintTextView, callback); cancellationSignal = new CancellationSignal(); if (ActivityCompat.checkSelfPermission(MainApp.getAppContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, helper, null); } } }
From source file:android.webkit.cts.WebViewTest.java
private void savePrintedPage(final PrintDocumentAdapter adapter, final ParcelFileDescriptor descriptor, final FutureTask<Boolean> result) { adapter.onWrite(new PageRange[] { PageRange.ALL_PAGES }, descriptor, new CancellationSignal(), new WriteResultCallback() { @Override/*www .j a va 2s. com*/ public void onWriteFinished(PageRange[] pages) { try { descriptor.close(); result.run(); } catch (IOException ex) { fail("Failed file operation: " + ex.toString()); } } }); }
From source file:android.webkit.cts.WebViewTest.java
private void printDocumentLayout(final PrintDocumentAdapter adapter, final PrintAttributes oldAttributes, final PrintAttributes newAttributes, final LayoutResultCallback layoutResultCallback) { mOnUiThread.runOnUiThread(new Runnable() { @Override//from ww w.j a v a 2s. c o m public void run() { adapter.onLayout(oldAttributes, newAttributes, new CancellationSignal(), layoutResultCallback, null); } }); }