Loading core/java/android/app/IActivityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -264,7 +264,7 @@ interface IActivityManager { boolean isImmersive(in IBinder token); void setImmersive(in IBinder token, boolean immersive); boolean isTopActivityImmersive(); void crashApplication(int uid, int initialPid, in String packageName, in String message); void crashApplication(int uid, int initialPid, in String packageName, int userId, in String message); String getProviderMimeType(in Uri uri, int userId); IBinder newUriPermissionOwner(in String name); void grantUriPermissionFromOwner(in IBinder owner, int fromUid, in String targetPkg, Loading services/core/java/com/android/server/am/ActivityManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -4937,7 +4937,7 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override public void crashApplication(int uid, int initialPid, String packageName, public void crashApplication(int uid, int initialPid, String packageName, int userId, String message) { if (checkCallingPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) != PackageManager.PERMISSION_GRANTED) { Loading @@ -4950,7 +4950,7 @@ public class ActivityManagerService extends IActivityManager.Stub } synchronized(this) { mAppErrors.scheduleAppCrashLocked(uid, initialPid, packageName, message); mAppErrors.scheduleAppCrashLocked(uid, initialPid, packageName, userId, message); } } Loading services/core/java/com/android/server/am/ActivityManagerShellCommand.java +30 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,8 @@ final class ActivityManagerShellCommand extends ShellCommand { return runBugReport(pw); case "force-stop": return runForceStop(pw); case "crash": return runCrash(pw); case "kill": return runKill(pw); case "kill-all": Loading Loading @@ -851,6 +853,32 @@ final class ActivityManagerShellCommand extends ShellCommand { return 0; } int runCrash(PrintWriter pw) throws RemoteException { int userId = UserHandle.USER_ALL; String opt; while ((opt=getNextOption()) != null) { if (opt.equals("--user")) { userId = UserHandle.parseUserArg(getNextArgRequired()); } else { getErrPrintWriter().println("Error: Unknown option: " + opt); return -1; } } int pid = -1; String packageName = null; final String arg = getNextArgRequired(); // The argument is either a pid or a package name try { pid = Integer.parseInt(arg); } catch (NumberFormatException e) { packageName = arg; } mInterface.crashApplication(-1, pid, packageName, userId, "shell-induced crash"); return 0; } int runKill(PrintWriter pw) throws RemoteException { int userId = UserHandle.USER_ALL; Loading Loading @@ -2480,6 +2508,8 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" --telephony: will dump only telephony sections."); pw.println(" force-stop [--user <USER_ID> | all | current] <PACKAGE>"); pw.println(" Completely stop the given application package."); pw.println(" crash [--user <USER_ID>] <PACKAGE|PID>"); pw.println(" Induce a VM crash in the specified package or process"); pw.println(" kill [--user <USER_ID> | all | current] <PACKAGE>"); pw.println(" Kill all processes associated with the given application."); pw.println(" kill-all"); Loading services/core/java/com/android/server/am/AppErrors.java +15 −4 Original line number Diff line number Diff line Loading @@ -259,7 +259,16 @@ class AppErrors { } } void scheduleAppCrashLocked(int uid, int initialPid, String packageName, /** * Induce a crash in the given app. * * @param uid if nonnegative, the required matching uid of the target to crash * @param initialPid fast-path match for the target to crash * @param packageName fallback match if the stated pid is not found or doesn't match uid * @param userId If nonnegative, required to identify a match by package name * @param message */ void scheduleAppCrashLocked(int uid, int initialPid, String packageName, int userId, String message) { ProcessRecord proc = null; Loading @@ -270,14 +279,15 @@ class AppErrors { synchronized (mService.mPidsSelfLocked) { for (int i=0; i<mService.mPidsSelfLocked.size(); i++) { ProcessRecord p = mService.mPidsSelfLocked.valueAt(i); if (p.uid != uid) { if (uid >= 0 && p.uid != uid) { continue; } if (p.pid == initialPid) { proc = p; break; } if (p.pkgList.containsKey(packageName)) { if (p.pkgList.containsKey(packageName) && (userId < 0 || p.userId == userId)) { proc = p; } } Loading @@ -286,7 +296,8 @@ class AppErrors { if (proc == null) { Slog.w(TAG, "crashApplication: nothing for uid=" + uid + " initialPid=" + initialPid + " packageName=" + packageName); + " packageName=" + packageName + " userId=" + userId); return; } Loading services/core/java/com/android/server/am/ServiceRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -534,7 +534,7 @@ final class ServiceRecord extends Binder { // get to be foreground. ams.setServiceForeground(name, ServiceRecord.this, 0, null, 0); ams.crashApplication(appUid, appPid, localPackageName, ams.crashApplication(appUid, appPid, localPackageName, -1, "Bad notification for startForeground: " + e); } } Loading Loading
core/java/android/app/IActivityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -264,7 +264,7 @@ interface IActivityManager { boolean isImmersive(in IBinder token); void setImmersive(in IBinder token, boolean immersive); boolean isTopActivityImmersive(); void crashApplication(int uid, int initialPid, in String packageName, in String message); void crashApplication(int uid, int initialPid, in String packageName, int userId, in String message); String getProviderMimeType(in Uri uri, int userId); IBinder newUriPermissionOwner(in String name); void grantUriPermissionFromOwner(in IBinder owner, int fromUid, in String targetPkg, Loading
services/core/java/com/android/server/am/ActivityManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -4937,7 +4937,7 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override public void crashApplication(int uid, int initialPid, String packageName, public void crashApplication(int uid, int initialPid, String packageName, int userId, String message) { if (checkCallingPermission(android.Manifest.permission.FORCE_STOP_PACKAGES) != PackageManager.PERMISSION_GRANTED) { Loading @@ -4950,7 +4950,7 @@ public class ActivityManagerService extends IActivityManager.Stub } synchronized(this) { mAppErrors.scheduleAppCrashLocked(uid, initialPid, packageName, message); mAppErrors.scheduleAppCrashLocked(uid, initialPid, packageName, userId, message); } } Loading
services/core/java/com/android/server/am/ActivityManagerShellCommand.java +30 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,8 @@ final class ActivityManagerShellCommand extends ShellCommand { return runBugReport(pw); case "force-stop": return runForceStop(pw); case "crash": return runCrash(pw); case "kill": return runKill(pw); case "kill-all": Loading Loading @@ -851,6 +853,32 @@ final class ActivityManagerShellCommand extends ShellCommand { return 0; } int runCrash(PrintWriter pw) throws RemoteException { int userId = UserHandle.USER_ALL; String opt; while ((opt=getNextOption()) != null) { if (opt.equals("--user")) { userId = UserHandle.parseUserArg(getNextArgRequired()); } else { getErrPrintWriter().println("Error: Unknown option: " + opt); return -1; } } int pid = -1; String packageName = null; final String arg = getNextArgRequired(); // The argument is either a pid or a package name try { pid = Integer.parseInt(arg); } catch (NumberFormatException e) { packageName = arg; } mInterface.crashApplication(-1, pid, packageName, userId, "shell-induced crash"); return 0; } int runKill(PrintWriter pw) throws RemoteException { int userId = UserHandle.USER_ALL; Loading Loading @@ -2480,6 +2508,8 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" --telephony: will dump only telephony sections."); pw.println(" force-stop [--user <USER_ID> | all | current] <PACKAGE>"); pw.println(" Completely stop the given application package."); pw.println(" crash [--user <USER_ID>] <PACKAGE|PID>"); pw.println(" Induce a VM crash in the specified package or process"); pw.println(" kill [--user <USER_ID> | all | current] <PACKAGE>"); pw.println(" Kill all processes associated with the given application."); pw.println(" kill-all"); Loading
services/core/java/com/android/server/am/AppErrors.java +15 −4 Original line number Diff line number Diff line Loading @@ -259,7 +259,16 @@ class AppErrors { } } void scheduleAppCrashLocked(int uid, int initialPid, String packageName, /** * Induce a crash in the given app. * * @param uid if nonnegative, the required matching uid of the target to crash * @param initialPid fast-path match for the target to crash * @param packageName fallback match if the stated pid is not found or doesn't match uid * @param userId If nonnegative, required to identify a match by package name * @param message */ void scheduleAppCrashLocked(int uid, int initialPid, String packageName, int userId, String message) { ProcessRecord proc = null; Loading @@ -270,14 +279,15 @@ class AppErrors { synchronized (mService.mPidsSelfLocked) { for (int i=0; i<mService.mPidsSelfLocked.size(); i++) { ProcessRecord p = mService.mPidsSelfLocked.valueAt(i); if (p.uid != uid) { if (uid >= 0 && p.uid != uid) { continue; } if (p.pid == initialPid) { proc = p; break; } if (p.pkgList.containsKey(packageName)) { if (p.pkgList.containsKey(packageName) && (userId < 0 || p.userId == userId)) { proc = p; } } Loading @@ -286,7 +296,8 @@ class AppErrors { if (proc == null) { Slog.w(TAG, "crashApplication: nothing for uid=" + uid + " initialPid=" + initialPid + " packageName=" + packageName); + " packageName=" + packageName + " userId=" + userId); return; } Loading
services/core/java/com/android/server/am/ServiceRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -534,7 +534,7 @@ final class ServiceRecord extends Binder { // get to be foreground. ams.setServiceForeground(name, ServiceRecord.this, 0, null, 0); ams.crashApplication(appUid, appPid, localPackageName, ams.crashApplication(appUid, appPid, localPackageName, -1, "Bad notification for startForeground: " + e); } } Loading