Avoid the suppression of an errorprone warning

Lock mService.mSpManager in initializeStorageWithCredential() so that
GuardedBy warnings don't have to be suppressed in that method anymore.

Test: m FrameworksServicesTests RUN_ERROR_PRONE=true
Test: atest LockSettingsServiceTests
Change-Id: I7451a7d32c3feb6c1ac40371cdb6f24f7b1fdd6d
This commit is contained in:
Eric Biggers
2022-07-25 22:28:13 +00:00
parent 8568657f9d
commit e8b1a8986a
2 changed files with 5 additions and 3 deletions

View File

@@ -234,7 +234,8 @@ public class LockSettingsService extends ILockSettings.Stub {
protected final UserManager mUserManager;
private final IStorageManager mStorageManager;
private final IActivityManager mActivityManager;
private final SyntheticPasswordManager mSpManager;
@VisibleForTesting
protected final SyntheticPasswordManager mSpManager;
private final KeyStore mKeyStore;
private final java.security.KeyStore mJavaKeyStore;

View File

@@ -504,11 +504,12 @@ public class LockSettingsServiceTests extends BaseLockSettingsServiceTests {
badCredential, userId, 0 /* flags */).getResponseCode());
}
@SuppressWarnings("GuardedBy") // for initializeSyntheticPasswordLocked
private void initializeStorageWithCredential(int userId, LockscreenCredential credential)
throws RemoteException {
assertEquals(0, mGateKeeperService.getSecureUserId(userId));
mService.initializeSyntheticPasswordLocked(credential, userId);
synchronized (mService.mSpManager) {
mService.initializeSyntheticPasswordLocked(credential, userId);
}
assertNotEquals(0, mGateKeeperService.getSecureUserId(userId));
}
}