Add bp subtitle for WiFi sharing

Move the screen lock message selection logic to Utils and update the
related strings as suzannechen@ suggested.

Test: manual (see bug)
Test: atest UtilsTest
Fixes: 291307701
Change-Id: I346c25426395eea1320edc07ce2d962efeb8daa6
This commit is contained in:
Wenhui Yang
2023-07-26 17:12:53 +00:00
parent a94cfc7b76
commit cf8ba456bb
5 changed files with 170 additions and 43 deletions

View File

@@ -16,6 +16,9 @@
package com.android.settings;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PASSWORD;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PATTERN;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PIN;
import static android.content.Intent.EXTRA_USER;
import static android.content.Intent.EXTRA_USER_ID;
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
@@ -782,6 +785,47 @@ public final class Utils extends com.android.settingslib.Utils {
return lpu.getCredentialTypeForUser(userId);
}
/**
* Returns the confirmation credential string of the given user id.
*/
@Nullable public static String getConfirmCredentialStringForUser(@NonNull Context context,
int userId, @LockPatternUtils.CredentialType int credentialType) {
final int effectiveUserId = UserManager.get(context).getCredentialOwnerProfile(userId);
final boolean isEffectiveUserManagedProfile = UserManager.get(context)
.isManagedProfile(effectiveUserId);
final DevicePolicyManager devicePolicyManager = context
.getSystemService(DevicePolicyManager.class);
switch (credentialType) {
case LockPatternUtils.CREDENTIAL_TYPE_PIN:
if (isEffectiveUserManagedProfile) {
return devicePolicyManager.getResources().getString(WORK_PROFILE_CONFIRM_PIN,
() -> context.getString(
R.string.lockpassword_confirm_your_pin_generic_profile));
}
return context.getString(R.string.lockpassword_confirm_your_pin_generic);
case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
if (isEffectiveUserManagedProfile) {
return devicePolicyManager.getResources().getString(
WORK_PROFILE_CONFIRM_PATTERN,
() -> context.getString(
R.string.lockpassword_confirm_your_pattern_generic_profile));
}
return context.getString(R.string.lockpassword_confirm_your_pattern_generic);
case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
if (isEffectiveUserManagedProfile) {
return devicePolicyManager.getResources().getString(
WORK_PROFILE_CONFIRM_PASSWORD,
() -> context.getString(
R.string.lockpassword_confirm_your_password_generic_profile));
}
return context.getString(R.string.lockpassword_confirm_your_password_generic);
}
return null;
}
private static final StringBuilder sBuilder = new StringBuilder(50);
private static final java.util.Formatter sFormatter = new java.util.Formatter(
sBuilder, Locale.getDefault());