use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class CompilerStats method write.
// I/O
// The encoding is simple:
//
// 1) The first line is a line consisting of the version header and the version number.
//
// 2) The rest of the file is package data.
// 2.1) A package is started by any line not starting with "-";
// 2.2) Any line starting with "-" is code path data. The format is:
// '-'{code-path}':'{compile-time}
public void write(Writer out) {
@SuppressWarnings("resource") FastPrintWriter fpw = new FastPrintWriter(out);
fpw.print(COMPILER_STATS_VERSION_HEADER);
fpw.println(COMPILER_STATS_VERSION);
synchronized (packageStats) {
for (PackageStats pkg : packageStats.values()) {
synchronized (pkg.compileTimePerCodePath) {
if (!pkg.compileTimePerCodePath.isEmpty()) {
fpw.println(pkg.getPackageName());
for (Map.Entry<String, Long> e : pkg.compileTimePerCodePath.entrySet()) {
fpw.println("-" + e.getKey() + ":" + e.getValue());
}
}
}
}
}
fpw.flush();
}
use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class WindowManagerService method saveANRStateLocked.
/**
* Saves information about the state of the window manager at
* the time an ANR occurred before anything else in the system changes
* in response.
*
* @param appWindowToken The application that ANR'd, may be null.
* @param windowState The window that ANR'd, may be null.
* @param reason The reason for the ANR, may be null.
*/
public void saveANRStateLocked(AppWindowToken appWindowToken, WindowState windowState, String reason) {
StringWriter sw = new StringWriter();
PrintWriter pw = new FastPrintWriter(sw, false, 1024);
pw.println(" ANR time: " + DateFormat.getInstance().format(new Date()));
if (appWindowToken != null) {
pw.println(" Application at fault: " + appWindowToken.stringName);
}
if (windowState != null) {
pw.println(" Window at fault: " + windowState.mAttrs.getTitle());
}
if (reason != null) {
pw.println(" Reason: " + reason);
}
pw.println();
dumpWindowsNoHeaderLocked(pw, true, null);
pw.println();
pw.println("Last ANR continued");
dumpDisplayContentsLocked(pw, true);
pw.close();
mLastANRState = sw.toString();
mH.removeMessages(H.RESET_ANR_MESSAGE);
mH.sendEmptyMessageDelayed(H.RESET_ANR_MESSAGE, LAST_ANR_LIFETIME_DURATION_MSECS);
}
use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
the class WindowManagerService method rebuildAppWindowListLocked.
private void rebuildAppWindowListLocked(final DisplayContent displayContent) {
final WindowList windows = displayContent.getWindowList();
int NW = windows.size();
int i;
int lastBelow = -1;
int numRemoved = 0;
if (mRebuildTmp.length < NW) {
mRebuildTmp = new WindowState[NW + 10];
}
// First remove all existing app windows.
i = 0;
while (i < NW) {
WindowState w = windows.get(i);
if (w.mAppToken != null) {
WindowState win = windows.remove(i);
win.mRebuilding = true;
mRebuildTmp[numRemoved] = win;
mWindowsChanged = true;
if (DEBUG_WINDOW_MOVEMENT)
Slog.v(TAG_WM, "Rebuild removing window: " + win);
NW--;
numRemoved++;
continue;
} else if (lastBelow == i - 1) {
if (w.mAttrs.type == TYPE_WALLPAPER) {
lastBelow = i;
}
}
i++;
}
// Keep whatever windows were below the app windows still below,
// by skipping them.
lastBelow++;
i = lastBelow;
// First add all of the exiting app tokens... these are no longer
// in the main app list, but still have windows shown. We put them
// in the back because now that the animation is over we no longer
// will care about them.
final ArrayList<TaskStack> stacks = displayContent.getStacks();
final int numStacks = stacks.size();
for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
AppTokenList exitingAppTokens = stacks.get(stackNdx).mExitingAppTokens;
int NT = exitingAppTokens.size();
for (int j = 0; j < NT; j++) {
i = reAddAppWindowsLocked(displayContent, i, exitingAppTokens.get(j));
}
}
// And add in the still active app tokens in Z order.
for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
final ArrayList<Task> tasks = stacks.get(stackNdx).getTasks();
final int numTasks = tasks.size();
for (int taskNdx = 0; taskNdx < numTasks; ++taskNdx) {
final AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
final int numTokens = tokens.size();
for (int tokenNdx = 0; tokenNdx < numTokens; ++tokenNdx) {
final AppWindowToken wtoken = tokens.get(tokenNdx);
if (wtoken.mIsExiting && !wtoken.waitingForReplacement()) {
continue;
}
i = reAddAppWindowsLocked(displayContent, i, wtoken);
}
}
}
i -= lastBelow;
if (i != numRemoved) {
displayContent.layoutNeeded = true;
Slog.w(TAG_WM, "On display=" + displayContent.getDisplayId() + " Rebuild removed " + numRemoved + " windows but added " + i + " rebuildAppWindowListLocked() " + " callers=" + Debug.getCallers(10));
for (i = 0; i < numRemoved; i++) {
WindowState ws = mRebuildTmp[i];
if (ws.mRebuilding) {
StringWriter sw = new StringWriter();
PrintWriter pw = new FastPrintWriter(sw, false, 1024);
ws.dump(pw, "", true);
pw.flush();
Slog.w(TAG_WM, "This window was lost: " + ws);
Slog.w(TAG_WM, sw.toString());
ws.mWinAnimator.destroySurfaceLocked();
}
}
Slog.w(TAG_WM, "Current app token list:");
dumpAppTokensLocked();
Slog.w(TAG_WM, "Final window list:");
dumpWindowsLocked();
}
Arrays.fill(mRebuildTmp, null);
}
Aggregations