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:
@@ -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());
|
||||
|
@@ -20,9 +20,6 @@ package com.android.settings.password;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PASSWORD_HEADER;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PATTERN_HEADER;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PIN_HEADER;
|
||||
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.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -211,7 +208,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
||||
}
|
||||
if (mDetails == null) {
|
||||
promptInfo.setDeviceCredentialSubtitle(
|
||||
getDetailsFromCredentialType(credentialType, isEffectiveUserManagedProfile));
|
||||
Utils.getConfirmCredentialStringForUser(this, mUserId, credentialType));
|
||||
}
|
||||
|
||||
boolean launchedBiometric = false;
|
||||
@@ -342,39 +339,6 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
|
||||
boolean isEffectiveUserManagedProfile) {
|
||||
switch (credentialType) {
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PIN:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return mDevicePolicyManager.getResources().getString(WORK_PROFILE_CONFIRM_PIN,
|
||||
() -> getString(
|
||||
R.string.lockpassword_confirm_your_pin_generic_profile));
|
||||
}
|
||||
|
||||
return getString(R.string.lockpassword_confirm_your_pin_generic);
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return mDevicePolicyManager.getResources().getString(
|
||||
WORK_PROFILE_CONFIRM_PATTERN,
|
||||
() -> getString(
|
||||
R.string.lockpassword_confirm_your_pattern_generic_profile));
|
||||
}
|
||||
|
||||
return getString(R.string.lockpassword_confirm_your_pattern_generic);
|
||||
case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
|
||||
if (isEffectiveUserManagedProfile) {
|
||||
return mDevicePolicyManager.getResources().getString(
|
||||
WORK_PROFILE_CONFIRM_PASSWORD,
|
||||
() -> getString(
|
||||
R.string.lockpassword_confirm_your_password_generic_profile));
|
||||
}
|
||||
|
||||
return getString(R.string.lockpassword_confirm_your_password_generic);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
@@ -27,11 +27,13 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.UserHandle;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
@@ -391,11 +393,19 @@ public class WifiDppUtils {
|
||||
}
|
||||
};
|
||||
|
||||
final int userId = UserHandle.myUserId();
|
||||
|
||||
final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
|
||||
.setTitle(context.getText(R.string.wifi_dpp_lockscreen_title));
|
||||
.setTitle(context.getText(R.string.wifi_dpp_lockscreen_title))
|
||||
.setUseDefaultSubtitle();
|
||||
|
||||
if (keyguardManager.isDeviceSecure()) {
|
||||
builder.setDeviceCredentialAllowed(true);
|
||||
builder.setTextForDeviceCredential(
|
||||
null /* title */,
|
||||
Utils.getConfirmCredentialStringForUser(
|
||||
context, userId, Utils.getCredentialType(context, userId)),
|
||||
null /* description */);
|
||||
}
|
||||
|
||||
final BiometricPrompt bp = builder.build();
|
||||
|
Reference in New Issue
Block a user