Search in sources :

Example 51 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Settings by AOSPA.

the class BiometricEnrollSidecar method startEnrollment.

protected void startEnrollment() {
    mHandler.removeCallbacks(mTimeoutRunnable);
    mEnrollmentSteps = -1;
    mEnrollmentCancel = new CancellationSignal();
    mEnrolling = true;
}
Also used : CancellationSignal(android.os.CancellationSignal)

Example 52 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Settings by AOSPA.

the class WifiDppUtils method showLockScreen.

/**
 * Shows authentication screen to confirm credentials (pin, pattern or password) for the current
 * user of the device.
 *
 * @param context The {@code Context} used to get {@code KeyguardManager} service
 * @param successRunnable The {@code Runnable} which will be executed if the user does not setup
 *                        device security or if lock screen is unlocked
 */
public static void showLockScreen(Context context, Runnable successRunnable) {
    final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if (keyguardManager.isKeyguardSecure()) {
        final BiometricPrompt.AuthenticationCallback authenticationCallback = new BiometricPrompt.AuthenticationCallback() {

            @Override
            public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
                successRunnable.run();
            }

            @Override
            public void onAuthenticationError(int errorCode, CharSequence errString) {
            // Do nothing
            }
        };
        final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context).setTitle(context.getText(R.string.wifi_dpp_lockscreen_title));
        if (keyguardManager.isDeviceSecure()) {
            builder.setDeviceCredentialAllowed(true);
        }
        final BiometricPrompt bp = builder.build();
        final Handler handler = new Handler(Looper.getMainLooper());
        bp.authenticate(new CancellationSignal(), runnable -> handler.post(runnable), authenticationCallback);
    } else {
        successRunnable.run();
    }
}
Also used : BiometricPrompt(android.hardware.biometrics.BiometricPrompt) Handler(android.os.Handler) KeyguardManager(android.app.KeyguardManager) CancellationSignal(android.os.CancellationSignal)

Example 53 with CancellationSignal

use of android.os.CancellationSignal in project android_packages_apps_Settings by AOSPA.

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());
}
Also used : PrintJob(android.print.PrintJob) Bundle(android.os.Bundle) UiDevice(android.support.test.uiautomator.UiDevice) Activity(android.app.Activity) Intent(android.content.Intent) PrintAttributes(android.print.PrintAttributes) PrintManager(android.print.PrintManager) ParcelFileDescriptor(android.os.ParcelFileDescriptor) UUID(java.util.UUID) PrintDocumentAdapter(android.print.PrintDocumentAdapter) CancellationSignal(android.os.CancellationSignal) UiObject2(android.support.test.uiautomator.UiObject2) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 54 with CancellationSignal

use of android.os.CancellationSignal in project packages_apps_Settings by PixelExperience.

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());
}
Also used : PrintJob(android.print.PrintJob) Bundle(android.os.Bundle) UiDevice(android.support.test.uiautomator.UiDevice) Activity(android.app.Activity) Intent(android.content.Intent) PrintAttributes(android.print.PrintAttributes) PrintManager(android.print.PrintManager) ParcelFileDescriptor(android.os.ParcelFileDescriptor) UUID(java.util.UUID) PrintDocumentAdapter(android.print.PrintDocumentAdapter) CancellationSignal(android.os.CancellationSignal) UiObject2(android.support.test.uiautomator.UiObject2) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 55 with CancellationSignal

use of android.os.CancellationSignal in project packages_apps_Settings by PixelExperience.

the class BiometricEnrollSidecar method startEnrollment.

protected void startEnrollment() {
    mHandler.removeCallbacks(mTimeoutRunnable);
    mEnrollmentSteps = -1;
    mEnrollmentCancel = new CancellationSignal();
    mEnrolling = true;
}
Also used : CancellationSignal(android.os.CancellationSignal)

Aggregations

CancellationSignal (android.os.CancellationSignal)170 Cursor (android.database.Cursor)22 Test (org.junit.Test)21 BiometricPrompt (android.hardware.biometrics.BiometricPrompt)20 OperationCanceledException (android.os.OperationCanceledException)18 ParcelFileDescriptor (android.os.ParcelFileDescriptor)17 Handler (android.os.Handler)15 KeyguardManager (android.app.KeyguardManager)14 Intent (android.content.Intent)14 FingerprintManager (android.hardware.fingerprint.FingerprintManager)14 Bundle (android.os.Bundle)14 Activity (android.app.Activity)12 PrintAttributes (android.print.PrintAttributes)12 PrintDocumentAdapter (android.print.PrintDocumentAdapter)12 PrintJob (android.print.PrintJob)12 PrintManager (android.print.PrintManager)12 UiDevice (android.support.test.uiautomator.UiDevice)12 UiObject2 (android.support.test.uiautomator.UiObject2)12 LargeTest (androidx.test.filters.LargeTest)12 UUID (java.util.UUID)12