use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class TransactionTracker method writeTracesToFile.
public void writeTracesToFile(ParcelFileDescriptor fd) {
if (mTraces.isEmpty()) {
return;
}
PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor()));
synchronized (this) {
for (String trace : mTraces.keySet()) {
pw.println("Count: " + mTraces.get(trace));
pw.println("Trace: " + trace);
pw.println();
}
}
pw.flush();
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class StrictMode method readAndHandleBinderCallViolations.
/**
* Called from Parcel.readException() when the exception is EX_STRICT_MODE_VIOLATIONS,
* we here read back all the encoded violations.
*/
/* package */
static void readAndHandleBinderCallViolations(Parcel p) {
// Our own stack trace to append
StringWriter sw = new StringWriter();
sw.append("# via Binder call with stack:\n");
PrintWriter pw = new FastPrintWriter(sw, false, 256);
new LogStackTrace().printStackTrace(pw);
pw.flush();
String ourStack = sw.toString();
final int policyMask = getThreadPolicyMask();
final boolean currentlyGathering = (policyMask & PENALTY_GATHER) != 0;
final int size = p.readInt();
for (int i = 0; i < size; i++) {
final ViolationInfo info = new ViolationInfo(p, !currentlyGathering);
info.crashInfo.appendStackTrace(ourStack);
BlockGuard.Policy policy = BlockGuard.getThreadPolicy();
if (policy instanceof AndroidBlockGuardPolicy) {
((AndroidBlockGuardPolicy) policy).handleViolationWithTimingAttempt(info);
}
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class BinderProxy method dumpAsync.
/**
* Like {@link #dump(FileDescriptor, String[])}, but ensures the target
* executes asynchronously.
*/
public void dumpAsync(final FileDescriptor fd, final String[] args) {
final FileOutputStream fout = new FileOutputStream(fd);
final PrintWriter pw = new FastPrintWriter(fout);
Thread thr = new Thread("Binder.dumpAsync") {
public void run() {
try {
dump(fd, pw, args);
} finally {
pw.flush();
}
}
};
thr.start();
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class ProcessCpuTracker method printCurrentLoad.
public final String printCurrentLoad() {
StringWriter sw = new StringWriter();
PrintWriter pw = new FastPrintWriter(sw, false, 128);
pw.print("Load: ");
pw.print(mLoad1);
pw.print(" / ");
pw.print(mLoad5);
pw.print(" / ");
pw.println(mLoad15);
pw.flush();
return sw.toString();
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class ProcessCpuTracker method printCurrentState.
public final String printCurrentState(long now) {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
buildWorkingProcs();
StringWriter sw = new StringWriter();
PrintWriter pw = new FastPrintWriter(sw, false, 1024);
pw.print("CPU usage from ");
if (now > mLastSampleTime) {
pw.print(now - mLastSampleTime);
pw.print("ms to ");
pw.print(now - mCurrentSampleTime);
pw.print("ms ago");
} else {
pw.print(mLastSampleTime - now);
pw.print("ms to ");
pw.print(mCurrentSampleTime - now);
pw.print("ms later");
}
pw.print(" (");
pw.print(sdf.format(new Date(mLastSampleWallTime)));
pw.print(" to ");
pw.print(sdf.format(new Date(mCurrentSampleWallTime)));
pw.print(")");
long sampleTime = mCurrentSampleTime - mLastSampleTime;
long sampleRealTime = mCurrentSampleRealTime - mLastSampleRealTime;
long percAwake = sampleRealTime > 0 ? ((sampleTime * 100) / sampleRealTime) : 0;
if (percAwake != 100) {
pw.print(" with ");
pw.print(percAwake);
pw.print("% awake");
}
pw.println(":");
final int totalTime = mRelUserTime + mRelSystemTime + mRelIoWaitTime + mRelIrqTime + mRelSoftIrqTime + mRelIdleTime;
if (DEBUG)
Slog.i(TAG, "totalTime " + totalTime + " over sample time " + (mCurrentSampleTime - mLastSampleTime));
int N = mWorkingProcs.size();
for (int i = 0; i < N; i++) {
Stats st = mWorkingProcs.get(i);
printProcessCPU(pw, st.added ? " +" : (st.removed ? " -" : " "), st.pid, st.name, (int) st.rel_uptime, st.rel_utime, st.rel_stime, 0, 0, 0, st.rel_minfaults, st.rel_majfaults);
if (!st.removed && st.workingThreads != null) {
int M = st.workingThreads.size();
for (int j = 0; j < M; j++) {
Stats tst = st.workingThreads.get(j);
printProcessCPU(pw, tst.added ? " +" : (tst.removed ? " -" : " "), tst.pid, tst.name, (int) st.rel_uptime, tst.rel_utime, tst.rel_stime, 0, 0, 0, 0, 0);
}
}
}
printProcessCPU(pw, "", -1, "TOTAL", totalTime, mRelUserTime, mRelSystemTime, mRelIoWaitTime, mRelIrqTime, mRelSoftIrqTime, 0, 0);
pw.flush();
return sw.toString();
}
Aggregations