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

Commit cc18dc45 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Only startSecondaryService for users that are running" into main

parents 91531e37 61311b3a
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -157,8 +157,7 @@ class UserSwitcherInteractorTest : SysuiTestCase() {

    @Test
    fun createUserInteractor_nonProcessUser_startsSecondaryService() {
        val userId = Process.myUserHandle().identifier + 1
        whenever(manager.aliveUsers).thenReturn(listOf(createUserInfo(userId, "abc")))
        whenever(manager.isUserRunning(anyInt())).thenReturn(true)

        createUserInteractor(false /* startAsProcessUser */)
        verify(spyContext).startServiceAsUser(any(), any())
@@ -710,7 +709,9 @@ class UserSwitcherInteractorTest : SysuiTestCase() {
    fun userSwitchedBroadcast() {
        testScope.runTest {
            val userInfos = createUserInfos(count = 2, includeGuest = false)
            whenever(manager.aliveUsers).thenReturn(userInfos)
            for (userInfo in userInfos) {
                whenever(manager.isUserRunning(eq(userInfo.id))).thenReturn(true)
            }
            createUserInteractor()
            userRepository.setUserInfos(userInfos)
            userRepository.setSelectedUserInfo(userInfos[0])
@@ -1147,8 +1148,8 @@ class UserSwitcherInteractorTest : SysuiTestCase() {
    }

    @Test
    fun initWithNoAliveUsers() {
        whenever(manager.aliveUsers).thenReturn(listOf())
    fun initWithNoRunningUsers() {
        whenever(manager.isUserRunning(anyInt())).thenReturn(false)
        createUserInteractor()
        verify(spyContext, never()).startServiceAsUser(any(), any())
    }
+2 −2
Original line number Diff line number Diff line
@@ -659,8 +659,8 @@ constructor(
    }

    private fun restartSecondaryService(@UserIdInt userId: Int) {
        // Do not start service for user that is marked for deletion.
        if (!manager.aliveUsers.map { it.id }.contains(userId)) {
        // Do not start service for user that isn't running
        if (!manager.isUserRunning(userId)) {
            return
        }