1/n Start adding Face settings (base, intro)
This change refactors common biometric settings code as well to minimize duplicated code in areas such as: Preference Controller EnrollBase EnrollIntro This change also updates ChooseLock to have Face + Pin/Pattern/Pass Bug: 110589286 Test: Fingerprint settings/enrollment still works Test: make -j56 RunSettingsRoboTests Change-Id: Ie35406a01b85617423beece42683ac086e9bc4a7
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics.fingerprint;
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
@@ -29,6 +29,8 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintSettings;
|
||||
import com.android.settings.core.InstrumentedActivity;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.setupwizardlib.GlifLayout;
|
||||
@@ -36,11 +38,11 @@ import com.android.setupwizardlib.GlifLayout;
|
||||
/**
|
||||
* Base activity for all fingerprint enrollment steps.
|
||||
*/
|
||||
public abstract class FingerprintEnrollBase extends InstrumentedActivity
|
||||
public abstract class BiometricEnrollBase extends InstrumentedActivity
|
||||
implements View.OnClickListener {
|
||||
public static final int RESULT_FINISHED = FingerprintSettings.RESULT_FINISHED;
|
||||
static final int RESULT_SKIP = FingerprintSettings.RESULT_SKIP;
|
||||
static final int RESULT_TIMEOUT = FingerprintSettings.RESULT_TIMEOUT;
|
||||
public static final int RESULT_FINISHED = BiometricSettings.RESULT_FINISHED;
|
||||
public static final int RESULT_SKIP = BiometricSettings.RESULT_SKIP;
|
||||
public static final int RESULT_TIMEOUT = BiometricSettings.RESULT_TIMEOUT;
|
||||
|
||||
protected byte[] mToken;
|
||||
protected int mUserId;
|
||||
@@ -118,7 +120,7 @@ public abstract class FingerprintEnrollBase extends InstrumentedActivity
|
||||
protected void onNextButtonClick() {
|
||||
}
|
||||
|
||||
protected Intent getEnrollingIntent() {
|
||||
protected Intent getFingerprintEnrollingIntent() {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName("com.android.settings", FingerprintEnrollEnrolling.class.getName());
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.setupwizardlib.span.LinkSpan;
|
||||
|
||||
/**
|
||||
* Abstract base class for the intro onboarding activity for biometric enrollment.
|
||||
*/
|
||||
public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
||||
implements LinkSpan.OnClickListener {
|
||||
|
||||
public static final int CHOOSE_LOCK_GENERIC_REQUEST = 1;
|
||||
public static final int BIOMETRIC_FIND_SENSOR_REQUEST = 2;
|
||||
public static final int LEARN_MORE_REQUEST = 3;
|
||||
|
||||
private UserManager mUserManager;
|
||||
private boolean mHasPassword;
|
||||
private boolean mBiometricUnlockDisabledByAdmin;
|
||||
private TextView mErrorText;
|
||||
|
||||
/**
|
||||
* @return true if the biometric is disabled by a device administrator
|
||||
*/
|
||||
protected abstract boolean isDisabledByAdmin();
|
||||
|
||||
/**
|
||||
* @return the layout resource
|
||||
*/
|
||||
protected abstract int getLayoutResource();
|
||||
|
||||
/**
|
||||
* @return the header resource for if the biometric has been disabled by a device administrator
|
||||
*/
|
||||
protected abstract int getHeaderResDisabledByAdmin();
|
||||
|
||||
/**
|
||||
* @return the default header resource
|
||||
*/
|
||||
protected abstract int getHeaderResDefault();
|
||||
|
||||
/**
|
||||
* @return the description resource for if the biometric has been disabled by a device admin
|
||||
*/
|
||||
protected abstract int getDescriptionResDisabledByAdmin();
|
||||
|
||||
/**
|
||||
* @return the cancel button
|
||||
*/
|
||||
protected abstract Button getCancelButton();
|
||||
|
||||
/**
|
||||
* @return the next button
|
||||
*/
|
||||
protected abstract Button getNextButton();
|
||||
|
||||
/**
|
||||
* @return the error TextView
|
||||
*/
|
||||
protected abstract TextView getErrorTextView();
|
||||
|
||||
/**
|
||||
* @return 0 if there are no errors, otherwise returns the resource ID for the error string
|
||||
* to be displayed.
|
||||
*/
|
||||
protected abstract int checkMaxEnrolled();
|
||||
|
||||
/**
|
||||
* @return the challenge generated by the biometric hardware
|
||||
*/
|
||||
protected abstract long getChallenge();
|
||||
|
||||
/**
|
||||
* @return one of the ChooseLockSettingsHelper#EXTRA_KEY_FOR_* constants
|
||||
*/
|
||||
protected abstract String getExtraKeyForBiometric();
|
||||
|
||||
/**
|
||||
* @return the intent for proceeding to the next step of enrollment
|
||||
*/
|
||||
protected abstract Intent getFindSensorIntent();
|
||||
|
||||
/**
|
||||
* @param span
|
||||
*/
|
||||
public abstract void onClick(LinkSpan span);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mBiometricUnlockDisabledByAdmin = isDisabledByAdmin();
|
||||
|
||||
setContentView(getLayoutResource());
|
||||
if (mBiometricUnlockDisabledByAdmin) {
|
||||
setHeaderText(getHeaderResDisabledByAdmin());
|
||||
} else {
|
||||
setHeaderText(getHeaderResDefault());
|
||||
}
|
||||
|
||||
Button cancelButton = getCancelButton();
|
||||
cancelButton.setOnClickListener(v -> onCancelButtonClick());
|
||||
|
||||
mErrorText = getErrorTextView();
|
||||
|
||||
mUserManager = UserManager.get(this);
|
||||
updatePasswordQuality();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
final int errorMsg = checkMaxEnrolled();
|
||||
if (errorMsg == 0) {
|
||||
mErrorText.setText(null);
|
||||
getNextButton().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mErrorText.setText(errorMsg);
|
||||
getNextButton().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePasswordQuality() {
|
||||
final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
|
||||
.getActivePasswordQuality(mUserManager.getCredentialOwnerProfile(mUserId));
|
||||
mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNextButtonClick() {
|
||||
if (!mHasPassword) {
|
||||
// No biometrics registered, launch into enrollment wizard.
|
||||
launchChooseLock();
|
||||
} else {
|
||||
// Lock thingy is already set up, launch directly into find sensor step from wizard.
|
||||
launchFindSensor(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void launchChooseLock() {
|
||||
Intent intent = getChooseLockIntent();
|
||||
long challenge = getChallenge();
|
||||
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
|
||||
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
|
||||
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
|
||||
intent.putExtra(getExtraKeyForBiometric(), true);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
|
||||
}
|
||||
|
||||
private void launchFindSensor(byte[] token) {
|
||||
Intent intent = getFindSensorIntent();
|
||||
if (token != null) {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
}
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
|
||||
}
|
||||
|
||||
protected Intent getChooseLockIntent() {
|
||||
return new Intent(this, ChooseLockGeneric.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
final boolean isResultFinished = resultCode == RESULT_FINISHED;
|
||||
if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST) {
|
||||
if (isResultFinished || resultCode == RESULT_SKIP) {
|
||||
final int result = isResultFinished ? RESULT_OK : RESULT_SKIP;
|
||||
setResult(result, data);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
} else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
|
||||
if (isResultFinished) {
|
||||
updatePasswordQuality();
|
||||
byte[] token = data.getByteArrayExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
launchFindSensor(token);
|
||||
return;
|
||||
}
|
||||
} else if (requestCode == LEARN_MORE_REQUEST) {
|
||||
overridePendingTransition(R.anim.suw_slide_back_in, R.anim.suw_slide_back_out);
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
protected void onCancelButtonClick() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
|
||||
TextView description = (TextView) findViewById(R.id.description_text);
|
||||
if (mBiometricUnlockDisabledByAdmin) {
|
||||
description.setText(getDescriptionResDisabledByAdmin());
|
||||
}
|
||||
}
|
||||
}
|
48
src/com/android/settings/biometrics/BiometricSettings.java
Normal file
48
src/com/android/settings/biometrics/BiometricSettings.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import com.android.settings.SubSettings;
|
||||
|
||||
/**
|
||||
* Abstract base class for biometric settings, such as Fingerprint, Face, Iris
|
||||
*/
|
||||
public abstract class BiometricSettings extends SubSettings {
|
||||
/**
|
||||
* Used by the choose fingerprint wizard to indicate the wizard is
|
||||
* finished, and each activity in the wizard should finish.
|
||||
* <p>
|
||||
* Previously, each activity in the wizard would finish itself after
|
||||
* starting the next activity. However, this leads to broken 'Back'
|
||||
* behavior. So, now an activity does not finish itself until it gets this
|
||||
* result.
|
||||
*/
|
||||
protected static final int RESULT_FINISHED = RESULT_FIRST_USER;
|
||||
|
||||
/**
|
||||
* Used by the enrolling screen during setup wizard to skip over setting up fingerprint, which
|
||||
* will be useful if the user accidentally entered this flow.
|
||||
*/
|
||||
protected static final int RESULT_SKIP = RESULT_FIRST_USER + 1;
|
||||
|
||||
/**
|
||||
* Like {@link #RESULT_FINISHED} except this one indicates enrollment failed because the
|
||||
* device was left idle. This is used to clear the credential token to require the user to
|
||||
* re-enter their pin/pattern/password before continuing.
|
||||
*/
|
||||
protected static final int RESULT_TIMEOUT = RESULT_FIRST_USER + 2;
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
public abstract class BiometricStatusPreferenceController extends BasePreferenceController {
|
||||
|
||||
protected final UserManager mUm;
|
||||
protected final LockPatternUtils mLockPatternUtils;
|
||||
|
||||
protected final int mUserId = UserHandle.myUserId();
|
||||
protected final int mProfileChallengeUserId;
|
||||
|
||||
/**
|
||||
* @return true if the manager is not null and the hardware is detected.
|
||||
*/
|
||||
protected abstract boolean isDeviceSupported();
|
||||
|
||||
/**
|
||||
* @return true if the user has enrolled biometrics of the subclassed type.
|
||||
*/
|
||||
protected abstract boolean hasEnrolledBiometrics();
|
||||
|
||||
/**
|
||||
* @return the summary text if biometrics are enrolled.
|
||||
*/
|
||||
protected abstract String getSummaryTextEnrolled();
|
||||
|
||||
/**
|
||||
* @return the summary text if no biometrics are enrolled.
|
||||
*/
|
||||
protected abstract String getSummaryTextNoneEnrolled();
|
||||
|
||||
/**
|
||||
* @return the class name for the settings page.
|
||||
*/
|
||||
protected abstract String getSettingsClassName();
|
||||
|
||||
/**
|
||||
* @return the class name for entry to enrollment.
|
||||
*/
|
||||
protected abstract String getEnrollClassName();
|
||||
|
||||
public BiometricStatusPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mLockPatternUtils = FeatureFactory.getFactory(context)
|
||||
.getSecurityFeatureProvider()
|
||||
.getLockPatternUtils(context);
|
||||
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!isDeviceSupported()) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (isUserSupported()) {
|
||||
return AVAILABLE;
|
||||
} else {
|
||||
return DISABLED_FOR_USER;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (!isAvailable()) {
|
||||
if (preference != null) {
|
||||
preference.setVisible(false);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
preference.setVisible(true);
|
||||
}
|
||||
final int userId = getUserId();
|
||||
final String clazz;
|
||||
if (hasEnrolledBiometrics()) {
|
||||
preference.setSummary(getSummaryTextEnrolled());
|
||||
clazz = getSettingsClassName();
|
||||
} else {
|
||||
preference.setSummary(getSummaryTextNoneEnrolled());
|
||||
clazz = getEnrollClassName();
|
||||
}
|
||||
preference.setOnPreferenceClickListener(target -> {
|
||||
final Context context = target.getContext();
|
||||
final UserManager userManager = UserManager.get(context);
|
||||
if (Utils.startQuietModeDialogIfNecessary(context, userManager,
|
||||
userId)) {
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName("com.android.settings", clazz);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
protected int getUserId() {
|
||||
return mUserId;
|
||||
}
|
||||
|
||||
protected boolean isUserSupported() {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics.face;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Intent;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollIntroduction;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.setupwizardlib.span.LinkSpan;
|
||||
|
||||
public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
|
||||
private static final String TAG = "FaceIntro";
|
||||
|
||||
private FaceManager mFaceManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mFaceManager = Utils.getFaceManagerOrNull(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDisabledByAdmin() {
|
||||
return RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
||||
this, DevicePolicyManager.KEYGUARD_DISABLE_FACE, mUserId) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResource() {
|
||||
return R.layout.face_enroll_introduction;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeaderResDisabledByAdmin() {
|
||||
return R.string.security_settings_face_enroll_introduction_title_unlock_disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeaderResDefault() {
|
||||
return R.string.security_settings_face_enroll_introduction_title;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDescriptionResDisabledByAdmin() {
|
||||
return R.string.security_settings_fingerprint_enroll_introduction_message_unlock_disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Button getCancelButton() {
|
||||
return findViewById(R.id.face_cancel_button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Button getNextButton() {
|
||||
return findViewById(R.id.face_next_button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextView getErrorTextView() {
|
||||
return findViewById(R.id.error_text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkMaxEnrolled() {
|
||||
if (mFaceManager != null) {
|
||||
final int max = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_faceMaxTemplatesPerUser);
|
||||
final int numEnrolledFaces = mFaceManager.getEnrolledFaces(mUserId).size();
|
||||
if (numEnrolledFaces >= max) {
|
||||
return R.string.face_intro_error_max;
|
||||
}
|
||||
} else {
|
||||
return R.string.face_intro_error_unknown;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long getChallenge() {
|
||||
if (mFaceManager == null) {
|
||||
return 0;
|
||||
}
|
||||
return mFaceManager.preEnroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getExtraKeyForBiometric() {
|
||||
return ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent getFindSensorIntent() {
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.FACE_ENROLL_INTRO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(LinkSpan span) {
|
||||
// TODO(b/110906762)
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics.face;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.face.FaceManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
||||
|
||||
public class FaceStatusPreferenceController extends BiometricStatusPreferenceController {
|
||||
|
||||
private static final String KEY_FACE_SETTINGS = "face_settings";
|
||||
|
||||
protected final FaceManager mFaceManager;
|
||||
|
||||
public FaceStatusPreferenceController(Context context) {
|
||||
this(context, KEY_FACE_SETTINGS);
|
||||
}
|
||||
|
||||
public FaceStatusPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mFaceManager = Utils.getFaceManagerOrNull(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDeviceSupported() {
|
||||
return mFaceManager != null && mFaceManager.isHardwareDetected();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasEnrolledBiometrics() {
|
||||
return mFaceManager.hasEnrolledFaces(mUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSummaryTextEnrolled() {
|
||||
return mContext.getResources()
|
||||
.getString(R.string.security_settings_face_preference_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSummaryTextNoneEnrolled() {
|
||||
return mContext.getResources()
|
||||
.getString(R.string.security_settings_face_preference_summary_none);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSettingsClassName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEnrollClassName() {
|
||||
return FaceEnrollIntroduction.class.getName();
|
||||
}
|
||||
|
||||
}
|
@@ -44,13 +44,14 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
|
||||
/**
|
||||
* Activity which handles the actual enrolling for fingerprint.
|
||||
*/
|
||||
public class FingerprintEnrollEnrolling extends FingerprintEnrollBase
|
||||
public class FingerprintEnrollEnrolling extends BiometricEnrollBase
|
||||
implements FingerprintEnrollSidecar.Listener {
|
||||
|
||||
static final String TAG_SIDECAR = "sidecar";
|
||||
|
@@ -27,6 +27,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintEnrollSidecar.Listener;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
|
||||
@@ -35,7 +36,7 @@ import androidx.annotation.Nullable;
|
||||
/**
|
||||
* Activity explaining the fingerprint sensor location for fingerprint enrollment.
|
||||
*/
|
||||
public class FingerprintEnrollFindSensor extends FingerprintEnrollBase {
|
||||
public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int CONFIRM_REQUEST = 1;
|
||||
@@ -166,7 +167,7 @@ public class FingerprintEnrollFindSensor extends FingerprintEnrollBase {
|
||||
}
|
||||
getFragmentManager().beginTransaction().remove(mSidecar).commitAllowingStateLoss();
|
||||
mSidecar = null;
|
||||
startActivityForResult(getEnrollingIntent(), ENROLLING);
|
||||
startActivityForResult(getFingerprintEnrollingIntent(), ENROLLING);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,11 +25,12 @@ import android.widget.Button;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
|
||||
/**
|
||||
* Activity which concludes fingerprint enrollment.
|
||||
*/
|
||||
public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
||||
public class FingerprintEnrollFinish extends BiometricEnrollBase {
|
||||
|
||||
private static final int REQUEST_ADD_ANOTHER = 1;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class FingerprintEnrollFinish extends FingerprintEnrollBase {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.add_another_button) {
|
||||
startActivityForResult(getEnrollingIntent(), REQUEST_ADD_ANOTHER);
|
||||
startActivityForResult(getFingerprintEnrollingIntent(), REQUEST_ADD_ANOTHER);
|
||||
}
|
||||
super.onClick(v);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,195 +21,109 @@ import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.biometrics.BiometricEnrollIntroduction;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.setupwizardlib.span.LinkSpan;
|
||||
|
||||
/**
|
||||
* Onboarding activity for fingerprint enrollment.
|
||||
*/
|
||||
public class FingerprintEnrollIntroduction extends FingerprintEnrollBase
|
||||
implements View.OnClickListener, LinkSpan.OnClickListener {
|
||||
public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
|
||||
private static final String TAG = "FingerprintIntro";
|
||||
|
||||
protected static final int CHOOSE_LOCK_GENERIC_REQUEST = 1;
|
||||
protected static final int FINGERPRINT_FIND_SENSOR_REQUEST = 2;
|
||||
protected static final int LEARN_MORE_REQUEST = 3;
|
||||
|
||||
private UserManager mUserManager;
|
||||
private boolean mHasPassword;
|
||||
private boolean mFingerprintUnlockDisabledByAdmin;
|
||||
private TextView mErrorText;
|
||||
private FingerprintManager mFingerprintManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mFingerprintUnlockDisabledByAdmin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
||||
this, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId) != null;
|
||||
|
||||
setContentView(R.layout.fingerprint_enroll_introduction);
|
||||
if (mFingerprintUnlockDisabledByAdmin) {
|
||||
setHeaderText(R.string
|
||||
.security_settings_fingerprint_enroll_introduction_title_unlock_disabled);
|
||||
} else {
|
||||
setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title);
|
||||
}
|
||||
|
||||
Button cancelButton = (Button) findViewById(R.id.fingerprint_cancel_button);
|
||||
cancelButton.setOnClickListener(this);
|
||||
|
||||
mErrorText = (TextView) findViewById(R.id.error_text);
|
||||
|
||||
mUserManager = UserManager.get(this);
|
||||
updatePasswordQuality();
|
||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(this);
|
||||
int errorMsg = 0;
|
||||
if (fingerprintManager != null) {
|
||||
final int max = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
||||
final int numEnrolledFingerprints =
|
||||
fingerprintManager.getEnrolledFingerprints(mUserId).size();
|
||||
if (numEnrolledFingerprints >= max) {
|
||||
errorMsg = R.string.fingerprint_intro_error_max;
|
||||
}
|
||||
} else {
|
||||
errorMsg = R.string.fingerprint_intro_error_unknown;
|
||||
}
|
||||
if (errorMsg == 0) {
|
||||
mErrorText.setText(null);
|
||||
getNextButton().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mErrorText.setText(errorMsg);
|
||||
getNextButton().setVisibility(View.GONE);
|
||||
}
|
||||
protected boolean isDisabledByAdmin() {
|
||||
return RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
|
||||
this, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId) != null;
|
||||
}
|
||||
|
||||
private void updatePasswordQuality() {
|
||||
final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
|
||||
.getActivePasswordQuality(mUserManager.getCredentialOwnerProfile(mUserId));
|
||||
mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||
@Override
|
||||
protected int getLayoutResource() {
|
||||
return R.layout.fingerprint_enroll_introduction;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeaderResDisabledByAdmin() {
|
||||
return R.string.security_settings_fingerprint_enroll_introduction_title_unlock_disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeaderResDefault() {
|
||||
return R.string.security_settings_fingerprint_enroll_introduction_title;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDescriptionResDisabledByAdmin() {
|
||||
return R.string.security_settings_fingerprint_enroll_introduction_message_unlock_disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Button getCancelButton() {
|
||||
return findViewById(R.id.fingerprint_cancel_button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Button getNextButton() {
|
||||
return (Button) findViewById(R.id.fingerprint_next_button);
|
||||
return findViewById(R.id.fingerprint_next_button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNextButtonClick() {
|
||||
if (!mHasPassword) {
|
||||
// No fingerprints registered, launch into enrollment wizard.
|
||||
launchChooseLock();
|
||||
protected TextView getErrorTextView() {
|
||||
return findViewById(R.id.error_text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkMaxEnrolled() {
|
||||
if (mFingerprintManager != null) {
|
||||
final int max = getResources().getInteger(
|
||||
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
||||
final int numEnrolledFingerprints =
|
||||
mFingerprintManager.getEnrolledFingerprints(mUserId).size();
|
||||
if (numEnrolledFingerprints >= max) {
|
||||
return R.string.fingerprint_intro_error_max;
|
||||
}
|
||||
} else {
|
||||
// Lock thingy is already set up, launch directly into find sensor step from wizard.
|
||||
launchFindSensor(null);
|
||||
return R.string.fingerprint_intro_error_unknown;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void launchChooseLock() {
|
||||
Intent intent = getChooseLockIntent();
|
||||
long challenge = Utils.getFingerprintManagerOrNull(this).preEnroll();
|
||||
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
|
||||
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
|
||||
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
@Override
|
||||
protected long getChallenge() {
|
||||
if (mFingerprintManager == null) {
|
||||
return 0;
|
||||
}
|
||||
startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
|
||||
return mFingerprintManager.preEnroll();
|
||||
}
|
||||
|
||||
private void launchFindSensor(byte[] token) {
|
||||
Intent intent = getFindSensorIntent();
|
||||
if (token != null) {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
|
||||
}
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
startActivityForResult(intent, FINGERPRINT_FIND_SENSOR_REQUEST);
|
||||
}
|
||||
|
||||
protected Intent getChooseLockIntent() {
|
||||
return new Intent(this, ChooseLockGeneric.class);
|
||||
@Override
|
||||
protected String getExtraKeyForBiometric() {
|
||||
return ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent getFindSensorIntent() {
|
||||
return new Intent(this, FingerprintEnrollFindSensor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
final boolean isResultFinished = resultCode == RESULT_FINISHED;
|
||||
if (requestCode == FINGERPRINT_FIND_SENSOR_REQUEST) {
|
||||
if (isResultFinished || resultCode == RESULT_SKIP) {
|
||||
final int result = isResultFinished ? RESULT_OK : RESULT_SKIP;
|
||||
setResult(result, data);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
} else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
|
||||
if (isResultFinished) {
|
||||
updatePasswordQuality();
|
||||
byte[] token = data.getByteArrayExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
launchFindSensor(token);
|
||||
return;
|
||||
}
|
||||
} else if (requestCode == LEARN_MORE_REQUEST) {
|
||||
overridePendingTransition(R.anim.suw_slide_back_in, R.anim.suw_slide_back_out);
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.fingerprint_cancel_button) {
|
||||
onCancelButtonClick();
|
||||
} else {
|
||||
super.onClick(v);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.FINGERPRINT_ENROLL_INTRO;
|
||||
}
|
||||
|
||||
protected void onCancelButtonClick() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
|
||||
TextView description = (TextView) findViewById(R.id.description_text);
|
||||
if (mFingerprintUnlockDisabledByAdmin) {
|
||||
description.setText(R.string
|
||||
.security_settings_fingerprint_enroll_introduction_message_unlock_disabled);
|
||||
}
|
||||
return MetricsProto.MetricsEvent.FINGERPRINT_ENROLL_INTRO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -43,6 +43,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricSettings;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
@@ -66,34 +67,10 @@ import androidx.preference.PreferenceViewHolder;
|
||||
/**
|
||||
* Settings screen for fingerprints
|
||||
*/
|
||||
public class FingerprintSettings extends SubSettings {
|
||||
public class FingerprintSettings extends BiometricSettings {
|
||||
|
||||
private static final String TAG = "FingerprintSettings";
|
||||
|
||||
/**
|
||||
* Used by the choose fingerprint wizard to indicate the wizard is
|
||||
* finished, and each activity in the wizard should finish.
|
||||
* <p>
|
||||
* Previously, each activity in the wizard would finish itself after
|
||||
* starting the next activity. However, this leads to broken 'Back'
|
||||
* behavior. So, now an activity does not finish itself until it gets this
|
||||
* result.
|
||||
*/
|
||||
protected static final int RESULT_FINISHED = RESULT_FIRST_USER;
|
||||
|
||||
/**
|
||||
* Used by the enrolling screen during setup wizard to skip over setting up fingerprint, which
|
||||
* will be useful if the user accidentally entered this flow.
|
||||
*/
|
||||
protected static final int RESULT_SKIP = RESULT_FIRST_USER + 1;
|
||||
|
||||
/**
|
||||
* Like {@link #RESULT_FINISHED} except this one indicates enrollment failed because the
|
||||
* device was left idle. This is used to clear the credential token to require the user to
|
||||
* re-enter their pin/pattern/password before continuing.
|
||||
*/
|
||||
protected static final int RESULT_TIMEOUT = RESULT_FIRST_USER + 2;
|
||||
|
||||
private static final long LOCKOUT_DURATION = 30000; // time we have to wait for fp to reset, ms
|
||||
|
||||
public static final String ANNOTATION_URL = "url";
|
||||
|
@@ -17,32 +17,17 @@
|
||||
package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
public class FingerprintStatusPreferenceController extends BasePreferenceController {
|
||||
public class FingerprintStatusPreferenceController extends BiometricStatusPreferenceController {
|
||||
|
||||
private static final String KEY_FINGERPRINT_SETTINGS = "fingerprint_settings";
|
||||
|
||||
protected final FingerprintManager mFingerprintManager;
|
||||
protected final UserManager mUm;
|
||||
protected final LockPatternUtils mLockPatternUtils;
|
||||
|
||||
protected final int mUserId = UserHandle.myUserId();
|
||||
protected final int mProfileChallengeUserId;
|
||||
|
||||
public FingerprintStatusPreferenceController(Context context) {
|
||||
this(context, KEY_FINGERPRINT_SETTINGS);
|
||||
@@ -51,69 +36,39 @@ public class FingerprintStatusPreferenceController extends BasePreferenceControl
|
||||
public FingerprintStatusPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mLockPatternUtils = FeatureFactory.getFactory(context)
|
||||
.getSecurityFeatureProvider()
|
||||
.getLockPatternUtils(context);
|
||||
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mFingerprintManager == null || !mFingerprintManager.isHardwareDetected()) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (isUserSupported()) {
|
||||
return AVAILABLE;
|
||||
} else {
|
||||
return DISABLED_FOR_USER;
|
||||
}
|
||||
protected boolean isDeviceSupported() {
|
||||
return mFingerprintManager != null && mFingerprintManager.isHardwareDetected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (!isAvailable()) {
|
||||
if (preference != null) {
|
||||
preference.setVisible(false);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
preference.setVisible(true);
|
||||
}
|
||||
final int userId = getUserId();
|
||||
final List<Fingerprint> items = mFingerprintManager.getEnrolledFingerprints(userId);
|
||||
final int fingerprintCount = items != null ? items.size() : 0;
|
||||
final String clazz;
|
||||
if (fingerprintCount > 0) {
|
||||
preference.setSummary(mContext.getResources().getQuantityString(
|
||||
R.plurals.security_settings_fingerprint_preference_summary,
|
||||
fingerprintCount, fingerprintCount));
|
||||
clazz = FingerprintSettings.class.getName();
|
||||
} else {
|
||||
preference.setSummary(
|
||||
R.string.security_settings_fingerprint_preference_summary_none);
|
||||
clazz = FingerprintEnrollIntroduction.class.getName();
|
||||
}
|
||||
preference.setOnPreferenceClickListener(target -> {
|
||||
final Context context = target.getContext();
|
||||
final UserManager userManager = UserManager.get(context);
|
||||
if (Utils.startQuietModeDialogIfNecessary(context, userManager,
|
||||
userId)) {
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName("com.android.settings", clazz);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
});
|
||||
protected boolean hasEnrolledBiometrics() {
|
||||
return mFingerprintManager.hasEnrolledFingerprints(mUserId);
|
||||
}
|
||||
|
||||
protected int getUserId() {
|
||||
return mUserId;
|
||||
@Override
|
||||
protected String getSummaryTextEnrolled() {
|
||||
final int numEnrolled = mFingerprintManager.getEnrolledFingerprints(mUserId).size();
|
||||
return mContext.getResources().getQuantityString(
|
||||
R.plurals.security_settings_fingerprint_preference_summary,
|
||||
numEnrolled, numEnrolled);
|
||||
}
|
||||
|
||||
protected boolean isUserSupported() {
|
||||
return true;
|
||||
@Override
|
||||
protected String getSummaryTextNoneEnrolled() {
|
||||
return mContext.getString(R.string.security_settings_fingerprint_preference_summary_none);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSettingsClassName() {
|
||||
return FingerprintSettings.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEnrollClassName() {
|
||||
return FingerprintEnrollIntroduction.class.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSenso
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent getEnrollingIntent() {
|
||||
protected Intent getFingerprintEnrollingIntent() {
|
||||
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
|
@@ -28,7 +28,7 @@ import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
public class SetupFingerprintEnrollFinish extends FingerprintEnrollFinish {
|
||||
|
||||
@Override
|
||||
protected Intent getEnrollingIntent() {
|
||||
protected Intent getFingerprintEnrollingIntent() {
|
||||
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
|
@@ -97,7 +97,7 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// if lock was already present, do not return intent data since it must have been
|
||||
// reported in previous attempts
|
||||
if (requestCode == FINGERPRINT_FIND_SENSOR_REQUEST && isKeyguardSecure()
|
||||
if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST && isKeyguardSecure()
|
||||
&& !mAlreadyHadLockScreenSetup) {
|
||||
data = getMetricIntent(data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user