Make failed ConfirmCredential attempts count towards wipe

Previously, failed ConfirmDeviceCredential attempts only counted towards the
wipe limit if it is used as a separate work challenge.

In this CL, we additionally make these failed attempts count towards the total
failures in the following scenarios:
  1) when unified work challenge is enabled
  2) for the primary user (e.g. when a wipe limit is set by a DO)
  3) for secondary users

Bug: 27238008
Test: manual, by entering wrong credentials multiple times
Test: make SettingsRoboTests
Change-Id: Ie5a099bb3fd46245c13ccf4c8f91c4d935412a4e
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index b66edfe..c16b55a 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -299,10 +299,8 @@
                         mDetailsTextView.setText(getDefaultDetails());
                     }
                     mErrorTextView.setText("");
-                    if (isProfileChallenge()) {
-                        updateErrorMessage(mLockPatternUtils.getCurrentFailedPasswordAttempts(
-                                mEffectiveUserId));
-                    }
+                    updateErrorMessage(
+                            mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
 
                     mLockPatternView.setEnabled(true);
                     mLockPatternView.enableInput();
@@ -497,7 +495,7 @@
             mLockPatternView.setEnabled(true);
             if (matched) {
                 if (newResult) {
-                    reportSuccessfullAttempt();
+                    reportSuccessfulAttempt();
                 }
                 startDisappearAnimation(intent);
                 checkForPendingIntent();
@@ -524,8 +522,17 @@
         }
 
         @Override
-        protected int getLastTryErrorMessage() {
-            return R.string.lock_profile_wipe_warning_content_pattern;
+        protected int getLastTryErrorMessage(int userType) {
+            switch (userType) {
+                case USER_TYPE_PRIMARY:
+                    return R.string.lock_last_pattern_attempt_before_wipe_device;
+                case USER_TYPE_MANAGED_PROFILE:
+                    return R.string.lock_last_pattern_attempt_before_wipe_profile;
+                case USER_TYPE_SECONDARY:
+                    return R.string.lock_last_pattern_attempt_before_wipe_user;
+                default:
+                    throw new IllegalArgumentException("Unrecognized user type:" + userType);
+            }
         }
 
         private void handleAttemptLockout(long elapsedRealtimeDeadline) {