Loading services/java/com/android/server/am/ActivityManagerService.java +77 −48 Original line number Diff line number Diff line Loading @@ -4757,19 +4757,32 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return tracesFile; } final void appNotRespondingLocked(ProcessRecord app, HistoryRecord activity, final void appNotResponding(ProcessRecord app, HistoryRecord activity, HistoryRecord parent, final String annotation) { ArrayList<Integer> pids = new ArrayList<Integer>(20); synchronized (this) { // PowerManager.reboot() can block for a long time, so ignore ANRs while shutting down. if (mShuttingDown || app.notResponding || app.crashing) { if (mShuttingDown) { Slog.i(TAG, "During shutdown skipping ANR: " + app + " " + annotation); return; } else if (app.notResponding) { Slog.i(TAG, "Skipping duplicate ANR: " + app + " " + annotation); return; } else if (app.crashing) { Slog.i(TAG, "Crashing app skipping ANR: " + app + " " + annotation); return; } // In case we come through here for the same app before completing // this one, mark as anring now so we will bail out. app.notResponding = true; // Log the ANR to the event log. EventLog.writeEvent(EventLogTags.AM_ANR, app.pid, app.processName, app.info.flags, annotation); // Dump thread traces as quickly as we can, starting with "interesting" processes. ArrayList<Integer> pids = new ArrayList<Integer>(20); pids.add(app.pid); int parentPid = app.pid; Loading @@ -4785,6 +4798,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (pid > 0 && pid != app.pid && pid != parentPid && pid != MY_PID) pids.add(pid); } } } File tracesFile = dumpStackTraces(pids); Loading @@ -4806,7 +4820,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen String cpuInfo = null; if (MONITOR_CPU_USAGE) { updateCpuStatsNow(); synchronized (mProcessStatsThread) { cpuInfo = mProcessStats.printCurrentState(); } synchronized (mProcessStatsThread) { cpuInfo = mProcessStats.printCurrentState(); } info.append(cpuInfo); } Loading Loading @@ -4834,6 +4850,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // Unless configured otherwise, swallow ANRs in background processes & kill the process. boolean showBackground = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0; synchronized (this) { if (!showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID) { Process.killProcess(app.pid); return; Loading @@ -4856,7 +4874,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } mHandler.sendMessage(msg); return; } } private final void decPersistentCountLocked(ProcessRecord app) Loading Loading @@ -11855,6 +11873,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } void serviceTimeout(ProcessRecord proc) { String anrMessage = null; synchronized(this) { if (proc.executingServices.size() == 0 || proc.thread == null) { return; Loading @@ -11875,13 +11895,17 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (timeout != null && mLruProcesses.contains(proc)) { Slog.w(TAG, "Timeout executing service: " + timeout); appNotRespondingLocked(proc, null, null, "Executing service " + timeout.shortName); anrMessage = "Executing service " + timeout.shortName; } else { Message msg = mHandler.obtainMessage(SERVICE_TIMEOUT_MSG); msg.obj = proc; mHandler.sendMessageAtTime(msg, nextTime+SERVICE_TIMEOUT); } } if (anrMessage != null) { appNotResponding(proc, null, null, anrMessage); } } // ========================================================= Loading Loading @@ -12680,6 +12704,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } private final void broadcastTimeout() { ProcessRecord app = null; String anrMessage = null; synchronized (this) { if (mOrderedBroadcasts.size() == 0) { return; Loading @@ -12705,8 +12732,6 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return; } ProcessRecord app = null; Object curReceiver = r.receivers.get(r.nextReceiver-1); Slog.w(TAG, "Receiver during timeout: " + curReceiver); logBroadcastReceiverDiscard(r); Loading @@ -12724,7 +12749,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (app != null) { appNotRespondingLocked(app, null, null, "Broadcast of " + r.intent.toString()); anrMessage = "Broadcast of " + r.intent.toString(); } if (mPendingBroadcast == r) { Loading @@ -12736,6 +12761,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen r.resultExtras, r.resultAbort, true); scheduleBroadcastsLocked(); } if (anrMessage != null) { appNotResponding(app, null, null, anrMessage); } } private final void processCurBroadcastLocked(BroadcastRecord r, Loading services/java/com/android/server/am/HistoryRecord.java +11 −4 Original line number Diff line number Diff line Loading @@ -458,8 +458,10 @@ class HistoryRecord extends IApplicationToken.Stub { } public boolean keyDispatchingTimedOut() { HistoryRecord r; ProcessRecord anrApp = null; synchronized(service) { HistoryRecord r = getWaitingHistoryRecordLocked(); r = getWaitingHistoryRecordLocked(); if (r != null && r.app != null) { if (r.app.debugging) { return false; Loading @@ -472,8 +474,7 @@ class HistoryRecord extends IApplicationToken.Stub { } if (r.app.instrumentationClass == null) { service.appNotRespondingLocked(r.app, r, this, "keyDispatchingTimedOut"); anrApp = r.app; } else { Bundle info = new Bundle(); info.putString("shortMsg", "keyDispatchingTimedOut"); Loading @@ -482,8 +483,14 @@ class HistoryRecord extends IApplicationToken.Stub { r.app, Activity.RESULT_CANCELED, info); } } return true; } if (anrApp != null) { service.appNotResponding(anrApp, r, this, "keyDispatchingTimedOut"); } return true; } /** Returns the key dispatching timeout for this application token. */ Loading Loading
services/java/com/android/server/am/ActivityManagerService.java +77 −48 Original line number Diff line number Diff line Loading @@ -4757,19 +4757,32 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return tracesFile; } final void appNotRespondingLocked(ProcessRecord app, HistoryRecord activity, final void appNotResponding(ProcessRecord app, HistoryRecord activity, HistoryRecord parent, final String annotation) { ArrayList<Integer> pids = new ArrayList<Integer>(20); synchronized (this) { // PowerManager.reboot() can block for a long time, so ignore ANRs while shutting down. if (mShuttingDown || app.notResponding || app.crashing) { if (mShuttingDown) { Slog.i(TAG, "During shutdown skipping ANR: " + app + " " + annotation); return; } else if (app.notResponding) { Slog.i(TAG, "Skipping duplicate ANR: " + app + " " + annotation); return; } else if (app.crashing) { Slog.i(TAG, "Crashing app skipping ANR: " + app + " " + annotation); return; } // In case we come through here for the same app before completing // this one, mark as anring now so we will bail out. app.notResponding = true; // Log the ANR to the event log. EventLog.writeEvent(EventLogTags.AM_ANR, app.pid, app.processName, app.info.flags, annotation); // Dump thread traces as quickly as we can, starting with "interesting" processes. ArrayList<Integer> pids = new ArrayList<Integer>(20); pids.add(app.pid); int parentPid = app.pid; Loading @@ -4785,6 +4798,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (pid > 0 && pid != app.pid && pid != parentPid && pid != MY_PID) pids.add(pid); } } } File tracesFile = dumpStackTraces(pids); Loading @@ -4806,7 +4820,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen String cpuInfo = null; if (MONITOR_CPU_USAGE) { updateCpuStatsNow(); synchronized (mProcessStatsThread) { cpuInfo = mProcessStats.printCurrentState(); } synchronized (mProcessStatsThread) { cpuInfo = mProcessStats.printCurrentState(); } info.append(cpuInfo); } Loading Loading @@ -4834,6 +4850,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // Unless configured otherwise, swallow ANRs in background processes & kill the process. boolean showBackground = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0; synchronized (this) { if (!showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID) { Process.killProcess(app.pid); return; Loading @@ -4856,7 +4874,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } mHandler.sendMessage(msg); return; } } private final void decPersistentCountLocked(ProcessRecord app) Loading Loading @@ -11855,6 +11873,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } void serviceTimeout(ProcessRecord proc) { String anrMessage = null; synchronized(this) { if (proc.executingServices.size() == 0 || proc.thread == null) { return; Loading @@ -11875,13 +11895,17 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (timeout != null && mLruProcesses.contains(proc)) { Slog.w(TAG, "Timeout executing service: " + timeout); appNotRespondingLocked(proc, null, null, "Executing service " + timeout.shortName); anrMessage = "Executing service " + timeout.shortName; } else { Message msg = mHandler.obtainMessage(SERVICE_TIMEOUT_MSG); msg.obj = proc; mHandler.sendMessageAtTime(msg, nextTime+SERVICE_TIMEOUT); } } if (anrMessage != null) { appNotResponding(proc, null, null, anrMessage); } } // ========================================================= Loading Loading @@ -12680,6 +12704,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } private final void broadcastTimeout() { ProcessRecord app = null; String anrMessage = null; synchronized (this) { if (mOrderedBroadcasts.size() == 0) { return; Loading @@ -12705,8 +12732,6 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return; } ProcessRecord app = null; Object curReceiver = r.receivers.get(r.nextReceiver-1); Slog.w(TAG, "Receiver during timeout: " + curReceiver); logBroadcastReceiverDiscard(r); Loading @@ -12724,7 +12749,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (app != null) { appNotRespondingLocked(app, null, null, "Broadcast of " + r.intent.toString()); anrMessage = "Broadcast of " + r.intent.toString(); } if (mPendingBroadcast == r) { Loading @@ -12736,6 +12761,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen r.resultExtras, r.resultAbort, true); scheduleBroadcastsLocked(); } if (anrMessage != null) { appNotResponding(app, null, null, anrMessage); } } private final void processCurBroadcastLocked(BroadcastRecord r, Loading
services/java/com/android/server/am/HistoryRecord.java +11 −4 Original line number Diff line number Diff line Loading @@ -458,8 +458,10 @@ class HistoryRecord extends IApplicationToken.Stub { } public boolean keyDispatchingTimedOut() { HistoryRecord r; ProcessRecord anrApp = null; synchronized(service) { HistoryRecord r = getWaitingHistoryRecordLocked(); r = getWaitingHistoryRecordLocked(); if (r != null && r.app != null) { if (r.app.debugging) { return false; Loading @@ -472,8 +474,7 @@ class HistoryRecord extends IApplicationToken.Stub { } if (r.app.instrumentationClass == null) { service.appNotRespondingLocked(r.app, r, this, "keyDispatchingTimedOut"); anrApp = r.app; } else { Bundle info = new Bundle(); info.putString("shortMsg", "keyDispatchingTimedOut"); Loading @@ -482,8 +483,14 @@ class HistoryRecord extends IApplicationToken.Stub { r.app, Activity.RESULT_CANCELED, info); } } return true; } if (anrApp != null) { service.appNotResponding(anrApp, r, this, "keyDispatchingTimedOut"); } return true; } /** Returns the key dispatching timeout for this application token. */ Loading