Merge "Fix issue #19020826: Including timing issues in ANR reason breaks clustering" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
66f8d9bb69
@@ -19,6 +19,7 @@ package com.android.server.am;
|
|||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -34,6 +35,7 @@ import android.util.ArraySet;
|
|||||||
import com.android.internal.app.ProcessStats;
|
import com.android.internal.app.ProcessStats;
|
||||||
import com.android.internal.os.BatteryStatsImpl;
|
import com.android.internal.os.BatteryStatsImpl;
|
||||||
import com.android.internal.os.TransferPipe;
|
import com.android.internal.os.TransferPipe;
|
||||||
|
import com.android.internal.util.FastPrintWriter;
|
||||||
import com.android.server.am.ActivityManagerService.ItemMatcher;
|
import com.android.server.am.ActivityManagerService.ItemMatcher;
|
||||||
import com.android.server.am.ActivityManagerService.NeededUriGrants;
|
import com.android.server.am.ActivityManagerService.NeededUriGrants;
|
||||||
|
|
||||||
@@ -141,6 +143,19 @@ public final class ActiveServices {
|
|||||||
final ArrayList<ServiceRecord> mDestroyingServices
|
final ArrayList<ServiceRecord> mDestroyingServices
|
||||||
= new ArrayList<ServiceRecord>();
|
= new ArrayList<ServiceRecord>();
|
||||||
|
|
||||||
|
/** Amount of time to allow a last ANR message to exist before freeing the memory. */
|
||||||
|
static final int LAST_ANR_LIFETIME_DURATION_MSECS = 2 * 60 * 60 * 1000; // Two hours
|
||||||
|
|
||||||
|
String mLastAnrDump;
|
||||||
|
|
||||||
|
final Runnable mLastAnrDumpClearer = new Runnable() {
|
||||||
|
@Override public void run() {
|
||||||
|
synchronized (mAm) {
|
||||||
|
mLastAnrDump = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static final class DelayingProcess extends ArrayList<ServiceRecord> {
|
static final class DelayingProcess extends ArrayList<ServiceRecord> {
|
||||||
long timeoout;
|
long timeoout;
|
||||||
}
|
}
|
||||||
@@ -2390,23 +2405,15 @@ public final class ActiveServices {
|
|||||||
}
|
}
|
||||||
if (timeout != null && mAm.mLruProcesses.contains(proc)) {
|
if (timeout != null && mAm.mLruProcesses.contains(proc)) {
|
||||||
Slog.w(TAG, "Timeout executing service: " + timeout);
|
Slog.w(TAG, "Timeout executing service: " + timeout);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringWriter sw = new StringWriter();
|
||||||
sb.append("sxecuting service ");
|
PrintWriter pw = new FastPrintWriter(sw, false, 1024);
|
||||||
sb.append(timeout.shortName);
|
pw.println(timeout);
|
||||||
sb.append(" (execStart=");
|
timeout.dump(pw, " ");
|
||||||
TimeUtils.formatDuration(timeout.executingStart - now, sb);
|
pw.close();
|
||||||
sb.append(", nesting=");
|
mLastAnrDump = sw.toString();
|
||||||
sb.append(timeout.executeNesting);
|
mAm.mHandler.removeCallbacks(mLastAnrDumpClearer);
|
||||||
sb.append(", destroyed=");
|
mAm.mHandler.postDelayed(mLastAnrDumpClearer, LAST_ANR_LIFETIME_DURATION_MSECS);
|
||||||
TimeUtils.formatDuration(timeout.destroyTime - now, sb);
|
anrMessage = "executing service " + timeout.shortName;
|
||||||
sb.append(", fg=");
|
|
||||||
sb.append(proc.execServicesFg);
|
|
||||||
sb.append(", create=");
|
|
||||||
TimeUtils.formatDuration(timeout.createTime - now, sb);
|
|
||||||
sb.append(", proc=");
|
|
||||||
sb.append(timeout.app != null ? timeout.app.toShortString() : "null");
|
|
||||||
sb.append(")");
|
|
||||||
anrMessage = sb.toString();
|
|
||||||
} else {
|
} else {
|
||||||
Message msg = mAm.mHandler.obtainMessage(
|
Message msg = mAm.mHandler.obtainMessage(
|
||||||
ActivityManagerService.SERVICE_TIMEOUT_MSG);
|
ActivityManagerService.SERVICE_TIMEOUT_MSG);
|
||||||
@@ -2446,6 +2453,11 @@ public final class ActiveServices {
|
|||||||
|
|
||||||
pw.println("ACTIVITY MANAGER SERVICES (dumpsys activity services)");
|
pw.println("ACTIVITY MANAGER SERVICES (dumpsys activity services)");
|
||||||
try {
|
try {
|
||||||
|
if (mLastAnrDump != null) {
|
||||||
|
pw.println(" Last ANR service:");
|
||||||
|
pw.print(mLastAnrDump);
|
||||||
|
pw.println();
|
||||||
|
}
|
||||||
int[] users = mAm.getUsersLocked();
|
int[] users = mAm.getUsersLocked();
|
||||||
for (int user : users) {
|
for (int user : users) {
|
||||||
ServiceMap smap = getServiceMap(user);
|
ServiceMap smap = getServiceMap(user);
|
||||||
|
|||||||
Reference in New Issue
Block a user