use of android.os.CancellationSignal in project packages_apps_Settings by Evolution-X.
the class PrintJobSettingsActivityTest method viewPrintJobSettings.
@Test
@LargeTest
public void viewPrintJobSettings() throws Exception {
UUID uuid = UUID.randomUUID();
Object isWriteCalled = new Object();
// Create adapter that is good enough to start a print preview
PrintDocumentAdapter adapter = new PrintDocumentAdapter() {
@Override
public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) {
callback.onLayoutFinished(new PrintDocumentInfo.Builder(uuid.toString()).build(), true);
}
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) {
synchronized (isWriteCalled) {
isWriteCalled.notify();
}
callback.onWriteFailed(null);
}
};
Activity activity = mActivityRule.getActivity();
PrintManager pm = mActivityRule.getActivity().getSystemService(PrintManager.class);
// Start printing
PrintJob printJob = pm.print(uuid.toString(), adapter, null);
// Wait until print preview is up
synchronized (isWriteCalled) {
isWriteCalled.wait();
}
// Start print job settings
Intent intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS);
intent.putExtra(EXTRA_PRINT_JOB_ID, printJob.getId().flattenToString());
intent.setData(Uri.fromParts("printjob", printJob.getId().flattenToString(), null));
activity.startActivity(intent);
UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject2 printPrefTitle = uiDevice.wait(Until.findObject(By.text("Configuring " + uuid.toString())), 5000);
assertNotNull(printPrefTitle);
Log.i(LOG_TAG, "Found " + printPrefTitle.getText());
}
use of android.os.CancellationSignal in project cyborg-core by nu-art.
the class FingerprintModule method startListening.
@RequiresPermission(USE_FINGERPRINT)
public void startListening(Cipher cipher) {
if (!isEnabled() || !hasEnrolledFingerprints()) {
return;
}
if (cancellationSignal != null && !cancellationSignal.isCanceled()) {
logWarning("Already listening");
return;
}
CryptoObject cryptoObject = new CryptoObject(cipher);
cancellationSignal = new CancellationSignal();
// The line below prevents the false positive inspection from Android Studio
// noinspection ResourceType
getFingerprintManager().authenticate(cryptoObject, cancellationSignal, 0, /* flags */
new AuthenticationCallback() {
@Override
public void onAuthenticationError(final int errorCode, final CharSequence errString) {
cancellationSignal = null;
dispatchGlobalEvent("Authentication help(" + errorCode + "): " + errString, FingerprintAuthenticationListener.class, new Processor<FingerprintAuthenticationListener>() {
@Override
public void process(FingerprintAuthenticationListener listener) {
listener.onAuthenticationError(errorCode, errString);
}
});
}
@Override
public void onAuthenticationHelp(final int helpCode, final CharSequence helpString) {
dispatchGlobalEvent("Authentication help(" + helpCode + "): " + helpString, FingerprintAuthenticationListener.class, new Processor<FingerprintAuthenticationListener>() {
@Override
public void process(FingerprintAuthenticationListener listener) {
listener.onAuthenticationHelp(helpCode, helpString);
}
});
}
@Override
public void onAuthenticationSucceeded(final AuthenticationResult result) {
cancellationSignal = null;
dispatchGlobalEvent("Authentication successful", FingerprintAuthenticationListener.class, new Processor<FingerprintAuthenticationListener>() {
@Override
public void process(FingerprintAuthenticationListener listener) {
listener.onAuthenticationSucceeded(result);
}
});
}
@Override
public void onAuthenticationFailed() {
dispatchGlobalEvent("Authentication failed", FingerprintAuthenticationListener.class, new Processor<FingerprintAuthenticationListener>() {
@Override
public void process(FingerprintAuthenticationListener listener) {
listener.onAuthenticationFailed();
}
});
}
}, handler);
}
use of android.os.CancellationSignal in project SightRemote by TebbeUbben.
the class ConfirmationDialog method show.
@SuppressLint("NewApi")
public void show() {
prepareViews();
dialog = builder.show();
dialog.setOnDismissListener((dialogInterface -> onClose()));
dialog.setOnCancelListener((dialog -> onClose()));
if (useFingerprint())
getFingerprintManager().authenticate(null, cancellationSignal = new CancellationSignal(), 0, new FingerprintManager.AuthenticationCallback() {
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
onConfirm();
}
@Override
public void onAuthenticationFailed() {
fingerprintIcon.getBackground().setColorFilter(ContextCompat.getColor(SightRemote.getInstance(), R.color.colorWrong), PorterDuff.Mode.MULTIPLY);
fingerprintText.setText(R.string.couldnt_recognize_fingerprint);
fingerprintText.setTextColor(ContextCompat.getColor(SightRemote.getInstance(), R.color.colorWrong));
}
}, null);
if (getBooleanPref(PREF_BOOLEAN_ENABLE_CONFIRMATION_CHALLENGES))
pin.requestFocus();
}
use of android.os.CancellationSignal in project platform_packages_apps_Settings by BlissRoms.
the class FingerprintEnrollSidecar method startEnrollment.
private void startEnrollment() {
mHandler.removeCallbacks(mTimeoutRunnable);
mEnrollmentSteps = -1;
mEnrollmentCancel = new CancellationSignal();
getActivity().getSystemService(FingerprintManager.class).enroll(mToken, mEnrollmentCancel, 0, /* flags */
mEnrollmentCallback);
mEnrolling = true;
}
use of android.os.CancellationSignal in project platform_packages_apps_Settings by AospExtended.
the class BiometricFragment method onResume.
@Override
public void onResume() {
super.onResume();
if (mCancellationSignal == null) {
mCancellationSignal = new CancellationSignal();
mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor, mAuthenticationCallback, mUserId);
}
}
Aggregations