Loading core/java/android/app/ActivityManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -244,4 +244,10 @@ public abstract class ActivityManagerInternal { public abstract void updateOomLevelsForDisplay(int displayId); public abstract boolean isActivityStartsLoggingEnabled(); public abstract void reportCurKeyguardUsageEvent(boolean keyguardShowing); /** Input dispatch timeout to a window, start the ANR process. */ public abstract long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason); public abstract boolean inputDispatchingTimedOut(Object proc, String activityShortComponentName, ApplicationInfo aInfo, String parentShortComponentName, Object parentProc, boolean aboveSystem, String reason); } services/core/java/com/android/server/Watchdog.java +1 −1 Original line number Diff line number Diff line Loading @@ -528,7 +528,7 @@ public class Watchdog extends Thread { Thread dropboxThread = new Thread("watchdogWriteToDropbox") { public void run() { mActivity.addErrorToDropBox( "watchdog", null, "system_server", null, null, "watchdog", null, "system_server", null, null, null, subject, null, stack, null); } }; Loading services/core/java/com/android/server/am/ActiveServices.java +2 −2 Original line number Diff line number Diff line Loading @@ -3641,7 +3641,7 @@ public final class ActiveServices { } if (anrMessage != null) { mAm.mAppErrors.appNotResponding(proc, null, null, false, anrMessage); proc.appNotResponding(null, null, null, null, false, anrMessage); } } Loading @@ -3666,7 +3666,7 @@ public final class ActiveServices { } if (app != null) { mAm.mAppErrors.appNotResponding(app, null, null, false, app.appNotResponding(null, null, null, null, false, "Context.startForegroundService() did not then call Service.startForeground(): " + r); } Loading services/core/java/com/android/server/am/ActivityManagerService.java +100 −17 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.am; import static android.Manifest.permission.CHANGE_CONFIGURATION; import static android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST; import static android.Manifest.permission.FILTER_EVENTS; import static android.Manifest.permission.INTERACT_ACROSS_USERS; import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL; import static android.Manifest.permission.MANAGE_ACTIVITY_STACKS; Loading Loading @@ -148,6 +149,7 @@ import static com.android.server.am.ActivityTaskManagerService.DUMP_LASTANR_TRAC import static com.android.server.am.ActivityTaskManagerService.DUMP_RECENTS_CMD; import static com.android.server.am.ActivityTaskManagerService.DUMP_RECENTS_SHORT_CMD; import static com.android.server.am.ActivityTaskManagerService.DUMP_STARTER_CMD; import static com.android.server.am.ActivityTaskManagerService.KEY_DISPATCHING_TIMEOUT_MS; import static com.android.server.am.MemoryStatUtil.hasMemcg; import static com.android.server.am.MemoryStatUtil.readCmdlineFromProcfs; import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem; Loading Loading @@ -8119,8 +8121,8 @@ public class ActivityManagerService extends IActivityManager.Stub mHandler.post(new Runnable() { @Override public void run() { mAppErrors.appNotResponding(host, null, null, false, "ContentProvider not responding"); host.appNotResponding( null, null, null, null, false, "ContentProvider not responding"); } }); } Loading Loading @@ -9790,7 +9792,8 @@ public class ActivityManagerService extends IActivityManager.Stub crashInfo.crashTag = crashInfo.crashTag + " " + relaunchReasonString; } addErrorToDropBox(eventType, r, processName, null, null, null, null, null, crashInfo); addErrorToDropBox( eventType, r, processName, null, null, null, null, null, null, crashInfo); mAppErrors.crashApplication(r, crashInfo); } Loading Loading @@ -9962,7 +9965,7 @@ public class ActivityManagerService extends IActivityManager.Stub StatsLog.write(StatsLog.WTF_OCCURRED, callingUid, tag, processName, callingPid); addErrorToDropBox("wtf", r, processName, null, null, tag, null, null, crashInfo); addErrorToDropBox("wtf", r, processName, null, null, null, tag, null, null, crashInfo); return r; } Loading Loading @@ -10061,17 +10064,18 @@ public class ActivityManagerService extends IActivityManager.Stub * Write a description of an error (crash, WTF, ANR) to the drop box. * @param eventType to include in the drop box tag ("crash", "wtf", etc.) * @param process which caused the error, null means the system server * @param activity which triggered the error, null if unknown * @param parent activity related to the error, null if unknown * @param activityShortComponentName which triggered the error, null if unknown * @param parentShortComponentName activity related to the error, null if unknown * @param parentProcess parent process * @param subject line related to the error, null if absent * @param report in long form describing the error, null if absent * @param dataFile text file to include in the report, null if none * @param crashInfo giving an application stack trace, null if absent */ public void addErrorToDropBox(String eventType, ProcessRecord process, String processName, ActivityRecord activity, ActivityRecord parent, String subject, final String report, final File dataFile, ProcessRecord process, String processName, String activityShortComponentName, String parentShortComponentName, ProcessRecord parentProcess, String subject, final String report, final File dataFile, final ApplicationErrorReport.CrashInfo crashInfo) { // NOTE -- this must never acquire the ActivityManagerService lock, // otherwise the watchdog may be prevented from resetting the system. Loading Loading @@ -10101,14 +10105,16 @@ public class ActivityManagerService extends IActivityManager.Stub .append(process.isInterestingToUserLocked() ? "Yes" : "No") .append("\n"); } if (activity != null) { sb.append("Activity: ").append(activity.shortComponentName).append("\n"); if (activityShortComponentName != null) { sb.append("Activity: ").append(activityShortComponentName).append("\n"); } if (parent != null && parent.app != null && parent.app.getPid() != process.pid) { sb.append("Parent-Process: ").append(parent.app.mName).append("\n"); if (parentShortComponentName != null) { if (parentProcess != null && parentProcess.pid != process.pid) { sb.append("Parent-Process: ").append(parentProcess.processName).append("\n"); } if (!parentShortComponentName.equals(activityShortComponentName)) { sb.append("Parent-Activity: ").append(parentShortComponentName).append("\n"); } if (parent != null && parent != activity) { sb.append("Parent-Activity: ").append(parent.shortComponentName).append("\n"); } if (subject != null) { sb.append("Subject: ").append(subject).append("\n"); Loading Loading @@ -13983,7 +13989,7 @@ public class ActivityManagerService extends IActivityManager.Stub dropBuilder.append(catSw.toString()); StatsLog.write(StatsLog.LOW_MEM_REPORTED); addErrorToDropBox("lowmem", null, "system_server", null, null, tag.toString(), dropBuilder.toString(), null, null); null, null, tag.toString(), dropBuilder.toString(), null, null); //Slog.i(TAG, "Sent to dropbox:"); //Slog.i(TAG, dropBuilder.toString()); synchronized (ActivityManagerService.this) { Loading Loading @@ -20295,6 +20301,83 @@ public class ActivityManagerService extends IActivityManager.Stub : UsageEvents.Event.KEYGUARD_HIDDEN); } } @Override public long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason) { synchronized (ActivityManagerService.this) { return ActivityManagerService.this.inputDispatchingTimedOut( pid, aboveSystem, reason); } } @Override public boolean inputDispatchingTimedOut(Object proc, String activityShortComponentName, ApplicationInfo aInfo, String parentShortComponentName, Object parentProc, boolean aboveSystem, String reason) { return ActivityManagerService.this.inputDispatchingTimedOut((ProcessRecord) proc, activityShortComponentName, aInfo, parentShortComponentName, (WindowProcessController) parentProc, aboveSystem, reason); } } long inputDispatchingTimedOut(int pid, final boolean aboveSystem, String reason) { if (checkCallingPermission(FILTER_EVENTS) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires permission " + FILTER_EVENTS); } ProcessRecord proc; long timeout; synchronized (this) { synchronized (mPidsSelfLocked) { proc = mPidsSelfLocked.get(pid); } timeout = proc != null ? proc.getInputDispatchingTimeout() : KEY_DISPATCHING_TIMEOUT_MS; } if (inputDispatchingTimedOut(proc, null, null, null, null, aboveSystem, reason)) { return -1; } return timeout; } /** * Handle input dispatching timeouts. * @return whether input dispatching should be aborted or not. */ boolean inputDispatchingTimedOut(ProcessRecord proc, String activityShortComponentName, ApplicationInfo aInfo, String parentShortComponentName, WindowProcessController parentProcess, boolean aboveSystem, String reason) { if (checkCallingPermission(FILTER_EVENTS) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires permission " + FILTER_EVENTS); } final String annotation; if (reason == null) { annotation = "Input dispatching timed out"; } else { annotation = "Input dispatching timed out (" + reason + ")"; } if (proc != null) { synchronized (this) { if (proc.isDebugging()) { return false; } if (proc.getActiveInstrumentation() != null) { Bundle info = new Bundle(); info.putString("shortMsg", "keyDispatchingTimedOut"); info.putString("longMsg", annotation); finishInstrumentationLocked(proc, Activity.RESULT_CANCELED, info); return true; } } proc.appNotResponding(activityShortComponentName, aInfo, parentShortComponentName, parentProcess, aboveSystem, annotation); } return true; } /** services/core/java/com/android/server/am/ActivityRecord.java +6 −2 Original line number Diff line number Diff line Loading @@ -2114,12 +2114,16 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo windowFromSameProcessAsActivity = !hasProcess() || app.getPid() == windowPid || windowPid == -1; } if (windowFromSameProcessAsActivity) { return service.inputDispatchingTimedOut(anrApp, anrActivity, this, false, reason); return service.mAmInternal.inputDispatchingTimedOut(anrApp.mOwner, anrActivity.shortComponentName, anrActivity.appInfo, shortComponentName, app, false, reason); } else { // In this case another process added windows using this activity token. So, we call the // generic service input dispatch timed out method so that the right process is blamed. return service.inputDispatchingTimedOut(windowPid, false /* aboveSystem */, reason) < 0; return service.mAmInternal.inputDispatchingTimedOut( windowPid, false /* aboveSystem */, reason) < 0; } } Loading Loading
core/java/android/app/ActivityManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -244,4 +244,10 @@ public abstract class ActivityManagerInternal { public abstract void updateOomLevelsForDisplay(int displayId); public abstract boolean isActivityStartsLoggingEnabled(); public abstract void reportCurKeyguardUsageEvent(boolean keyguardShowing); /** Input dispatch timeout to a window, start the ANR process. */ public abstract long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason); public abstract boolean inputDispatchingTimedOut(Object proc, String activityShortComponentName, ApplicationInfo aInfo, String parentShortComponentName, Object parentProc, boolean aboveSystem, String reason); }
services/core/java/com/android/server/Watchdog.java +1 −1 Original line number Diff line number Diff line Loading @@ -528,7 +528,7 @@ public class Watchdog extends Thread { Thread dropboxThread = new Thread("watchdogWriteToDropbox") { public void run() { mActivity.addErrorToDropBox( "watchdog", null, "system_server", null, null, "watchdog", null, "system_server", null, null, null, subject, null, stack, null); } }; Loading
services/core/java/com/android/server/am/ActiveServices.java +2 −2 Original line number Diff line number Diff line Loading @@ -3641,7 +3641,7 @@ public final class ActiveServices { } if (anrMessage != null) { mAm.mAppErrors.appNotResponding(proc, null, null, false, anrMessage); proc.appNotResponding(null, null, null, null, false, anrMessage); } } Loading @@ -3666,7 +3666,7 @@ public final class ActiveServices { } if (app != null) { mAm.mAppErrors.appNotResponding(app, null, null, false, app.appNotResponding(null, null, null, null, false, "Context.startForegroundService() did not then call Service.startForeground(): " + r); } Loading
services/core/java/com/android/server/am/ActivityManagerService.java +100 −17 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.am; import static android.Manifest.permission.CHANGE_CONFIGURATION; import static android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST; import static android.Manifest.permission.FILTER_EVENTS; import static android.Manifest.permission.INTERACT_ACROSS_USERS; import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL; import static android.Manifest.permission.MANAGE_ACTIVITY_STACKS; Loading Loading @@ -148,6 +149,7 @@ import static com.android.server.am.ActivityTaskManagerService.DUMP_LASTANR_TRAC import static com.android.server.am.ActivityTaskManagerService.DUMP_RECENTS_CMD; import static com.android.server.am.ActivityTaskManagerService.DUMP_RECENTS_SHORT_CMD; import static com.android.server.am.ActivityTaskManagerService.DUMP_STARTER_CMD; import static com.android.server.am.ActivityTaskManagerService.KEY_DISPATCHING_TIMEOUT_MS; import static com.android.server.am.MemoryStatUtil.hasMemcg; import static com.android.server.am.MemoryStatUtil.readCmdlineFromProcfs; import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem; Loading Loading @@ -8119,8 +8121,8 @@ public class ActivityManagerService extends IActivityManager.Stub mHandler.post(new Runnable() { @Override public void run() { mAppErrors.appNotResponding(host, null, null, false, "ContentProvider not responding"); host.appNotResponding( null, null, null, null, false, "ContentProvider not responding"); } }); } Loading Loading @@ -9790,7 +9792,8 @@ public class ActivityManagerService extends IActivityManager.Stub crashInfo.crashTag = crashInfo.crashTag + " " + relaunchReasonString; } addErrorToDropBox(eventType, r, processName, null, null, null, null, null, crashInfo); addErrorToDropBox( eventType, r, processName, null, null, null, null, null, null, crashInfo); mAppErrors.crashApplication(r, crashInfo); } Loading Loading @@ -9962,7 +9965,7 @@ public class ActivityManagerService extends IActivityManager.Stub StatsLog.write(StatsLog.WTF_OCCURRED, callingUid, tag, processName, callingPid); addErrorToDropBox("wtf", r, processName, null, null, tag, null, null, crashInfo); addErrorToDropBox("wtf", r, processName, null, null, null, tag, null, null, crashInfo); return r; } Loading Loading @@ -10061,17 +10064,18 @@ public class ActivityManagerService extends IActivityManager.Stub * Write a description of an error (crash, WTF, ANR) to the drop box. * @param eventType to include in the drop box tag ("crash", "wtf", etc.) * @param process which caused the error, null means the system server * @param activity which triggered the error, null if unknown * @param parent activity related to the error, null if unknown * @param activityShortComponentName which triggered the error, null if unknown * @param parentShortComponentName activity related to the error, null if unknown * @param parentProcess parent process * @param subject line related to the error, null if absent * @param report in long form describing the error, null if absent * @param dataFile text file to include in the report, null if none * @param crashInfo giving an application stack trace, null if absent */ public void addErrorToDropBox(String eventType, ProcessRecord process, String processName, ActivityRecord activity, ActivityRecord parent, String subject, final String report, final File dataFile, ProcessRecord process, String processName, String activityShortComponentName, String parentShortComponentName, ProcessRecord parentProcess, String subject, final String report, final File dataFile, final ApplicationErrorReport.CrashInfo crashInfo) { // NOTE -- this must never acquire the ActivityManagerService lock, // otherwise the watchdog may be prevented from resetting the system. Loading Loading @@ -10101,14 +10105,16 @@ public class ActivityManagerService extends IActivityManager.Stub .append(process.isInterestingToUserLocked() ? "Yes" : "No") .append("\n"); } if (activity != null) { sb.append("Activity: ").append(activity.shortComponentName).append("\n"); if (activityShortComponentName != null) { sb.append("Activity: ").append(activityShortComponentName).append("\n"); } if (parent != null && parent.app != null && parent.app.getPid() != process.pid) { sb.append("Parent-Process: ").append(parent.app.mName).append("\n"); if (parentShortComponentName != null) { if (parentProcess != null && parentProcess.pid != process.pid) { sb.append("Parent-Process: ").append(parentProcess.processName).append("\n"); } if (!parentShortComponentName.equals(activityShortComponentName)) { sb.append("Parent-Activity: ").append(parentShortComponentName).append("\n"); } if (parent != null && parent != activity) { sb.append("Parent-Activity: ").append(parent.shortComponentName).append("\n"); } if (subject != null) { sb.append("Subject: ").append(subject).append("\n"); Loading Loading @@ -13983,7 +13989,7 @@ public class ActivityManagerService extends IActivityManager.Stub dropBuilder.append(catSw.toString()); StatsLog.write(StatsLog.LOW_MEM_REPORTED); addErrorToDropBox("lowmem", null, "system_server", null, null, tag.toString(), dropBuilder.toString(), null, null); null, null, tag.toString(), dropBuilder.toString(), null, null); //Slog.i(TAG, "Sent to dropbox:"); //Slog.i(TAG, dropBuilder.toString()); synchronized (ActivityManagerService.this) { Loading Loading @@ -20295,6 +20301,83 @@ public class ActivityManagerService extends IActivityManager.Stub : UsageEvents.Event.KEYGUARD_HIDDEN); } } @Override public long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason) { synchronized (ActivityManagerService.this) { return ActivityManagerService.this.inputDispatchingTimedOut( pid, aboveSystem, reason); } } @Override public boolean inputDispatchingTimedOut(Object proc, String activityShortComponentName, ApplicationInfo aInfo, String parentShortComponentName, Object parentProc, boolean aboveSystem, String reason) { return ActivityManagerService.this.inputDispatchingTimedOut((ProcessRecord) proc, activityShortComponentName, aInfo, parentShortComponentName, (WindowProcessController) parentProc, aboveSystem, reason); } } long inputDispatchingTimedOut(int pid, final boolean aboveSystem, String reason) { if (checkCallingPermission(FILTER_EVENTS) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires permission " + FILTER_EVENTS); } ProcessRecord proc; long timeout; synchronized (this) { synchronized (mPidsSelfLocked) { proc = mPidsSelfLocked.get(pid); } timeout = proc != null ? proc.getInputDispatchingTimeout() : KEY_DISPATCHING_TIMEOUT_MS; } if (inputDispatchingTimedOut(proc, null, null, null, null, aboveSystem, reason)) { return -1; } return timeout; } /** * Handle input dispatching timeouts. * @return whether input dispatching should be aborted or not. */ boolean inputDispatchingTimedOut(ProcessRecord proc, String activityShortComponentName, ApplicationInfo aInfo, String parentShortComponentName, WindowProcessController parentProcess, boolean aboveSystem, String reason) { if (checkCallingPermission(FILTER_EVENTS) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires permission " + FILTER_EVENTS); } final String annotation; if (reason == null) { annotation = "Input dispatching timed out"; } else { annotation = "Input dispatching timed out (" + reason + ")"; } if (proc != null) { synchronized (this) { if (proc.isDebugging()) { return false; } if (proc.getActiveInstrumentation() != null) { Bundle info = new Bundle(); info.putString("shortMsg", "keyDispatchingTimedOut"); info.putString("longMsg", annotation); finishInstrumentationLocked(proc, Activity.RESULT_CANCELED, info); return true; } } proc.appNotResponding(activityShortComponentName, aInfo, parentShortComponentName, parentProcess, aboveSystem, annotation); } return true; } /**
services/core/java/com/android/server/am/ActivityRecord.java +6 −2 Original line number Diff line number Diff line Loading @@ -2114,12 +2114,16 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo windowFromSameProcessAsActivity = !hasProcess() || app.getPid() == windowPid || windowPid == -1; } if (windowFromSameProcessAsActivity) { return service.inputDispatchingTimedOut(anrApp, anrActivity, this, false, reason); return service.mAmInternal.inputDispatchingTimedOut(anrApp.mOwner, anrActivity.shortComponentName, anrActivity.appInfo, shortComponentName, app, false, reason); } else { // In this case another process added windows using this activity token. So, we call the // generic service input dispatch timed out method so that the right process is blamed. return service.inputDispatchingTimedOut(windowPid, false /* aboveSystem */, reason) < 0; return service.mAmInternal.inputDispatchingTimedOut( windowPid, false /* aboveSystem */, reason) < 0; } } Loading