Support remote device credentials validation in UI.
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.password Test: Manual Bug: 258505917 Change-Id: Ifb9f15728eb8396b34c844d28f71a8e6e1aad837
This commit is contained in:
@@ -8,6 +8,7 @@ import android.annotation.Nullable;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.DevicePolicyManager.DeviceOwnerType;
|
||||
import android.app.admin.ManagedSubscriptionsPolicy;
|
||||
import android.app.admin.PasswordMetrics;
|
||||
import android.app.admin.PasswordPolicy;
|
||||
import android.content.ComponentName;
|
||||
@@ -29,6 +30,7 @@ public class ShadowDevicePolicyManager extends org.robolectric.shadows.ShadowDev
|
||||
private Map<Integer, CharSequence> mSupportMessagesMap = new HashMap<>();
|
||||
private boolean mIsAdminActiveAsUser = false;
|
||||
private ComponentName mDeviceOwnerComponentName;
|
||||
private ManagedSubscriptionsPolicy mManagedSubscriptionsPolicy;
|
||||
private int mDeviceOwnerUserId = -1;
|
||||
private int mPasswordMinQuality = PASSWORD_QUALITY_UNSPECIFIED;
|
||||
private int mPasswordMinLength = 0;
|
||||
@@ -85,6 +87,10 @@ public class ShadowDevicePolicyManager extends org.robolectric.shadows.ShadowDev
|
||||
mDeviceOwnerTypes.put(admin.getPackageName(), deviceOwnerType);
|
||||
}
|
||||
|
||||
public void setManagedSubscriptionsPolicy(ManagedSubscriptionsPolicy policy) {
|
||||
mManagedSubscriptionsPolicy = policy;
|
||||
}
|
||||
|
||||
@DeviceOwnerType
|
||||
public int getDeviceOwnerType(@NonNull ComponentName admin) {
|
||||
return mDeviceOwnerTypes.getOrDefault(admin.getPackageName(), DEVICE_OWNER_TYPE_DEFAULT);
|
||||
@@ -99,6 +105,11 @@ public class ShadowDevicePolicyManager extends org.robolectric.shadows.ShadowDev
|
||||
return policy.getMinMetrics();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public ManagedSubscriptionsPolicy getManagedSubscriptionsPolicy() {
|
||||
return mManagedSubscriptionsPolicy;
|
||||
}
|
||||
|
||||
public void setPasswordQuality(int quality) {
|
||||
mPasswordMinQuality = quality;
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.testutils.shadow;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.PasswordMetrics;
|
||||
import android.content.ComponentName;
|
||||
@@ -43,6 +45,10 @@ public class ShadowLockPatternUtils {
|
||||
private static Map<Integer, PasswordMetrics> sUserToMetricsMap = new HashMap<>();
|
||||
private static Map<Integer, PasswordMetrics> sUserToProfileMetricsMap = new HashMap<>();
|
||||
private static Map<Integer, Boolean> sUserToIsSecureMap = new HashMap<>();
|
||||
private static Map<Integer, Boolean> sUserToPatternEverChosenMap = new HashMap<>();
|
||||
private static Map<Integer, Boolean> sUserToVisiblePatternEnabledMap = new HashMap<>();
|
||||
private static Map<Integer, Boolean> sUserToBiometricAllowedMap = new HashMap<>();
|
||||
private static Map<Integer, Boolean> sUserToLockPatternEnabledMap = new HashMap<>();
|
||||
|
||||
private static boolean sIsUserOwnsFrpCredential;
|
||||
|
||||
@@ -53,6 +59,10 @@ public class ShadowLockPatternUtils {
|
||||
sUserToMetricsMap.clear();
|
||||
sUserToProfileMetricsMap.clear();
|
||||
sUserToIsSecureMap.clear();
|
||||
sUserToPatternEverChosenMap.clear();
|
||||
sUserToVisiblePatternEnabledMap.clear();
|
||||
sUserToBiometricAllowedMap.clear();
|
||||
sUserToLockPatternEnabledMap.clear();
|
||||
sDeviceEncryptionEnabled = false;
|
||||
sIsUserOwnsFrpCredential = false;
|
||||
}
|
||||
@@ -136,6 +146,56 @@ public class ShadowLockPatternUtils {
|
||||
sIsUserOwnsFrpCredential = isUserOwnsFrpCredential;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isVisiblePatternEnabled(int userId) {
|
||||
return sUserToVisiblePatternEnabledMap.getOrDefault(userId, false);
|
||||
}
|
||||
|
||||
public static void setIsVisiblePatternEnabled(int userId, boolean isVisiblePatternEnabled) {
|
||||
sUserToVisiblePatternEnabledMap.put(userId, isVisiblePatternEnabled);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isPatternEverChosen(int userId) {
|
||||
return sUserToPatternEverChosenMap.getOrDefault(userId, true);
|
||||
}
|
||||
|
||||
public static void setIsPatternEverChosen(int userId, boolean isPatternEverChosen) {
|
||||
sUserToPatternEverChosenMap.put(userId, isPatternEverChosen);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isBiometricAllowedForUser(int userId) {
|
||||
return sUserToBiometricAllowedMap.getOrDefault(userId, false);
|
||||
}
|
||||
|
||||
public static void setIsBiometricAllowedForUser(int userId, boolean isBiometricAllowed) {
|
||||
sUserToBiometricAllowedMap.put(userId, isBiometricAllowed);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isLockPatternEnabled(int userId) {
|
||||
return sUserToBiometricAllowedMap.getOrDefault(userId, false);
|
||||
}
|
||||
|
||||
public static void setIsLockPatternEnabled(int userId, boolean isLockPatternEnabled) {
|
||||
sUserToLockPatternEnabledMap.put(userId, isLockPatternEnabled);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean setLockCredential(@NonNull LockscreenCredential newCredential,
|
||||
@NonNull LockscreenCredential savedCredential, int userHandle) {
|
||||
setIsSecure(userHandle, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean checkCredential(@NonNull LockscreenCredential credential, int userId,
|
||||
@Nullable LockPatternUtils.CheckCredentialProgressCallback progressCallback)
|
||||
throws LockPatternUtils.RequestThrottledException {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setRequiredPasswordComplexity(int userHandle, int complexity) {
|
||||
sUserToComplexityMap.put(userHandle, complexity);
|
||||
}
|
||||
|
Reference in New Issue
Block a user