Merge "Added logoutCurrentUser method" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
89f1622e48
@@ -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} */
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user