Show customized message for private space lock setup screen
go/ss/3kmkEkasv6vmDDo.png go/ss/7CzzSXZthbJVcEr.png Bug: 308862923 Test: atest ChooseLockGenericTest and Verified manually customized message is shown when passed with intent. Change-Id: I784d42c4702801ec45bc8d4c5e911a404f549d46
This commit is contained in:
@@ -1310,6 +1310,10 @@
|
||||
<string name="privatespace_retry_signin_title">Sign in to set up Private Space</string>
|
||||
<!-- Summary for the Private Space account login error screen. [CHAR LIMIT=NONE] -->
|
||||
<string name="privatespace_retry_summary">You need to sign in to an account to set up Private Space</string>
|
||||
<!-- private space lock setup screen title. This title is asking the user to choose a type of screen lock (such as a pattern, PIN, or password) that they need to enter to unlock private space. [CHAR LIMIT=60] -->
|
||||
<string name="private_space_lock_setup_title">Choose a lock for your private space</string>
|
||||
<!-- private space lock setup screen description [CHAR LIMIT=NONE] -->
|
||||
<string name="private_space_lock_setup_description">You can unlock your private space using your fingerprint. For security, this option requires a backup lock.</string>
|
||||
|
||||
<!-- TODO(b/309950257): Remove below strings once QSTIle fulfillment is complete. -->
|
||||
<!-- Header in hide Private Space settings page to unhide Private Space. [CHAR LIMIT=90] -->
|
||||
@@ -1323,7 +1327,6 @@
|
||||
<!-- Note in hide Private Space settings page to inform that this is a development feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="privatespace_development_note">Note to Googlers: The development of this feature is still in progress</string>
|
||||
|
||||
|
||||
<!-- Text shown when "Add fingerprint" button is disabled -->
|
||||
<string name="fingerprint_add_max">You can add up to <xliff:g id="count" example="5">%d</xliff:g> fingerprints</string>
|
||||
<!-- Text shown when users has enrolled a maximum number of fingerprints [CHAR LIMIT=NONE] -->
|
||||
|
@@ -30,6 +30,8 @@ import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROF
|
||||
|
||||
import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
@@ -86,6 +88,10 @@ import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
/**
|
||||
* Activity class that provides a generic implementation for displaying options to choose a lock
|
||||
* type, either for setting up a new lock or updating an existing lock.
|
||||
*/
|
||||
public class ChooseLockGeneric extends SettingsActivity {
|
||||
public static final String CONFIRM_CREDENTIALS = "confirm_credentials";
|
||||
|
||||
@@ -194,6 +200,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
protected boolean mForBiometrics = false;
|
||||
|
||||
private boolean mOnlyEnforceDevicePasswordRequirement = false;
|
||||
private int mExtraLockScreenTitleResId;
|
||||
private int mExtraLockScreenDescriptionResId;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -242,6 +250,10 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
mForBiometrics = intent.getBooleanExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, false);
|
||||
|
||||
mExtraLockScreenTitleResId = intent.getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, -1);
|
||||
mExtraLockScreenDescriptionResId =
|
||||
intent.getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION, -1);
|
||||
|
||||
mRequestedMinComplexity = intent.getIntExtra(
|
||||
EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE);
|
||||
mOnlyEnforceDevicePasswordRequirement = intent.getBooleanExtra(
|
||||
@@ -343,13 +355,19 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
if (updateExistingLock) {
|
||||
getActivity().setTitle(mDpm.getResources().getString(
|
||||
LOCK_SETTINGS_UPDATE_PROFILE_LOCK_TITLE,
|
||||
() -> getString(
|
||||
R.string.lock_settings_picker_update_profile_lock_title)));
|
||||
() -> getString(mExtraLockScreenTitleResId != -1
|
||||
? mExtraLockScreenTitleResId
|
||||
: R.string.lock_settings_picker_update_profile_lock_title)));
|
||||
} else {
|
||||
getActivity().setTitle(mDpm.getResources().getString(
|
||||
LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE,
|
||||
() -> getString(R.string.lock_settings_picker_new_profile_lock_title)));
|
||||
() -> getString(mExtraLockScreenTitleResId != -1
|
||||
? mExtraLockScreenTitleResId
|
||||
: R.string.lock_settings_picker_new_profile_lock_title)));
|
||||
}
|
||||
} else if (mExtraLockScreenTitleResId != -1) {
|
||||
// Show customized screen lock title if it is passed as an extra in the intent.
|
||||
getActivity().setTitle(mExtraLockScreenTitleResId);
|
||||
} else {
|
||||
updateExistingLock = mLockPatternUtils.isSecure(mUserId);
|
||||
if (updateExistingLock) {
|
||||
@@ -377,7 +395,16 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
setHeaderView(R.layout.choose_lock_generic_biometric_header);
|
||||
TextView textView = getHeaderView().findViewById(R.id.biometric_header_description);
|
||||
|
||||
if (mForFingerprint) {
|
||||
if (mIsManagedProfile) {
|
||||
textView.setText(mDpm.getResources().getString(
|
||||
WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE,
|
||||
() -> getString(mExtraLockScreenDescriptionResId != -1
|
||||
? mExtraLockScreenDescriptionResId
|
||||
: R.string.lock_settings_picker_profile_message)));
|
||||
} else if (mExtraLockScreenDescriptionResId != -1) {
|
||||
// Show customized description in screen lock if passed as an extra in the intent.
|
||||
textView.setText(mExtraLockScreenDescriptionResId);
|
||||
} else if (mForFingerprint) {
|
||||
if (mIsSetNewPassword) {
|
||||
textView.setText(R.string.fingerprint_unlock_title);
|
||||
} else {
|
||||
@@ -395,16 +422,10 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
} else {
|
||||
textView.setText(R.string.lock_settings_picker_biometric_message);
|
||||
}
|
||||
} else {
|
||||
if (mIsManagedProfile) {
|
||||
textView.setText(mDpm.getResources().getString(
|
||||
WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE,
|
||||
() -> getString(R.string.lock_settings_picker_profile_message)));
|
||||
} else {
|
||||
textView.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
@@ -426,6 +447,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
}
|
||||
// Forward the target user id to ChooseLockGeneric.
|
||||
chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
chooseLockGenericIntent.putExtra(
|
||||
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, mExtraLockScreenTitleResId);
|
||||
chooseLockGenericIntent.putExtra(CONFIRM_CREDENTIALS, !mPasswordConfirmed);
|
||||
chooseLockGenericIntent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY,
|
||||
mRequestedMinComplexity);
|
||||
|
@@ -118,6 +118,14 @@ public final class ChooseLockSettingsHelper {
|
||||
public static final String EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY =
|
||||
"device_password_requirement_only";
|
||||
|
||||
/** Intent extra for passing the screen title resource ID to show in the set lock screen. */
|
||||
public static final String EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE =
|
||||
"choose_lock_setup_screen_title";
|
||||
|
||||
/** Intent extra for passing the description resource ID to show in the set lock screen. */
|
||||
public static final String EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION =
|
||||
"choose_lock_setup_screen_description";
|
||||
|
||||
@VisibleForTesting @NonNull LockPatternUtils mLockPatternUtils;
|
||||
@NonNull private final Activity mActivity;
|
||||
@Nullable private final Fragment mFragment;
|
||||
|
@@ -24,6 +24,8 @@ import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
|
||||
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
|
||||
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_IS_CALLING_APP_ADMIN;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
|
||||
@@ -126,6 +128,10 @@ public class SetNewPasswordActivity extends Activity implements SetNewPasswordCo
|
||||
: new Intent(this, ChooseLockGeneric.class);
|
||||
intent.setAction(mNewPasswordAction);
|
||||
intent.putExtras(chooseLockFingerprintExtras);
|
||||
intent.putExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE,
|
||||
getIntent().getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, -1));
|
||||
intent.putExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION,
|
||||
getIntent().getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION, -1));
|
||||
if (mCallerAppName != null) {
|
||||
intent.putExtra(EXTRA_KEY_CALLER_APP_NAME, mCallerAppName);
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
|
||||
import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
|
||||
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_LOW;
|
||||
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE;
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.ACCOUNT_LOGIN_ACTION;
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.EXTRA_ACTION_TYPE;
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LOCK_ACTION;
|
||||
@@ -34,6 +36,7 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
@@ -77,6 +80,11 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
|
||||
private void createPrivateSpaceLock() {
|
||||
final Intent intent = new Intent(ACTION_SET_NEW_PASSWORD);
|
||||
intent.putExtra(EXTRA_PASSWORD_COMPLEXITY, PASSWORD_COMPLEXITY_LOW);
|
||||
intent.putExtra(
|
||||
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, R.string.private_space_lock_setup_title);
|
||||
intent.putExtra(
|
||||
EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION,
|
||||
R.string.private_space_lock_setup_description);
|
||||
mVerifyDeviceLock.launch(intent);
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,8 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;
|
||||
import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.KEY_LOCK_SETTINGS_FOOTER;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CALLER_APP_NAME;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_DEVICE_PASSWORD_REQUIREMENT_ONLY;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS;
|
||||
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE;
|
||||
@@ -52,6 +54,7 @@ import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings.Global;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
@@ -379,6 +382,47 @@ public class ChooseLockGenericTest {
|
||||
.isEqualTo("app name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSetNewPassword_withTitleAndDescription_displaysPassedTitleAndDescription() {
|
||||
Intent intent =
|
||||
new Intent(ACTION_SET_NEW_PASSWORD)
|
||||
.putExtra(
|
||||
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE,
|
||||
R.string.private_space_lock_setup_title)
|
||||
.putExtra(
|
||||
EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION,
|
||||
R.string.private_space_lock_setup_description);
|
||||
initActivity(intent);
|
||||
|
||||
CharSequence expectedTitle = mActivity.getString(R.string.private_space_lock_setup_title);
|
||||
CharSequence expectedDescription =
|
||||
mActivity.getString(R.string.private_space_lock_setup_description);
|
||||
assertThat(mActivity.getTitle().toString().contentEquals(expectedTitle)).isTrue();
|
||||
TextView textView =
|
||||
mFragment.getHeaderView().findViewById(R.id.biometric_header_description);
|
||||
assertThat(textView.getText().toString().contentEquals(expectedDescription)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSetNewPassword_withLockScreenTitle_titlePassedOntoNextActivity() {
|
||||
Intent intent =
|
||||
new Intent(ACTION_SET_NEW_PASSWORD)
|
||||
.putExtra(
|
||||
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE,
|
||||
R.string.private_space_lock_setup_title);
|
||||
initActivity(intent);
|
||||
|
||||
Preference facePref = new Preference(application);
|
||||
facePref.setKey("unlock_skip_biometrics");
|
||||
boolean result = mFragment.onPreferenceTreeClick(facePref);
|
||||
|
||||
assertThat(result).isTrue();
|
||||
Intent actualIntent = shadowOf(mActivity).getNextStartedActivityForResult().intent;
|
||||
assertThat(actualIntent.hasExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE)).isTrue();
|
||||
assertThat(actualIntent.getIntExtra(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, -1))
|
||||
.isEqualTo(R.string.private_space_lock_setup_title);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnifyProfile_IntentPassedToChooseLockPassword() {
|
||||
final Bundle arguments = new Bundle();
|
||||
|
Reference in New Issue
Block a user