Merge "In Private space settings when no face support show only fingerprint unlock" into main
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3435842..b63f806 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1231,6 +1231,10 @@
<string name="private_space_screen_lock_title">Use device screen lock</string>
<!-- Title for the Face and Fingerprint preference. [CHAR LIMIT=60] -->
<string name="private_space_biometric_title">Face & Fingerprint Unlock</string>
+ <!-- Title for the Fingerprint preference when face hardware is not supported on device. [CHAR LIMIT=40] -->
+ <string name="private_space_fingerprint_title">Fingerprint Unlock</string>
+ <!-- Title for the Face preference when fingerprint unlock is not supported on device. [CHAR LIMIT=40] -->
+ <string name="private_space_face_title">Face Unlock</string>
<!-- Summary for the Face and Fingerprint preference when no biometric is set. [CHAR LIMIT=60] -->
<string name="private_space_biometric_summary">Tap to set up</string>
<!-- Title for the Fingerprint unlock for private space preference. [CHAR LIMIT=60] -->
diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java
index cc22b87..2a5ff88 100644
--- a/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java
+++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java
@@ -20,8 +20,13 @@
import android.os.UserHandle;
import android.util.Log;
+import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.biometrics.combination.BiometricFaceStatusPreferenceController;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
@@ -62,4 +67,25 @@
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
+
+ @Override
+ public void updateState(@NonNull Preference preference) {
+ if (mLockPatternUtils.isSeparateProfileChallengeEnabled(getUserId())) {
+ super.updateState(preference);
+ preference.setEnabled(true);
+ } else {
+ preference.setSummary(
+ mContext.getString(R.string.lock_settings_profile_unified_summary));
+ preference.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ Preference preference = screen.findPreference(getPreferenceKey());
+ if (!Utils.isMultipleBiometricsSupported(mContext)) {
+ preference.setTitle(R.string.private_space_face_title);
+ }
+ }
}
diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java
index f2f0801..b6c4457 100644
--- a/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java
+++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java
@@ -20,8 +20,13 @@
import android.os.UserHandle;
import android.util.Log;
+import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.biometrics.combination.BiometricFingerprintStatusPreferenceController;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
@@ -64,4 +69,25 @@
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
+
+ @Override
+ public void updateState(@NonNull Preference preference) {
+ if (mLockPatternUtils.isSeparateProfileChallengeEnabled(getUserId())) {
+ super.updateState(preference);
+ preference.setEnabled(true);
+ } else {
+ preference.setSummary(
+ mContext.getString(R.string.lock_settings_profile_unified_summary));
+ preference.setEnabled(false);
+ }
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ Preference preference = screen.findPreference(getPreferenceKey());
+ if (!Utils.isMultipleBiometricsSupported(mContext)) {
+ preference.setTitle(R.string.private_space_fingerprint_title);
+ }
+ }
}
diff --git a/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java b/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java
index 6af6c38..413e02a 100644
--- a/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java
+++ b/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java
@@ -24,6 +24,7 @@
import androidx.annotation.Nullable;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -71,7 +72,17 @@
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new UseOneLockControllerSwitch(context, this));
controllers.add(new PrivateSpaceLockController(context, this));
- controllers.add(new FaceFingerprintUnlockController(context, getSettingsLifecycle()));
+ if (Utils.isMultipleBiometricsSupported(context)) {
+ controllers.add(new FaceFingerprintUnlockController(context, getSettingsLifecycle()));
+ } else if (Utils.hasFingerprintHardware(context)) {
+ controllers.add(
+ new PrivateSpaceFingerprintPreferenceController(
+ context, "private_space_biometrics", getSettingsLifecycle()));
+ } else if (Utils.hasFaceHardware(context)) {
+ controllers.add(
+ new PrivateSpaceFacePreferenceController(
+ context, "private_space_biometrics", getSettingsLifecycle()));
+ }
return controllers;
}