Merge "Face and fingerprint unlock strings for private space" into main

This commit is contained in:
Joseph Vincent
2024-05-25 01:29:35 +00:00
committed by Android (Google) Code Review
14 changed files with 128 additions and 12 deletions

View File

@@ -1400,6 +1400,16 @@ public final class Utils extends com.android.settingslib.Utils {
&& userManager.isQuietModeEnabled(userHandle);
}
/**
* Returns true if the userId is a private profile, false otherwise.
*/
public static boolean isPrivateProfile(int userId, @NonNull Context context) {
final UserManager userManager = context.getSystemService(UserManager.class);
UserInfo userInfo = userManager.getUserInfo(userId);
return Flags.allowPrivateProfile() && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& userInfo.isPrivateProfile();
}
/**
* Enable new edge to edge feature.
*

View File

@@ -93,7 +93,10 @@ public class CombinedBiometricStatusUtils {
public String getTitle() {
UserManager userManager = mContext.getSystemService(UserManager.class);
if (userManager != null && userManager.isProfile()) {
return mContext.getString(R.string.security_settings_work_biometric_preference_title);
return mContext.getString(
Utils.isPrivateProfile(mUserId, mContext)
? R.string.private_space_biometric_unlock_title
: R.string.security_settings_work_biometric_preference_title);
} else {
return mContext.getString(R.string.security_settings_biometric_preference_title);
}

View File

@@ -365,7 +365,9 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@StringRes
protected int getInfoMessageLooking() {
return R.string.security_settings_face_enroll_introduction_info_looking;
return isPrivateProfile()
? R.string.private_space_face_enroll_introduction_info_looking
: R.string.security_settings_face_enroll_introduction_info_looking;
}
@StringRes
@@ -390,7 +392,10 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@StringRes
protected int getLessSecureMessage() {
return R.string.security_settings_face_enroll_introduction_info_less_secure;
return isPrivateProfile()
? R.string.private_space_face_enroll_introduction_info_less_secure
: R.string.security_settings_face_enroll_introduction_info_less_secure;
}
@Override
@@ -411,6 +416,9 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@Override
protected int getHeaderResDefault() {
if (isPrivateProfile()) {
return R.string.private_space_face_enroll_introduction_title;
}
return R.string.security_settings_face_enroll_introduction_title;
}
@@ -577,7 +585,10 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@Override
protected void updateDescriptionText() {
if (mIsFaceStrong) {
if (isPrivateProfile()) {
setDescriptionText(getString(
R.string.private_space_face_enroll_introduction_message));
} else if (mIsFaceStrong) {
setDescriptionText(getString(
R.string.security_settings_face_enroll_introduction_message_class3));
}
@@ -608,4 +619,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
}
updateDescriptionText();
}
private boolean isPrivateProfile() {
return Utils.isPrivateProfile(mUserId, getApplicationContext());
}
}

View File

@@ -211,6 +211,8 @@ public class FaceSettings extends DashboardFragment {
((FaceSettingsPreferenceController) controller).setUserId(mUserId);
} else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) {
((FaceSettingsEnrollButtonPreferenceController) controller).setUserId(mUserId);
} else if (controller instanceof FaceSettingsFooterPreferenceController) {
((FaceSettingsFooterPreferenceController) controller).setUserId(mUserId);
}
}
mRemoveController.setUserId(mUserId);
@@ -367,6 +369,7 @@ public class FaceSettings extends DashboardFragment {
controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));
controllers.add(new FaceSettingsConfirmPreferenceController(context));
controllers.add(new FaceSettingsEnrollButtonPreferenceController(context));
controllers.add(new FaceSettingsFooterPreferenceController(context));
return controllers;
}

View File

@@ -24,10 +24,12 @@ import android.hardware.face.FaceManager.GetFeatureCallback;
import android.hardware.face.FaceManager.SetFeatureCallback;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.Utils;
/**
@@ -98,6 +100,18 @@ public class FaceSettingsAttentionPreferenceController extends FaceSettingsPrefe
mPreference = screen.findPreference(KEY);
}
@Override
public void updateState(@Nullable Preference preference) {
if (preference == null) {
return;
}
super.updateState(preference);
if (Utils.isPrivateProfile(getUserId(), mContext)) {
preference.setSummary(mContext.getString(
R.string.private_space_face_settings_require_attention_details));
}
}
@Override
public boolean isChecked() {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {

View File

@@ -30,6 +30,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.utils.AnnotationSpan;
@@ -41,12 +42,17 @@ import java.util.List;
* Footer for face settings showing the help text and help link.
*/
public class FaceSettingsFooterPreferenceController extends BasePreferenceController {
private static final String KEY = "security_face_footer";
private static final String TAG = "FaceSettingsFooterPreferenceController";
private static final String ANNOTATION_URL = "url";
private final FaceFeatureProvider mProvider;
private Preference mPreference;
private boolean mIsFaceStrong;
private int mUserId;
public FaceSettingsFooterPreferenceController(@NonNull Context context) {
this(context, KEY);
}
public FaceSettingsFooterPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mProvider = FeatureFactory.getFeatureFactory().getFaceFeatureProvider();
@@ -79,7 +85,9 @@ public class FaceSettingsFooterPreferenceController extends BasePreferenceContro
int footerRes;
boolean isAttentionSupported = mProvider.isAttentionSupported(mContext);
if (mIsFaceStrong) {
if (Utils.isPrivateProfile(mUserId, mContext)) {
footerRes = R.string.private_space_face_settings_footer;
} else if (mIsFaceStrong) {
footerRes = isAttentionSupported
? R.string.security_settings_face_settings_footer_class3
: R.string.security_settings_face_settings_footer_attention_not_supported;
@@ -92,6 +100,10 @@ public class FaceSettingsFooterPreferenceController extends BasePreferenceContro
mContext.getText(footerRes), linkInfo));
}
public void setUserId(int userId) {
mUserId = userId;
}
private void addAuthenticatorsRegisteredCallback(Context context) {
final FaceManager faceManager = context.getSystemService(FaceManager.class);
faceManager.addAuthenticatorsRegisteredCallback(

View File

@@ -67,7 +67,10 @@ public class FaceStatusUtils {
public String getTitle() {
UserManager userManager = mContext.getSystemService(UserManager.class);
if (userManager != null && userManager.isProfile()) {
return mContext.getString(R.string.security_settings_face_profile_preference_title);
return mContext.getString(
Utils.isPrivateProfile(mUserId, mContext)
? R.string.private_space_face_unlock_title
: R.string.security_settings_face_profile_preference_title);
} else {
return mContext.getString(R.string.security_settings_face_preference_title);
}

View File

@@ -78,7 +78,10 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
setContentView(R.layout.fingerprint_enroll_finish);
}
setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
setDescriptionText(R.string.security_settings_fingerprint_enroll_finish_v2_message);
setDescriptionText(Utils.isPrivateProfile(mUserId, getApplicationContext())
? R.string.private_space_fingerprint_enroll_finish_message
: R.string.security_settings_fingerprint_enroll_finish_v2_message);
final String sfpsDescription = mSfpsRestToUnlockFeature != null
? mSfpsRestToUnlockFeature.getDescriptionForSfps(this)
: null;

View File

@@ -176,7 +176,9 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
@Override
protected void initViews() {
setDescriptionText(getString(
R.string.security_settings_fingerprint_enroll_introduction_v3_message,
isPrivateProfile()
? R.string.private_space_fingerprint_enroll_introduction_message
: R.string.security_settings_fingerprint_enroll_introduction_v3_message,
DeviceHelper.getDeviceName(this)));
super.initViews();
@@ -261,6 +263,9 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
@StringRes
protected int getFooterMessage5() {
if (isPrivateProfile()) {
return R.string.private_space_fingerprint_enroll_introduction_footer_message;
}
return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_5;
}
@@ -292,6 +297,9 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
@Override
protected int getHeaderResDefault() {
if (isPrivateProfile()) {
return R.string.private_space_fingerprint_enroll_introduction_title;
}
return R.string.security_settings_fingerprint_enroll_introduction_title;
}
@@ -477,4 +485,8 @@ public class FingerprintEnrollIntroduction extends BiometricEnrollIntroduction {
data.putExtra(MultiBiometricEnrollHelper.EXTRA_SKIP_PENDING_ENROLL, true);
return data;
}
private boolean isPrivateProfile() {
return Utils.isPrivateProfile(mUserId, getApplicationContext());
}
}

View File

@@ -510,8 +510,9 @@ public class FingerprintSettings extends SubSettings {
mFooterColumns.add(column2);
} else {
final FooterColumn column = new FooterColumn();
column.mTitle = getString(
R.string.security_settings_fingerprint_enroll_introduction_v3_message,
column.mTitle = getString(isPrivateProfile()
? R.string.private_space_fingerprint_enroll_introduction_message
: R.string.security_settings_fingerprint_enroll_introduction_v3_message,
DeviceHelper.getDeviceName(getActivity()));
column.mLearnMoreClickListener = learnMoreClickListener;
column.mLearnMoreOverrideText = getText(
@@ -1130,6 +1131,10 @@ public class FingerprintSettings extends SubSettings {
}
};
private boolean isPrivateProfile() {
return Utils.isPrivateProfile(mUserId, getContext());
}
public static class DeleteFingerprintDialog extends InstrumentedDialogFragment
implements DialogInterface.OnClickListener {

View File

@@ -68,7 +68,10 @@ public class FingerprintStatusUtils {
public String getTitle() {
UserManager userManager = mContext.getSystemService(UserManager.class);
if (userManager != null && userManager.isProfile()) {
return mContext.getString(R.string.security_settings_work_fingerprint_preference_title);
return mContext.getString(
Utils.isPrivateProfile(mUserId, mContext)
? R.string.private_space_fingerprint_unlock_title
: R.string.security_settings_work_fingerprint_preference_title);
} else {
return mContext.getString(R.string.security_settings_fingerprint_preference_title);
}