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

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

Merge changes I61a44a15,I6ac5117f into main

* changes:
  Register callback on main thread.
  Move user switcher to different thread.
parents a10bdf1c ab2be101
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -240,6 +240,13 @@ flag {
   bug: "229856884"
}

flag {
   name: "switch_user_on_bg"
   namespace: "systemui"
   description: "Does user switching on a background thread"
   bug: "284095720"
}

flag {
    name: "status_bar_static_inout_indicators"
    namespace: "systemui"
@@ -247,4 +254,3 @@ flag {
        "prefer using alpha to distinguish network activity."
    bug: "310715220"
}
+20 −5
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.internal.logging.UiEventLogger
import com.android.internal.util.UserIcons
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.systemui.Flags.switchUserOnBg
import com.android.systemui.SystemUISecondaryUserService
import com.android.systemui.animation.Expandable
import com.android.systemui.broadcast.BroadcastDispatcher
@@ -44,6 +45,7 @@ import com.android.systemui.common.shared.model.Text
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
@@ -100,6 +102,7 @@ constructor(
    broadcastDispatcher: BroadcastDispatcher,
    keyguardUpdateMonitor: KeyguardUpdateMonitor,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    @Main private val mainDispatcher: CoroutineDispatcher,
    private val activityManager: ActivityManager,
    private val refreshUsersScheduler: RefreshUsersScheduler,
    private val guestUserInteractor: GuestUserInteractor,
@@ -339,8 +342,12 @@ constructor(
            }
            .launchIn(applicationScope)
        restartSecondaryService(repository.getSelectedUserInfo().id)
        applicationScope.launch {
            withContext(mainDispatcher) {
                keyguardUpdateMonitor.registerCallback(keyguardUpdateMonitorCallback)
            }
        }
    }

    fun addCallback(callback: UserCallback) {
        applicationScope.launch { callbackMutex.withLock { callbacks.add(callback) } }
@@ -593,6 +600,7 @@ constructor(
    private fun switchUser(userId: Int) {
        // TODO(b/246631653): track jank and latency like in the old impl.
        refreshUsersScheduler.pause()
        val runnable = Runnable {
            try {
                activityManager.switchUser(userId)
            } catch (e: RemoteException) {
@@ -600,6 +608,13 @@ constructor(
            }
        }

        if (switchUserOnBg()) {
            applicationScope.launch { withContext(backgroundDispatcher) { runnable.run() } }
        } else {
            runnable.run()
        }
    }

    private suspend fun onBroadcastReceived(
        intent: Intent,
        previousUserInfo: UserInfo?,
+1 −0
Original line number Diff line number Diff line
@@ -1115,6 +1115,7 @@ class UserSwitcherInteractorTest : SysuiTestCase() {
                broadcastDispatcher = fakeBroadcastDispatcher,
                keyguardUpdateMonitor = keyguardUpdateMonitor,
                backgroundDispatcher = utils.testDispatcher,
                mainDispatcher = utils.testDispatcher,
                activityManager = activityManager,
                refreshUsersScheduler = refreshUsersScheduler,
                guestUserInteractor =
+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ class StatusBarUserChipViewModelTest : SysuiTestCase() {
                    broadcastDispatcher = fakeBroadcastDispatcher,
                    keyguardUpdateMonitor = keyguardUpdateMonitor,
                    backgroundDispatcher = testDispatcher,
                    mainDispatcher = testDispatcher,
                    activityManager = activityManager,
                    refreshUsersScheduler = refreshUsersScheduler,
                    guestUserInteractor = guestUserInteractor,
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ class UserSwitcherViewModelTest : SysuiTestCase() {
                        broadcastDispatcher = fakeBroadcastDispatcher,
                        keyguardUpdateMonitor = keyguardUpdateMonitor,
                        backgroundDispatcher = testDispatcher,
                        mainDispatcher = testDispatcher,
                        activityManager = activityManager,
                        refreshUsersScheduler = refreshUsersScheduler,
                        guestUserInteractor = guestUserInteractor,
Loading