Loading cmds/am/src/com/android/commands/am/Am.java +14 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.graphics.Rect; import android.net.Uri; Loading @@ -63,6 +64,7 @@ import android.util.ArrayMap; import android.view.IWindowManager; import com.android.internal.os.BaseCommand; import com.android.internal.util.Preconditions; import java.io.BufferedReader; import java.io.File; Loading Loading @@ -168,6 +170,7 @@ public class Am extends BaseCommand { " am get-inactive [--user <USER_ID>] <PACKAGE>\n" + " am send-trim-memory [--user <USER_ID>] <PROCESS>\n" + " [HIDDEN|RUNNING_MODERATE|BACKGROUND|RUNNING_LOW|MODERATE|RUNNING_CRITICAL|COMPLETE]\n" + " am get-current-user\n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + Loading Loading @@ -334,7 +337,9 @@ public class Am extends BaseCommand { "\n" + "am get-inactive: returns the inactive state of an app.\n" + "\n" + "am send-trim-memory: Send a memory trim event to a <PROCESS>.\n" + "am send-trim-memory: send a memory trim event to a <PROCESS>.\n" + "\n" + "am get-current-user: returns id of the current foreground user.\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + Loading Loading @@ -464,6 +469,8 @@ public class Am extends BaseCommand { runGetInactive(); } else if (op.equals("send-trim-memory")) { runSendTrimMemory(); } else if (op.equals("get-current-user")) { runGetCurrentUser(); } else { showError("Error: unknown command '" + op + "'"); } Loading Loading @@ -2712,6 +2719,12 @@ public class Am extends BaseCommand { } } private void runGetCurrentUser() throws Exception { UserInfo currentUser = Preconditions.checkNotNull(mAm.getCurrentUser(), "Current user not set"); System.out.println(currentUser.id); } /** * Open the given file for sending into the system process. This verifies * with SELinux that the system will have access to the file. Loading services/core/java/com/android/server/pm/UserManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -1520,6 +1520,11 @@ public class UserManagerService extends IUserManager.Stub { long ident = Binder.clearCallingIdentity(); try { final UserInfo user; int currentUser = ActivityManager.getCurrentUser(); if (currentUser == userHandle) { Log.w(LOG_TAG, "Current user cannot be removed"); return false; } synchronized (mPackagesLock) { user = mUsers.get(userHandle); if (userHandle == 0 || user == null || mRemovingUserIds.get(userHandle)) { Loading Loading
cmds/am/src/com/android/commands/am/Am.java +14 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.graphics.Rect; import android.net.Uri; Loading @@ -63,6 +64,7 @@ import android.util.ArrayMap; import android.view.IWindowManager; import com.android.internal.os.BaseCommand; import com.android.internal.util.Preconditions; import java.io.BufferedReader; import java.io.File; Loading Loading @@ -168,6 +170,7 @@ public class Am extends BaseCommand { " am get-inactive [--user <USER_ID>] <PACKAGE>\n" + " am send-trim-memory [--user <USER_ID>] <PROCESS>\n" + " [HIDDEN|RUNNING_MODERATE|BACKGROUND|RUNNING_LOW|MODERATE|RUNNING_CRITICAL|COMPLETE]\n" + " am get-current-user\n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + Loading Loading @@ -334,7 +337,9 @@ public class Am extends BaseCommand { "\n" + "am get-inactive: returns the inactive state of an app.\n" + "\n" + "am send-trim-memory: Send a memory trim event to a <PROCESS>.\n" + "am send-trim-memory: send a memory trim event to a <PROCESS>.\n" + "\n" + "am get-current-user: returns id of the current foreground user.\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + Loading Loading @@ -464,6 +469,8 @@ public class Am extends BaseCommand { runGetInactive(); } else if (op.equals("send-trim-memory")) { runSendTrimMemory(); } else if (op.equals("get-current-user")) { runGetCurrentUser(); } else { showError("Error: unknown command '" + op + "'"); } Loading Loading @@ -2712,6 +2719,12 @@ public class Am extends BaseCommand { } } private void runGetCurrentUser() throws Exception { UserInfo currentUser = Preconditions.checkNotNull(mAm.getCurrentUser(), "Current user not set"); System.out.println(currentUser.id); } /** * Open the given file for sending into the system process. This verifies * with SELinux that the system will have access to the file. Loading
services/core/java/com/android/server/pm/UserManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -1520,6 +1520,11 @@ public class UserManagerService extends IUserManager.Stub { long ident = Binder.clearCallingIdentity(); try { final UserInfo user; int currentUser = ActivityManager.getCurrentUser(); if (currentUser == userHandle) { Log.w(LOG_TAG, "Current user cannot be removed"); return false; } synchronized (mPackagesLock) { user = mUsers.get(userHandle); if (userHandle == 0 || user == null || mRemovingUserIds.get(userHandle)) { Loading