Make recoverablekeystore use LockscreenCredential instead of (type, bytes)
Passing raw credential type values and byte arrays around is error-prone. Instead, just use LockscreenCredential which is for exactly that purpose. Some of the unit tests used invalid credentials that cannot actually be represented by LockscreenCredential and therefore don't occur in the real system. For the unit tests that used invalid patterns (containing bytes other than digits 1-9), update them to use valid patterns. Remove the unit test run_customLockScreen_RecoveryStatusFailure(), since the type system prevents that case from being reachable anymore. To keep the unit tests run_setsCorrectSnapshotVersion() and run_recreatesMissingSnapshot() passing, I also replaced the first call to KeySyncTask#run() in them with KeySyncTask#syncKeys() directly. This was necessary because the second call to KeySyncTask#run() would otherwise occur after the KeySyncTask's credential was already zeroized. Before, it worked by accident. After this change, an exception gets thrown from LockscreenCredential#ensureNotZeroized(). Note that this change in behavior does not affect the non-test code, since it never calls run() multiple times on the same KeySyncTask. Bug: 431226484 Test: atest FrameworksServicesTests:com.android.server.locksettings Flag: EXEMPT refactor Change-Id: I2ea19109abe3fc30ffbccba94013b47b449ef27c
Loading
Please register or sign in to comment