Move all the shared data from biometric controllers to separate utility classes
Test: atest SettingsUnitTests Bug: 215517420 Change-Id: Ic5421cd910ae77d4e7c0a29ae0337edb98a1d3b9
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
||||||
|
import static com.android.settings.biometrics.BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.core.SettingsBaseActivity;
|
||||||
|
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities for navigation shared between Security Settings and Safety Center.
|
||||||
|
*/
|
||||||
|
public class BiometricNavigationUtils {
|
||||||
|
|
||||||
|
private final int mUserId = UserHandle.myUserId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to launch the Settings screen if Quiet Mode is not enabled
|
||||||
|
* for managed profile, otherwise shows a dialog to disable the Quiet Mode.
|
||||||
|
*
|
||||||
|
* @param className The class name of Settings screen to launch.
|
||||||
|
* @param extras Extras to put into the launching {@link Intent}.
|
||||||
|
* @return true if the Settings screen is launching.
|
||||||
|
*/
|
||||||
|
public boolean launchBiometricSettings(Context context, String className, Bundle extras) {
|
||||||
|
final UserManager userManager = UserManager.get(context);
|
||||||
|
if (Utils.startQuietModeDialogIfNecessary(context, userManager, mUserId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
intent.setClassName(SETTINGS_PACKAGE_NAME, className);
|
||||||
|
if (!extras.isEmpty()) {
|
||||||
|
intent.putExtras(extras);
|
||||||
|
}
|
||||||
|
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
|
||||||
|
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||||
|
intent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
|
||||||
|
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
|
||||||
|
context.startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -16,11 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.biometrics;
|
package com.android.settings.biometrics;
|
||||||
|
|
||||||
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
|
||||||
import static com.android.settings.biometrics.BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -30,9 +26,7 @@ import androidx.preference.Preference;
|
|||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.SettingsBaseActivity;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
|
||||||
|
|
||||||
public abstract class BiometricStatusPreferenceController extends BasePreferenceController {
|
public abstract class BiometricStatusPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
@@ -42,36 +36,23 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
|||||||
private final int mUserId = UserHandle.myUserId();
|
private final int mUserId = UserHandle.myUserId();
|
||||||
protected final int mProfileChallengeUserId;
|
protected final int mProfileChallengeUserId;
|
||||||
|
|
||||||
|
private final BiometricNavigationUtils mBiometricNavigationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the manager is not null and the hardware is detected.
|
* @return true if the manager is not null and the hardware is detected.
|
||||||
*/
|
*/
|
||||||
protected abstract boolean isDeviceSupported();
|
protected abstract boolean isDeviceSupported();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the user has enrolled biometrics of the subclassed type.
|
* @return the summary text.
|
||||||
*/
|
*/
|
||||||
protected abstract boolean hasEnrolledBiometrics();
|
protected abstract String getSummaryText();
|
||||||
|
|
||||||
/**
|
|
||||||
* @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.
|
* @return the class name for the settings page.
|
||||||
*/
|
*/
|
||||||
protected abstract String getSettingsClassName();
|
protected abstract String getSettingsClassName();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the class name for entry to enrollment.
|
|
||||||
*/
|
|
||||||
protected abstract String getEnrollClassName();
|
|
||||||
|
|
||||||
public BiometricStatusPreferenceController(Context context, String key) {
|
public BiometricStatusPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
@@ -79,6 +60,7 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
|||||||
.getSecurityFeatureProvider()
|
.getSecurityFeatureProvider()
|
||||||
.getLockPatternUtils(context);
|
.getLockPatternUtils(context);
|
||||||
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
|
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
|
||||||
|
mBiometricNavigationUtils = new BiometricNavigationUtils();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,8 +85,7 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
|||||||
} else {
|
} else {
|
||||||
preference.setVisible(true);
|
preference.setVisible(true);
|
||||||
}
|
}
|
||||||
preference.setSummary(hasEnrolledBiometrics() ? getSummaryTextEnrolled()
|
preference.setSummary(getSummaryText());
|
||||||
: getSummaryTextNoneEnrolled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,26 +94,8 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
|||||||
return super.handlePreferenceTreeClick(preference);
|
return super.handlePreferenceTreeClick(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Context context = preference.getContext();
|
return mBiometricNavigationUtils.launchBiometricSettings(
|
||||||
final UserManager userManager = UserManager.get(context);
|
preference.getContext(), getSettingsClassName(), preference.getExtras());
|
||||||
final int userId = getUserId();
|
|
||||||
if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Intent intent = new Intent();
|
|
||||||
final String clazz = hasEnrolledBiometrics() ? getSettingsClassName()
|
|
||||||
: getEnrollClassName();
|
|
||||||
intent.setClassName(SETTINGS_PACKAGE_NAME, clazz);
|
|
||||||
if (!preference.getExtras().isEmpty()) {
|
|
||||||
intent.putExtras(preference.getExtras());
|
|
||||||
}
|
|
||||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
|
||||||
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
|
|
||||||
intent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
|
|
||||||
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
|
|
||||||
context.startActivity(intent);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getUserId() {
|
protected int getUserId() {
|
||||||
|
@@ -29,7 +29,7 @@ import com.android.settings.biometrics.face.FaceStatusPreferenceController;
|
|||||||
public class BiometricFaceStatusPreferenceController extends FaceStatusPreferenceController {
|
public class BiometricFaceStatusPreferenceController extends FaceStatusPreferenceController {
|
||||||
|
|
||||||
public BiometricFaceStatusPreferenceController(Context context, String key) {
|
public BiometricFaceStatusPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key, null /* lifecycle */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiometricFaceStatusPreferenceController(
|
public BiometricFaceStatusPreferenceController(
|
||||||
|
@@ -30,7 +30,7 @@ public class BiometricFingerprintStatusPreferenceController extends
|
|||||||
FingerprintStatusPreferenceController {
|
FingerprintStatusPreferenceController {
|
||||||
|
|
||||||
public BiometricFingerprintStatusPreferenceController(Context context, String key) {
|
public BiometricFingerprintStatusPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key, null /* lifecycle */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiometricFingerprintStatusPreferenceController(
|
public BiometricFingerprintStatusPreferenceController(
|
||||||
|
@@ -20,8 +20,6 @@ import android.os.UserHandle;
|
|||||||
|
|
||||||
import androidx.lifecycle.Lifecycle;
|
import androidx.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import com.android.settings.Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller for biometrics settings page of work profile, controlling the ability to
|
* Preference controller for biometrics settings page of work profile, controlling the ability to
|
||||||
* unlock the phone with face and fingerprint.
|
* unlock the phone with face and fingerprint.
|
||||||
@@ -62,11 +60,6 @@ public class CombinedBiometricProfileStatusPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getSettingsClassName() {
|
protected String getSettingsClassName() {
|
||||||
return Settings.CombinedBiometricProfileSettingsActivity.class.getName();
|
return mCombinedBiometricStatusUtils.getProfileSettingsClassName();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getEnrollClassName() {
|
|
||||||
return Settings.CombinedBiometricProfileSettingsActivity.class.getName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,6 @@
|
|||||||
package com.android.settings.biometrics.combination;
|
package com.android.settings.biometrics.combination;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
|
||||||
import android.hardware.face.FaceManager;
|
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.Lifecycle;
|
import androidx.lifecycle.Lifecycle;
|
||||||
@@ -28,11 +25,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Settings;
|
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
||||||
import com.android.settings.biometrics.ParentalControlsUtils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
@@ -44,12 +37,9 @@ public class CombinedBiometricStatusPreferenceController extends
|
|||||||
BiometricStatusPreferenceController implements LifecycleObserver {
|
BiometricStatusPreferenceController implements LifecycleObserver {
|
||||||
private static final String KEY_BIOMETRIC_SETTINGS = "biometric_settings";
|
private static final String KEY_BIOMETRIC_SETTINGS = "biometric_settings";
|
||||||
|
|
||||||
@Nullable
|
|
||||||
FingerprintManager mFingerprintManager;
|
|
||||||
@Nullable
|
|
||||||
FaceManager mFaceManager;
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
RestrictedPreference mPreference;
|
RestrictedPreference mPreference;
|
||||||
|
protected final CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
||||||
|
|
||||||
public CombinedBiometricStatusPreferenceController(Context context) {
|
public CombinedBiometricStatusPreferenceController(Context context) {
|
||||||
this(context, KEY_BIOMETRIC_SETTINGS, null /* lifecycle */);
|
this(context, KEY_BIOMETRIC_SETTINGS, null /* lifecycle */);
|
||||||
@@ -66,8 +56,7 @@ public class CombinedBiometricStatusPreferenceController extends
|
|||||||
public CombinedBiometricStatusPreferenceController(
|
public CombinedBiometricStatusPreferenceController(
|
||||||
Context context, String key, Lifecycle lifecycle) {
|
Context context, String key, Lifecycle lifecycle) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(context);
|
||||||
mFaceManager = Utils.getFaceManagerOrNull(context);
|
|
||||||
|
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
@@ -87,12 +76,7 @@ public class CombinedBiometricStatusPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isDeviceSupported() {
|
protected boolean isDeviceSupported() {
|
||||||
return Utils.hasFingerprintHardware(mContext) && Utils.hasFaceHardware(mContext);
|
return mCombinedBiometricStatusUtils.isAvailable();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean hasEnrolledBiometrics() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,80 +86,35 @@ public class CombinedBiometricStatusPreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateStateInternal() {
|
private void updateStateInternal() {
|
||||||
// This controller currently is shown if fingerprint&face exist on the device. If this
|
final RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
// changes in the future, the modalities passed into the below will need to be updated.
|
mCombinedBiometricStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
final RestrictedLockUtils.EnforcedAdmin faceAdmin = ParentalControlsUtils
|
updateStateInternal(admin);
|
||||||
.parentConsentRequired(mContext, BiometricAuthenticator.TYPE_FACE);
|
|
||||||
final RestrictedLockUtils.EnforcedAdmin fpAdmin = ParentalControlsUtils
|
|
||||||
.parentConsentRequired(mContext, BiometricAuthenticator.TYPE_FINGERPRINT);
|
|
||||||
|
|
||||||
// If the admins are non-null, they are actually always the same. Just the helper class
|
|
||||||
// we create above always return the admin, instead of a boolean.
|
|
||||||
final boolean faceConsentRequired = faceAdmin != null;
|
|
||||||
final boolean fpConsentRequired = fpAdmin != null;
|
|
||||||
final RestrictedLockUtils.EnforcedAdmin admin = faceAdmin != null ? faceAdmin : fpAdmin;
|
|
||||||
|
|
||||||
updateStateInternal(admin, faceConsentRequired, fpConsentRequired);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the preference and shows the consent flow only if consent is required for all
|
||||||
|
* modalities.
|
||||||
|
*
|
||||||
|
* <p>Otherwise, users will not be able to enter and modify settings for modalities which have
|
||||||
|
* already been consented. In any case, the controllers for the modalities which have not yet
|
||||||
|
* been consented will be disabled in the combined page anyway - users can go through the
|
||||||
|
* consent+enrollment flow from there.
|
||||||
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void updateStateInternal(@Nullable RestrictedLockUtils.EnforcedAdmin enforcedAdmin,
|
void updateStateInternal(@Nullable RestrictedLockUtils.EnforcedAdmin enforcedAdmin) {
|
||||||
boolean faceConsentRequired, boolean fpConsentRequired) {
|
|
||||||
// Disable the preference (and show the consent flow) only if consent is required for all
|
|
||||||
// modalities. Otherwise, users will not be able to enter and modify settings for modalities
|
|
||||||
// which have already been consented. In any case, the controllers for the modalities which
|
|
||||||
// have not yet been consented will be disabled in the combined page anyway - users can
|
|
||||||
// go through the consent+enrollment flow from there.
|
|
||||||
final boolean disablePreference = faceConsentRequired && fpConsentRequired;
|
|
||||||
if (!disablePreference) {
|
|
||||||
enforcedAdmin = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mPreference != null) {
|
if (mPreference != null) {
|
||||||
mPreference.setDisabledByAdmin(enforcedAdmin);
|
mPreference.setDisabledByAdmin(enforcedAdmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getSummaryTextEnrolled() {
|
protected String getSummaryText() {
|
||||||
// Note that this is currently never called (see the super class)
|
return mCombinedBiometricStatusUtils.getSummary();
|
||||||
return mContext.getString(
|
|
||||||
R.string.security_settings_biometric_preference_summary_none_enrolled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getSummaryTextNoneEnrolled() {
|
|
||||||
final int numFingerprintsEnrolled = mFingerprintManager != null ?
|
|
||||||
mFingerprintManager.getEnrolledFingerprints(getUserId()).size() : 0;
|
|
||||||
final boolean faceEnrolled = mFaceManager != null
|
|
||||||
&& mFaceManager.hasEnrolledTemplates(getUserId());
|
|
||||||
|
|
||||||
if (faceEnrolled && numFingerprintsEnrolled > 1) {
|
|
||||||
return mContext.getString(
|
|
||||||
R.string.security_settings_biometric_preference_summary_both_fp_multiple);
|
|
||||||
} else if (faceEnrolled && numFingerprintsEnrolled == 1) {
|
|
||||||
return mContext.getString(
|
|
||||||
R.string.security_settings_biometric_preference_summary_both_fp_single);
|
|
||||||
} else if (faceEnrolled) {
|
|
||||||
return mContext.getString(R.string.security_settings_face_preference_summary);
|
|
||||||
} else if (numFingerprintsEnrolled > 0) {
|
|
||||||
return mContext.getResources().getQuantityString(
|
|
||||||
R.plurals.security_settings_fingerprint_preference_summary,
|
|
||||||
numFingerprintsEnrolled, numFingerprintsEnrolled);
|
|
||||||
} else {
|
|
||||||
return mContext.getString(
|
|
||||||
R.string.security_settings_biometric_preference_summary_none_enrolled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getSettingsClassName() {
|
protected String getSettingsClassName() {
|
||||||
return Settings.CombinedBiometricSettingsActivity.class.getName();
|
return mCombinedBiometricStatusUtils.getSettingsClassName();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getEnrollClassName() {
|
|
||||||
return Settings.CombinedBiometricSettingsActivity.class.getName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.combination;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.biometrics.BiometricAuthenticator;
|
||||||
|
import android.hardware.face.FaceManager;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.biometrics.ParentalControlsUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities for combined biometric details shared between Security Settings and Safety Center.
|
||||||
|
*/
|
||||||
|
public class CombinedBiometricStatusUtils {
|
||||||
|
|
||||||
|
private final int mUserId = UserHandle.myUserId();
|
||||||
|
private final Context mContext;
|
||||||
|
@Nullable
|
||||||
|
FingerprintManager mFingerprintManager;
|
||||||
|
@Nullable
|
||||||
|
FaceManager mFaceManager;
|
||||||
|
|
||||||
|
public CombinedBiometricStatusUtils(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||||
|
mFaceManager = Utils.getFaceManagerOrNull(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the combined biometric settings entity should be shown.
|
||||||
|
*/
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return Utils.hasFingerprintHardware(mContext) && Utils.hasFaceHardware(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link EnforcedAdmin} in case parental consent is required to change both
|
||||||
|
* face and fingerprint settings.
|
||||||
|
*
|
||||||
|
* @return null if either face or fingerprint settings do not require a parental consent.
|
||||||
|
*/
|
||||||
|
public EnforcedAdmin getDisablingAdmin() {
|
||||||
|
// This controller currently is shown if fingerprint&face exist on the device. If this
|
||||||
|
// changes in the future, the modalities passed into the below will need to be updated.
|
||||||
|
|
||||||
|
final EnforcedAdmin faceAdmin = ParentalControlsUtils
|
||||||
|
.parentConsentRequired(mContext, BiometricAuthenticator.TYPE_FACE);
|
||||||
|
final EnforcedAdmin fpAdmin = ParentalControlsUtils
|
||||||
|
.parentConsentRequired(mContext, BiometricAuthenticator.TYPE_FINGERPRINT);
|
||||||
|
|
||||||
|
final boolean faceConsentRequired = faceAdmin != null;
|
||||||
|
final boolean fpConsentRequired = fpAdmin != null;
|
||||||
|
|
||||||
|
// Result is only required if all modalities require consent.
|
||||||
|
// If the admins are non-null, they are actually always the same.
|
||||||
|
return faceConsentRequired && fpConsentRequired ? faceAdmin : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the summary of combined biometric settings entity.
|
||||||
|
*/
|
||||||
|
public String getSummary() {
|
||||||
|
final int numFingerprintsEnrolled = mFingerprintManager != null
|
||||||
|
? mFingerprintManager.getEnrolledFingerprints(mUserId).size() : 0;
|
||||||
|
final boolean faceEnrolled = mFaceManager != null
|
||||||
|
&& mFaceManager.hasEnrolledTemplates(mUserId);
|
||||||
|
|
||||||
|
if (faceEnrolled && numFingerprintsEnrolled > 1) {
|
||||||
|
return mContext.getString(
|
||||||
|
R.string.security_settings_biometric_preference_summary_both_fp_multiple);
|
||||||
|
} else if (faceEnrolled && numFingerprintsEnrolled == 1) {
|
||||||
|
return mContext.getString(
|
||||||
|
R.string.security_settings_biometric_preference_summary_both_fp_single);
|
||||||
|
} else if (faceEnrolled) {
|
||||||
|
return mContext.getString(R.string.security_settings_face_preference_summary);
|
||||||
|
} else if (numFingerprintsEnrolled > 0) {
|
||||||
|
return mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.security_settings_fingerprint_preference_summary,
|
||||||
|
numFingerprintsEnrolled, numFingerprintsEnrolled);
|
||||||
|
} else {
|
||||||
|
return mContext.getString(
|
||||||
|
R.string.security_settings_biometric_preference_summary_none_enrolled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class name of the Settings page corresponding to combined biometric settings.
|
||||||
|
*/
|
||||||
|
public String getSettingsClassName() {
|
||||||
|
return Settings.CombinedBiometricSettingsActivity.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class name of the Settings page corresponding to combined biometric settings
|
||||||
|
* for work profile.
|
||||||
|
*/
|
||||||
|
public String getProfileSettingsClassName() {
|
||||||
|
return Settings.CombinedBiometricProfileSettingsActivity.class.getName();
|
||||||
|
}
|
||||||
|
}
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.biometrics.face;
|
package com.android.settings.biometrics.face;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
|
||||||
import android.hardware.face.FaceManager;
|
import android.hardware.face.FaceManager;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -28,11 +27,8 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Settings;
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
||||||
import com.android.settings.biometrics.ParentalControlsUtils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
@@ -44,6 +40,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
|
|||||||
protected final FaceManager mFaceManager;
|
protected final FaceManager mFaceManager;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
RestrictedPreference mPreference;
|
RestrictedPreference mPreference;
|
||||||
|
private final FaceStatusUtils mFaceStatusUtils;
|
||||||
|
|
||||||
public FaceStatusPreferenceController(Context context) {
|
public FaceStatusPreferenceController(Context context) {
|
||||||
this(context, KEY_FACE_SETTINGS, null /* lifecycle */);
|
this(context, KEY_FACE_SETTINGS, null /* lifecycle */);
|
||||||
@@ -60,6 +57,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
|
|||||||
public FaceStatusPreferenceController(Context context, String key, Lifecycle lifecycle) {
|
public FaceStatusPreferenceController(Context context, String key, Lifecycle lifecycle) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mFaceManager = Utils.getFaceManagerOrNull(context);
|
mFaceManager = Utils.getFaceManagerOrNull(context);
|
||||||
|
mFaceStatusUtils = new FaceStatusUtils(context, mFaceManager);
|
||||||
|
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
@@ -79,12 +77,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isDeviceSupported() {
|
protected boolean isDeviceSupported() {
|
||||||
return !Utils.isMultipleBiometricsSupported(mContext) && Utils.hasFaceHardware(mContext);
|
return mFaceStatusUtils.isAvailable();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean hasEnrolledBiometrics() {
|
|
||||||
return mFaceManager.hasEnrolledTemplates(getUserId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,8 +87,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateStateInternal() {
|
private void updateStateInternal() {
|
||||||
updateStateInternal(ParentalControlsUtils.parentConsentRequired(
|
updateStateInternal(mFaceStatusUtils.getDisablingAdmin());
|
||||||
mContext, BiometricAuthenticator.TYPE_FACE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -106,25 +98,12 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getSummaryTextEnrolled() {
|
protected String getSummaryText() {
|
||||||
return mContext.getResources()
|
return mFaceStatusUtils.getSummary();
|
||||||
.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
|
@Override
|
||||||
protected String getSettingsClassName() {
|
protected String getSettingsClassName() {
|
||||||
return Settings.FaceSettingsActivity.class.getName();
|
return mFaceStatusUtils.getSettingsClassName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getEnrollClassName() {
|
|
||||||
return FaceEnrollIntroduction.class.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.biometrics.BiometricAuthenticator;
|
||||||
|
import android.hardware.face.FaceManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.biometrics.ParentalControlsUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities for face details shared between Security Settings and Safety Center.
|
||||||
|
*/
|
||||||
|
public class FaceStatusUtils {
|
||||||
|
|
||||||
|
private final int mUserId = UserHandle.myUserId();
|
||||||
|
private final Context mContext;
|
||||||
|
private final FaceManager mFaceManager;
|
||||||
|
|
||||||
|
public FaceStatusUtils(Context context, FaceManager faceManager) {
|
||||||
|
mContext = context;
|
||||||
|
mFaceManager = faceManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the face settings entity should be shown.
|
||||||
|
*/
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return !Utils.isMultipleBiometricsSupported(mContext) && Utils.hasFaceHardware(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link EnforcedAdmin} if parental consent is required to change face settings.
|
||||||
|
*
|
||||||
|
* @return null if face settings does not require a parental consent.
|
||||||
|
*/
|
||||||
|
public EnforcedAdmin getDisablingAdmin() {
|
||||||
|
return ParentalControlsUtils.parentConsentRequired(
|
||||||
|
mContext, BiometricAuthenticator.TYPE_FACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the summary of face settings entity.
|
||||||
|
*/
|
||||||
|
public String getSummary() {
|
||||||
|
return mContext.getResources().getString(hasEnrolled()
|
||||||
|
? R.string.security_settings_face_preference_summary
|
||||||
|
: R.string.security_settings_face_preference_summary_none);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class name of the Settings page corresponding to face settings.
|
||||||
|
*/
|
||||||
|
public String getSettingsClassName() {
|
||||||
|
return hasEnrolled() ? Settings.FaceSettingsActivity.class.getName()
|
||||||
|
: FaceEnrollIntroduction.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasEnrolled() {
|
||||||
|
return mFaceManager.hasEnrolledTemplates(mUserId);
|
||||||
|
}
|
||||||
|
}
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.biometrics.fingerprint;
|
package com.android.settings.biometrics.fingerprint;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -28,10 +27,8 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
import com.android.settings.biometrics.BiometricStatusPreferenceController;
|
||||||
import com.android.settings.biometrics.ParentalControlsUtils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
@@ -43,6 +40,7 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
|
|||||||
protected final FingerprintManager mFingerprintManager;
|
protected final FingerprintManager mFingerprintManager;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
RestrictedPreference mPreference;
|
RestrictedPreference mPreference;
|
||||||
|
private final FingerprintStatusUtils mFingerprintStatusUtils;
|
||||||
|
|
||||||
public FingerprintStatusPreferenceController(Context context) {
|
public FingerprintStatusPreferenceController(Context context) {
|
||||||
this(context, KEY_FINGERPRINT_SETTINGS);
|
this(context, KEY_FINGERPRINT_SETTINGS);
|
||||||
@@ -59,6 +57,8 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
|
|||||||
public FingerprintStatusPreferenceController(Context context, String key, Lifecycle lifecycle) {
|
public FingerprintStatusPreferenceController(Context context, String key, Lifecycle lifecycle) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||||
|
mFingerprintStatusUtils =
|
||||||
|
new FingerprintStatusUtils(context, mFingerprintManager);
|
||||||
|
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
@@ -78,13 +78,7 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isDeviceSupported() {
|
protected boolean isDeviceSupported() {
|
||||||
return !Utils.isMultipleBiometricsSupported(mContext)
|
return mFingerprintStatusUtils.isAvailable();
|
||||||
&& Utils.hasFingerprintHardware(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean hasEnrolledBiometrics() {
|
|
||||||
return mFingerprintManager.hasEnrolledFingerprints(getUserId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,8 +88,17 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateStateInternal() {
|
private void updateStateInternal() {
|
||||||
updateStateInternal(ParentalControlsUtils.parentConsentRequired(
|
updateStateInternal(mFingerprintStatusUtils.getDisablingAdmin());
|
||||||
mContext, BiometricAuthenticator.TYPE_FINGERPRINT));
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getSummaryText() {
|
||||||
|
return mFingerprintStatusUtils.getSummary();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getSettingsClassName() {
|
||||||
|
return mFingerprintStatusUtils.getSettingsClassName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -104,28 +107,4 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
|
|||||||
mPreference.setDisabledByAdmin(enforcedAdmin);
|
mPreference.setDisabledByAdmin(enforcedAdmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getSummaryTextEnrolled() {
|
|
||||||
final int numEnrolled = mFingerprintManager.getEnrolledFingerprints(getUserId()).size();
|
|
||||||
return mContext.getResources().getQuantityString(
|
|
||||||
R.plurals.security_settings_fingerprint_preference_summary,
|
|
||||||
numEnrolled, numEnrolled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.fingerprint;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.biometrics.BiometricAuthenticator;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.biometrics.ParentalControlsUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities for fingerprint details shared between Security Settings and Safety Center.
|
||||||
|
*/
|
||||||
|
public class FingerprintStatusUtils {
|
||||||
|
|
||||||
|
private final int mUserId = UserHandle.myUserId();
|
||||||
|
private final Context mContext;
|
||||||
|
private final FingerprintManager mFingerprintManager;
|
||||||
|
|
||||||
|
public FingerprintStatusUtils(Context context, FingerprintManager fingerprintManager) {
|
||||||
|
mContext = context;
|
||||||
|
mFingerprintManager = fingerprintManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the fingerprint settings entity should be shown.
|
||||||
|
*/
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return !Utils.isMultipleBiometricsSupported(mContext)
|
||||||
|
&& Utils.hasFingerprintHardware(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link EnforcedAdmin} if parental consent is required to change face settings.
|
||||||
|
*
|
||||||
|
* @return null if face settings does not require a parental consent.
|
||||||
|
*/
|
||||||
|
public EnforcedAdmin getDisablingAdmin() {
|
||||||
|
return ParentalControlsUtils.parentConsentRequired(
|
||||||
|
mContext, BiometricAuthenticator.TYPE_FINGERPRINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the summary of fingerprint settings entity.
|
||||||
|
*/
|
||||||
|
public String getSummary() {
|
||||||
|
if (hasEnrolled()) {
|
||||||
|
final int numEnrolled = mFingerprintManager.getEnrolledFingerprints(mUserId).size();
|
||||||
|
return mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.security_settings_fingerprint_preference_summary,
|
||||||
|
numEnrolled, numEnrolled);
|
||||||
|
} else {
|
||||||
|
return mContext.getString(
|
||||||
|
R.string.security_settings_fingerprint_preference_summary_none);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class name of the Settings page corresponding to fingerprint settings.
|
||||||
|
*/
|
||||||
|
public String getSettingsClassName() {
|
||||||
|
return hasEnrolled() ? FingerprintSettings.class.getName()
|
||||||
|
: FingerprintEnrollIntroduction.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasEnrolled() {
|
||||||
|
return mFingerprintManager.hasEnrolledFingerprints(mUserId);
|
||||||
|
}
|
||||||
|
}
|
@@ -18,10 +18,7 @@ package com.android.settings.biometrics.combination;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.any;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.reset;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -42,7 +39,6 @@ import com.android.settingslib.RestrictedPreference;
|
|||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -96,7 +92,6 @@ public class CombinedBiometricStatusPreferenceControllerTest {
|
|||||||
mContext, TEST_PREF_KEY, mLifecycle);
|
mContext, TEST_PREF_KEY, mLifecycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_parentalConsentRequired_preferenceDisabled() {
|
public void updateState_parentalConsentRequired_preferenceDisabled() {
|
||||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
@@ -106,16 +101,10 @@ public class CombinedBiometricStatusPreferenceControllerTest {
|
|||||||
RestrictedLockUtils.EnforcedAdmin admin = mock(RestrictedLockUtils.EnforcedAdmin.class);
|
RestrictedLockUtils.EnforcedAdmin admin = mock(RestrictedLockUtils.EnforcedAdmin.class);
|
||||||
|
|
||||||
mController.mPreference = restrictedPreference;
|
mController.mPreference = restrictedPreference;
|
||||||
mController.updateStateInternal(admin, true, true);
|
mController.updateStateInternal(admin);
|
||||||
verify(restrictedPreference).setDisabledByAdmin(eq(admin));
|
verify(restrictedPreference).setDisabledByAdmin(eq(admin));
|
||||||
|
|
||||||
mController.updateStateInternal(admin, true, false);
|
mController.updateStateInternal(null);
|
||||||
verify(restrictedPreference).setDisabledByAdmin(eq(null));
|
|
||||||
|
|
||||||
mController.updateStateInternal(admin, false, true);
|
|
||||||
verify(restrictedPreference).setDisabledByAdmin(eq(null));
|
|
||||||
|
|
||||||
mController.updateStateInternal(admin, false, false);
|
|
||||||
verify(restrictedPreference).setDisabledByAdmin(eq(null));
|
verify(restrictedPreference).setDisabledByAdmin(eq(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class BiometricNavigationUtilsTest {
|
||||||
|
|
||||||
|
private static final String SETTINGS_CLASS_NAME = "SettingsClassName";
|
||||||
|
private static final String EXTRA_KEY = "EXTRA_KEY";
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private UserManager mUserManager;
|
||||||
|
private Context mContext;
|
||||||
|
private BiometricNavigationUtils mBiometricNavigationUtils;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||||
|
doNothing().when(mContext).startActivity(any());
|
||||||
|
mBiometricNavigationUtils = new BiometricNavigationUtils();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void openBiometricSettings_quietMode_launchesQuiteModeDialog() {
|
||||||
|
when(mUserManager.isQuietModeEnabled(any())).thenReturn(true);
|
||||||
|
|
||||||
|
mBiometricNavigationUtils.launchBiometricSettings(mContext, SETTINGS_CLASS_NAME,
|
||||||
|
Bundle.EMPTY);
|
||||||
|
|
||||||
|
assertQuietModeDialogLaunchRequested();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void openBiometricSettings_quietMode_returnsFalse() {
|
||||||
|
when(mUserManager.isQuietModeEnabled(any())).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mBiometricNavigationUtils.launchBiometricSettings(
|
||||||
|
mContext, SETTINGS_CLASS_NAME, Bundle.EMPTY)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void openBiometricSettings_noQuietMode_emptyExtras_launchesFragmentWithoutExtras() {
|
||||||
|
when(mUserManager.isQuietModeEnabled(any())).thenReturn(false);
|
||||||
|
|
||||||
|
mBiometricNavigationUtils.launchBiometricSettings(
|
||||||
|
mContext, SETTINGS_CLASS_NAME, Bundle.EMPTY);
|
||||||
|
|
||||||
|
assertSettingsPageLaunchRequested(false /* shouldContainExtras */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void openBiometricSettings_noQuietMode_emptyExtras_returnsTrue() {
|
||||||
|
when(mUserManager.isQuietModeEnabled(any())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mBiometricNavigationUtils.launchBiometricSettings(
|
||||||
|
mContext, SETTINGS_CLASS_NAME, Bundle.EMPTY)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void openBiometricSettings_noQuietMode_withExtras_launchesFragmentWithExtras() {
|
||||||
|
when(mUserManager.isQuietModeEnabled(any())).thenReturn(false);
|
||||||
|
|
||||||
|
final Bundle extras = createNotEmptyExtras();
|
||||||
|
mBiometricNavigationUtils.launchBiometricSettings(mContext, SETTINGS_CLASS_NAME, extras);
|
||||||
|
|
||||||
|
assertSettingsPageLaunchRequested(true /* shouldContainExtras */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void openBiometricSettings_noQuietMode_withExtras_returnsTrue() {
|
||||||
|
when(mUserManager.isQuietModeEnabled(any())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mBiometricNavigationUtils.launchBiometricSettings(
|
||||||
|
mContext, SETTINGS_CLASS_NAME, createNotEmptyExtras())).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bundle createNotEmptyExtras() {
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt(EXTRA_KEY, 0);
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertQuietModeDialogLaunchRequested() {
|
||||||
|
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
verify(mContext).startActivity(intentCaptor.capture());
|
||||||
|
|
||||||
|
Intent intent = intentCaptor.getValue();
|
||||||
|
assertThat(intent.getComponent().getPackageName())
|
||||||
|
.isEqualTo("android");
|
||||||
|
assertThat(intent.getComponent().getClassName())
|
||||||
|
.isEqualTo("com.android.internal.app.UnlaunchableAppActivity");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSettingsPageLaunchRequested(boolean shouldContainExtras) {
|
||||||
|
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||||
|
verify(mContext).startActivity(intentCaptor.capture());
|
||||||
|
|
||||||
|
Intent intent = intentCaptor.getValue();
|
||||||
|
assertThat(intent.getComponent().getPackageName())
|
||||||
|
.isEqualTo("com.android.settings");
|
||||||
|
assertThat(intent.getComponent().getClassName())
|
||||||
|
.isEqualTo(SETTINGS_CLASS_NAME);
|
||||||
|
assertThat(intent.getExtras().containsKey(EXTRA_KEY)).isEqualTo(shouldContainExtras);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,263 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.combination;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FACE;
|
||||||
|
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.hardware.face.FaceManager;
|
||||||
|
import android.hardware.fingerprint.Fingerprint;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.testutils.ResourcesUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class CombinedBiometricStatusUtilsTest {
|
||||||
|
|
||||||
|
private static final ComponentName COMPONENT_NAME =
|
||||||
|
new ComponentName("package", "class");
|
||||||
|
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
|
||||||
|
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
@Mock
|
||||||
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
|
@Mock
|
||||||
|
private FingerprintManager mFingerprintManager;
|
||||||
|
@Mock
|
||||||
|
private FaceManager mFaceManager;
|
||||||
|
|
||||||
|
private Context mApplicationContext;
|
||||||
|
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mApplicationContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
|
.thenReturn(mFingerprintManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
|
.thenReturn(mDevicePolicyManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(mApplicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withoutFingerprint_withoutFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withoutFingerprint_whenFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_whenFingerprint_withoutFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_whenFingerprint_whenFace_returnsTrue() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceDisabled_returnsEnforcedAdmin() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
|
.thenReturn(KEYGUARD_DISABLE_FACE | KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
final RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
|
mCombinedBiometricStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
|
assertThat(admin).isEqualTo(new RestrictedLockUtils.EnforcedAdmin(
|
||||||
|
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceEnabled_returnsNull() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
|
.thenReturn(KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getDisablingAdmin()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_whenFingerprintEnabled_whenFaceDisabled_returnsNull() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
|
.thenReturn(KEYGUARD_DISABLE_FACE);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getDisablingAdmin()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_whenFingerprintEnabled_whenFaceEnabled_returnsNull() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getDisablingAdmin()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenFaceEnrolled_whenMultipleFingerprints_returnsBothFpMultiple() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(2));
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_biometric_preference_summary_both_fp_multiple"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenFaceEnrolled_whenSingleFingerprint_returnsBothFpSingle() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(1));
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_biometric_preference_summary_both_fp_single"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenFaceEnrolled_whenNoFingerprints_returnsFace() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(0));
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_face_preference_summary"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenNoFaceEnrolled_whenMultipleFingerprints_returnsFingerprints() {
|
||||||
|
final int enrolledFingerprintsCount = 2;
|
||||||
|
final int stringResId = ResourcesUtils.getResourcesId(
|
||||||
|
ApplicationProvider.getApplicationContext(), "plurals",
|
||||||
|
"security_settings_fingerprint_preference_summary");
|
||||||
|
final String summary = mApplicationContext.getResources().getQuantityString(
|
||||||
|
stringResId, enrolledFingerprintsCount /* quantity */,
|
||||||
|
enrolledFingerprintsCount /* formatArgs */);
|
||||||
|
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(enrolledFingerprintsCount));
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSummary()).isEqualTo(summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenNoFaceEnrolled_whenSingleFingerprints_returnsFingerprints() {
|
||||||
|
final int enrolledFingerprintsCount = 1;
|
||||||
|
final int stringResId = ResourcesUtils.getResourcesId(
|
||||||
|
ApplicationProvider.getApplicationContext(), "plurals",
|
||||||
|
"security_settings_fingerprint_preference_summary");
|
||||||
|
final String summary = mApplicationContext.getResources().getQuantityString(
|
||||||
|
stringResId, enrolledFingerprintsCount /* quantity */,
|
||||||
|
enrolledFingerprintsCount /* formatArgs */);
|
||||||
|
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(enrolledFingerprintsCount));
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSummary()).isEqualTo(summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenNoFaceEnrolled_whenNoFingerprints_returnsNoneEnrolled() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(0));
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_biometric_preference_summary_none_enrolled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSettingsClassName_returnsCombinedBiometricSettings() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getSettingsClassName())
|
||||||
|
.isEqualTo(Settings.CombinedBiometricSettingsActivity.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getProfileSettingsClassName_returnsCombinedBiometricProfileSettings() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mCombinedBiometricStatusUtils.getProfileSettingsClassName())
|
||||||
|
.isEqualTo(Settings.CombinedBiometricProfileSettingsActivity.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Fingerprint> createFingerprintList(int size) {
|
||||||
|
final List<Fingerprint> fingerprintList = new ArrayList<>(size);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
fingerprintList.add(new Fingerprint("fingerprint" + i, 0, 0));
|
||||||
|
}
|
||||||
|
return fingerprintList;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,169 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.hardware.face.FaceManager;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.Settings;
|
||||||
|
import com.android.settings.testutils.ResourcesUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class FaceStatusUtilsTest {
|
||||||
|
|
||||||
|
private static final ComponentName COMPONENT_NAME =
|
||||||
|
new ComponentName("package", "class");
|
||||||
|
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
|
||||||
|
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
@Mock
|
||||||
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
|
@Mock
|
||||||
|
private FingerprintManager mFingerprintManager;
|
||||||
|
@Mock
|
||||||
|
private FaceManager mFaceManager;
|
||||||
|
|
||||||
|
private Context mApplicationContext;
|
||||||
|
private FaceStatusUtils mFaceStatusUtils;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mApplicationContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
|
.thenReturn(mFingerprintManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
|
.thenReturn(mDevicePolicyManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
mFaceStatusUtils = new FaceStatusUtils(mApplicationContext, mFaceManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withoutFingerprint_withoutFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withoutFingerprint_withFace_returnsTrue() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withFingerprint_withoutFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withFingerprint_withFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_whenFaceDisabled_returnsEnforcedAdmin() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FACE);
|
||||||
|
|
||||||
|
final RestrictedLockUtils.EnforcedAdmin admin = mFaceStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
|
assertThat(admin).isEqualTo(new RestrictedLockUtils.EnforcedAdmin(
|
||||||
|
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_withFaceEnabled_returnsNull() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.getDisablingAdmin()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenNotEnrolled_returnsSummaryNone() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_face_preference_summary_none"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenEnrolled_returnsSummary() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_face_preference_summary"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSettingsClassName_whenNotEnrolled_returnsFaceEnrollInduction() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.getSettingsClassName())
|
||||||
|
.isEqualTo(FaceEnrollIntroduction.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSettingsClassName_whenEnrolled_returnsFaceSettings() {
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFaceStatusUtils.getSettingsClassName())
|
||||||
|
.isEqualTo(Settings.FaceSettingsActivity.class.getName());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.fingerprint;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.hardware.face.FaceManager;
|
||||||
|
import android.hardware.fingerprint.Fingerprint;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.testutils.ResourcesUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class FingerprintStatusUtilsTest {
|
||||||
|
|
||||||
|
private static final ComponentName COMPONENT_NAME =
|
||||||
|
new ComponentName("package", "class");
|
||||||
|
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
|
||||||
|
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
@Mock
|
||||||
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
|
@Mock
|
||||||
|
private FingerprintManager mFingerprintManager;
|
||||||
|
@Mock
|
||||||
|
private FaceManager mFaceManager;
|
||||||
|
|
||||||
|
private Context mApplicationContext;
|
||||||
|
private FingerprintStatusUtils mFingerprintStatusUtils;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mApplicationContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
|
.thenReturn(mFingerprintManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
|
.thenReturn(mDevicePolicyManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
mFingerprintStatusUtils =
|
||||||
|
new FingerprintStatusUtils(mApplicationContext, mFingerprintManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withoutFingerprint_withoutFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withoutFingerprint_withFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withFingerprint_withoutFace_returnsTrue() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_withFingerprint_withFace_returnsFalse() {
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_whenFingerprintDisabled_returnsEnforcedAdmin() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
final RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
|
mFingerprintStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
|
assertThat(admin).isEqualTo(new RestrictedLockUtils.EnforcedAdmin(
|
||||||
|
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDisabledAdmin_withFingerprintEnabled_returnsNull() {
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.getDisablingAdmin()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenNotEnrolled_returnsSummaryNone() {
|
||||||
|
when(mFingerprintManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.getSummary())
|
||||||
|
.isEqualTo(ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext,
|
||||||
|
"security_settings_fingerprint_preference_summary_none"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSummary_whenEnrolled_returnsSummary() {
|
||||||
|
final int enrolledFingerprintsCount = 2;
|
||||||
|
final int stringResId = ResourcesUtils.getResourcesId(
|
||||||
|
ApplicationProvider.getApplicationContext(), "plurals",
|
||||||
|
"security_settings_fingerprint_preference_summary");
|
||||||
|
final String summary = mApplicationContext.getResources().getQuantityString(
|
||||||
|
stringResId, enrolledFingerprintsCount /* quantity */,
|
||||||
|
enrolledFingerprintsCount /* formatArgs */);
|
||||||
|
|
||||||
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(true);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt())).thenReturn(
|
||||||
|
createFingerprintList(enrolledFingerprintsCount));
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.getSummary()).isEqualTo(summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSettingsClassName_whenNotEnrolled_returnsFingerprintEnrollInduction() {
|
||||||
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.getSettingsClassName())
|
||||||
|
.isEqualTo(FingerprintEnrollIntroduction.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSettingsClassName_whenEnrolled_returnsFingerprintSettings() {
|
||||||
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mFingerprintStatusUtils.getSettingsClassName())
|
||||||
|
.isEqualTo(FingerprintSettings.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Fingerprint> createFingerprintList(int size) {
|
||||||
|
final List<Fingerprint> fingerprintList = new ArrayList<>(size);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
fingerprintList.add(new Fingerprint("fingerprint" + i, 0, 0));
|
||||||
|
}
|
||||||
|
return fingerprintList;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user