Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3e50363 authored by Wu Ahan's avatar Wu Ahan Committed by Android (Google) Code Review
Browse files

Merge "Add SfpsRestToUnlockFeature to FingerprintFeatureProvider" into main

parents c2251539 a9913cb7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

    <LinearLayout
        style="@style/SudContentFrame"
        android:id="@+id/sfps_enrollment_finish_content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
@@ -31,6 +32,7 @@
        android:clipChildren="false">

            <com.google.android.setupdesign.view.FillContentLayout
                android:id="@+id/sfps_enrollment_finish_content_layout"
                android:layout_width="@dimen/sfps_enrollment_finished_icon_max_size"
                android:layout_height="@dimen/sfps_enrollment_finished_icon_max_size"
                android:layout_marginTop="24dp"
+2 −0
Original line number Diff line number Diff line
@@ -1114,6 +1114,8 @@
    <string name="security_settings_udfps_enroll_progress_a11y_message">Enrolling fingerprint <xliff:g id="percentage" example="10">%d</xliff:g> percent</string>
    <!-- Title shown in fingerprint enrollment dialog once enrollment is completed [CHAR LIMIT=29] -->
    <string name="security_settings_fingerprint_enroll_finish_title">Fingerprint added</string>
    <!-- Key for require screen on to auth toggle shown in fingerprint enrollment dialog once enrollment is completed. [CHAR LIMIT=NONE] -->
    <string name="security_settings_require_screen_on_to_auth_key" translatable="false">security_settings_require_screen_on_to_auth</string>
    <!-- Title for require screen on to auth toggle shown in fingerprint enrollment dialog once enrollment is completed. [CHAR LIMIT=NONE] -->
    <string name="security_settings_require_screen_on_to_auth_title">Touch to unlock anytime</string>
    <!-- Description for require screen on to auth toggle shown in fingerprint enrollment dialog once enrollment is completed. [CHAR LIMIT=NONE] -->
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
        settings:isPreferenceVisible="false">

        <com.android.settingslib.RestrictedSwitchPreference
            android:key="security_settings_require_screen_on_to_auth"
            android:key="@string/security_settings_require_screen_on_to_auth_key"
            android:title="@string/security_settings_require_screen_on_to_auth_title"
            android:summary="@string/security_settings_require_screen_on_to_auth_description"
            settings:keywords="@string/security_settings_require_screen_on_to_auth_keywords"
+24 −5
Original line number Diff line number Diff line
@@ -23,8 +23,10 @@ import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.VisibleForTesting;

@@ -32,6 +34,8 @@ import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.biometrics.fingerprint.feature.SfpsRestToUnlockFeature;
import com.android.settings.overlay.FeatureFactory;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
@@ -56,6 +60,8 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {

    private boolean mIsAddAnotherOrFinish;

    private SfpsRestToUnlockFeature mSfpsRestToUnlockFeature;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -64,14 +70,20 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
                mFingerprintManager.getSensorPropertiesInternal();
        mCanAssumeSfps = props != null && props.size() == 1 && props.get(0).isAnySidefpsType();
        if (mCanAssumeSfps) {
            mSfpsRestToUnlockFeature = FeatureFactory.getFeatureFactory()
                    .getFingerprintFeatureProvider().getSfpsRestToUnlockFeature(this);
            setContentView(R.layout.sfps_enroll_finish);
            setUpRestToUnlockLayout();
        } else {
            setContentView(R.layout.fingerprint_enroll_finish);
        }
        setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
        setDescriptionText(R.string.security_settings_fingerprint_enroll_finish_v2_message);
        if (mCanAssumeSfps) {
            setDescriptionForSfps();
        final String sfpsDescription = mSfpsRestToUnlockFeature != null
                ? mSfpsRestToUnlockFeature.getDescriptionForSfps(this)
                : null;
        if (mCanAssumeSfps && !TextUtils.isEmpty(sfpsDescription)) {
            setDescriptionForSfps(sfpsDescription);
        }

        mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
@@ -93,7 +105,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
        );
    }

    private void setDescriptionForSfps() {
    private void setDescriptionForSfps(String sfpsDescription) {
        final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
        if (fpm != null) {
            final List<FingerprintSensorPropertiesInternal> props =
@@ -101,12 +113,19 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
            final int maxEnrollments = props.get(0).maxEnrollmentsPerUser;
            final int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
            if (enrolled < maxEnrollments) {
                setDescriptionText(R.string
                        .security_settings_fingerprint_enroll_finish_v2_add_fingerprint_message);
                setDescriptionText(sfpsDescription);
            }
        }
    }

    private void setUpRestToUnlockLayout() {
        final ViewGroup contentFrame = findViewById(R.id.sfps_enrollment_finish_content_frame);
        final View restToUnlockLayout = mSfpsRestToUnlockFeature.getRestToUnlockLayout(this);
        if (restToUnlockLayout == null) return;
        contentFrame.removeAllViews();
        contentFrame.addView(restToUnlockLayout);
    }

    @Override
    public void onBackPressed() {
        updateFingerprintSuggestionEnableState();
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.settings.biometrics.fingerprint.feature.SfpsEnrollmentFeature;
import com.android.settings.biometrics.fingerprint.feature.SfpsRestToUnlockFeature;

public interface FingerprintFeatureProvider {
    /**
@@ -44,4 +45,11 @@ public interface FingerprintFeatureProvider {
            @Nullable Bundle activitySavedInstanceState, @Nullable Intent activityIntent) {
        return null;
    }

    /**
     * Gets the feature implementation of SFPS rest to unlock.
     * @param context context
     * @return the feature implementation
     */
    SfpsRestToUnlockFeature getSfpsRestToUnlockFeature(@NonNull Context context);
}
Loading