Throw if admin sets password constraints that have no effect.

For admin apps targeting R+, throw when the app sets password requirement
that is not taken into account at  given quality, e.g. when quality is set
to UNSPECIFIED, it doesn't make sense to require certain password length.
If the intent is to require a password of certain length having at least
NUMERIC quality, the admin should first call setPasswordQuality() and only
then call setPasswordMinimumLength().

Conversely when an admin targeting R+ lowers password quality, those
requiremnts that stop making sense, are reset to default values.

+ fix the behaviour of getPasswordMinimumLength to match the docs: only
  admins with password quality >= NUMERIC should be taken into account.

Test: com.android.cts.devicepolicy..MixedDeviceOwnerTest#testResetPasswordWithToken
Test: com.android.cts.devicepolicy.DeviceAdminHostSideTestApi23#testRunDeviceOwnerPasswordTest
Test: com.android.cts.devicepolicy.MixedDeviceOwnerTestApi#testPasswordRequirementsApi
Test: com.android.cts.devicepolicy.MixedDeviceOwnerTestApi25#testPasswordRequirementsApi
Bug: 123562444
Change-Id: Id134a7918718e3b0a220caaf6c672df4238a062c
2 files changed