Clean up choose lock intent creation
Consolidated the many variants of ChooseLock*.createIntent, so that
it will take the same set of arguments.
Also modified SetupChooseLock*.createIntent to modifyIntentForSetup,
which will take the intent created by ChooseLock* and modify it for
use with setup.
Test: cd tests/robotests && mma
Change-Id: I5ff033f459c33ec9980872a536b3996d89f2bbbb
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 24b9632..970ee76 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1497,7 +1497,7 @@
<!-- Second and third-level settings -->
<!-- Lock screen settings -->
- <activity android:name="ConfirmDeviceCredentialActivity"
+ <activity android:name=".password.ConfirmDeviceCredentialActivity"
android:exported="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter android:priority="1">
@@ -1505,9 +1505,13 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <!-- Activity alias for compatibility -->
+ <activity-alias android:name=".ConfirmDeviceCredentialActivity"
+ android:targetActivity=".password.ConfirmDeviceCredentialActivity"
+ android:exported="true" />
<!-- Note this must not be exported since it authenticates the given user -->
- <activity android:name="ConfirmDeviceCredentialActivity$InternalActivity"
+ <activity android:name=".password.ConfirmDeviceCredentialActivity$InternalActivity"
android:exported="false"
android:permission="android.permission.MANAGE_USERS"
android:resizeableActivity="false"
@@ -1548,10 +1552,10 @@
</intent-filter>
</activity>
- <activity android:name="ConfirmLockPattern"
+ <activity android:name=".password.ConfirmLockPattern"
android:theme="@style/GlifTheme.Light"/>
- <activity android:name="ConfirmLockPassword"
+ <activity android:name=".password.ConfirmLockPassword"
android:windowSoftInputMode="stateHidden|adjustResize"
android:theme="@style/GlifTheme.Light"/>
@@ -1593,17 +1597,17 @@
</activity>
<!-- Note this must not be exported since it returns the password in the intent -->
- <activity android:name="ConfirmLockPattern$InternalActivity"
+ <activity android:name=".password.ConfirmLockPattern$InternalActivity"
android:exported="false"
android:theme="@style/GlifTheme.Light"/>
<!-- Note this must not be exported since it returns the password in the intent -->
- <activity android:name="ConfirmLockPassword$InternalActivity"
+ <activity android:name=".password.ConfirmLockPassword$InternalActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize"
android:theme="@style/GlifTheme.Light"/>
- <activity android:name="SetupChooseLockGeneric"
+ <activity android:name=".password.SetupChooseLockGeneric"
android:taskAffinity="com.android.wizard"
android:theme="@style/GlifTheme.Light"
android:label="@string/lock_settings_picker_title">
@@ -1613,7 +1617,7 @@
</intent-filter>
</activity>
- <activity android:name="ChooseLockGeneric"
+ <activity android:name=".password.ChooseLockGeneric"
android:label="@string/lockpassword_choose_lock_generic_header"
android:excludeFromRecents="true"
android:exported="false" />
@@ -1660,27 +1664,27 @@
android:resource="@string/suggested_fingerprint_lock_settings_summary" />
</activity>
- <activity android:name="ChooseLockGeneric$InternalActivity" android:exported="false"
+ <activity android:name=".password.ChooseLockGeneric$InternalActivity"
+ android:exported="false"
android:label="@string/lockpassword_choose_lock_generic_header"
- android:excludeFromRecents="true"
- />
+ android:excludeFromRecents="true" />
- <activity android:name="SetupChooseLockPattern"
+ <activity android:name=".password.SetupChooseLockPattern"
android:exported="false"
android:taskAffinity="com.android.wizard"
android:theme="@style/GlifTheme.Light" />
- <activity android:name="ChooseLockPattern"
+ <activity android:name=".password.ChooseLockPattern"
android:exported="false"
android:theme="@style/GlifTheme.Light" />
- <activity android:name="SetupChooseLockPassword"
+ <activity android:name=".password.SetupChooseLockPassword"
android:exported="false"
android:taskAffinity="com.android.wizard"
android:theme="@style/GlifTheme.Light"
android:windowSoftInputMode="stateVisible|adjustResize" />
- <activity android:name="ChooseLockPassword"
+ <activity android:name=".password.ChooseLockPassword"
android:exported="false"
android:theme="@style/GlifTheme.Light"
android:windowSoftInputMode="stateVisible|adjustResize"/>
diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java
index d662c2e..03a5f4b 100644
--- a/src/com/android/settings/CredentialStorage.java
+++ b/src/com/android/settings/CredentialStorage.java
@@ -47,14 +47,16 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.org.bouncycastle.asn1.ASN1InputStream;
import com.android.org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
+import com.android.settings.password.ChooseLockGeneric;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.vpn2.VpnUtils;
-import sun.security.util.ObjectIdentifier;
-import sun.security.x509.AlgorithmId;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import sun.security.util.ObjectIdentifier;
+import sun.security.x509.AlgorithmId;
+
/**
* CredentialStorage handles KeyStore reset, unlock, and install.
*
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index d9b98f0..e11bccd 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -37,6 +37,8 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.InstrumentedPreferenceFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.password.ConfirmLockPattern;
public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
private static final String TAG = "CryptKeeper";
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index ed9596d..c352bf0 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -36,6 +36,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.setupwizardlib.GlifLayout;
import java.util.List;
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index ef4190b..77c6091 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -16,6 +16,8 @@
package com.android.settings;
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
@@ -48,13 +50,13 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.password.ConfirmLockPattern;
import com.android.settings.widget.CarrierDemoPasswordDialogFragment;
import com.android.settingslib.RestrictedLockUtils;
import java.util.List;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
/**
* Confirm and execute a reset of the device to a clean "just out of the box"
* state. Multiple confirmations are required: first, a general "are you sure
diff --git a/src/com/android/settings/ResetNetwork.java b/src/com/android/settings/ResetNetwork.java
index 45490ab..1529e77 100644
--- a/src/com/android/settings/ResetNetwork.java
+++ b/src/com/android/settings/ResetNetwork.java
@@ -34,13 +34,14 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.telephony.PhoneConstants;
+import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.password.ConfirmLockPattern;
import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import java.util.ArrayList;
import java.util.List;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
/**
* Confirm and execute a reset of the device's network settings to a clean "just out of the box"
* state. Multiple confirmations are required: first, a general "are you sure you want to do this?"
diff --git a/src/com/android/settings/ScreenPinningSettings.java b/src/com/android/settings/ScreenPinningSettings.java
index d74a07f..c4870f7 100644
--- a/src/com/android/settings/ScreenPinningSettings.java
+++ b/src/com/android/settings/ScreenPinningSettings.java
@@ -33,6 +33,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 9d44c42..ec57ed1 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -17,6 +17,7 @@
package com.android.settings;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
+
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
@@ -65,6 +66,9 @@
import com.android.settings.location.LocationPreferenceController;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.password.ManagedLockPasswordProvider;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
@@ -635,7 +639,7 @@
return false;
}
}
- startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ startFragment(this, ChooseLockGenericFragment.class.getName(),
R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
} else if (KEY_UNLOCK_SET_OR_CHANGE_PROFILE.equals(key)) {
if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
@@ -644,7 +648,7 @@
}
Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
- startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ startFragment(this, ChooseLockGenericFragment.class.getName(),
R.string.lock_settings_picker_title_profile,
SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
} else if (KEY_TRUST_AGENT.equals(key)) {
@@ -744,7 +748,7 @@
private void unifyUncompliantLocks() {
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false,
mCurrentProfilePassword);
- startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ startFragment(this, ChooseLockGenericFragment.class.getName(),
R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
}
@@ -752,7 +756,7 @@
Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
startFragment(this,
- "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ ChooseLockGenericFragment.class.getName(),
R.string.lock_settings_picker_title_profile,
SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 2e6aed0..38b6e1b 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -22,6 +22,7 @@
import com.android.settings.enterprise.EnterprisePrivacySettings;
import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.fingerprint.FingerprintSettings;
+import com.android.settings.password.ChooseLockGeneric;
/**
* Top-level Settings activity
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 9c01a5f..04aa5e4 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -22,7 +22,6 @@
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
@@ -33,22 +32,15 @@
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.text.TextUtils;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.MotionEvent;
-import android.view.View;
import android.view.accessibility.AccessibilityManager;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.ConfirmDeviceCredentialActivity;
import com.android.settings.R;
+import com.android.settings.password.ConfirmDeviceCredentialActivity;
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
import com.android.settingslib.accessibility.AccessibilityUtils;
diff --git a/src/com/android/settings/accounts/AddAccountSettings.java b/src/com/android/settings/accounts/AddAccountSettings.java
index 345f9fc..cca15c9 100644
--- a/src/com/android/settings/accounts/AddAccountSettings.java
+++ b/src/com/android/settings/accounts/AddAccountSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.accounts;
+import static android.content.Intent.EXTRA_USER;
+
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
@@ -32,14 +34,12 @@
import android.util.Log;
import android.widget.Toast;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.Utils;
+import com.android.settings.password.ChooseLockSettingsHelper;
import java.io.IOException;
-
-import static android.content.Intent.EXTRA_USER;
/**
* Entry point Activity for account setup. Works as follows
*
diff --git a/src/com/android/settings/applications/ConvertToFbe.java b/src/com/android/settings/applications/ConvertToFbe.java
index 9c43af4..c5e6d77 100644
--- a/src/com/android/settings/applications/ConvertToFbe.java
+++ b/src/com/android/settings/applications/ConvertToFbe.java
@@ -25,10 +25,10 @@
import android.widget.Button;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
/* Class to prompt for conversion of userdata to file based encryption
*/
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 8869bf1..ac3c8ac 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -18,8 +18,6 @@
import com.android.settings.ApnEditor;
import com.android.settings.ApnSettings;
-import com.android.settings.ChooseLockPassword;
-import com.android.settings.ChooseLockPattern;
import com.android.settings.CryptKeeperSettings;
import com.android.settings.DateTimeSettings;
import com.android.settings.DeviceAdminSettings;
@@ -109,6 +107,8 @@
import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.notification.ZenModeVisualInterruptionSettings;
+import com.android.settings.password.ChooseLockPassword;
+import com.android.settings.password.ChooseLockPattern;
import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.security.LockscreenDashboardFragment;
diff --git a/src/com/android/settings/development/DevelopmentSettings.java b/src/com/android/settings/development/DevelopmentSettings.java
index 2b3b826..b4dda75 100644
--- a/src/com/android/settings/development/DevelopmentSettings.java
+++ b/src/com/android/settings/development/DevelopmentSettings.java
@@ -82,13 +82,13 @@
import com.android.internal.app.LocalePicker;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.webview.WebViewAppPreferenceController;
diff --git a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
index 5a1835d..9232838 100644
--- a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -30,7 +30,6 @@
import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
@@ -38,6 +37,7 @@
import com.android.settings.development.DevelopmentSettings;
import com.android.settings.development.DevelopmentSettingsEnabler;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollBase.java b/src/com/android/settings/fingerprint/FingerprintEnrollBase.java
index d581804..df7bf3c 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollBase.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollBase.java
@@ -26,9 +26,9 @@
import android.widget.Button;
import android.widget.TextView;
-import com.android.settings.ChooseLockSettingsHelper;
-import com.android.settings.core.InstrumentedActivity;
import com.android.settings.R;
+import com.android.settings.core.InstrumentedActivity;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.setupwizardlib.GlifLayout;
/**
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
index e6e6bcd..3b3e61d 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
@@ -40,9 +40,9 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
/**
* Activity which handles the actual enrolling for fingerprint.
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java
index 107838c..b46fef7 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java
@@ -22,10 +22,10 @@
import android.os.UserHandle;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.fingerprint.FingerprintEnrollSidecar.Listener;
+import com.android.settings.password.ChooseLockSettingsHelper;
/**
* Activity explaining the fingerprint sensor location for fingerprint enrollment.
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java
index 551564d..dd83121 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollIntroduction.java
@@ -29,10 +29,10 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockGeneric;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.password.ChooseLockGeneric;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.setupwizardlib.span.LinkSpan;
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java b/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java
index 7fc7a04..0225f11 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java
@@ -26,9 +26,10 @@
import android.os.UserHandle;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.Utils;
import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
+
import com.android.settings.password.IFingerprintManager;
/**
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index 9b54385..a5595f9 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -46,8 +46,8 @@
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
-import android.text.style.URLSpan;
import android.text.TextUtils;
+import android.text.style.URLSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -56,21 +56,20 @@
import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockGeneric;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.SubSettings;
import com.android.settings.Utils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.password.ChooseLockGeneric;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.HelpUtils;
import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.widget.FooterPreference;
-import java.util.List;
import java.util.HashMap;
-
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import java.util.List;
/**
* Settings screen for fingerprints
diff --git a/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensor.java
index aff1028..d7a4a73 100644
--- a/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -21,9 +21,9 @@
import android.os.UserHandle;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
+import com.android.settings.password.ChooseLockSettingsHelper;
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
diff --git a/src/com/android/settings/fingerprint/SetupFingerprintEnrollFinish.java b/src/com/android/settings/fingerprint/SetupFingerprintEnrollFinish.java
index 92ea5cb..4d7395d 100644
--- a/src/com/android/settings/fingerprint/SetupFingerprintEnrollFinish.java
+++ b/src/com/android/settings/fingerprint/SetupFingerprintEnrollFinish.java
@@ -23,9 +23,9 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
+import com.android.settings.password.ChooseLockSettingsHelper;
public class SetupFingerprintEnrollFinish extends FingerprintEnrollFinish {
diff --git a/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java b/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java
index 3951aff..a1f4017 100644
--- a/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/fingerprint/SetupFingerprintEnrollIntroduction.java
@@ -26,8 +26,8 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
-import com.android.settings.SetupChooseLockGeneric;
import com.android.settings.SetupWizardUtils;
+import com.android.settings.password.SetupChooseLockGeneric;
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction {
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
similarity index 92%
rename from src/com/android/settings/ChooseLockGeneric.java
rename to src/com/android/settings/password/ChooseLockGeneric.java
index 546b11e..bbf5a16 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD;
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
-import static com.android.settings.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
@@ -50,10 +50,17 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.EncryptionInterstitial;
+import com.android.settings.EventLogTags;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.fingerprint.FingerprintEnrollBase;
import com.android.settings.fingerprint.FingerprintEnrollFindSensor;
import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedPreference;
import java.util.List;
@@ -120,7 +127,6 @@
private boolean mWaitingForConfirmation = false;
private int mEncryptionRequestQuality;
private boolean mEncryptionRequestDisabled;
- private boolean mRequirePassword;
private boolean mForChangeCredRequiredForBoot = false;
private String mUserPassword;
private LockPatternUtils mLockPatternUtils;
@@ -271,7 +277,7 @@
mEncryptionRequestDisabled = disabled;
// Get the intent that the encryption interstitial should start for creating
// the new unlock method.
- Intent unlockMethodIntent = getIntentForUnlockMethod(quality, disabled);
+ Intent unlockMethodIntent = getIntentForUnlockMethod(quality);
unlockMethodIntent.putExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT,
mForChangeCredRequiredForBoot);
@@ -297,7 +303,6 @@
finish();
return;
}
- mRequirePassword = false; // device encryption not enabled or not device owner.
updateUnlockMethodAndFinish(quality, disabled);
}
}
@@ -595,44 +600,34 @@
}
}
- protected Intent getLockManagedPasswordIntent(boolean requirePassword, String password) {
- return mManagedPasswordProvider.createIntent(requirePassword, password);
+ protected Intent getLockManagedPasswordIntent(String password) {
+ return mManagedPasswordProvider.createIntent(false, password);
}
- protected Intent getLockPasswordIntent(Context context, int quality,
- int minLength, final int maxLength,
- boolean requirePasswordToDecrypt, boolean confirmCredentials, int userId) {
- return ChooseLockPassword.createIntent(context, quality, minLength,
- maxLength, requirePasswordToDecrypt, confirmCredentials, userId);
+ protected Intent getLockPasswordIntent(int quality, int minLength, int maxLength) {
+ ChooseLockPassword.IntentBuilder builder =
+ new ChooseLockPassword.IntentBuilder(getContext())
+ .setPasswordQuality(quality)
+ .setPasswordLengthRange(minLength, maxLength)
+ .setUserId(mUserId);
+ if (mHasChallenge) {
+ builder.setChallenge(mChallenge);
+ } else {
+ builder.setPassword(mUserPassword);
+ }
+ return builder.build();
}
- protected Intent getLockPasswordIntent(Context context, int quality,
- int minLength, final int maxLength,
- boolean requirePasswordToDecrypt, long challenge, int userId) {
- return ChooseLockPassword.createIntent(context, quality, minLength,
- maxLength, requirePasswordToDecrypt, challenge, userId);
- }
-
- protected Intent getLockPasswordIntent(Context context, int quality, int minLength,
- int maxLength, boolean requirePasswordToDecrypt, String password, int userId) {
- return ChooseLockPassword.createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, password, userId);
- }
-
- protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
- final boolean confirmCredentials, int userId) {
- return ChooseLockPattern.createIntent(context, requirePassword,
- confirmCredentials, userId);
- }
-
- protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
- long challenge, int userId) {
- return ChooseLockPattern.createIntent(context, requirePassword, challenge, userId);
- }
-
- protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
- final String pattern, int userId) {
- return ChooseLockPattern.createIntent(context, requirePassword, pattern, userId);
+ protected Intent getLockPatternIntent() {
+ ChooseLockPattern.IntentBuilder builder =
+ new ChooseLockPattern.IntentBuilder(getContext())
+ .setUserId(mUserId);
+ if (mHasChallenge) {
+ builder.setChallenge(mChallenge);
+ } else {
+ builder.setPattern(mUserPassword);
+ }
+ return builder.build();
}
protected Intent getEncryptionInterstitialIntent(Context context, int quality,
@@ -657,7 +652,7 @@
}
quality = upgradeQuality(quality);
- Intent intent = getIntentForUnlockMethod(quality, disabled);
+ Intent intent = getIntentForUnlockMethod(quality);
if (intent != null) {
startActivityForResult(intent,
mIsSetNewPassword && mHasChallenge
@@ -677,32 +672,19 @@
}
}
- private Intent getIntentForUnlockMethod(int quality, boolean disabled) {
+ private Intent getIntentForUnlockMethod(int quality) {
Intent intent = null;
- final Context context = getActivity();
if (quality >= DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
- intent = getLockManagedPasswordIntent(mRequirePassword, mUserPassword);
+ intent = getLockManagedPasswordIntent(mUserPassword);
} else if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
int minLength = mDPM.getPasswordMinimumLength(null, mUserId);
if (minLength < MIN_PASSWORD_LENGTH) {
minLength = MIN_PASSWORD_LENGTH;
}
final int maxLength = mDPM.getPasswordMaximumLength(quality);
- if (mHasChallenge) {
- intent = getLockPasswordIntent(context, quality, minLength,
- maxLength, mRequirePassword, mChallenge, mUserId);
- } else {
- intent = getLockPasswordIntent(context, quality, minLength,
- maxLength, mRequirePassword, mUserPassword, mUserId);
- }
+ intent = getLockPasswordIntent(quality, minLength, maxLength);
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
- if (mHasChallenge) {
- intent = getLockPatternIntent(context, mRequirePassword,
- mChallenge, mUserId);
- } else {
- intent = getLockPatternIntent(context, mRequirePassword,
- mUserPassword, mUserId);
- }
+ intent = getLockPatternIntent();
}
if (intent != null) {
intent.putExtra(EXTRA_HIDE_DRAWER, mHideDrawer);
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
similarity index 92%
rename from src/com/android/settings/ChooseLockPassword.java
rename to src/com/android/settings/password/ChooseLockPassword.java
index 88f3165..f9aabd6 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC;
@@ -28,8 +28,6 @@
import android.app.admin.PasswordMetrics;
import android.content.Context;
import android.content.Intent;
-import android.graphics.Rect;
-import android.graphics.drawable.InsetDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -41,14 +39,12 @@
import android.text.Spannable;
import android.text.TextUtils;
import android.text.TextWatcher;
-import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
-import android.view.ViewParent;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
@@ -60,9 +56,12 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
import com.android.internal.widget.TextViewInputDisabler;
+import com.android.settings.EncryptionInterstitial;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.notification.RedactionInterstitial;
-import com.android.settings.password.PasswordRequirementAdapter;
import com.android.setupwizardlib.GlifLayout;
import java.util.ArrayList;
@@ -87,58 +86,47 @@
return modIntent;
}
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt,
- boolean confirmCredentials) {
- Intent intent = new Intent().setClass(context, ChooseLockPassword.class);
- intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
- intent.putExtra(PASSWORD_MIN_KEY, minLength);
- intent.putExtra(PASSWORD_MAX_KEY, maxLength);
- intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
- intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePasswordToDecrypt);
- return intent;
- }
+ public static class IntentBuilder {
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt,
- boolean confirmCredentials, int userId) {
- Intent intent = createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, confirmCredentials);
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
- return intent;
- }
+ private final Intent mIntent;
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) {
- Intent intent = createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, false);
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
- return intent;
- }
+ public IntentBuilder(Context context) {
+ mIntent = new Intent(context, ChooseLockPassword.class);
+ mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false);
+ mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false);
+ }
- public static Intent createIntent(Context context, int quality, int minLength,
- int maxLength, boolean requirePasswordToDecrypt, String password, int userId) {
- Intent intent = createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, password);
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
- return intent;
- }
+ public IntentBuilder setPasswordQuality(int quality) {
+ mIntent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
+ return this;
+ }
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) {
- Intent intent = createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, false);
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
- return intent;
- }
+ public IntentBuilder setPasswordLengthRange(int min, int max) {
+ mIntent.putExtra(PASSWORD_MIN_KEY, min);
+ mIntent.putExtra(PASSWORD_MAX_KEY, max);
+ return this;
+ }
- public static Intent createIntent(Context context, int quality, int minLength,
- int maxLength, boolean requirePasswordToDecrypt, long challenge, int userId) {
- Intent intent = createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, challenge);
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
- return intent;
+ public IntentBuilder setUserId(int userId) {
+ mIntent.putExtra(Intent.EXTRA_USER_ID, userId);
+ return this;
+ }
+
+ public IntentBuilder setChallenge(long challenge) {
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
+ return this;
+ }
+
+ public IntentBuilder setPassword(String password) {
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
+ return this;
+ }
+
+ public Intent build() {
+ return mIntent;
+ }
}
@Override
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
similarity index 95%
rename from src/com/android/settings/ChooseLockPattern.java
rename to src/com/android/settings/password/ChooseLockPattern.java
index 4afeae0..a9035c2 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Activity;
import android.app.Fragment;
@@ -37,9 +37,14 @@
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell;
import com.android.internal.widget.LockPatternView.DisplayMode;
+import com.android.settings.EncryptionInterstitial;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.notification.RedactionInterstitial;
import com.android.setupwizardlib.GlifLayout;
+
import com.google.android.collect.Lists;
import java.util.ArrayList;
@@ -75,29 +80,35 @@
return modIntent;
}
- public static Intent createIntent(Context context,
- boolean requirePassword, boolean confirmCredentials, int userId) {
- Intent intent = new Intent(context, ChooseLockPattern.class);
- intent.putExtra("key_lock_method", "pattern");
- intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
- intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword);
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
- return intent;
- }
+ public static class IntentBuilder {
+ private final Intent mIntent;
- public static Intent createIntent(Context context,
- boolean requirePassword, String pattern, int userId) {
- Intent intent = createIntent(context, requirePassword, false, userId);
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
- return intent;
- }
+ public IntentBuilder(Context context) {
+ mIntent = new Intent(context, ChooseLockPattern.class);
+ mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false);
+ mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false);
+ }
- public static Intent createIntent(Context context,
- boolean requirePassword, long challenge, int userId) {
- Intent intent = createIntent(context, requirePassword, false, userId);
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
- return intent;
+ public IntentBuilder setUserId(int userId) {
+ mIntent.putExtra(Intent.EXTRA_USER_ID, userId);
+ return this;
+ }
+
+ public IntentBuilder setChallenge(long challenge) {
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
+ return this;
+ }
+
+ public IntentBuilder setPattern(String pattern) {
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
+ mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
+ return this;
+ }
+
+ public Intent build() {
+ return mIntent;
+ }
}
@Override
@@ -442,7 +453,7 @@
topLayout.setDefaultTouchRecepient(mLockPatternView);
final boolean confirmCredentials = getActivity().getIntent()
- .getBooleanExtra("confirm_credentials", true);
+ .getBooleanExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
Intent intent = getActivity().getIntent();
mCurrentPattern = intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
mHasChallenge = intent.getBooleanExtra(
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/password/ChooseLockSettingsHelper.java
similarity index 97%
rename from src/com/android/settings/ChooseLockSettingsHelper.java
rename to src/com/android/settings/password/ChooseLockSettingsHelper.java
index 6f0c453..8c73355 100644
--- a/src/com/android/settings/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.annotation.Nullable;
import android.app.Activity;
@@ -26,11 +26,13 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
public final class ChooseLockSettingsHelper {
- static final String EXTRA_KEY_TYPE = "type";
- static final String EXTRA_KEY_PASSWORD = "password";
+ public static final String EXTRA_KEY_TYPE = "type";
+ public static final String EXTRA_KEY_PASSWORD = "password";
public static final String EXTRA_KEY_RETURN_CREDENTIALS = "return_credentials";
public static final String EXTRA_KEY_HAS_CHALLENGE = "has_challenge";
public static final String EXTRA_KEY_CHALLENGE = "challenge";
@@ -77,7 +79,7 @@
* @return true if one exists and we launched an activity to confirm it
* @see Activity#onActivityResult(int, int, android.content.Intent)
*/
- boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials) {
+ public boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials) {
return launchConfirmationActivity(request, title, null, null, returnCredentials, false);
}
diff --git a/src/com/android/settings/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
similarity index 98%
rename from src/com/android/settings/ConfirmDeviceCredentialActivity.java
rename to src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 22f1e52..38b38fc 100644
--- a/src/com/android/settings/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Activity;
import android.app.KeyguardManager;
@@ -27,6 +27,7 @@
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.Utils;
/**
* Launch this when you want to confirm the user is present by asking them to enter their
diff --git a/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
similarity index 96%
rename from src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java
rename to src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index d36947f..2de955f 100644
--- a/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Fragment;
import android.app.KeyguardManager;
@@ -24,6 +24,10 @@
import android.view.WindowManager;
import android.widget.LinearLayout;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
+
public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivity {
private static final String STATE_IS_KEYGUARD_LOCKED = "STATE_IS_KEYGUARD_LOCKED";
diff --git a/src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
similarity index 98%
rename from src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java
rename to src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index 2c97e1a..ae2dd42 100644
--- a/src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -15,7 +15,7 @@
*/
// TODO (b/35202196): move this class out of the root of the package.
-package com.android.settings;
+package com.android.settings.password;
import android.annotation.Nullable;
import android.app.ActivityManager;
@@ -47,6 +47,9 @@
import android.widget.TextView;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.OptionsMenuFragment;
+import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.fingerprint.FingerprintUiHelper;
/**
diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
similarity index 99%
rename from src/com/android/settings/ConfirmLockPassword.java
rename to src/com/android/settings/password/ConfirmLockPassword.java
index 489f7a5..ef11521 100644
--- a/src/com/android/settings/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
+import android.app.Activity;
import android.app.Fragment;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -43,6 +44,8 @@
import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.TextViewInputDisabler;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
diff --git a/src/com/android/settings/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
similarity index 99%
rename from src/com/android/settings/ConfirmLockPattern.java
rename to src/com/android/settings/password/ConfirmLockPattern.java
index 56d92f1..b66edfe 100644
--- a/src/com/android/settings/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Activity;
import android.content.Intent;
@@ -37,6 +37,8 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settingslib.animation.AppearAnimationCreator;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
diff --git a/src/com/android/settings/CredentialCheckResultTracker.java b/src/com/android/settings/password/CredentialCheckResultTracker.java
similarity index 98%
rename from src/com/android/settings/CredentialCheckResultTracker.java
rename to src/com/android/settings/password/CredentialCheckResultTracker.java
index cfd6f29..a17939c 100644
--- a/src/com/android/settings/CredentialCheckResultTracker.java
+++ b/src/com/android/settings/password/CredentialCheckResultTracker.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Fragment;
import android.content.Intent;
diff --git a/src/com/android/settings/ManagedLockPasswordProvider.java b/src/com/android/settings/password/ManagedLockPasswordProvider.java
similarity index 92%
rename from src/com/android/settings/ManagedLockPasswordProvider.java
rename to src/com/android/settings/password/ManagedLockPasswordProvider.java
index b9725d7..65bf1f6 100644
--- a/src/com/android/settings/ManagedLockPasswordProvider.java
+++ b/src/com/android/settings/password/ManagedLockPasswordProvider.java
@@ -14,11 +14,13 @@
* limitations under the License
*/
-package com.android.settings;
+package com.android.settings.password;
import android.content.Context;
import android.content.Intent;
+import com.android.settings.R;
+
/**
* Helper for handling managed passwords in security settings UI.
* It provides resources that should be shown in settings UI when lock password quality is set to
@@ -28,7 +30,7 @@
*/
public class ManagedLockPasswordProvider {
/** Factory method to make it easier to inject extended ManagedLockPasswordProviders. */
- static ManagedLockPasswordProvider get(Context context, int userId) {
+ public static ManagedLockPasswordProvider get(Context context, int userId) {
return new ManagedLockPasswordProvider();
}
@@ -58,7 +60,7 @@
* {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
* @param forProfile Whether the settings are shown for a user profile rather than a user.
*/
- int getResIdForLockUnlockScreen(boolean forProfile) {
+ public int getResIdForLockUnlockScreen(boolean forProfile) {
return forProfile ? R.xml.security_settings_password_profile
: R.xml.security_settings_password;
}
@@ -68,7 +70,7 @@
* screen preference in security settings if the current password quality is set to
* {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
*/
- int getResIdForLockUnlockSubScreen() {
+ public int getResIdForLockUnlockSubScreen() {
return R.xml.security_settings_password_sub;
}
diff --git a/src/com/android/settings/password/PasswordRequirementAdapter.java b/src/com/android/settings/password/PasswordRequirementAdapter.java
index b05d8b8..5fcd8a9 100644
--- a/src/com/android/settings/password/PasswordRequirementAdapter.java
+++ b/src/com/android/settings/password/PasswordRequirementAdapter.java
@@ -23,12 +23,10 @@
import android.widget.TextView;
import com.android.settings.R;
-
-import static com.android.settings.password.PasswordRequirementAdapter
- .PasswordRequirementViewHolder;
+import com.android.settings.password.PasswordRequirementAdapter.PasswordRequirementViewHolder;
/**
- * Used in {@link com.android.settings.ChooseLockPassword} to show password requirements.
+ * Used in {@link ChooseLockPassword} to show password requirements.
*/
public class PasswordRequirementAdapter extends
RecyclerView.Adapter<PasswordRequirementViewHolder> {
diff --git a/src/com/android/settings/SaveChosenLockWorkerBase.java b/src/com/android/settings/password/SaveChosenLockWorkerBase.java
similarity index 98%
rename from src/com/android/settings/SaveChosenLockWorkerBase.java
rename to src/com/android/settings/password/SaveChosenLockWorkerBase.java
index 7ce7a90..95980e9 100644
--- a/src/com/android/settings/SaveChosenLockWorkerBase.java
+++ b/src/com/android/settings/password/SaveChosenLockWorkerBase.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Fragment;
import android.content.Context;
diff --git a/src/com/android/settings/password/SetNewPasswordActivity.java b/src/com/android/settings/password/SetNewPasswordActivity.java
index 4692609..99f67cb 100644
--- a/src/com/android/settings/password/SetNewPasswordActivity.java
+++ b/src/com/android/settings/password/SetNewPasswordActivity.java
@@ -25,8 +25,6 @@
import android.os.Bundle;
import android.util.Log;
-import com.android.settings.ChooseLockGeneric;
-import com.android.settings.SetupChooseLockGeneric;
import com.android.settings.Utils;
/**
diff --git a/src/com/android/settings/password/SetNewPasswordController.java b/src/com/android/settings/password/SetNewPasswordController.java
index 9443541..57aa8c1 100644
--- a/src/com/android/settings/password/SetNewPasswordController.java
+++ b/src/com/android/settings/password/SetNewPasswordController.java
@@ -19,6 +19,7 @@
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT;
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
+
import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.Nullable;
@@ -34,8 +35,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.ChooseLockGeneric;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.Utils;
/**
diff --git a/src/com/android/settings/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
similarity index 76%
rename from src/com/android/settings/SetupChooseLockGeneric.java
rename to src/com/android/settings/password/SetupChooseLockGeneric.java
index 2c8195d..74aac2c 100644
--- a/src/com/android/settings/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -31,6 +31,9 @@
import android.widget.LinearLayout;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
+import com.android.settings.SetupEncryptionInterstitial;
+import com.android.settings.SetupWizardUtils;
import com.android.settings.fingerprint.SetupFingerprintEnrollFindSensor;
import com.android.settings.fingerprint.SetupSkipDialog;
import com.android.settings.utils.SettingsDividerItemDecoration;
@@ -172,57 +175,17 @@
}
@Override
- protected Intent getLockPasswordIntent(Context context, int quality,
- int minLength, final int maxLength,
- boolean requirePasswordToDecrypt, boolean confirmCredentials, int userId) {
- final Intent intent = SetupChooseLockPassword.createIntent(context, quality, minLength,
- maxLength, requirePasswordToDecrypt, confirmCredentials);
+ protected Intent getLockPasswordIntent(int quality, int minLength, int maxLength) {
+ final Intent intent = SetupChooseLockPassword.modifyIntentForSetup(
+ getContext(), super.getLockPasswordIntent(quality, minLength, maxLength));
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
return intent;
}
@Override
- protected Intent getLockPasswordIntent(Context context, int quality,
- int minLength, final int maxLength,
- boolean requirePasswordToDecrypt, long challenge, int userId) {
- final Intent intent = SetupChooseLockPassword.createIntent(context, quality, minLength,
- maxLength, requirePasswordToDecrypt, challenge);
- SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
- return intent;
- }
-
- @Override
- protected Intent getLockPasswordIntent(Context context, int quality, int minLength,
- int maxLength, boolean requirePasswordToDecrypt, String password, int userId) {
- final Intent intent = SetupChooseLockPassword.createIntent(context, quality, minLength,
- maxLength, requirePasswordToDecrypt, password);
- SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
- return intent;
- }
-
- @Override
- protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
- final boolean confirmCredentials, int userId) {
- final Intent intent = SetupChooseLockPattern.createIntent(context, requirePassword,
- confirmCredentials);
- SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
- return intent;
- }
-
- @Override
- protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
- long challenge, int userId) {
- final Intent intent = SetupChooseLockPattern.createIntent(context, requirePassword,
- challenge);
- SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
- return intent;
- }
-
- @Override
- protected Intent getLockPatternIntent(Context context, final boolean requirePassword,
- final String pattern, int userId) {
- final Intent intent = SetupChooseLockPattern.createIntent(context, requirePassword,
- pattern);
+ protected Intent getLockPatternIntent() {
+ final Intent intent = SetupChooseLockPattern.modifyIntentForSetup(
+ getContext(), super.getLockPatternIntent());
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
return intent;
}
diff --git a/src/com/android/settings/SetupChooseLockPassword.java b/src/com/android/settings/password/SetupChooseLockPassword.java
similarity index 63%
rename from src/com/android/settings/SetupChooseLockPassword.java
rename to src/com/android/settings/password/SetupChooseLockPassword.java
index f2c24d0..b8a741d 100644
--- a/src/com/android/settings/SetupChooseLockPassword.java
+++ b/src/com/android/settings/password/SetupChooseLockPassword.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Fragment;
import android.content.Context;
@@ -23,6 +23,10 @@
import android.os.Bundle;
import android.widget.LinearLayout;
+import com.android.settings.R;
+import com.android.settings.SetupRedactionInterstitial;
+import com.android.settings.SetupWizardUtils;
+
/**
* Setup Wizard's version of ChooseLockPassword screen. It inherits the logic and basic structure
* from ChooseLockPassword class, and should remain similar to that behaviorally. This class should
@@ -32,32 +36,12 @@
*/
public class SetupChooseLockPassword extends ChooseLockPassword {
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt,
- boolean confirmCredentials) {
- Intent intent = ChooseLockPassword.createIntent(context, quality, minLength,
- maxLength, requirePasswordToDecrypt, confirmCredentials);
- intent.setClass(context, SetupChooseLockPassword.class);
- intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
- return intent;
- }
-
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) {
- Intent intent = ChooseLockPassword.createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, password);
- intent.setClass(context, SetupChooseLockPassword.class);
- intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
- return intent;
- }
-
- public static Intent createIntent(Context context, int quality,
- int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) {
- Intent intent = ChooseLockPassword.createIntent(context, quality, minLength, maxLength,
- requirePasswordToDecrypt, challenge);
- intent.setClass(context, SetupChooseLockPassword.class);
- intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
- return intent;
+ public static Intent modifyIntentForSetup(
+ Context context,
+ Intent chooseLockPasswordIntent) {
+ chooseLockPasswordIntent.setClass(context, SetupChooseLockPassword.class);
+ chooseLockPasswordIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
+ return chooseLockPasswordIntent;
}
@Override
diff --git a/src/com/android/settings/SetupChooseLockPattern.java b/src/com/android/settings/password/SetupChooseLockPattern.java
similarity index 67%
rename from src/com/android/settings/SetupChooseLockPattern.java
rename to src/com/android/settings/password/SetupChooseLockPattern.java
index 762d3b3..7cb5afb 100644
--- a/src/com/android/settings/SetupChooseLockPattern.java
+++ b/src/com/android/settings/password/SetupChooseLockPattern.java
@@ -14,13 +14,15 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import android.os.UserHandle;
+
+import com.android.settings.SetupRedactionInterstitial;
+import com.android.settings.SetupWizardUtils;
/**
* Setup Wizard's version of ChooseLockPattern screen. It inherits the logic and basic structure
@@ -31,26 +33,9 @@
*/
public class SetupChooseLockPattern extends ChooseLockPattern {
- public static Intent createIntent(Context context, boolean requirePassword,
- boolean confirmCredentials) {
- Intent intent = ChooseLockPattern.createIntent(context, requirePassword,
- confirmCredentials, UserHandle.myUserId());
- intent.setClass(context, SetupChooseLockPattern.class);
- return intent;
- }
-
- public static Intent createIntent(Context context, boolean requirePassword, String pattern) {
- Intent intent = ChooseLockPattern.createIntent(
- context, requirePassword, pattern, UserHandle.myUserId());
- intent.setClass(context, SetupChooseLockPattern.class);
- return intent;
- }
-
- public static Intent createIntent(Context context, boolean requirePassword, long challenge) {
- Intent intent = ChooseLockPattern.createIntent(
- context, requirePassword, challenge, UserHandle.myUserId());
- intent.setClass(context, SetupChooseLockPattern.class);
- return intent;
+ public static Intent modifyIntentForSetup(Context context, Intent chooseLockPatternIntent) {
+ chooseLockPatternIntent.setClass(context, SetupChooseLockPattern.class);
+ return chooseLockPatternIntent;
}
@Override
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 8026e27..5cb27f9 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -54,7 +54,6 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.ChooseLockGeneric;
import com.android.settings.DimmableIconPreference;
import com.android.settings.OwnerInfoSettings;
import com.android.settings.R;
@@ -62,11 +61,12 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.drawable.CircleFramedDrawable;
import java.util.ArrayList;
@@ -74,8 +74,6 @@
import java.util.HashMap;
import java.util.List;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
/**
* Screen that manages the list of users on the device.
* Guest user is an always visible entry, even if the guest is not currently
diff --git a/tests/app/src/com/android/settings/ChooseLockGenericTest.java b/tests/app/src/com/android/settings/password/ChooseLockGenericTest.java
similarity index 98%
rename from tests/app/src/com/android/settings/ChooseLockGenericTest.java
rename to tests/app/src/com/android/settings/password/ChooseLockGenericTest.java
index 924e716..e2bd6ee 100644
--- a/tests/app/src/com/android/settings/ChooseLockGenericTest.java
+++ b/tests/app/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.password;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.InstrumentationRegistry.getTargetContext;
@@ -56,7 +56,7 @@
* m SettingsTests &&
* adb install \
* -r -g ${ANDROID_PRODUCT_OUT}/data/app/SettingsTests/SettingsTests.apk &&
- * adb shell am instrument -e class com.android.settings.ChooseLockGenericTest \
+ * adb shell am instrument -e class com.android.settings.password.ChooseLockGenericTest \
* -w com.android.settings.tests/android.support.test.runner.AndroidJUnitRunner
*/
@RunWith(AndroidJUnit4.class)
diff --git a/tests/app/src/com/android/settings/ConfirmLockPasswordTest.java b/tests/app/src/com/android/settings/password/ConfirmLockPasswordTest.java
similarity index 97%
rename from tests/app/src/com/android/settings/ConfirmLockPasswordTest.java
rename to tests/app/src/com/android/settings/password/ConfirmLockPasswordTest.java
index 05464ad..25e7da0 100644
--- a/tests/app/src/com/android/settings/ConfirmLockPasswordTest.java
+++ b/tests/app/src/com/android/settings/password/ConfirmLockPasswordTest.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.settings;
+package com.android.settings.password;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.pressKey;
@@ -30,6 +30,8 @@
import android.support.test.runner.AndroidJUnit4;
import android.view.KeyEvent;
+import com.android.settings.R;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index ca6d764..9ecc0b4 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -96,10 +96,10 @@
com.android.settings.SecuritySettings$SecuritySubSettings
com.android.settings.PrivacySettings
com.android.settings.WifiCallingSettings
-com.android.settings.SetupChooseLockGeneric$SetupChooseLockGenericFragment
+com.android.settings.password.SetupChooseLockGeneric$SetupChooseLockGenericFragment
com.android.settings.SetupRedactionInterstitial$SetupRedactionInterstitialFragment
com.android.settings.TrustAgentSettings
-com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment
+com.android.settings.password.ChooseLockGeneric$ChooseLockGenericFragment
com.android.settings.IccLockSettings
com.android.settings.TetherSettings
com.android.settings.ApplicationSettings
diff --git a/tests/robotests/assets/grandfather_not_implementing_instrumentable b/tests/robotests/assets/grandfather_not_implementing_instrumentable
index b0b4051..992f25a 100644
--- a/tests/robotests/assets/grandfather_not_implementing_instrumentable
+++ b/tests/robotests/assets/grandfather_not_implementing_instrumentable
@@ -3,9 +3,9 @@
com.android.settings.inputmethod.UserDictionaryLocalePicker
com.android.settings.CustomEditTextPreference$CustomPreferenceDialogFragment
com.android.settings.CustomListPreference$CustomListPreferenceDialogFragment
-com.android.settings.ChooseLockPassword$SaveAndFinishWorker
-com.android.settings.ChooseLockPattern$SaveAndFinishWorker
+com.android.settings.password.ChooseLockPassword$SaveAndFinishWorker
+com.android.settings.password.ChooseLockPattern$SaveAndFinishWorker
com.android.settings.RestrictedListPreference$RestrictedListPreferenceDialogFragment
com.android.settings.CustomDialogPreference$CustomPreferenceDialogFragment
-com.android.settings.ConfirmDeviceCredentialBaseFragment$LastTryDialog
-com.android.settings.CredentialCheckResultTracker
+com.android.settings.password.ConfirmDeviceCredentialBaseFragment$LastTryDialog
+com.android.settings.password.CredentialCheckResultTracker
diff --git a/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java
index 4b78ee7..5238a39 100644
--- a/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/SetupChooseLockPatternTest.java
@@ -25,7 +25,9 @@
import android.content.pm.PackageManager;
import android.os.UserHandle;
-import com.android.settings.ChooseLockPattern.ChooseLockPatternFragment;
+import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
+import com.android.settings.password.ChooseLockPattern.IntentBuilder;
+import com.android.settings.password.SetupChooseLockPattern;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
@@ -63,11 +65,11 @@
mActivity = Robolectric.buildActivity(
SetupChooseLockPattern.class,
- SetupChooseLockPattern.createIntent(
+ SetupChooseLockPattern.modifyIntentForSetup(
application,
- false, /* requirePassword */
- false, /* confirmCredentials */
- UserHandle.myUserId()))
+ new IntentBuilder(application)
+ .setUserId(UserHandle.myUserId())
+ .build()))
.setup().get();
}
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java
index 646774d..74cfc7b 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollFindSensorTest.java
@@ -29,10 +29,10 @@
import android.os.CancellationSignal;
import android.widget.Button;
-import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.IFingerprintManager;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
new file mode 100644
index 0000000..b077c9a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.password;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.RuntimeEnvironment.application;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Intent;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.password.ChooseLockPassword;
+import com.android.settings.password.ChooseLockPassword.IntentBuilder;
+import com.android.settings.password.ChooseLockSettingsHelper;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION)
+public class ChooseLockPasswordTest {
+
+ @Test
+ public void intentBuilder_setPassword_shouldAddExtras() {
+ Intent intent = new IntentBuilder(application)
+ .setPassword("password")
+ .setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
+ .setPasswordLengthRange(123, 456)
+ .setUserId(123)
+ .build();
+
+ assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
+ .named("EXTRA_KEY_HAS_CHALLENGE")
+ .isFalse();
+ assertThat(intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
+ .named("EXTRA_KEY_PASSWORD")
+ .isEqualTo("password");
+ assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0))
+ .named("PASSWORD_MIN_KEY")
+ .isEqualTo(123);
+ assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MAX_KEY, 0))
+ .named("PASSWORD_MAX_KEY")
+ .isEqualTo(456);
+ assertThat(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, 0))
+ .named("PASSWORD_TYPE_KEY")
+ .isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+ assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
+ .named("EXTRA_USER_ID")
+ .isEqualTo(123);
+ }
+
+ @Test
+ public void intentBuilder_setChallenge_shouldAddExtras() {
+ Intent intent = new IntentBuilder(application)
+ .setChallenge(12345L)
+ .setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC)
+ .setPasswordLengthRange(123, 456)
+ .setUserId(123)
+ .build();
+
+ assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false))
+ .named("EXTRA_KEY_HAS_CHALLENGE")
+ .isTrue();
+ assertThat(intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L))
+ .named("EXTRA_KEY_CHALLENGE")
+ .isEqualTo(12345L);
+ assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0))
+ .named("PASSWORD_MIN_KEY")
+ .isEqualTo(123);
+ assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MAX_KEY, 0))
+ .named("PASSWORD_MAX_KEY")
+ .isEqualTo(456);
+ assertThat(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, 0))
+ .named("PASSWORD_TYPE_KEY")
+ .isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
+ assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
+ .named("EXTRA_USER_ID")
+ .isEqualTo(123);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
new file mode 100644
index 0000000..49ca717
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.password;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.RuntimeEnvironment.application;
+
+import android.content.Intent;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.password.ChooseLockPattern;
+import com.android.settings.password.ChooseLockPattern.IntentBuilder;
+import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
+import com.android.settings.testutils.shadow.ShadowEventLogWriter;
+import com.android.settings.testutils.shadow.ShadowUtils;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {
+ SettingsShadowResources.class,
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowDynamicIndexableContentMonitor.class,
+ ShadowEventLogWriter.class,
+ ShadowUtils.class
+ })
+public class ChooseLockPatternTest {
+
+ @Test
+ public void activityCreationTest() {
+ // Basic sanity test for activity created without crashing
+ Robolectric.buildActivity(ChooseLockPattern.class, new IntentBuilder(application).build())
+ .setup().get();
+ }
+
+ @Test
+ public void intentBuilder_setPattern_shouldAddExtras() {
+ Intent intent = new IntentBuilder(application)
+ .setPattern("pattern")
+ .setUserId(123)
+ .build();
+
+ assertThat(intent
+ .getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
+ .named("EXTRA_KEY_HAS_CHALLENGE")
+ .isFalse();
+ assertThat(intent
+ .getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
+ .named("EXTRA_KEY_PASSWORD")
+ .isEqualTo("pattern");
+ assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
+ .named("EXTRA_USER_ID")
+ .isEqualTo(123);
+ }
+
+ @Test
+ public void intentBuilder_setChallenge_shouldAddExtras() {
+ Intent intent = new IntentBuilder(application)
+ .setChallenge(12345L)
+ .setUserId(123)
+ .build();
+
+ assertThat(intent
+ .getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false))
+ .named("EXTRA_KEY_HAS_CHALLENGE")
+ .isTrue();
+ assertThat(intent
+ .getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0L))
+ .named("EXTRA_KEY_CHALLENGE")
+ .isEqualTo(12345L);
+ assertThat(intent
+ .getIntExtra(Intent.EXTRA_USER_ID, 0))
+ .named("EXTRA_USER_ID")
+ .isEqualTo(123);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/ConfirmCredentialTest.java b/tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java
similarity index 72%
rename from tests/robotests/src/com/android/settings/ConfirmCredentialTest.java
rename to tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java
index f771a1f..6072d42 100644
--- a/tests/robotests/src/com/android/settings/ConfirmCredentialTest.java
+++ b/tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java
@@ -14,14 +14,15 @@
* limitations under the License
*/
-package com.android.settings;
+package com.android.settings.password;
-import static com.android.settings.ConfirmDeviceCredentialBaseFragment.LastTryDialog;
import static com.google.common.truth.Truth.assertThat;
-import android.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.password.ConfirmDeviceCredentialBaseFragment.LastTryDialog;
+
import android.app.Activity;
-import android.app.Fragment;
import android.app.FragmentManager;
import com.android.settings.testutils.shadow.SettingsShadowResources;
@@ -45,11 +46,14 @@
FragmentManager fm = Robolectric.buildActivity(Activity.class).get().getFragmentManager();
// Launch only one instance at a time.
- assertThat(LastTryDialog.show(fm, "title", R.string.yes, R.string.ok, false)).isTrue();
- assertThat(LastTryDialog.show(fm, "title", R.string.yes, R.string.ok, false)).isFalse();
+ assertThat(LastTryDialog.show(
+ fm, "title", android.R.string.yes, android.R.string.ok, false)).isTrue();
+ assertThat(LastTryDialog.show(
+ fm, "title", android.R.string.yes, android.R.string.ok, false)).isFalse();
// After cancelling, the dialog should be re-shown when asked for.
LastTryDialog.hide(fm);
- assertThat(LastTryDialog.show(fm, "title", R.string.yes, R.string.ok, false)).isTrue();
+ assertThat(LastTryDialog.show(
+ fm, "title", android.R.string.yes, android.R.string.ok, false)).isTrue();
}
}
diff --git a/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java b/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
index 573f5d8..44f1fef 100644
--- a/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetNewPasswordActivityTest.java
@@ -16,14 +16,16 @@
package com.android.settings.password;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
-import com.android.settings.ChooseLockGeneric;
import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.SetupChooseLockGeneric;
import com.android.settings.TestConfig;
import org.junit.After;
@@ -35,9 +37,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;
-import static com.google.common.truth.Truth.assertThat;
-import static org.robolectric.Shadows.shadowOf;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SetNewPasswordActivityTest {
diff --git a/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java b/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java
index ab01360..bb7f5c1 100644
--- a/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java
@@ -16,6 +16,25 @@
package com.android.settings.password;
+import static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
+
+import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment
+ .HIDE_DISABLED_PREFS;
+import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment
+ .MINIMUM_QUALITY_KEY;
+import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE;
+import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT;
+import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Intent;
@@ -33,20 +52,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
-import static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
-import static com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS;
-import static com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY;
-import static com.android.settings.ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE;
-import static com.android.settings.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT;
-import static com.android.settings.ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE;
-import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
/**
* Tests for {@link SetNewPasswordController}.
diff --git a/tests/unit/src/com/android/settings/ChooseLockSettingsHelperTest.java b/tests/unit/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
similarity index 99%
rename from tests/unit/src/com/android/settings/ChooseLockSettingsHelperTest.java
rename to tests/unit/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
index 218a74e..e534fb6 100644
--- a/tests/unit/src/com/android/settings/ChooseLockSettingsHelperTest.java
+++ b/tests/unit/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
@@ -1,6 +1,13 @@
-package com.android.settings;
+package com.android.settings.password;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -16,13 +23,6 @@
import java.util.List;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
public class ChooseLockSettingsHelperTest extends AndroidTestCase {
private static final String SYSTEM_PROPERTY_DEXMAKER_DEXCACHE = "dexmaker.dexcache";