use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
the class PackageDexUsage method write.
/**
* File format:
*
* file_magic_version
* package_name_1
* #dex_file_path_1_1
* user_1_1, used_by_other_app_1_1, user_isa_1_1_1, user_isa_1_1_2
* #dex_file_path_1_2
* user_1_2, used_by_other_app_1_2, user_isa_1_2_1, user_isa_1_2_2
* ...
* package_name_2
* #dex_file_path_2_1
* user_2_1, used_by_other_app_2_1, user_isa_2_1_1, user_isa_2_1_2
* #dex_file_path_2_2,
* user_2_2, used_by_other_app_2_2, user_isa_2_2_1, user_isa_2_2_2
* ...
*/
/* package */
void write(Writer out) {
// Make a clone to avoid locking while writing to disk.
Map<String, PackageUseInfo> packageUseInfoMapClone = clonePackageUseInfoMap();
FastPrintWriter fpw = new FastPrintWriter(out);
// Write the header.
fpw.print(PACKAGE_DEX_USAGE_VERSION_HEADER);
fpw.println(PACKAGE_DEX_USAGE_VERSION);
for (Map.Entry<String, PackageUseInfo> pEntry : packageUseInfoMapClone.entrySet()) {
// Write the package line.
String packageName = pEntry.getKey();
PackageUseInfo packageUseInfo = pEntry.getValue();
fpw.println(String.join(SPLIT_CHAR, packageName, writeBoolean(packageUseInfo.mIsUsedByOtherApps)));
// Write dex file lines.
for (Map.Entry<String, DexUseInfo> dEntry : packageUseInfo.mDexUseInfoMap.entrySet()) {
String dexPath = dEntry.getKey();
DexUseInfo dexUseInfo = dEntry.getValue();
fpw.println(DEX_LINE_CHAR + dexPath);
fpw.print(String.join(SPLIT_CHAR, Integer.toString(dexUseInfo.mOwnerUserId), writeBoolean(dexUseInfo.mIsUsedByOtherApps)));
for (String isa : dexUseInfo.mLoaderIsas) {
fpw.print(SPLIT_CHAR + isa);
}
fpw.println();
}
}
fpw.flush();
}
use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
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;
}
use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
the class BackStackRecord method popFromBackStack.
public TransitionState popFromBackStack(boolean doStateMove, TransitionState state, SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments) {
if (FragmentManagerImpl.DEBUG) {
Log.v(TAG, "popFromBackStack: " + this);
LogWriter logw = new LogWriter(Log.VERBOSE, TAG);
PrintWriter pw = new FastPrintWriter(logw, false, 1024);
dump(" ", null, pw, null);
pw.flush();
}
if (mManager.mCurState >= Fragment.CREATED) {
if (state == null) {
if (firstOutFragments.size() != 0 || lastInFragments.size() != 0) {
state = beginTransition(firstOutFragments, lastInFragments, true);
}
} else if (!doStateMove) {
setNameOverrides(state, mSharedElementTargetNames, mSharedElementSourceNames);
}
}
bumpBackStackNesting(-1);
Op op = mTail;
while (op != null) {
switch(op.cmd) {
case OP_ADD:
{
Fragment f = op.fragment;
f.mNextAnim = op.popExitAnim;
mManager.removeFragment(f, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
}
break;
case OP_REPLACE:
{
Fragment f = op.fragment;
if (f != null) {
f.mNextAnim = op.popExitAnim;
mManager.removeFragment(f, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
}
if (op.removed != null) {
for (int i = 0; i < op.removed.size(); i++) {
Fragment old = op.removed.get(i);
old.mNextAnim = op.popEnterAnim;
mManager.addFragment(old, false);
}
}
}
break;
case OP_REMOVE:
{
Fragment f = op.fragment;
f.mNextAnim = op.popEnterAnim;
mManager.addFragment(f, false);
}
break;
case OP_HIDE:
{
Fragment f = op.fragment;
f.mNextAnim = op.popEnterAnim;
mManager.showFragment(f, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
}
break;
case OP_SHOW:
{
Fragment f = op.fragment;
f.mNextAnim = op.popExitAnim;
mManager.hideFragment(f, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
}
break;
case OP_DETACH:
{
Fragment f = op.fragment;
f.mNextAnim = op.popEnterAnim;
mManager.attachFragment(f, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
}
break;
case OP_ATTACH:
{
Fragment f = op.fragment;
f.mNextAnim = op.popExitAnim;
mManager.detachFragment(f, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle);
}
break;
default:
{
throw new IllegalArgumentException("Unknown cmd: " + op.cmd);
}
}
op = op.prev;
}
if (doStateMove) {
mManager.moveToState(mManager.mCurState, FragmentManagerImpl.reverseTransit(mTransition), mTransitionStyle, true);
state = null;
}
if (mIndex >= 0) {
mManager.freeBackStackIndex(mIndex);
mIndex = -1;
}
return state;
}
use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
the class Debug method startNativeTracing.
/**
* Enable qemu tracing. For this to work requires running everything inside
* the qemu emulator; otherwise, this method will have no effect. The trace
* file is specified on the command line when the emulator is started. For
* example, the following command line <br />
* <code>emulator -trace foo</code><br />
* will start running the emulator and create a trace file named "foo". This
* method simply enables writing the trace records to the trace file.
*
* <p>
* The main differences between this and {@link #startMethodTracing()} are
* that tracing in the qemu emulator traces every cpu instruction of every
* process, including kernel code, so we have more complete information,
* including all context switches. We can also get more detailed information
* such as cache misses. The sequence of calls is determined by
* post-processing the instruction trace. The qemu tracing is also done
* without modifying the application or perturbing the timing of calls
* because no instrumentation is added to the application being traced.
* </p>
*
* <p>
* One limitation of using this method compared to using
* {@link #startMethodTracing()} on the real device is that the emulator
* does not model all of the real hardware effects such as memory and
* bus contention. The emulator also has a simple cache model and cannot
* capture all the complexities of a real cache.
* </p>
*/
public static void startNativeTracing() {
// Open the sysfs file for writing and write "1" to it.
PrintWriter outStream = null;
try {
FileOutputStream fos = new FileOutputStream(SYSFS_QEMU_TRACE_STATE);
outStream = new FastPrintWriter(fos);
outStream.println("1");
} catch (Exception e) {
} finally {
if (outStream != null)
outStream.close();
}
VMDebug.startEmulatorTracing();
}
use of com.android.internal.util.FastPrintWriter in project platform_frameworks_base by android.
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();
}
}
Aggregations