diff options
| author | 2017-07-26 18:59:13 +0000 | |
|---|---|---|
| committer | 2017-07-26 18:59:13 +0000 | |
| commit | c58e47cfdccd65385958e1645022cce72ba26c06 (patch) | |
| tree | 19f8b9f4a0f387aa1537d9bfe5bcbc6b6d4ed7c3 | |
| parent | 6cb150d094b526d5f05c11efd83be833c0ca4d0d (diff) | |
| parent | b31912544661f0ea3d05e07a8250530660101c0b (diff) | |
Merge "Don't attribute incorrect unified challenge attempt to profile." into oc-mr1-dev
| -rw-r--r-- | core/java/com/android/internal/widget/LockPatternUtils.java | 61 | ||||
| -rw-r--r-- | services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java | 4 | 
2 files changed, 38 insertions, 27 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 53a965452df3..9462a06a1a05 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -909,44 +909,38 @@ public class LockPatternUtils {       */      public void setSeparateProfileChallengeEnabled(int userHandle, boolean enabled,              String managedUserPassword) { -        UserInfo info = getUserManager().getUserInfo(userHandle); -        if (info.isManagedProfile()) { -            try { -                getLockSettings().setSeparateProfileChallengeEnabled(userHandle, enabled, -                        managedUserPassword); -                onAfterChangingPassword(userHandle); -            } catch (RemoteException e) { -                Log.e(TAG, "Couldn't update work profile challenge enabled"); -            } +        if (!isManagedProfile(userHandle)) { +            return; +        } +        try { +            getLockSettings().setSeparateProfileChallengeEnabled(userHandle, enabled, +                    managedUserPassword); +            onAfterChangingPassword(userHandle); +        } catch (RemoteException e) { +            Log.e(TAG, "Couldn't update work profile challenge enabled");          }      }      /** -     * Retrieves whether the Separate Profile Challenge is enabled for this {@param userHandle}. +     * Returns true if {@param userHandle} is a managed profile with separate challenge.       */      public boolean isSeparateProfileChallengeEnabled(int userHandle) { -        UserInfo info = getUserManager().getUserInfo(userHandle); -        if (info == null || !info.isManagedProfile()) { -            return false; -        } -        try { -            return getLockSettings().getSeparateProfileChallengeEnabled(userHandle); -        } catch (RemoteException e) { -            Log.e(TAG, "Couldn't get separate profile challenge enabled"); -            // Default value is false -            return false; -        } +        return isManagedProfile(userHandle) && hasSeparateChallenge(userHandle); +    } + +    /** +     * Returns true if {@param userHandle} is a managed profile with unified challenge. +     */ +    public boolean isManagedProfileWithUnifiedChallenge(int userHandle) { +        return isManagedProfile(userHandle) && !hasSeparateChallenge(userHandle);      }      /**       * Retrieves whether the current DPM allows use of the Profile Challenge.       */      public boolean isSeparateProfileChallengeAllowed(int userHandle) { -        UserInfo info = getUserManager().getUserInfo(userHandle); -        if (info == null || !info.isManagedProfile()) { -            return false; -        } -        return getDevicePolicyManager().isSeparateProfileChallengeAllowed(userHandle); +        return isManagedProfile(userHandle) +                && getDevicePolicyManager().isSeparateProfileChallengeAllowed(userHandle);      }      /** @@ -956,6 +950,21 @@ public class LockPatternUtils {          return getDevicePolicyManager().isProfileActivePasswordSufficientForParent(userHandle);      } +    private boolean hasSeparateChallenge(int userHandle) { +        try { +            return getLockSettings().getSeparateProfileChallengeEnabled(userHandle); +        } catch (RemoteException e) { +            Log.e(TAG, "Couldn't get separate profile challenge enabled"); +            // Default value is false +            return false; +        } +    } + +    private boolean isManagedProfile(int userHandle) { +        final UserInfo info = getUserManager().getUserInfo(userHandle); +        return info != null && info.isManagedProfile(); +    } +      /**       * Deserialize a pattern.       * @param string The pattern serialized with {@link #patternToString} diff --git a/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java b/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java index 4facbb87af42..3c236b401481 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsShellCommand.java @@ -168,7 +168,9 @@ class LockSettingsShellCommand extends ShellCommand {                      result = mLockPatternUtils.checkPattern(stringToPattern(mOld), mCurrentUserId);                  }                  if (!result) { -                    mLockPatternUtils.reportFailedPasswordAttempt(mCurrentUserId); +                    if (!mLockPatternUtils.isManagedProfileWithUnifiedChallenge(mCurrentUserId)) { +                        mLockPatternUtils.reportFailedPasswordAttempt(mCurrentUserId); +                    }                      getOutPrintWriter().println("Old password '" + mOld + "' didn't match");                  }                  return result;  |