use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
the class ActivityThread method handleDumpActivity.
private void handleDumpActivity(DumpComponentInfo info) {
final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
ActivityClientRecord r = mActivities.get(info.token);
if (r != null && r.activity != null) {
PrintWriter pw = new FastPrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
r.activity.dump(info.prefix, info.fd.getFileDescriptor(), pw, info.args);
pw.flush();
}
} finally {
IoUtils.closeQuietly(info.fd);
StrictMode.setThreadPolicy(oldPolicy);
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class ActivityThread method handleDumpService.
private void handleDumpService(DumpComponentInfo info) {
final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
Service s = mServices.get(info.token);
if (s != null) {
PrintWriter pw = new FastPrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
s.dump(info.fd.getFileDescriptor(), pw, info.args);
pw.flush();
}
} finally {
IoUtils.closeQuietly(info.fd);
StrictMode.setThreadPolicy(oldPolicy);
}
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
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);
}
use of com.android.internal.util.FastPrintWriter in project android_frameworks_base by ResurrectionRemix.
the class FragmentManagerImpl method restoreAllState.
void restoreAllState(Parcelable state, FragmentManagerNonConfig nonConfig) {
// any nonConfig fragments either, so that is that.
if (state == null)
return;
FragmentManagerState fms = (FragmentManagerState) state;
if (fms.mActive == null)
return;
List<FragmentManagerNonConfig> childNonConfigs = null;
// to their saved state, so we don't try to instantiate them again.
if (nonConfig != null) {
List<Fragment> nonConfigFragments = nonConfig.getFragments();
childNonConfigs = nonConfig.getChildNonConfigs();
final int count = nonConfigFragments != null ? nonConfigFragments.size() : 0;
for (int i = 0; i < count; i++) {
Fragment f = nonConfigFragments.get(i);
if (DEBUG)
Log.v(TAG, "restoreAllState: re-attaching retained " + f);
FragmentState fs = fms.mActive[f.mIndex];
fs.mInstance = f;
f.mSavedViewState = null;
f.mBackStackNesting = 0;
f.mInLayout = false;
f.mAdded = false;
f.mTarget = null;
if (fs.mSavedFragmentState != null) {
fs.mSavedFragmentState.setClassLoader(mHost.getContext().getClassLoader());
f.mSavedViewState = fs.mSavedFragmentState.getSparseParcelableArray(FragmentManagerImpl.VIEW_STATE_TAG);
f.mSavedFragmentState = fs.mSavedFragmentState;
}
}
}
// Build the full list of active fragments, instantiating them from
// their saved state.
mActive = new ArrayList<>(fms.mActive.length);
if (mAvailIndices != null) {
mAvailIndices.clear();
}
for (int i = 0; i < fms.mActive.length; i++) {
FragmentState fs = fms.mActive[i];
if (fs != null) {
FragmentManagerNonConfig childNonConfig = null;
if (childNonConfigs != null && i < childNonConfigs.size()) {
childNonConfig = childNonConfigs.get(i);
}
Fragment f = fs.instantiate(mHost, mParent, childNonConfig);
if (DEBUG)
Log.v(TAG, "restoreAllState: active #" + i + ": " + f);
mActive.add(f);
// Now that the fragment is instantiated (or came from being
// retained above), clear mInstance in case we end up re-restoring
// from this FragmentState again.
fs.mInstance = null;
} else {
mActive.add(null);
if (mAvailIndices == null) {
mAvailIndices = new ArrayList<>();
}
if (DEBUG)
Log.v(TAG, "restoreAllState: avail #" + i);
mAvailIndices.add(i);
}
}
// Update the target of all retained fragments.
if (nonConfig != null) {
List<Fragment> nonConfigFragments = nonConfig.getFragments();
final int count = nonConfigFragments != null ? nonConfigFragments.size() : 0;
for (int i = 0; i < count; i++) {
Fragment f = nonConfigFragments.get(i);
if (f.mTargetIndex >= 0) {
if (f.mTargetIndex < mActive.size()) {
f.mTarget = mActive.get(f.mTargetIndex);
} else {
Log.w(TAG, "Re-attaching retained fragment " + f + " target no longer exists: " + f.mTargetIndex);
f.mTarget = null;
}
}
}
}
// Build the list of currently added fragments.
if (fms.mAdded != null) {
mAdded = new ArrayList<Fragment>(fms.mAdded.length);
for (int i = 0; i < fms.mAdded.length; i++) {
Fragment f = mActive.get(fms.mAdded[i]);
if (f == null) {
throwException(new IllegalStateException("No instantiated fragment for index #" + fms.mAdded[i]));
}
f.mAdded = true;
if (DEBUG)
Log.v(TAG, "restoreAllState: added #" + i + ": " + f);
if (mAdded.contains(f)) {
throw new IllegalStateException("Already added!");
}
mAdded.add(f);
}
} else {
mAdded = null;
}
// Build the back stack.
if (fms.mBackStack != null) {
mBackStack = new ArrayList<BackStackRecord>(fms.mBackStack.length);
for (int i = 0; i < fms.mBackStack.length; i++) {
BackStackRecord bse = fms.mBackStack[i].instantiate(this);
if (DEBUG) {
Log.v(TAG, "restoreAllState: back stack #" + i + " (index " + bse.mIndex + "): " + bse);
LogWriter logw = new LogWriter(Log.VERBOSE, TAG);
PrintWriter pw = new FastPrintWriter(logw, false, 1024);
bse.dump(" ", pw, false);
pw.flush();
}
mBackStack.add(bse);
if (bse.mIndex >= 0) {
setBackStackIndex(bse.mIndex, bse);
}
}
} else {
mBackStack = null;
}
}
Aggregations