Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98710a95 authored by Eric Biggers's avatar Eric Biggers
Browse files

LockSettingsService: always get user properties from UserManagerInternal

UserManagerInternal is the preferred way to get user properties in
system_server itself, since it avoids unnecessary checks and an
unnecessary copy of the UserProperties object.

Bug: 403355811
Test: atest FrameworksServicesTests:com.android.server.locksettings
Flag: EXEMPT refactor
Change-Id: If83c4ee8a1624424ebd2a05b8385bb0c728727da
parent 02586d4c
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -847,7 +847,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        if (android.os.Flags.allowPrivateProfile()
                && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
                && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
            UserProperties userProperties = mUserManager.getUserProperties(UserHandle.of(userId));
            UserProperties userProperties = getUserProperties(userId);
            if (userProperties != null && userProperties.getAllowStoppingUserWithDelayedLocking()) {
                return;
            }
@@ -960,19 +960,13 @@ public class LockSettingsService extends ILockSettings.Stub {
                            && android.multiuser.Flags.enablePrivateSpaceFeatures()
                            && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()) {
                        mHandler.post(() -> {
                            try {
                                UserProperties userProperties =
                                        mUserManager.getUserProperties(UserHandle.of(userId));
                            UserProperties userProperties = getUserProperties(userId);
                            if (userProperties != null && userProperties
                                    .getAllowStoppingUserWithDelayedLocking()) {
                                int strongAuthRequired = LockPatternUtils.StrongAuthTracker
                                        .getDefaultFlags(mContext);
                                requireStrongAuth(strongAuthRequired, userId);
                            }
                            } catch (IllegalArgumentException e) {
                                Slogf.d(TAG, "User %d does not exist or has been removed",
                                        userId);
                            }
                        });
                    }
                }};
@@ -2047,9 +2041,13 @@ public class LockSettingsService extends ILockSettings.Stub {
        return mInjector.getDevicePolicyManager().getPasswordHistoryLength(null, userId);
    }

    private @Nullable UserProperties getUserProperties(int userId) {
        return mInjector.getUserManagerInternal().getUserProperties(userId);
    }

    @VisibleForTesting /** Note: this method is overridden in unit tests */
    protected boolean isCredentialShareableWithParent(int userId) {
        UserProperties props = mInjector.getUserManagerInternal().getUserProperties(userId);
        UserProperties props = getUserProperties(userId);
        return props != null && props.isCredentialShareableWithParent();
    }