Provide data to LockScreenSafetySource

Test: atest SettingsUnitTests

Bug: 215515298
Change-Id: I59640e9f691754a2225870d40f5db3e6fd8557f8
This commit is contained in:
Yuri Ufimtsev
2022-02-18 14:33:47 +00:00
parent 3b3c6bc564
commit fc9b13e865
5 changed files with 297 additions and 49 deletions

View File

@@ -18,12 +18,14 @@ package com.android.settings.security;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
import androidx.annotation.StringRes;
import com.android.internal.app.UnlaunchableAppActivity;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -81,21 +83,35 @@ public class ScreenLockPreferenceDetailsUtils {
== DevicePolicyManager.PASSWORD_QUALITY_MANAGED;
}
/**
* Returns whether the lock pattern is secure.
*/
public boolean isLockPatternSecure() {
return mLockPatternUtils.isSecure(mUserId);
}
/**
* Returns whether the Gear Menu should be shown.
*/
public boolean shouldShowGearMenu() {
return mLockPatternUtils.isSecure(mUserId);
return isLockPatternSecure();
}
/**
* Launches the {@link ScreenLockSettings}.
*/
public void openScreenLockSettings() {
new SubSettingLauncher(mContext)
mContext.startActivity(getLaunchScreenLockSettingsIntent());
}
/**
* Returns {@link Intent} to launch the {@link ScreenLockSettings}.
*/
public Intent getLaunchScreenLockSettingsIntent() {
return new SubSettingLauncher(mContext)
.setDestination(ScreenLockSettings.class.getName())
.setSourceMetricsCategory(mSourceMetricsCategory)
.launch();
.toIntent();
}
/**
@@ -105,6 +121,29 @@ public class ScreenLockPreferenceDetailsUtils {
* @return true if the {@link ChooseLockGenericFragment} is launching.
*/
public boolean openChooseLockGenericFragment() {
final Intent quietModeDialogIntent = getQuietModeDialogIntent();
if (quietModeDialogIntent != null) {
mContext.startActivity(quietModeDialogIntent);
return false;
}
mContext.startActivity(getChooseLockGenericFragmentIntent());
return true;
}
/**
* Returns {@link Intent} to launch an appropriate Settings screen.
*
* <p>If Quiet Mode is enabled for managed profile, returns {@link Intent} to launch a dialog
* to disable the Quiet Mode, otherwise returns {@link Intent} to launch
* {@link ChooseLockGenericFragment}.
*/
public Intent getLaunchChooseLockGenericFragmentIntent() {
final Intent quietModeDialogIntent = getQuietModeDialogIntent();
return quietModeDialogIntent != null ? quietModeDialogIntent
: getChooseLockGenericFragmentIntent();
}
private Intent getQuietModeDialogIntent() {
// TODO(b/35930129): Remove once existing password can be passed into vold directly.
// Currently we need this logic to ensure that the QUIET_MODE is off for any work
// profile with unified challenge on FBE-enabled devices. Otherwise, vold would not be
@@ -112,17 +151,20 @@ public class ScreenLockPreferenceDetailsUtils {
if (mProfileChallengeUserId != UserHandle.USER_NULL
&& !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)
&& StorageManager.isFileEncryptedNativeOnly()) {
if (Utils.startQuietModeDialogIfNecessary(mContext, mUm, mProfileChallengeUserId)) {
return false;
if (mUm.isQuietModeEnabled(UserHandle.of(mProfileChallengeUserId))) {
return UnlaunchableAppActivity.createInQuietModeDialogIntent(
mProfileChallengeUserId);
}
}
return null;
}
new SubSettingLauncher(mContext)
private Intent getChooseLockGenericFragmentIntent() {
return new SubSettingLauncher(mContext)
.setDestination(ChooseLockGenericFragment.class.getName())
.setSourceMetricsCategory(mSourceMetricsCategory)
.setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
.launch();
return true;
.toIntent();
}
@StringRes