diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index 90f2a6a8cdfc1..f6cdba05a07c4 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -375,7 +375,7 @@ public class LockSettingsService extends ILockSettings.Stub { * @param profileUserId profile user Id * @param profileUserPassword profile original password (when it has separated lock). */ - public void tieProfileLockIfNecessary(int profileUserId, + private void tieProfileLockIfNecessary(int profileUserId, LockscreenCredential profileUserPassword) { if (DEBUG) Slog.v(TAG, "Check child profile lock for user: " + profileUserId); // Only for profiles that shares credential with parent @@ -713,7 +713,8 @@ public class LockSettingsService extends ILockSettings.Stub { userHandle); } - public void onCleanupUser(int userId) { + @VisibleForTesting + void onCleanupUser(int userId) { hideEncryptionNotification(new UserHandle(userId)); // User is stopped with its CE key evicted. Restore strong auth requirement to the default // flags after boot since stopping and restarting a user later is equivalent to rebooting @@ -725,7 +726,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } - public void onStartUser(final int userId) { + private void onStartUser(final int userId) { maybeShowEncryptionNotificationForUser(userId, "user started"); } @@ -779,7 +780,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } - public void onUnlockUser(final int userId) { + private void onUnlockUser(final int userId) { // Perform tasks which require locks in LSS on a handler, as we are callbacks from // ActivityManager.unlockUser() mHandler.post(new Runnable() { @@ -1222,7 +1223,7 @@ public class LockSettingsService extends ILockSettings.Stub { * {@link #CREDENTIAL_TYPE_PATTERN}, {@link #CREDENTIAL_TYPE_PIN} and * {@link #CREDENTIAL_TYPE_PASSWORD} */ - public int getCredentialTypeInternal(int userId) { + private int getCredentialTypeInternal(int userId) { if (userId == USER_FRP) { return getFrpCredentialType(); } @@ -1802,6 +1803,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } + @VisibleForTesting /** Note: this method is overridden in unit tests */ protected boolean isCredentialSharableWithParent(int userId) { return getUserManagerFromCache(userId).isCredentialSharableWithParent(); } @@ -2560,7 +2562,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } - protected synchronized IGateKeeperService getGateKeeperService() { + private synchronized IGateKeeperService getGateKeeperService() { if (mGateKeeperService != null) { return mGateKeeperService; } diff --git a/services/core/java/com/android/server/locksettings/LockSettingsStrongAuth.java b/services/core/java/com/android/server/locksettings/LockSettingsStrongAuth.java index 1203769cb72b7..b77670d4df1eb 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsStrongAuth.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsStrongAuth.java @@ -44,6 +44,7 @@ import com.android.internal.widget.LockPatternUtils.StrongAuthTracker; /** * Keeps track of requests for strong authentication. */ +@VisibleForTesting // public visibility is needed for Mockito public class LockSettingsStrongAuth { private static final String TAG = "LockSettings"; diff --git a/services/core/java/com/android/server/locksettings/ManagedProfilePasswordCache.java b/services/core/java/com/android/server/locksettings/ManagedProfilePasswordCache.java index e43d4e8ce4a6f..ddc0e54244216 100644 --- a/services/core/java/com/android/server/locksettings/ManagedProfilePasswordCache.java +++ b/services/core/java/com/android/server/locksettings/ManagedProfilePasswordCache.java @@ -26,6 +26,7 @@ import android.security.keystore.UserNotAuthenticatedException; import android.util.Slog; import android.util.SparseArray; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import com.android.internal.widget.LockscreenCredential; @@ -60,6 +61,7 @@ import javax.crypto.spec.GCMParameterSpec; *

The encrypted credential is stored in-memory only so the cache does not persist across * reboots. */ +@VisibleForTesting // public visibility is needed for Mockito public class ManagedProfilePasswordCache { private static final String TAG = "ManagedProfilePasswordCache"; diff --git a/services/core/java/com/android/server/locksettings/PasswordSlotManager.java b/services/core/java/com/android/server/locksettings/PasswordSlotManager.java index 21fb403a41c9b..b039d5e2de766 100644 --- a/services/core/java/com/android/server/locksettings/PasswordSlotManager.java +++ b/services/core/java/com/android/server/locksettings/PasswordSlotManager.java @@ -43,7 +43,7 @@ import java.util.Set; * If a /metadata partition does not exist, GSIs are not supported, and PasswordSlotManager will * simply not persist the slot mapping. */ -public class PasswordSlotManager { +class PasswordSlotManager { private static final String TAG = "PasswordSlotManager"; private static final String GSI_RUNNING_PROP = "ro.gsid.image_running"; diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java index cb6e43ce7d05f..b283726315ccb 100644 --- a/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java +++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java @@ -49,7 +49,7 @@ import javax.crypto.SecretKey; import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class SyntheticPasswordCrypto { +class SyntheticPasswordCrypto { private static final String TAG = "SyntheticPasswordCrypto"; private static final int AES_GCM_KEY_SIZE = 32; // AES-256-GCM private static final int AES_GCM_IV_SIZE = 12; diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java index 66ce429c2df1f..67d1c71e736eb 100644 --- a/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java +++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordManager.java @@ -112,7 +112,7 @@ import java.util.Set; * WEAVER_SLOT: Contains the Weaver slot number used by this protector. Only exists if the * protector uses Weaver. */ -public class SyntheticPasswordManager { +class SyntheticPasswordManager { private static final String SP_BLOB_NAME = "spblob"; private static final String SP_E0_NAME = "e0"; private static final String SP_P1_NAME = "p1"; @@ -394,7 +394,7 @@ public class SyntheticPasswordManager { } } - static class SyntheticPasswordBlob { + private static class SyntheticPasswordBlob { byte mVersion; byte mProtectorType; byte[] mContent; @@ -431,7 +431,7 @@ public class SyntheticPasswordManager { static final int TOKEN_TYPE_STRONG = 0; static final int TOKEN_TYPE_WEAK = 1; - static class TokenData { + private static class TokenData { byte[] secdiscardableOnDisk; byte[] weaverSecret; byte[] aggregatedSecret; @@ -1623,7 +1623,7 @@ public class SyntheticPasswordManager { SyntheticPasswordCrypto.destroyProtectorKey(keyAlias); } - public static long generateProtectorId() { + private static long generateProtectorId() { SecureRandom rng = new SecureRandom(); long result; do { @@ -1685,15 +1685,17 @@ public class SyntheticPasswordManager { return Arrays.copyOf(key, mWeaverConfig.keySize); } + @VisibleForTesting protected long sidFromPasswordHandle(byte[] handle) { return nativeSidFromPasswordHandle(handle); } + @VisibleForTesting protected byte[] scrypt(byte[] password, byte[] salt, int n, int r, int p, int outLen) { return new Scrypt().scrypt(password, salt, n, r, p, outLen); } - native long nativeSidFromPasswordHandle(byte[] handle); + private native long nativeSidFromPasswordHandle(byte[] handle); @VisibleForTesting static byte[] bytesToHex(byte[] bytes) { diff --git a/services/core/java/com/android/server/locksettings/VersionedPasswordMetrics.java b/services/core/java/com/android/server/locksettings/VersionedPasswordMetrics.java index b06e3814ac7c8..b10dfb24d874d 100644 --- a/services/core/java/com/android/server/locksettings/VersionedPasswordMetrics.java +++ b/services/core/java/com/android/server/locksettings/VersionedPasswordMetrics.java @@ -25,7 +25,7 @@ import java.nio.ByteBuffer; * A versioned and serializable wrapper around {@link PasswordMetrics}, * for long-term persistence on disk. */ -public class VersionedPasswordMetrics { +class VersionedPasswordMetrics { private static final int VERSION_1 = 1; private final PasswordMetrics mMetrics;