From efa5b5a480224971c39ff6f7b627bc6cd3c7882f Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Wed, 23 Feb 2022 07:38:59 -0500 Subject: [PATCH] User switcher - Create user dialog fixes Make sure the activity is started with the correct user in order to display properly. Also, the ShadeController is not properly bound in dagger for non-system users, which was throwing a NullPointerException. Avoid this and instead use a broadcast to close the shade. Fixes: 219638055 Test: atest UserSwitcherControllerTest Change-Id: I8af80aa10b1bcac92eecdbc65b750a734b2f86ac --- .../statusbar/policy/UserSwitcherController.java | 14 ++++++-------- .../statusbar/policy/UserSwitcherControllerTest.kt | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index f4e53e22b02c3..d1c9b3f1c2c50 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -76,14 +76,11 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.qs.QSUserSwitcherEvent; import com.android.systemui.qs.user.UserSwitchDialogController.DialogShower; import com.android.systemui.settings.UserTracker; -import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.telephony.TelephonyListenerManager; import com.android.systemui.user.CreateUserActivity; import com.android.systemui.util.settings.SecureSettings; -import dagger.Lazy; - import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.ref.WeakReference; @@ -129,7 +126,6 @@ public class UserSwitcherController implements Dumpable { private final InteractionJankMonitor mInteractionJankMonitor; private final LatencyTracker mLatencyTracker; private final DialogLaunchAnimator mDialogLaunchAnimator; - private final Lazy mShadeController; private ArrayList mUsers = new ArrayList<>(); @VisibleForTesting @@ -178,7 +174,6 @@ public class UserSwitcherController implements Dumpable { InteractionJankMonitor interactionJankMonitor, LatencyTracker latencyTracker, DumpManager dumpManager, - Lazy shadeController, DialogLaunchAnimator dialogLaunchAnimator) { mContext = context; mActivityManager = activityManager; @@ -207,7 +202,6 @@ public class UserSwitcherController implements Dumpable { mActivityStarter = activityStarter; mUserManager = userManager; mDialogLaunchAnimator = dialogLaunchAnimator; - mShadeController = shadeController; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_ADDED); @@ -1206,8 +1200,12 @@ public class UserSwitcherController implements Dumpable { if (ActivityManager.isUserAMonkey()) { return; } - mShadeController.get().collapsePanel(); - getContext().startActivity(CreateUserActivity.createIntentForStart(getContext())); + // Use broadcast instead of ShadeController, as this dialog may have started in + // another process and normal dagger bindings are not available + getContext().sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); + getContext().startActivityAsUser( + CreateUserActivity.createIntentForStart(getContext()), + mUserTracker.getUserHandle()); } } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt index 07e0279e0c528..896dab6c060d2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/UserSwitcherControllerTest.kt @@ -48,7 +48,6 @@ import com.android.systemui.qs.QSUserSwitcherEvent import com.android.systemui.qs.user.UserSwitchDialogController import com.android.systemui.settings.UserTracker import com.android.systemui.statusbar.phone.NotificationShadeWindowView -import com.android.systemui.statusbar.phone.ShadeController import com.android.systemui.telephony.TelephonyListenerManager import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.settings.SecureSettings @@ -95,7 +94,6 @@ class UserSwitcherControllerTest : SysuiTestCase() { @Mock private lateinit var notificationShadeWindowView: NotificationShadeWindowView @Mock private lateinit var threadedRenderer: ThreadedRenderer @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator - @Mock private lateinit var shadeController: ShadeController private lateinit var testableLooper: TestableLooper private lateinit var bgExecutor: FakeExecutor private lateinit var uiExecutor: FakeExecutor @@ -171,7 +169,6 @@ class UserSwitcherControllerTest : SysuiTestCase() { interactionJankMonitor, latencyTracker, dumpManager, - { shadeController }, dialogLaunchAnimator) userSwitcherController.init(notificationShadeWindowView) }