Search in sources :

Example 1 with FingerprintSensorPropertiesInternal

use of android.hardware.fingerprint.FingerprintSensorPropertiesInternal in project android_packages_apps_crDroidSettings by crdroidandroid.

the class DeviceUtils method hasUDFPS.

/**
 * Checks if the device has udfps
 * @param context context for getting FingerprintManager
 * @return true is udfps is present
 */
public static boolean hasUDFPS(Context context) {
    final FingerprintManager fingerprintManager = context.getSystemService(FingerprintManager.class);
    final List<FingerprintSensorPropertiesInternal> props = fingerprintManager.getSensorPropertiesInternal();
    return props != null && props.size() == 1 && props.get(0).isAnyUdfpsType();
}
Also used : FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) FingerprintManager(android.hardware.fingerprint.FingerprintManager)

Example 2 with FingerprintSensorPropertiesInternal

use of android.hardware.fingerprint.FingerprintSensorPropertiesInternal in project android_packages_apps_Settings by omnirom.

the class BiometricEnrollActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    if (this instanceof InternalActivity) {
        mUserId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
        if (BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
            mGkPwHandle = BiometricUtils.getGatekeeperPasswordHandle(getIntent());
        }
    }
    if (savedInstanceState != null) {
        mConfirmingCredentials = savedInstanceState.getBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, false);
        mIsEnrollActionLogged = savedInstanceState.getBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, false);
        mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS);
        if (savedInstanceState.containsKey(SAVED_STATE_GK_PW_HANDLE)) {
            mGkPwHandle = savedInstanceState.getLong(SAVED_STATE_GK_PW_HANDLE);
        }
    }
    // Log a framework stats event if this activity was launched via intent action.
    if (!mIsEnrollActionLogged && ACTION_BIOMETRIC_ENROLL.equals(intent.getAction())) {
        mIsEnrollActionLogged = true;
        // Get the current status for each authenticator type.
        @BiometricError final int strongBiometricStatus;
        @BiometricError final int weakBiometricStatus;
        @BiometricError final int deviceCredentialStatus;
        final BiometricManager bm = getSystemService(BiometricManager.class);
        if (bm != null) {
            strongBiometricStatus = bm.canAuthenticate(Authenticators.BIOMETRIC_STRONG);
            weakBiometricStatus = bm.canAuthenticate(Authenticators.BIOMETRIC_WEAK);
            deviceCredentialStatus = bm.canAuthenticate(Authenticators.DEVICE_CREDENTIAL);
        } else {
            strongBiometricStatus = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
            weakBiometricStatus = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
            deviceCredentialStatus = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
        }
        FrameworkStatsLog.write(FrameworkStatsLog.AUTH_ENROLL_ACTION_INVOKED, strongBiometricStatus == BiometricManager.BIOMETRIC_SUCCESS, weakBiometricStatus == BiometricManager.BIOMETRIC_SUCCESS, deviceCredentialStatus == BiometricManager.BIOMETRIC_SUCCESS, intent.hasExtra(EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED), intent.getIntExtra(EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, 0));
    }
    // Put the theme in the intent so it gets propagated to other activities in the flow
    if (intent.getStringExtra(WizardManagerHelper.EXTRA_THEME) == null) {
        intent.putExtra(WizardManagerHelper.EXTRA_THEME, SetupWizardUtils.getThemeString(intent));
    }
    final PackageManager pm = getApplicationContext().getPackageManager();
    mHasFeatureFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
    mHasFeatureFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE);
    // determine what can be enrolled
    final boolean isSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
    if (mHasFeatureFace) {
        final FaceManager faceManager = getSystemService(FaceManager.class);
        final List<FaceSensorPropertiesInternal> faceProperties = faceManager.getSensorPropertiesInternal();
        if (!faceProperties.isEmpty()) {
            final int maxEnrolls = isSetupWizard ? 1 : faceProperties.get(0).maxEnrollmentsPerUser;
            mIsFaceEnrollable = faceManager.getEnrolledFaces(mUserId).size() < maxEnrolls;
        }
    }
    if (mHasFeatureFingerprint) {
        final FingerprintManager fpManager = getSystemService(FingerprintManager.class);
        final List<FingerprintSensorPropertiesInternal> fpProperties = fpManager.getSensorPropertiesInternal();
        if (!fpProperties.isEmpty()) {
            final int maxEnrolls = isSetupWizard ? 1 : fpProperties.get(0).maxEnrollmentsPerUser;
            mIsFingerprintEnrollable = fpManager.getEnrolledFingerprints(mUserId).size() < maxEnrolls;
        }
    }
    mParentalOptionsRequired = intent.getBooleanExtra(EXTRA_REQUIRE_PARENTAL_CONSENT, false);
    mSkipReturnToParent = intent.getBooleanExtra(EXTRA_SKIP_RETURN_TO_PARENT, false);
    Log.d(TAG, "parentalOptionsRequired: " + mParentalOptionsRequired + ", skipReturnToParent: " + mSkipReturnToParent + ", isSetupWizard: " + isSetupWizard);
    // module. This can be removed when there is a way to notify consent status out of band.
    if (isSetupWizard && mParentalOptionsRequired) {
        Log.w(TAG, "Enrollment with parental consent is not supported when launched " + " directly from SuW - skipping enrollment");
        setResult(RESULT_SKIP);
        finish();
        return;
    }
    // restarting the process once it has been fully completed at least one time.
    if (isSetupWizard && mParentalOptionsRequired) {
        final boolean consentAlreadyManaged = ParentalControlsUtils.parentConsentRequired(this, BiometricAuthenticator.TYPE_FACE | BiometricAuthenticator.TYPE_FINGERPRINT) != null;
        if (consentAlreadyManaged) {
            Log.w(TAG, "Consent was already setup - skipping enrollment");
            setResult(RESULT_SKIP);
            finish();
            return;
        }
    }
    // start enrollment process if we haven't bailed out yet
    if (mParentalOptionsRequired && mParentalOptions == null) {
        mParentalConsentHelper = new ParentalConsentHelper(mIsFaceEnrollable, mIsFingerprintEnrollable, mGkPwHandle);
        setOrConfirmCredentialsNow();
    } else {
        startEnroll();
    }
}
Also used : FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) BiometricError(android.hardware.biometrics.BiometricManager.BiometricError) Intent(android.content.Intent) FaceSensorPropertiesInternal(android.hardware.face.FaceSensorPropertiesInternal) BiometricManager(android.hardware.biometrics.BiometricManager) PackageManager(android.content.pm.PackageManager) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FaceManager(android.hardware.face.FaceManager)

