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

Commit 688c823f authored by Aaron Liu's avatar Aaron Liu
Browse files

Move user switcher to different thread.

Also add this behavior behind a flag.

Test: switch between users.
Fixes: 284095720
Flag: ACONFIG com.android.systemui.switch_user_on_bg DISABLED

Change-Id: I6ac5117fb496eb78a5de50a9145b048aa047a3bf
parent 7493a09d
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"
}
+13 −4
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
@@ -593,6 +594,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 +602,13 @@ constructor(
            }
        }

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

    private suspend fun onBroadcastReceived(
        intent: Intent,
        previousUserInfo: UserInfo?,