use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class PackageManagerService method logCriticalInfo.
static void logCriticalInfo(int priority, String msg) {
Slog.println(priority, TAG, msg);
EventLogTags.writePmCriticalInfo(msg);
try {
File fname = getSettingsProblemFile();
FileOutputStream out = new FileOutputStream(fname, true);
PrintWriter pw = new FastPrintWriter(out);
SimpleDateFormat formatter = new SimpleDateFormat();
String dateString = formatter.format(new Date(System.currentTimeMillis()));
pw.println(dateString + ": " + msg);
pw.close();
FileUtils.setPermissions(fname.toString(), FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IROTH, -1, -1);
} catch (java.io.IOException e) {
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class ActiveServices method serviceTimeout.
void serviceTimeout(ProcessRecord proc) {
String anrMessage = null;
synchronized (mAm) {
if (proc.executingServices.size() == 0 || proc.thread == null) {
return;
}
final long now = SystemClock.uptimeMillis();
final long maxTime = now - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
ServiceRecord timeout = null;
long nextTime = 0;
for (int i = proc.executingServices.size() - 1; i >= 0; i--) {
ServiceRecord sr = proc.executingServices.valueAt(i);
if (sr.executingStart < maxTime) {
timeout = sr;
break;
}
if (sr.executingStart > nextTime) {
nextTime = sr.executingStart;
}
}
if (timeout != null && mAm.mLruProcesses.contains(proc)) {
Slog.w(TAG, "Timeout executing service: " + timeout);
StringWriter sw = new StringWriter();
PrintWriter pw = new FastPrintWriter(sw, false, 1024);
pw.println(timeout);
timeout.dump(pw, " ");
pw.close();
mLastAnrDump = sw.toString();
mAm.mHandler.removeCallbacks(mLastAnrDumpClearer);
mAm.mHandler.postDelayed(mLastAnrDumpClearer, LAST_ANR_LIFETIME_DURATION_MSECS);
anrMessage = "executing service " + timeout.shortName;
} else {
Message msg = mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
msg.obj = proc;
mAm.mHandler.sendMessageAtTime(msg, proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
}
}
if (anrMessage != null) {
mAm.mAppErrors.appNotResponding(proc, null, null, false, anrMessage);
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.
the class ActivityManagerService method stopBinderTrackingAndDump.
public boolean stopBinderTrackingAndDump(ParcelFileDescriptor fd) throws RemoteException {
try {
synchronized (this) {
mBinderTransactionTrackingEnabled = false;
// permission (same as profileControl).
if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER) != PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires permission " + android.Manifest.permission.SET_ACTIVITY_WATCHER);
}
if (fd == null) {
throw new IllegalArgumentException("null fd");
}
PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor()));
pw.println("Binder transaction traces for all processes.\n");
for (ProcessRecord process : mLruProcesses) {
if (!processSanityChecksLocked(process)) {
continue;
}
pw.println("Traces for process: " + process.processName);
pw.flush();
try {
TransferPipe tp = new TransferPipe();
try {
process.thread.stopBinderTrackingAndDump(tp.getWriteFd().getFileDescriptor());
tp.go(fd.getFileDescriptor());
} finally {
tp.kill();
}
} catch (IOException e) {
pw.println("Failure while dumping IPC traces from " + process + ". Exception: " + e);
pw.flush();
} catch (RemoteException e) {
pw.println("Got a RemoteException while dumping IPC traces from " + process + ". Exception: " + e);
pw.flush();
}
}
fd = null;
return true;
}
} finally {
if (fd != null) {
try {
fd.close();
} catch (IOException e) {
}
}
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by AOSPA.
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 AOSPA.
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);
}
}
}
Aggregations