Merge "Allow the LockPatterUtils to be null" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
ec78150e69
@@ -95,8 +95,7 @@ public final class LockScreenSafetySource {
|
||||
new SafetySourceStatus.Builder(
|
||||
context.getString(R.string.unlock_set_unlock_launch_picker_title),
|
||||
lockScreenAllowedByAdmin
|
||||
? screenLockPreferenceDetailsUtils.getSummary(
|
||||
UserHandle.myUserId())
|
||||
? getScreenLockSummary(screenLockPreferenceDetailsUtils)
|
||||
: context.getString(R.string.disabled_by_policy_title),
|
||||
severityLevel)
|
||||
.setPendingIntent(lockScreenAllowedByAdmin ? pendingIntent : null)
|
||||
@@ -114,6 +113,12 @@ public final class LockScreenSafetySource {
|
||||
.setSafetySourceData(context, SAFETY_SOURCE_ID, safetySourceData, safetyEvent);
|
||||
}
|
||||
|
||||
private static String getScreenLockSummary(
|
||||
ScreenLockPreferenceDetailsUtils screenLockPreferenceDetailsUtils) {
|
||||
String summary = screenLockPreferenceDetailsUtils.getSummary(UserHandle.myUserId());
|
||||
return summary != null ? summary : "";
|
||||
}
|
||||
|
||||
/** Notifies Safety Center of a change in lock screen settings. */
|
||||
public static void onLockScreenChange(Context context) {
|
||||
setSafetySourceData(
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.storage.StorageManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.android.internal.app.UnlaunchableAppActivity;
|
||||
@@ -43,6 +44,7 @@ public class ScreenLockPreferenceDetailsUtils {
|
||||
|
||||
private final int mUserId = UserHandle.myUserId();
|
||||
private final Context mContext;
|
||||
@Nullable
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final int mProfileChallengeUserId;
|
||||
private final UserManager mUm;
|
||||
@@ -85,7 +87,7 @@ public class ScreenLockPreferenceDetailsUtils {
|
||||
* Returns whether the lock pattern is secure.
|
||||
*/
|
||||
public boolean isLockPatternSecure() {
|
||||
return mLockPatternUtils.isSecure(mUserId);
|
||||
return mLockPatternUtils != null && mLockPatternUtils.isSecure(mUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,6 +150,7 @@ public class ScreenLockPreferenceDetailsUtils {
|
||||
// profile with unified challenge on FBE-enabled devices. Otherwise, vold would not be
|
||||
// able to complete the operation due to the lack of (old) encryption key.
|
||||
if (mProfileChallengeUserId != UserHandle.USER_NULL
|
||||
&& mLockPatternUtils != null
|
||||
&& !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)
|
||||
&& StorageManager.isFileEncrypted()) {
|
||||
if (mUm.isQuietModeEnabled(UserHandle.of(mProfileChallengeUserId))) {
|
||||
@@ -166,8 +169,12 @@ public class ScreenLockPreferenceDetailsUtils {
|
||||
.toIntent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@StringRes
|
||||
private Integer getSummaryResId(int userId) {
|
||||
if (mLockPatternUtils == null) {
|
||||
return null;
|
||||
}
|
||||
if (!mLockPatternUtils.isSecure(userId)) {
|
||||
if (userId == mProfileChallengeUserId
|
||||
|| mLockPatternUtils.isLockScreenDisabled(userId)) {
|
||||
|
||||
Reference in New Issue
Block a user