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

Commit 848a7b8d authored by Aaron Liu's avatar Aaron Liu
Browse files

[User Switcher] Finish activity when switch user

When switching to owner (user 0), we don't end up in lock screen like
when you switch to a secondary user. My belief is that this is because
the system user does not need to spin up a new process for system UI,
whereas a secondary user will need a secondary process.

We can keep the experience consistent by ensuring that the activity
finishes when a user is switched.

Bug: 228901638
Test: Manual Test
Change-Id: I74623655704cb89e499940498aef5a811dadf77e
parent cab274dc
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import com.android.systemui.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.FalsingManager.LOW_PENALTY
import com.android.systemui.statusbar.phone.ShadeController
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.policy.UserSwitcherController
import com.android.systemui.statusbar.policy.UserSwitcherController.BaseUserAdapter
import com.android.systemui.statusbar.policy.UserSwitcherController.USER_SWITCH_DISABLED_ALPHA
@@ -63,7 +63,7 @@ class UserSwitcherActivity @Inject constructor(
    private val layoutInflater: LayoutInflater,
    private val falsingManager: FalsingManager,
    private val userManager: UserManager,
    private val shadeController: ShadeController
    private val userTracker: UserTracker
) : LifecycleActivity() {

    private lateinit var parent: ViewGroup
@@ -215,6 +215,11 @@ class UserSwitcherActivity @Inject constructor(
        initBroadcastReceiver()

        parent.post { buildUserViews() }
        userTracker.addCallback(object : UserTracker.Callback {
            override fun onUserChanged(newUser: Int, userContext: Context) {
                finish()
            }
        }, mainExecutor)
    }

    private fun showPopupMenu() {
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.statusbar.phone.ShadeController
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.policy.UserSwitcherController
import com.google.common.truth.Truth.assertThat
import org.junit.Before
@@ -50,7 +50,7 @@ class UserSwitcherActivityTest : SysuiTestCase() {
    @Mock
    private lateinit var userManager: UserManager
    @Mock
    private lateinit var shadeController: ShadeController
    private lateinit var userTracker: UserTracker

    @Before
    fun setUp() {
@@ -61,7 +61,7 @@ class UserSwitcherActivityTest : SysuiTestCase() {
            layoutInflater,
            falsingManager,
            userManager,
            shadeController
            userTracker
        )
    }