Merge "Added logoutCurrentUser method" into nyc-dev

am: 89f1622e48

* commit '89f1622e48206d2f8ebd9af9c32449f1f8eab7d1':
  Added logoutCurrentUser method
This commit is contained in:
Fyodor Kupolov
2016-03-11 23:54:21 +00:00
committed by android-build-merger
2 changed files with 19 additions and 10 deletions

View File

@@ -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} */

View File

@@ -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();