[PM-30664] Unlock with PIN doesn’t appear as enabled after enabling ‘Require master password on app restart’ (#6344)

This commit is contained in:
Shamim Shahrier Emon
2026-01-22 00:42:02 +06:00
committed by GitHub
parent 40c8346bf7
commit acc3e24d65
2 changed files with 29 additions and 1 deletions

View File

@@ -373,7 +373,10 @@ class AuthDiskSourceImpl(
inMemoryOnly: Boolean,
) {
inMemoryPinProtectedUserKeyEnvelopes[userId] = pinProtectedUserKeyEnvelope
if (inMemoryOnly) return
if (inMemoryOnly) {
getMutablePinProtectedUserKeyEnvelopeFlow(userId).tryEmit(pinProtectedUserKeyEnvelope)
return
}
putString(
key = PIN_PROTECTED_USER_KEY_KEY_ENVELOPE.appendIdentifier(userId),
value = pinProtectedUserKeyEnvelope,

View File

@@ -865,6 +865,31 @@ class AuthDiskSourceTest {
}
}
@Test
@Suppress("MaxLineLength")
fun `storePinProtectedUserKeyEnvelope with inMemoryOnly true emits flow and stores only in memory`() =
runTest {
val userId = "mockUserId"
val envelope = "topSecretEnvelope"
authDiskSource.getPinProtectedUserKeyEnvelopeFlow(userId).test {
assertNull(awaitItem())
authDiskSource.storePinProtectedUserKeyEnvelope(
userId = userId,
pinProtectedUserKeyEnvelope = envelope,
inMemoryOnly = true,
)
assertEquals(envelope, awaitItem())
assertEquals(envelope, authDiskSource.getPinProtectedUserKeyEnvelope(userId))
assertNull(
fakeSharedPreferences.getString(
"pinKeyEncryptedUserKeyEnvelope_$userId",
null,
),
)
}
}
@Test
fun `getPinProtectedUserKeyEnvelope should pull from SharedPreferences`() {
val pinProtectedUserKeyEnvelopeBaseKey =