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

Commit 4e47cb8f authored by Heemin Seog's avatar Heemin Seog
Browse files

Notify window manager service that we are switching users

Bug: 158617677
Test: manual (try user switching on emulator)
Change-Id: Ia04e887846bce6047973d6db094e97a6515715fe
parent 89a801ac
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -23,9 +23,12 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
import android.view.IWindowManager;
import android.widget.ImageView;
import android.widget.TextView;

@@ -44,13 +47,14 @@ import javax.inject.Singleton;
 */
@Singleton
public class UserSwitchTransitionViewController extends OverlayViewController {
    private static final String TAG = "UserSwitchTransitionViewController";
    private static final String TAG = "UserSwitchTransition";
    private static final String ENABLE_DEVELOPER_MESSAGE_TRUE = "true";

    private final Context mContext;
    private final Handler mHandler;
    private final Resources mResources;
    private final UserManager mUserManager;
    private final IWindowManager mWindowManagerService;

    @GuardedBy("this")
    private boolean mShowing;
@@ -62,6 +66,7 @@ public class UserSwitchTransitionViewController extends OverlayViewController {
            @Main Handler handler,
            @Main Resources resources,
            UserManager userManager,
            IWindowManager windowManagerService,
            OverlayViewGlobalStateController overlayViewGlobalStateController) {

        super(R.id.user_switching_dialog_stub, overlayViewGlobalStateController);
@@ -70,6 +75,7 @@ public class UserSwitchTransitionViewController extends OverlayViewController {
        mHandler = handler;
        mResources = resources;
        mUserManager = userManager;
        mWindowManagerService = windowManagerService;
    }

    /**
@@ -81,6 +87,13 @@ public class UserSwitchTransitionViewController extends OverlayViewController {
        if (mPreviousUserId == newUserId || mShowing) return;
        mShowing = true;
        mHandler.post(() -> {
            try {
                mWindowManagerService.setSwitchingUser(true);
                mWindowManagerService.lockNow(null);
            } catch (RemoteException e) {
                Log.e(TAG, "unable to notify window manager service regarding user switch");
            }

            start();
            populateDialog(mPreviousUserId, newUserId);
            // next time a new user is selected, this current new user will be the previous user.
+7 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableResources;
import android.view.IWindowManager;
import android.view.LayoutInflater;
import android.view.ViewGroup;

@@ -52,6 +53,8 @@ public class UserSwitchTransitionViewControllerTest extends SysuiTestCase {
    private TestableResources mTestableResources;
    @Mock
    private OverlayViewGlobalStateController mOverlayViewGlobalStateController;
    @Mock
    private IWindowManager mWindowManagerService;

    @Before
    public void setUp() {
@@ -62,6 +65,7 @@ public class UserSwitchTransitionViewControllerTest extends SysuiTestCase {
                Handler.getMain(),
                mTestableResources.getResources(),
                (UserManager) mContext.getSystemService(Context.USER_SERVICE),
                mWindowManagerService,
                mOverlayViewGlobalStateController
        );

@@ -125,8 +129,10 @@ public class UserSwitchTransitionViewControllerTest extends SysuiTestCase {

        TestableUserSwitchTransitionViewController(Context context, Handler handler,
                Resources resources, UserManager userManager,
                IWindowManager windowManagerService,
                OverlayViewGlobalStateController overlayViewGlobalStateController) {
            super(context, handler, resources, userManager, overlayViewGlobalStateController);
            super(context, handler, resources, userManager, windowManagerService,
                    overlayViewGlobalStateController);
            mHandler = handler;
        }