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

Commit 1494dac0 authored by Diya Bera's avatar Diya Bera
Browse files

Add null checker for parent profile

Flag: N/A
Fixes: 325867085
Test: atest CredentialInteractorImplTest
Change-Id: Id87e49867efcc0a06318ea1e235e3a94f1d5fbf8
parent 30fc8e6e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ constructor(
        userManager.getCredentialOwnerProfile(userId)

    override fun getParentProfileIdOrSelfId(userId: Int): Int =
        userManager.getProfileParent(userId).id
        userManager.getProfileParent(userId)?.id ?: userManager.getCredentialOwnerProfile(userId)

    override fun verifyCredential(
        request: BiometricPromptRequest.Credential,
+10 −0
Original line number Diff line number Diff line
@@ -99,6 +99,16 @@ class CredentialInteractorImplTest : SysuiTestCase() {
        }
    }

    @Test
    fun useCredentialOwnerWhenParentProfileIsNull() {
        val value = 1

        whenever(userManager.getProfileParent(eq(USER_ID))).thenReturn(null)
        whenever(userManager.getCredentialOwnerProfile(eq(USER_ID))).thenReturn(value)

        assertThat(interactor.getParentProfileIdOrSelfId(USER_ID)).isEqualTo(value)
    }

    @Test fun pinCredentialWhenGood() = pinCredential(goodCredential())

    @Test fun pinCredentialWhenBad() = pinCredential(badCredential())