Merge changes I0cf5f6d6,I8957d9a9 into tm-qpr-dev

* changes:
  Turns on refactored UserSwitcherController.
  Lazy UserSwitcherDialogCoordinator.
This commit is contained in:
Ale Nijamkin
2022-10-19 21:30:12 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 25 deletions

View File

@@ -115,8 +115,8 @@ public class Flags {
* <p>If this is {@code false}, the interactor and repo skip the controller and directly access * <p>If this is {@code false}, the interactor and repo skip the controller and directly access
* the framework APIs. * the framework APIs.
*/ */
public static final ReleasedFlag USER_INTERACTOR_AND_REPO_USE_CONTROLLER = public static final UnreleasedFlag USER_INTERACTOR_AND_REPO_USE_CONTROLLER =
new ReleasedFlag(210); new UnreleasedFlag(210);
/** /**
* Whether `UserSwitcherController` should use the user interactor. * Whether `UserSwitcherController` should use the user interactor.
@@ -127,7 +127,7 @@ public class Flags {
* <p>Note: do not set this to true if {@link #USER_INTERACTOR_AND_REPO_USE_CONTROLLER} is * <p>Note: do not set this to true if {@link #USER_INTERACTOR_AND_REPO_USE_CONTROLLER} is
* {@code true} as it would created a cycle between controller -> interactor -> controller. * {@code true} as it would created a cycle between controller -> interactor -> controller.
*/ */
public static final UnreleasedFlag USER_CONTROLLER_USES_INTERACTOR = new UnreleasedFlag(211); public static final ReleasedFlag USER_CONTROLLER_USES_INTERACTOR = new ReleasedFlag(211);
/***************************************/ /***************************************/
// 300 - power menu // 300 - power menu

View File

@@ -30,6 +30,7 @@ import com.android.systemui.flags.Flags
import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.FalsingManager
import com.android.systemui.user.domain.interactor.UserInteractor import com.android.systemui.user.domain.interactor.UserInteractor
import com.android.systemui.user.domain.model.ShowDialogRequestModel import com.android.systemui.user.domain.model.ShowDialogRequestModel
import dagger.Lazy
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
@@ -41,19 +42,19 @@ import kotlinx.coroutines.launch
class UserSwitcherDialogCoordinator class UserSwitcherDialogCoordinator
@Inject @Inject
constructor( constructor(
@Application private val context: Context, @Application private val context: Lazy<Context>,
@Application private val applicationScope: CoroutineScope, @Application private val applicationScope: Lazy<CoroutineScope>,
private val falsingManager: FalsingManager, private val falsingManager: Lazy<FalsingManager>,
private val broadcastSender: BroadcastSender, private val broadcastSender: Lazy<BroadcastSender>,
private val dialogLaunchAnimator: DialogLaunchAnimator, private val dialogLaunchAnimator: Lazy<DialogLaunchAnimator>,
private val interactor: UserInteractor, private val interactor: Lazy<UserInteractor>,
private val featureFlags: FeatureFlags, private val featureFlags: Lazy<FeatureFlags>,
) : CoreStartable { ) : CoreStartable {
private var currentDialog: Dialog? = null private var currentDialog: Dialog? = null
override fun start() { override fun start() {
if (featureFlags.isEnabled(Flags.USER_INTERACTOR_AND_REPO_USE_CONTROLLER)) { if (featureFlags.get().isEnabled(Flags.USER_INTERACTOR_AND_REPO_USE_CONTROLLER)) {
return return
} }
@@ -62,8 +63,8 @@ constructor(
} }
private fun startHandlingDialogShowRequests() { private fun startHandlingDialogShowRequests() {
applicationScope.launch { applicationScope.get().launch {
interactor.dialogShowRequests.filterNotNull().collect { request -> interactor.get().dialogShowRequests.filterNotNull().collect { request ->
currentDialog?.let { currentDialog?.let {
if (it.isShowing) { if (it.isShowing) {
it.cancel() it.cancel()
@@ -74,48 +75,48 @@ constructor(
when (request) { when (request) {
is ShowDialogRequestModel.ShowAddUserDialog -> is ShowDialogRequestModel.ShowAddUserDialog ->
AddUserDialog( AddUserDialog(
context = context, context = context.get(),
userHandle = request.userHandle, userHandle = request.userHandle,
isKeyguardShowing = request.isKeyguardShowing, isKeyguardShowing = request.isKeyguardShowing,
showEphemeralMessage = request.showEphemeralMessage, showEphemeralMessage = request.showEphemeralMessage,
falsingManager = falsingManager, falsingManager = falsingManager.get(),
broadcastSender = broadcastSender, broadcastSender = broadcastSender.get(),
dialogLaunchAnimator = dialogLaunchAnimator, dialogLaunchAnimator = dialogLaunchAnimator.get(),
) )
is ShowDialogRequestModel.ShowUserCreationDialog -> is ShowDialogRequestModel.ShowUserCreationDialog ->
UserCreatingDialog( UserCreatingDialog(
context, context.get(),
request.isGuest, request.isGuest,
) )
is ShowDialogRequestModel.ShowExitGuestDialog -> is ShowDialogRequestModel.ShowExitGuestDialog ->
ExitGuestDialog( ExitGuestDialog(
context = context, context = context.get(),
guestUserId = request.guestUserId, guestUserId = request.guestUserId,
isGuestEphemeral = request.isGuestEphemeral, isGuestEphemeral = request.isGuestEphemeral,
targetUserId = request.targetUserId, targetUserId = request.targetUserId,
isKeyguardShowing = request.isKeyguardShowing, isKeyguardShowing = request.isKeyguardShowing,
falsingManager = falsingManager, falsingManager = falsingManager.get(),
dialogLaunchAnimator = dialogLaunchAnimator, dialogLaunchAnimator = dialogLaunchAnimator.get(),
onExitGuestUserListener = request.onExitGuestUser, onExitGuestUserListener = request.onExitGuestUser,
) )
} }
currentDialog?.show() currentDialog?.show()
interactor.onDialogShown() interactor.get().onDialogShown()
} }
} }
} }
private fun startHandlingDialogDismissRequests() { private fun startHandlingDialogDismissRequests() {
applicationScope.launch { applicationScope.get().launch {
interactor.dialogDismissRequests.filterNotNull().collect { interactor.get().dialogDismissRequests.filterNotNull().collect {
currentDialog?.let { currentDialog?.let {
if (it.isShowing) { if (it.isShowing) {
it.cancel() it.cancel()
} }
} }
interactor.onDialogDismissed() interactor.get().onDialogDismissed()
} }
} }
} }