Add Biometrics settings inside private space One Lock settings

This includes below changes:
- Add Biometrics preferernce in Private Space One Lock settings page
- Face and Fingerprint enrolment for Private profile
- Feature is behind flag android.multiuser.enable_biometrics_to_unlock_private_space

Screenshots:
go/ss/9cWZRAuvGGW7gMm.png
go/ss/B3NoFbL3KbpSzeN.png
go/ss/7xH3DLi9d6Lu2mR.png
go/ss/8WBEgKychWpduXg.png
go/ss/8pmPGshd9aiPvVC.png
go/ss/AFPBPbiaBBvTj3p.png
go/ss/3fE4XKLLUdP8LmF.png

Bug: 308862923
Test: atest CombinedBiometricStatusUtilsTest, atest FaceFingerprintUnlockControllerTest
Change-Id: I1853107a4df4fc97db53c97524c6d44a4f554e37
This commit is contained in:
josephpv
2023-12-08 16:11:25 +00:00
committed by Joseph Vincent
parent a123021e1d
commit 0b7d46746c
15 changed files with 477 additions and 22 deletions

View File

@@ -57,7 +57,9 @@ public class Settings extends SettingsActivity {
public static class CombinedBiometricProfileSettingsActivity extends SettingsActivity { /* empty */ }
public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrivateSpaceBiometricSettingsActivity extends SettingsActivity {
/* empty */
}
public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
/** Activity for Data saver settings. */
public static class DataSaverSummaryActivity extends SettingsActivity { /* empty */ }

View File

@@ -159,4 +159,12 @@ public class CombinedBiometricStatusUtils {
public String getProfileSettingsClassName() {
return Settings.CombinedBiometricProfileSettingsActivity.class.getName();
}
/**
* Returns the class name of the Settings page corresponding to combined biometric settings for
* Private profile.
*/
public String getPrivateProfileSettingsClassName() {
return Settings.PrivateSpaceBiometricSettingsActivity.class.getName();
}
}

View File

@@ -165,6 +165,7 @@ import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.privacy.PrivacyControlsFragment;
import com.android.settings.privacy.PrivacyDashboardFragment;
import com.android.settings.privatespace.onelock.PrivateSpaceBiometricSettings;
import com.android.settings.regionalpreferences.RegionalPreferencesEntriesFragment;
import com.android.settings.safetycenter.MoreSecurityPrivacyFragment;
import com.android.settings.security.LockscreenDashboardFragment;
@@ -264,6 +265,7 @@ public class SettingsGateway {
FingerprintSettingsV2Fragment.class.getName(),
CombinedBiometricSettings.class.getName(),
CombinedBiometricProfileSettings.class.getName(),
PrivateSpaceBiometricSettings.class.getName(),
SwipeToNotificationSettings.class.getName(),
DoubleTapPowerSettings.class.getName(),
DoubleTapScreenSettings.class.getName(),

View File

@@ -17,25 +17,43 @@
package com.android.settings.privatespace.onelock;
import android.content.Context;
import android.text.TextUtils;
import android.os.UserHandle;
import android.util.Log;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settings.biometrics.combination.CombinedBiometricStatusPreferenceController;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
import com.android.settingslib.core.lifecycle.Lifecycle;
/** Represents the preference controller to enroll biometrics for private space lock. */
public class FaceFingerprintUnlockController extends AbstractPreferenceController {
public class FaceFingerprintUnlockController extends CombinedBiometricStatusPreferenceController {
private static final String TAG = "PSBiometricCtrl";
private static final String KEY_SET_UNSET_FACE_FINGERPRINT = "private_space_biometrics";
private final int mProfileUserId;
public FaceFingerprintUnlockController(Context context, SettingsPreferenceFragment host) {
super(context);
public FaceFingerprintUnlockController(Context context, Lifecycle lifecycle) {
super(context, KEY_SET_UNSET_FACE_FINGERPRINT, lifecycle);
mProfileUserId = getUserId();
}
protected boolean isUserSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& mProfileUserId != UserHandle.USER_NULL;
}
@Override
public boolean isAvailable() {
return android.os.Flags.allowPrivateProfile();
protected int getUserId() {
UserHandle privateProfileHandle =
PrivateSpaceMaintainer.getInstance(mContext).getPrivateProfileHandle();
if (privateProfileHandle != null) {
return privateProfileHandle.getIdentifier();
} else {
Log.e(TAG, "Private profile user handle is not expected to be null.");
}
return UserHandle.USER_NULL;
}
@Override
@@ -44,14 +62,19 @@ public class FaceFingerprintUnlockController extends AbstractPreferenceControlle
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
return TextUtils.equals(preference.getKey(), getPreferenceKey());
protected String getSettingsClassName() {
return mCombinedBiometricStatusUtils.getPrivateProfileSettingsClassName();
}
@Override
public void updateState(Preference preference) {
//TODO(b/308862923) : Add condition to check and enable when separate private lock is set.
preference.setSummary(mContext.getString(R.string.lock_settings_profile_unified_summary));
preference.setEnabled(false);
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileUserId)) {
super.updateState(preference);
preference.setEnabled(true);
} else {
preference.setSummary(
mContext.getString(R.string.lock_settings_profile_unified_summary));
preference.setEnabled(false);
}
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2023 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.privatespace.onelock;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.UserHandle;
import android.util.Log;
import com.android.settings.R;
import com.android.settings.biometrics.combination.BiometricsSettingsBase;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
public class PrivateSpaceBiometricSettings extends BiometricsSettingsBase {
private static final String TAG = "PSBiometricSettings";
private static final String KEY_FACE_SETTINGS = "private_space_face_unlock_settings";
private static final String KEY_FINGERPRINT_SETTINGS =
"private_space_fingerprint_unlock_settings";
@Override
public void onAttach(Context context) {
if (android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()) {
super.onAttach(context);
UserHandle privateProfileHandle =
PrivateSpaceMaintainer.getInstance(context).getPrivateProfileHandle();
if (privateProfileHandle != null) {
mUserId = privateProfileHandle.getIdentifier();
} else {
mUserId = -1;
Log.e(TAG, "Private profile user handle is not expected to be null.");
}
}
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.private_space_biometric_settings;
}
@Override
public String getFacePreferenceKey() {
return KEY_FACE_SETTINGS;
}
@Override
public String getFingerprintPreferenceKey() {
return KEY_FINGERPRINT_SETTINGS;
}
@Override
public String getUnlockPhonePreferenceKey() {
return "";
}
@Override
public String getUseInAppsPreferenceKey() {
return "";
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.PRIVATE_SPACE_SETTINGS;
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2023 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.privatespace.onelock;
import android.content.Context;
import android.os.UserHandle;
import android.util.Log;
import androidx.lifecycle.Lifecycle;
import com.android.settings.biometrics.combination.BiometricFaceStatusPreferenceController;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
public class PrivateSpaceFacePreferenceController extends BiometricFaceStatusPreferenceController {
private static final String TAG = "PrivateSpaceFaceCtrl";
public PrivateSpaceFacePreferenceController(Context context, String key) {
super(context, key);
}
public PrivateSpaceFacePreferenceController(Context context, String key, Lifecycle lifecycle) {
super(context, key, lifecycle);
}
@Override
protected boolean isUserSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& getUserId() != UserHandle.USER_NULL;
}
@Override
protected int getUserId() {
UserHandle privateProfileHandle =
PrivateSpaceMaintainer.getInstance(mContext).getPrivateProfileHandle();
if (privateProfileHandle != null) {
return privateProfileHandle.getIdentifier();
} else {
Log.e(TAG, "Private profile user handle is not expected to be null.");
}
return UserHandle.USER_NULL;
}
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2023 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.privatespace.onelock;
import android.content.Context;
import android.os.UserHandle;
import android.util.Log;
import androidx.lifecycle.Lifecycle;
import com.android.settings.biometrics.combination.BiometricFingerprintStatusPreferenceController;
import com.android.settings.privatespace.PrivateSpaceMaintainer;
public class PrivateSpaceFingerprintPreferenceController
extends BiometricFingerprintStatusPreferenceController {
private static final String TAG = "PrivateSpaceFingerCtrl";
public PrivateSpaceFingerprintPreferenceController(Context context, String key) {
super(context, key);
}
public PrivateSpaceFingerprintPreferenceController(
Context context, String key, Lifecycle lifecycle) {
super(context, key, lifecycle);
}
@Override
protected boolean isUserSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& getUserId() != UserHandle.USER_NULL;
}
@Override
protected int getUserId() {
UserHandle privateProfileHandle =
PrivateSpaceMaintainer.getInstance(mContext).getPrivateProfileHandle();
if (privateProfileHandle != null) {
return privateProfileHandle.getIdentifier();
} else {
Log.e(TAG, "Private profile user handle is not expected to be null.");
}
return UserHandle.USER_NULL;
}
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
}

View File

@@ -31,6 +31,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -122,15 +123,15 @@ public class UseOneLockControllerSwitch extends AbstractPreferenceController
}
/** Method to handle onActivityResult */
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
public boolean handleActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == UNUNIFY_PRIVATE_LOCK_FROM_DEVICE_REQUEST
&& resultCode == Activity.RESULT_OK) {
&& resultCode == Activity.RESULT_OK && data != null) {
mCurrentDevicePassword =
data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
separateLocks();
return true;
} else if (requestCode == UNIFY_PRIVATE_LOCK_WITH_DEVICE_REQUEST
&& resultCode == Activity.RESULT_OK) {
&& resultCode == Activity.RESULT_OK && data != null) {
mCurrentProfilePassword =
data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
unifyLocks();

View File

@@ -71,14 +71,14 @@ public class UseOneLockSettingsFragment extends DashboardFragment {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new UseOneLockControllerSwitch(context, this));
controllers.add(new PrivateSpaceLockController(context, this));
controllers.add(new FaceFingerprintUnlockController(context, this));
controllers.add(new FaceFingerprintUnlockController(context, getSettingsLifecycle()));
return controllers;
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (use(UseOneLockControllerSwitch.class)
.handleActivityResult(requestCode, resultCode, data)) {
.handleActivityResult(requestCode, resultCode, data)) {
return;
}
super.onActivityResult(requestCode, resultCode, data);