Example 3 with FingerprintSensorPropertiesInternal

use of android.hardware.fingerprint.FingerprintSensorPropertiesInternal in project android_packages_apps_Settings by omnirom.

the class FingerprintSuggestionActivityTest method setUp.

@Before
public void setUp() {
    Shadows.shadowOf(application.getPackageManager()).setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
    final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
    componentInfo.add(new ComponentInfoInternal("faceSensor", /* componentId */
    "vendor/model/revision", /* hardwareVersion */
    "1.01", /* firmwareVersion */
    "00000001", /* serialNumber */
    ""));
    componentInfo.add(new ComponentInfoInternal("matchingAlgorithm", /* componentId */
    "", /* hardwareVersion */
    "", /* firmwareVersion */
    "", /* serialNumber */
    "vendor/version/revision"));
    final FingerprintSensorPropertiesInternal prop = new FingerprintSensorPropertiesInternal(0, /* sensorId */
    SensorProperties.STRENGTH_STRONG, 5, /* maxEnrollmentsPerUser */
    componentInfo, FingerprintSensorProperties.TYPE_REAR, true);
    final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
    props.add(prop);
    ShadowFingerprintManager.setSensorProperties(props);
    FakeFeatureFactory.setupForTest();
    final Intent intent = new Intent();
    mController = Robolectric.buildActivity(FingerprintSuggestionActivity.class, intent);
    mActivity = mController.get();
}
Also used : ComponentInfoInternal(android.hardware.biometrics.ComponentInfoInternal) FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Before(org.junit.Before)

Example 4 with FingerprintSensorPropertiesInternal

use of android.hardware.fingerprint.FingerprintSensorPropertiesInternal in project android_packages_apps_Settings by omnirom.

