Add show emergency button call to biometric prompt
useDefaultSubtitle has to be set explicitly from promptInfo rather than being assumed true remove subtext for managed profile challenge screen to create space for emergency call button Test: manually tested Bug: 286391641 Bug: 286422726 Change-Id: I848e00dcd0013124e59ef711c3615e6773c3d210
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
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;
|
||||
@@ -791,36 +788,15 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
@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);
|
||||
if (UserManager.get(context).isManagedProfile(effectiveUserId)) {
|
||||
return null;
|
||||
}
|
||||
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;
|
||||
|
@@ -126,10 +126,9 @@ public class BiometricFragment extends InstrumentedFragment {
|
||||
final Bundle bundle = getArguments();
|
||||
final PromptInfo promptInfo = bundle.getParcelable(KEY_PROMPT_INFO);
|
||||
|
||||
mBiometricPrompt = new BiometricPrompt.Builder(getContext())
|
||||
BiometricPrompt.Builder promptBuilder = new BiometricPrompt.Builder(getContext())
|
||||
.setTitle(promptInfo.getTitle())
|
||||
.setUseDefaultTitle() // use default title if title is null/empty
|
||||
.setUseDefaultSubtitle() // use default subtitle if subtitle is null/empty
|
||||
.setDeviceCredentialAllowed(true)
|
||||
.setSubtitle(promptInfo.getSubtitle())
|
||||
.setDescription(promptInfo.getDescription())
|
||||
@@ -140,9 +139,15 @@ public class BiometricFragment extends InstrumentedFragment {
|
||||
.setConfirmationRequired(promptInfo.isConfirmationRequested())
|
||||
.setDisallowBiometricsIfPolicyExists(
|
||||
promptInfo.isDisallowBiometricsIfPolicyExists())
|
||||
.setShowEmergencyCallButton(promptInfo.isShowEmergencyCallButton())
|
||||
.setReceiveSystemEvents(true)
|
||||
.setAllowBackgroundAuthentication(true)
|
||||
.build();
|
||||
.setAllowBackgroundAuthentication(true);
|
||||
|
||||
// Check if the default subtitle should be used if subtitle is null/empty
|
||||
if (promptInfo.isUseDefaultSubtitle()) {
|
||||
promptBuilder.setUseDefaultSubtitle();
|
||||
}
|
||||
mBiometricPrompt = promptBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -26,6 +26,7 @@ import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.RemoteLockscreenValidationSession;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.ManagedSubscriptionsPolicy;
|
||||
import android.app.trust.TrustManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -200,6 +201,13 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
||||
promptInfo.setDescription(mDetails);
|
||||
promptInfo.setDisallowBiometricsIfPolicyExists(mCheckDevicePolicyManager);
|
||||
|
||||
final int policyType = mDevicePolicyManager.getManagedSubscriptionsPolicy().getPolicyType();
|
||||
|
||||
if (isEffectiveUserManagedProfile
|
||||
&& (policyType == ManagedSubscriptionsPolicy.TYPE_ALL_MANAGED_SUBSCRIPTIONS)) {
|
||||
promptInfo.setShowEmergencyCallButton(true);
|
||||
}
|
||||
|
||||
final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType(
|
||||
mContext, effectiveUserId);
|
||||
if (mTitle == null) {
|
||||
|
@@ -396,8 +396,7 @@ 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))
|
||||
.setUseDefaultSubtitle();
|
||||
.setTitle(context.getText(R.string.wifi_dpp_lockscreen_title));
|
||||
|
||||
if (keyguardManager.isDeviceSecure()) {
|
||||
builder.setDeviceCredentialAllowed(true);
|
||||
|
@@ -16,15 +16,10 @@
|
||||
|
||||
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 com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -399,45 +394,33 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_workPin_shouldReturnCorrectString() {
|
||||
public void getConfirmCredentialStringForUser_workPin_shouldReturnNull() {
|
||||
setUpForConfirmCredentialString(true /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mDevicePolicyResourcesManager
|
||||
.getString(eq(WORK_PROFILE_CONFIRM_PIN), any()))
|
||||
.thenReturn("WORK PIN");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PIN);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("WORK PIN");
|
||||
assertNull(confirmCredentialString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_workPattern_shouldReturnCorrectString() {
|
||||
public void getConfirmCredentialStringForUser_workPattern_shouldReturnNull() {
|
||||
setUpForConfirmCredentialString(true /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mDevicePolicyResourcesManager
|
||||
.getString(eq(WORK_PROFILE_CONFIRM_PATTERN), any()))
|
||||
.thenReturn("WORK PATTERN");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PATTERN);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("WORK PATTERN");
|
||||
assertNull(confirmCredentialString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfirmCredentialStringForUser_workPassword_shouldReturnCorrectString() {
|
||||
public void getConfirmCredentialStringForUser_workPassword_shouldReturnNull() {
|
||||
setUpForConfirmCredentialString(true /* isEffectiveUserManagedProfile */);
|
||||
|
||||
when(mDevicePolicyResourcesManager
|
||||
.getString(eq(WORK_PROFILE_CONFIRM_PASSWORD), any()))
|
||||
.thenReturn("WORK PASSWORD");
|
||||
|
||||
String confirmCredentialString = Utils.getConfirmCredentialStringForUser(mContext,
|
||||
USER_ID, LockPatternUtils.CREDENTIAL_TYPE_PASSWORD);
|
||||
|
||||
assertThat(confirmCredentialString).isEqualTo("WORK PASSWORD");
|
||||
assertNull(confirmCredentialString);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -454,7 +437,5 @@ public class UtilsTest {
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mMockUserManager);
|
||||
when(mMockUserManager.getCredentialOwnerProfile(USER_ID)).thenReturn(USER_ID);
|
||||
when(mMockUserManager.isManagedProfile(USER_ID)).thenReturn(isEffectiveUserManagedProfile);
|
||||
when(mContext.getSystemService(DevicePolicyManager.class)).thenReturn(mDevicePolicyManager);
|
||||
when(mDevicePolicyManager.getResources()).thenReturn(mDevicePolicyResourcesManager);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user