Loading core/java/android/app/ActivityManagerNative.java +22 −0 Original line number Diff line number Diff line Loading @@ -1713,6 +1713,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case START_USER_IN_BACKGROUND_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int userid = data.readInt(); boolean result = startUserInBackground(userid); reply.writeNoException(); reply.writeInt(result ? 1 : 0); return true; } case STOP_USER_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int userid = data.readInt(); Loading Loading @@ -4304,6 +4313,19 @@ class ActivityManagerProxy implements IActivityManager return result; } public boolean startUserInBackground(int userid) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(userid); mRemote.transact(START_USER_IN_BACKGROUND_TRANSACTION, data, reply, 0); reply.readException(); boolean result = reply.readInt() != 0; reply.recycle(); data.recycle(); return result; } public int stopUser(int userid, IStopUserCallback callback) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); Loading core/java/android/app/IActivityManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -349,6 +349,7 @@ public interface IActivityManager extends IInterface { // Multi-user APIs public boolean switchUser(int userid) throws RemoteException; public boolean startUserInBackground(int userid) throws RemoteException; public int stopUser(int userid, IStopUserCallback callback) throws RemoteException; public UserInfo getCurrentUser() throws RemoteException; public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException; Loading Loading @@ -715,4 +716,5 @@ public interface IActivityManager extends IInterface { // Start of L transactions int GET_TAG_FOR_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+210; int START_USER_IN_BACKGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+211; } services/core/java/com/android/server/am/ActivityManagerService.java +39 −16 Original line number Diff line number Diff line Loading @@ -16081,8 +16081,20 @@ public final class ActivityManagerService extends ActivityManagerNative // Multi-user methods /** * Start user, if its not already running, but don't bring it to foreground. */ @Override public boolean startUserInBackground(final int userId) { return startUser(userId, /* foreground */ false); } @Override public boolean switchUser(final int userId) { return startUser(userId, /* foregound */ true); } private boolean startUser(final int userId, boolean foreground) { if (checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) != PackageManager.PERMISSION_GRANTED) { String msg = "Permission Denial: switchUser() from pid=" Loading Loading @@ -16120,12 +16132,18 @@ public final class ActivityManagerService extends ActivityManagerNative needStart = true; } mCurrentUserId = userId; final Integer userIdInt = Integer.valueOf(userId); mUserLru.remove(userIdInt); mUserLru.add(userIdInt); if (foreground) { mCurrentUserId = userId; mWindowManager.setCurrentUser(userId); } else { final Integer currentUserIdInt = Integer.valueOf(mCurrentUserId); mUserLru.remove(currentUserIdInt); mUserLru.add(currentUserIdInt); } // Once the internal notion of the active user has switched, we lock the device // with the option to show the user switcher on the keyguard. Loading @@ -16150,12 +16168,15 @@ public final class ActivityManagerService extends ActivityManagerNative needStart = true; } if (foreground) { mHandler.removeMessages(REPORT_USER_SWITCH_MSG); mHandler.removeMessages(USER_SWITCH_TIMEOUT_MSG); mHandler.sendMessage(mHandler.obtainMessage(REPORT_USER_SWITCH_MSG, oldUserId, userId, uss)); mHandler.sendMessageDelayed(mHandler.obtainMessage(USER_SWITCH_TIMEOUT_MSG, oldUserId, userId, uss), USER_SWITCH_TIMEOUT); } if (needStart) { Intent intent = new Intent(Intent.ACTION_USER_STARTED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY Loading Loading @@ -16186,16 +16207,18 @@ public final class ActivityManagerService extends ActivityManagerNative } } if (foreground) { boolean homeInFront = mStackSupervisor.switchUserLocked(userId, uss); if (homeInFront) { startHomeActivityLocked(userId); } else { mStackSupervisor.resumeTopActivitiesLocked(); } EventLogTags.writeAmSwitchUser(userId); getUserManagerLocked().userForeground(userId); sendUserSwitchBroadcastsLocked(oldUserId, userId); } if (needStart) { Intent intent = new Intent(Intent.ACTION_USER_STARTING); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); Loading
core/java/android/app/ActivityManagerNative.java +22 −0 Original line number Diff line number Diff line Loading @@ -1713,6 +1713,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case START_USER_IN_BACKGROUND_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int userid = data.readInt(); boolean result = startUserInBackground(userid); reply.writeNoException(); reply.writeInt(result ? 1 : 0); return true; } case STOP_USER_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int userid = data.readInt(); Loading Loading @@ -4304,6 +4313,19 @@ class ActivityManagerProxy implements IActivityManager return result; } public boolean startUserInBackground(int userid) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(userid); mRemote.transact(START_USER_IN_BACKGROUND_TRANSACTION, data, reply, 0); reply.readException(); boolean result = reply.readInt() != 0; reply.recycle(); data.recycle(); return result; } public int stopUser(int userid, IStopUserCallback callback) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); Loading
core/java/android/app/IActivityManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -349,6 +349,7 @@ public interface IActivityManager extends IInterface { // Multi-user APIs public boolean switchUser(int userid) throws RemoteException; public boolean startUserInBackground(int userid) throws RemoteException; public int stopUser(int userid, IStopUserCallback callback) throws RemoteException; public UserInfo getCurrentUser() throws RemoteException; public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException; Loading Loading @@ -715,4 +716,5 @@ public interface IActivityManager extends IInterface { // Start of L transactions int GET_TAG_FOR_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+210; int START_USER_IN_BACKGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+211; }
services/core/java/com/android/server/am/ActivityManagerService.java +39 −16 Original line number Diff line number Diff line Loading @@ -16081,8 +16081,20 @@ public final class ActivityManagerService extends ActivityManagerNative // Multi-user methods /** * Start user, if its not already running, but don't bring it to foreground. */ @Override public boolean startUserInBackground(final int userId) { return startUser(userId, /* foreground */ false); } @Override public boolean switchUser(final int userId) { return startUser(userId, /* foregound */ true); } private boolean startUser(final int userId, boolean foreground) { if (checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) != PackageManager.PERMISSION_GRANTED) { String msg = "Permission Denial: switchUser() from pid=" Loading Loading @@ -16120,12 +16132,18 @@ public final class ActivityManagerService extends ActivityManagerNative needStart = true; } mCurrentUserId = userId; final Integer userIdInt = Integer.valueOf(userId); mUserLru.remove(userIdInt); mUserLru.add(userIdInt); if (foreground) { mCurrentUserId = userId; mWindowManager.setCurrentUser(userId); } else { final Integer currentUserIdInt = Integer.valueOf(mCurrentUserId); mUserLru.remove(currentUserIdInt); mUserLru.add(currentUserIdInt); } // Once the internal notion of the active user has switched, we lock the device // with the option to show the user switcher on the keyguard. Loading @@ -16150,12 +16168,15 @@ public final class ActivityManagerService extends ActivityManagerNative needStart = true; } if (foreground) { mHandler.removeMessages(REPORT_USER_SWITCH_MSG); mHandler.removeMessages(USER_SWITCH_TIMEOUT_MSG); mHandler.sendMessage(mHandler.obtainMessage(REPORT_USER_SWITCH_MSG, oldUserId, userId, uss)); mHandler.sendMessageDelayed(mHandler.obtainMessage(USER_SWITCH_TIMEOUT_MSG, oldUserId, userId, uss), USER_SWITCH_TIMEOUT); } if (needStart) { Intent intent = new Intent(Intent.ACTION_USER_STARTED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY Loading Loading @@ -16186,16 +16207,18 @@ public final class ActivityManagerService extends ActivityManagerNative } } if (foreground) { boolean homeInFront = mStackSupervisor.switchUserLocked(userId, uss); if (homeInFront) { startHomeActivityLocked(userId); } else { mStackSupervisor.resumeTopActivitiesLocked(); } EventLogTags.writeAmSwitchUser(userId); getUserManagerLocked().userForeground(userId); sendUserSwitchBroadcastsLocked(oldUserId, userId); } if (needStart) { Intent intent = new Intent(Intent.ACTION_USER_STARTING); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);