Refactor ChooseLockGenericController

* Move all logics around aggregating password policies
  to the controller
* Replace HIDE_DISABLED_PREFS and MINIMUM_QUALITY_KEY
  with HIDE_INSECURE_OPTIONS as all call sites are just
  using them to hide insecure screenlock options.
* Remove password policy aggregation logic from
  ChooseLockPassword and make it use policies passed in.
* Remove padlock from disabled screen lock options,
  per UX mock.
* Increase char limit for some strings

Bug: 177638284
Bug: 177641868
Bug: 182561862
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.password
Test: 1. set profile password quality/complexity and enroll device lock
      2. set profile password quality/complexity and enroll work challenge
      3. set parent password quality/complexity and enroll device lock
      4. set parent password quality/complexity and enroll work challenge
      5. set profile and parent password complexity, then enroll work challenge
      6. set profile and parent password complexity, then unify work challenge
      7. Enroll device lock during SUW
Change-Id: Iba1d37e6f33eba7b7e8e1f805f8e37aaec108404
This commit is contained in:
Rubin Xu
2021-04-14 14:32:26 +01:00
parent 660341876d
commit 8e4acdbf51
18 changed files with 386 additions and 319 deletions

View File

@@ -21,7 +21,6 @@ import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -160,22 +159,12 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
return SetupChooseLockGeneric.InternalActivity.class;
}
/***
* Disables preferences that are less secure than required quality and shows only secure
* screen lock options here.
*
* @param quality the requested quality.
*/
@Override
protected void disableUnusablePreferences(final int quality, boolean hideDisabled) {
protected boolean alwaysHideInsecureScreenLockTypes() {
// At this part of the flow, the user has already indicated they want to add a pin,
// pattern or password, so don't show "None" or "Slide". We disable them here and set
// the HIDE_DISABLED flag to true to hide them. This only happens for setup wizard.
// We do the following max check here since the device may already have a Device Admin
// installed with a policy we need to honor.
final int newQuality = Math.max(quality,
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
super.disableUnusablePreferencesImpl(newQuality, true /* hideDisabled */);
// pattern or password, so don't show "None" or "Slide". We disable them here.
// This only happens for setup wizard.
return true;
}
@Override