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

Commit d05804e8 authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge changes I28adc747,I6c87f6f8,Ib7af8ca3 into main

* changes:
  Update users when locale changes.
  Remove dialog when user is switched.
  Prevent Sysui crash when user is deleted.
parents 58329667 ec287c08
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ open class UserTrackerImpl internal constructor(
        setUserIdInternal(startingUser)

        val filter = IntentFilter().apply {
            addAction(Intent.ACTION_LOCALE_CHANGED)
            addAction(Intent.ACTION_USER_INFO_CHANGED)
            // These get called when a managed profile goes in or out of quiet mode.
            addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE)
@@ -149,6 +150,7 @@ open class UserTrackerImpl internal constructor(

    override fun onReceive(context: Context, intent: Intent) {
        when (intent.action) {
            Intent.ACTION_LOCALE_CHANGED,
            Intent.ACTION_USER_INFO_CHANGED,
            Intent.ACTION_MANAGED_PROFILE_AVAILABLE,
            Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE,
+8 −0
Original line number Diff line number Diff line
@@ -325,6 +325,7 @@ constructor(
                            addAction(Intent.ACTION_USER_SWITCHED)
                            addAction(Intent.ACTION_USER_STOPPED)
                            addAction(Intent.ACTION_USER_UNLOCKED)
                            addAction(Intent.ACTION_LOCALE_CHANGED)
                        },
                    user = UserHandle.SYSTEM,
                    map = { intent, _ -> intent },
@@ -615,6 +616,7 @@ constructor(
    ) {
        val shouldRefreshAllUsers =
            when (intent.action) {
                Intent.ACTION_LOCALE_CHANGED -> true
                Intent.ACTION_USER_SWITCHED -> {
                    dismissDialog()
                    val selectedUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1)
@@ -644,6 +646,11 @@ 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)) {
            return
        }

        val intent = Intent(applicationContext, SystemUISecondaryUserService::class.java)
        // Disconnect from the old secondary user's service
        val secondaryUserId = repository.secondaryUserId
@@ -657,6 +664,7 @@ constructor(

        // Connect to the new secondary user's service (purely to ensure that a persistent
        // SystemUI application is created for that user)

        if (userId != Process.myUserHandle().identifier) {
            applicationContext.startServiceAsUser(
                intent,
+9 −3
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ constructor(

    private val hasCancelButtonBeenClicked = MutableStateFlow(false)
    private val isFinishRequiredDueToExecutedAction = MutableStateFlow(false)
    private val userSwitched = MutableStateFlow(false)

    /**
     * Whether the observer should finish the experience. Once consumed, [onFinished] must be called
@@ -89,6 +90,7 @@ constructor(
    fun onFinished() {
        hasCancelButtonBeenClicked.value = false
        isFinishRequiredDueToExecutedAction.value = false
        userSwitched.value = false
    }

    /** Notifies that the user has clicked the "open menu" button. */
@@ -121,8 +123,9 @@ constructor(
            hasCancelButtonBeenClicked,
            // If an executed action told us to finish, we should finish,
            isFinishRequiredDueToExecutedAction,
        ) { cancelButtonClicked, executedActionFinish ->
            cancelButtonClicked || executedActionFinish
            userSwitched,
        ) { cancelButtonClicked, executedActionFinish, userSwitched ->
            cancelButtonClicked || executedActionFinish || userSwitched
        }

    private fun toViewModel(
@@ -191,7 +194,10 @@ constructor(
        return if (!model.isSelectable) {
            null
        } else {
            { userInteractor.selectUser(model.id) }
            {
                userInteractor.selectUser(model.id)
                userSwitched.value = true
            }
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ class UserTrackerImplReceiveTest : SysuiTestCase() {
        @Parameterized.Parameters
        fun data(): Iterable<String> =
            listOf(
                Intent.ACTION_LOCALE_CHANGED,
                Intent.ACTION_USER_INFO_CHANGED,
                Intent.ACTION_MANAGED_PROFILE_AVAILABLE,
                Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE,
+2 −1
Original line number Diff line number Diff line
@@ -177,7 +177,8 @@ class UserTrackerImplTest : SysuiTestCase() {
        verify(context)
                .registerReceiverForAllUsers(eq(tracker), capture(captor), isNull(), eq(handler))
        with(captor.value) {
            assertThat(countActions()).isEqualTo(6)
            assertThat(countActions()).isEqualTo(7)
            assertThat(hasAction(Intent.ACTION_LOCALE_CHANGED)).isTrue()
            assertThat(hasAction(Intent.ACTION_USER_INFO_CHANGED)).isTrue()
            assertThat(hasAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE)).isTrue()
            assertThat(hasAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)).isTrue()
Loading