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

Commit 89f1622e authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Added logoutCurrentUser method" into nyc-dev

parents 026cf53f b5690bc3
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -3329,6 +3329,23 @@ public class ActivityManager {
        }
    }

    /**
     * Logs out current current foreground user by switching to the system user and stopping the
     * user being switched from.
     * @hide
     */
    public static void logoutCurrentUser() {
        int currentUser = ActivityManager.getCurrentUser();
        if (currentUser != UserHandle.USER_SYSTEM) {
            try {
                ActivityManagerNative.getDefault().switchUser(UserHandle.USER_SYSTEM);
                ActivityManagerNative.getDefault().stopUser(currentUser, /* force= */ false, null);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }
        }
    }

    /** {@hide} */
    public static final int FLAG_OR_STOPPED = 1 << 0;
    /** {@hide} */
+2 −10
Original line number Diff line number Diff line
@@ -315,8 +315,8 @@ public class UserSwitcherController {
    public void logoutCurrentUser() {
        int currentUser = ActivityManager.getCurrentUser();
        if (currentUser != UserHandle.USER_SYSTEM) {
            switchToUserId(UserHandle.USER_SYSTEM);
            stopUserId(currentUser);
            pauseRefreshUsers();
            ActivityManager.logoutCurrentUser();
        }
    }

@@ -384,14 +384,6 @@ public class UserSwitcherController {
        }
    }

    private void stopUserId(int id) {
        try {
            ActivityManagerNative.getDefault().stopUser(id, /* force= */ false, null);
        } catch (RemoteException e) {
            Log.e(TAG, "Couldn't stop user.", e);
        }
    }

    private void showExitGuestDialog(int id) {
        if (mExitGuestDialog != null && mExitGuestDialog.isShowing()) {
            mExitGuestDialog.cancel();