the class FingerprintEnrollEnrolling method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mFingerprintManager = getSystemService(FingerprintManager.class);
    final List<FingerprintSensorPropertiesInternal> props = mFingerprintManager.getSensorPropertiesInternal();
    mCanAssumeUdfps = props.size() == 1 && props.get(0).isAnyUdfpsType();
    mAccessibilityManager = getSystemService(AccessibilityManager.class);
    mIsAccessibilityEnabled = mAccessibilityManager.isEnabled();
    listenOrientationEvent();
    if (mCanAssumeUdfps) {
        if (BiometricUtils.isReverseLandscape(getApplicationContext())) {
            setContentView(R.layout.udfps_enroll_enrolling_land);
        } else {
            setContentView(R.layout.udfps_enroll_enrolling);
        }
        setDescriptionText(R.string.security_settings_udfps_enroll_start_message);
    } else {
        setContentView(R.layout.fingerprint_enroll_enrolling);
        setDescriptionText(R.string.security_settings_fingerprint_enroll_start_message);
    }
    mIsSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
    if (mCanAssumeUdfps) {
        updateTitleAndDescriptionForUdfps();
    } else {
        setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
    }
    mErrorText = findViewById(R.id.error_text);
    mProgressBar = findViewById(R.id.fingerprint_progress_bar);
    mVibrator = getSystemService(Vibrator.class);
    mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
    mFooterBarMixin.setSecondaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_fingerprint_enroll_enrolling_skip).setListener(this::onSkipButtonClick).setButtonType(FooterButton.ButtonType.SKIP).setTheme(R.style.SudGlifButton_Secondary).build());
    final LayerDrawable fingerprintDrawable = mProgressBar != null ? (LayerDrawable) mProgressBar.getBackground() : null;
    if (fingerprintDrawable != null) {
        mIconAnimationDrawable = (AnimatedVectorDrawable) fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation);
        mIconBackgroundBlinksDrawable = (AnimatedVectorDrawable) fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_background);
        mIconAnimationDrawable.registerAnimationCallback(mIconAnimationCallback);
    }
    mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);
    mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in);
    mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in);
    if (mProgressBar != null) {
        mProgressBar.setOnTouchListener((v, event) -> {
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                mIconTouchCount++;
                if (mIconTouchCount == ICON_TOUCH_COUNT_SHOW_UNTIL_DIALOG_SHOWN) {
                    showIconTouchDialog();
                } else {
                    mProgressBar.postDelayed(mShowDialogRunnable, ICON_TOUCH_DURATION_UNTIL_DIALOG_SHOWN);
                }
            } else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || event.getActionMasked() == MotionEvent.ACTION_UP) {
                mProgressBar.removeCallbacks(mShowDialogRunnable);
            }
            return true;
        });
    }
    mRestoring = savedInstanceState != null;
}
Also used : FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) AccessibilityManager(android.view.accessibility.AccessibilityManager) FingerprintManager(android.hardware.fingerprint.FingerprintManager) LayerDrawable(android.graphics.drawable.LayerDrawable) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) Vibrator(android.os.Vibrator)

Example 5 with FingerprintSensorPropertiesInternal

use of android.hardware.fingerprint.FingerprintSensorPropertiesInternal in project android_packages_apps_Settings by omnirom.

the class FingerprintEnrollFindSensor method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
    final List<FingerprintSensorPropertiesInternal> props = fingerprintManager.getSensorPropertiesInternal();
    mCanAssumeUdfps = props != null && props.size() == 1 && props.get(0).isAnyUdfpsType();
    setContentView(getContentView());
    mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
    mFooterBarMixin.setSecondaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_fingerprint_enroll_enrolling_skip).setListener(this::onSkipButtonClick).setButtonType(FooterButton.ButtonType.SKIP).setTheme(R.style.SudGlifButton_Secondary).build());
    if (mCanAssumeUdfps) {
        setHeaderText(R.string.security_settings_udfps_enroll_find_sensor_title);
        setDescriptionText(R.string.security_settings_udfps_enroll_find_sensor_message);
        mFooterBarMixin.setPrimaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_udfps_enroll_find_sensor_start_button).setListener(this::onStartButtonClick).setButtonType(FooterButton.ButtonType.NEXT).setTheme(R.style.SudGlifButton_Primary).build());
    } else {
        setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title);
        setDescriptionText(R.string.security_settings_fingerprint_enroll_find_sensor_message);
    }
    // adb shell am start -a android.app.action.SET_NEW_PASSWORD
    if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
        final FingerprintManager fpm = getSystemService(FingerprintManager.class);
        fpm.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
            mChallenge = challenge;
            mSensorId = sensorId;
            mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
            // Put this into the intent. This is really just to work around the fact that the
            // enrollment sidecar gets the HAT from the activity's intent, rather than having
            // it passed in.
            getIntent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
            startLookingForFingerprint();
        });
    } else if (mToken != null) {
        // HAT passed in from somewhere else, such as FingerprintEnrollIntroduction
        startLookingForFingerprint();
    } else {
        // There's something wrong with the enrollment flow, this should never happen.
        throw new IllegalStateException("HAT and GkPwHandle both missing...");
    }
    mAnimation = null;
    if (!mCanAssumeUdfps) {
        View animationView = findViewById(R.id.fingerprint_sensor_location_animation);
        if (animationView instanceof FingerprintFindSensorAnimation) {
            mAnimation = (FingerprintFindSensorAnimation) animationView;
        }
    }
}
Also used : FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) View(android.view.View)

Aggregations

FingerprintSensorPropertiesInternal (android.hardware.fingerprint.FingerprintSensorPropertiesInternal)6 FingerprintManager (android.hardware.fingerprint.FingerprintManager)4 Intent (android.content.Intent)3 ComponentInfoInternal (android.hardware.biometrics.ComponentInfoInternal)2 FooterBarMixin (com.google.android.setupcompat.template.FooterBarMixin)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 PackageManager (android.content.pm.PackageManager)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 BiometricManager (android.hardware.biometrics.BiometricManager)1 BiometricError (android.hardware.biometrics.BiometricManager.BiometricError)1 FaceManager (android.hardware.face.FaceManager)1 FaceSensorPropertiesInternal (android.hardware.face.FaceSensorPropertiesInternal)1 Vibrator (android.os.Vibrator)1 View (android.view.View)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1