Search in sources :

Example 26 with FastPrintWriter

use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.

the class BackStackRecord method commitInternal.

int commitInternal(boolean allowStateLoss) {
    if (mCommitted) {
        throw new IllegalStateException("commit already called");
    }
    if (FragmentManagerImpl.DEBUG) {
        Log.v(TAG, "Commit: " + this);
        LogWriter logw = new LogWriter(Log.VERBOSE, TAG);
        PrintWriter pw = new FastPrintWriter(logw, false, 1024);
        dump("  ", null, pw, null);
        pw.flush();
    }
    mCommitted = true;
    if (mAddToBackStack) {
        mIndex = mManager.allocBackStackIndex(this);
    } else {
        mIndex = -1;
    }
    mManager.enqueueAction(this, allowStateLoss);
    return mIndex;
}
Also used : LogWriter(android.util.LogWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter)

Example 27 with FastPrintWriter

use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.

the class WindowLeaked method dumpGfxInfo.

public void dumpGfxInfo(FileDescriptor fd, String[] args) {
    FileOutputStream fout = new FileOutputStream(fd);
    PrintWriter pw = new FastPrintWriter(fout);
    try {
        synchronized (mLock) {
            final int count = mViews.size();
            pw.println("Profile data in ms:");
            for (int i = 0; i < count; i++) {
                ViewRootImpl root = mRoots.get(i);
                String name = getWindowName(root);
                pw.printf("\n\t%s (visibility=%d)", name, root.getHostVisibility());
                ThreadedRenderer renderer = root.getView().mAttachInfo.mHardwareRenderer;
                if (renderer != null) {
                    renderer.dumpGfxInfo(pw, fd, args);
                }
            }
            pw.println("\nView hierarchy:\n");
            int viewsCount = 0;
            int displayListsSize = 0;
            int[] info = new int[2];
            for (int i = 0; i < count; i++) {
                ViewRootImpl root = mRoots.get(i);
                root.dumpGfxInfo(info);
                String name = getWindowName(root);
                pw.printf("  %s\n  %d views, %.2f kB of display lists", name, info[0], info[1] / 1024.0f);
                pw.printf("\n\n");
                viewsCount += info[0];
                displayListsSize += info[1];
            }
            pw.printf("\nTotal ViewRootImpl: %d\n", count);
            pw.printf("Total Views:        %d\n", viewsCount);
            pw.printf("Total DisplayList:  %.2f kB\n\n", displayListsSize / 1024.0f);
        }
    } finally {
        pw.flush();
    }
}
Also used : FastPrintWriter(com.android.internal.util.FastPrintWriter) FileOutputStream(java.io.FileOutputStream) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter)

Example 28 with FastPrintWriter

use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.

the class ActivityManager method dumpPackageStateStatic.

/**
     * @hide
     */
public static void dumpPackageStateStatic(FileDescriptor fd, String packageName) {
    FileOutputStream fout = new FileOutputStream(fd);
    PrintWriter pw = new FastPrintWriter(fout);
    dumpService(pw, fd, "package", new String[] { packageName });
    pw.println();
    dumpService(pw, fd, Context.ACTIVITY_SERVICE, new String[] { "-a", "package", packageName });
    pw.println();
    dumpService(pw, fd, "meminfo", new String[] { "--local", "--package", packageName });
    pw.println();
    dumpService(pw, fd, ProcessStats.SERVICE_NAME, new String[] { packageName });
    pw.println();
    dumpService(pw, fd, "usagestats", new String[] { "--packages", packageName });
    pw.println();
    dumpService(pw, fd, BatteryStats.SERVICE_NAME, new String[] { packageName });
    pw.flush();
}
Also used : FastPrintWriter(com.android.internal.util.FastPrintWriter) FileOutputStream(java.io.FileOutputStream) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter)

Example 29 with FastPrintWriter

use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.

the class ActivityThread method handleDumpProvider.

private void handleDumpProvider(DumpComponentInfo info) {
    final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
    try {
        ProviderClientRecord r = mLocalProviders.get(info.token);
        if (r != null && r.mLocalProvider != null) {
            PrintWriter pw = new FastPrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
            r.mLocalProvider.dump(info.fd.getFileDescriptor(), pw, info.args);
            pw.flush();
        }
    } finally {
        IoUtils.closeQuietly(info.fd);
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
Also used : StrictMode(android.os.StrictMode) FastPrintWriter(com.android.internal.util.FastPrintWriter) FileOutputStream(java.io.FileOutputStream) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter)

Example 30 with FastPrintWriter

use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by DirtyUnicorns.

the class Log method getStackTraceString.

/**
     * Handy function to get a loggable stack trace from a Throwable
     * @param tr An exception to log
     */
public static String getStackTraceString(Throwable tr) {
    if (tr == null) {
        return "";
    }
    // This is to reduce the amount of log spew that apps do in the non-error
    // condition of the network being unavailable.
    Throwable t = tr;
    while (t != null) {
        if (t instanceof UnknownHostException) {
            return "";
        }
        t = t.getCause();
    }
    StringWriter sw = new StringWriter();
    PrintWriter pw = new FastPrintWriter(sw, false, 256);
    tr.printStackTrace(pw);
    pw.flush();
    return sw.toString();
}
Also used : UnknownHostException(java.net.UnknownHostException) StringWriter(java.io.StringWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter)

Aggregations

FastPrintWriter (com.android.internal.util.FastPrintWriter)128 PrintWriter (java.io.PrintWriter)122 FileOutputStream (java.io.FileOutputStream)61 StringWriter (java.io.StringWriter)34 LogWriter (android.util.LogWriter)24 StrictMode (android.os.StrictMode)17 IOException (java.io.IOException)16 FileNotFoundException (java.io.FileNotFoundException)12 Date (java.util.Date)10 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Uri (android.net.Uri)7 Message (android.os.Message)7 ArrayMap (android.util.ArrayMap)7 PrintWriterPrinter (android.util.PrintWriterPrinter)7 SimpleDateFormat (java.text.SimpleDateFormat)7 NotFoundException (android.content.res.Resources.NotFoundException)5 Point (android.graphics.Point)5 LogPrinter (android.util.LogPrinter)5 Printer (android.util.Printer)5