use of android.util.Printer in project double-espresso by JakeWharton.
the class HumanReadables method describe.
/**
* Transforms an arbitrary view into a string with (hopefully) enough debug info.
*
* @param v nullable view
* @return a string for human consumption.
*/
public static String describe(View v) {
if (null == v) {
return "null";
}
ToStringHelper helper = Objects.toStringHelper(v).add("id", v.getId());
if (v.getId() != -1 && v.getResources() != null) {
try {
helper.add("res-name", v.getResources().getResourceEntryName(v.getId()));
} catch (Resources.NotFoundException ignore) {
// Do nothing.
}
}
if (null != v.getContentDescription()) {
helper.add("desc", v.getContentDescription());
}
switch(v.getVisibility()) {
case View.GONE:
helper.add("visibility", "GONE");
break;
case View.INVISIBLE:
helper.add("visibility", "INVISIBLE");
break;
case View.VISIBLE:
helper.add("visibility", "VISIBLE");
break;
default:
helper.add("visibility", v.getVisibility());
}
helper.add("width", v.getWidth()).add("height", v.getHeight()).add("has-focus", v.hasFocus()).add("has-focusable", v.hasFocusable()).add("has-window-focus", v.hasWindowFocus()).add("is-clickable", v.isClickable()).add("is-enabled", v.isEnabled()).add("is-focused", v.isFocused()).add("is-focusable", v.isFocusable()).add("is-layout-requested", v.isLayoutRequested()).add("is-selected", v.isSelected());
if (null != v.getRootView()) {
// pretty much only true in unit-tests.
helper.add("root-is-layout-requested", v.getRootView().isLayoutRequested());
}
EditorInfo ei = new EditorInfo();
InputConnection ic = v.onCreateInputConnection(ei);
boolean hasInputConnection = ic != null;
helper.add("has-input-connection", hasInputConnection);
if (hasInputConnection) {
StringBuilder sb = new StringBuilder();
sb.append("[");
Printer p = new StringBuilderPrinter(sb);
ei.dump(p, "");
sb.append("]");
helper.add("editor-info", sb.toString().replace("\n", " "));
}
if (Build.VERSION.SDK_INT > 10) {
helper.add("x", v.getX()).add("y", v.getY());
}
if (v instanceof TextView) {
innerDescribe((TextView) v, helper);
}
if (v instanceof Checkable) {
innerDescribe((Checkable) v, helper);
}
if (v instanceof ViewGroup) {
innerDescribe((ViewGroup) v, helper);
}
return helper.toString();
}
use of android.util.Printer in project android_frameworks_base by AOSPA.
the class SQLiteConnectionPool method dump.
/**
* Dumps debugging information about this connection pool.
*
* @param printer The printer to receive the dump, not null.
* @param verbose True to dump more verbose information.
*/
public void dump(Printer printer, boolean verbose) {
Printer indentedPrinter = PrefixPrinter.create(printer, " ");
synchronized (mLock) {
printer.println("Connection pool for " + mConfiguration.path + ":");
printer.println(" Open: " + mIsOpen);
printer.println(" Max connections: " + mMaxConnectionPoolSize);
printer.println(" Available primary connection:");
if (mAvailablePrimaryConnection != null) {
mAvailablePrimaryConnection.dump(indentedPrinter, verbose);
} else {
indentedPrinter.println("<none>");
}
printer.println(" Available non-primary connections:");
if (!mAvailableNonPrimaryConnections.isEmpty()) {
final int count = mAvailableNonPrimaryConnections.size();
for (int i = 0; i < count; i++) {
mAvailableNonPrimaryConnections.get(i).dump(indentedPrinter, verbose);
}
} else {
indentedPrinter.println("<none>");
}
printer.println(" Acquired connections:");
if (!mAcquiredConnections.isEmpty()) {
for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry : mAcquiredConnections.entrySet()) {
final SQLiteConnection connection = entry.getKey();
connection.dumpUnsafe(indentedPrinter, verbose);
indentedPrinter.println(" Status: " + entry.getValue());
}
} else {
indentedPrinter.println("<none>");
}
printer.println(" Connection waiters:");
if (mConnectionWaiterQueue != null) {
int i = 0;
final long now = SystemClock.uptimeMillis();
for (ConnectionWaiter waiter = mConnectionWaiterQueue; waiter != null; waiter = waiter.mNext, i++) {
indentedPrinter.println(i + ": waited for " + ((now - waiter.mStartTime) * 0.001f) + " ms - thread=" + waiter.mThread + ", priority=" + waiter.mPriority + ", sql='" + waiter.mSql + "'");
}
} else {
indentedPrinter.println("<none>");
}
}
}
use of android.util.Printer in project android_frameworks_base by AOSPA.
the class IntentResolver method buildResolveList.
private void buildResolveList(Intent intent, FastImmutableArraySet<String> categories, boolean debug, boolean defaultOnly, String resolvedType, String scheme, F[] src, List<R> dest, int userId) {
final String action = intent.getAction();
final Uri data = intent.getData();
final String packageName = intent.getPackage();
final boolean excludingStopped = intent.isExcludingStopped();
final Printer logPrinter;
final PrintWriter logPrintWriter;
if (debug) {
logPrinter = new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM);
logPrintWriter = new FastPrintWriter(logPrinter);
} else {
logPrinter = null;
logPrintWriter = null;
}
final int N = src != null ? src.length : 0;
boolean hasNonDefaults = false;
int i;
F filter;
for (i = 0; i < N && (filter = src[i]) != null; i++) {
int match;
if (debug)
Slog.v(TAG, "Matching against filter " + filter);
if (excludingStopped && isFilterStopped(filter, userId)) {
if (debug) {
Slog.v(TAG, " Filter's target is stopped; skipping");
}
continue;
}
// Is delivery being limited to filters owned by a particular package?
if (packageName != null && !isPackageForFilter(packageName, filter)) {
if (debug) {
Slog.v(TAG, " Filter is not from package " + packageName + "; skipping");
}
continue;
}
// Are we verified ?
if (filter.getAutoVerify()) {
if (localVerificationLOGV || debug) {
Slog.v(TAG, " Filter verified: " + isFilterVerified(filter));
int authorities = filter.countDataAuthorities();
for (int z = 0; z < authorities; z++) {
Slog.v(TAG, " " + filter.getDataAuthority(z).getHost());
}
}
}
// Do we already have this one?
if (!allowFilterResult(filter, dest)) {
if (debug) {
Slog.v(TAG, " Filter's target already added");
}
continue;
}
match = filter.match(action, resolvedType, scheme, data, categories, TAG);
if (match >= 0) {
if (debug)
Slog.v(TAG, " Filter matched! match=0x" + Integer.toHexString(match) + " hasDefault=" + filter.hasCategory(Intent.CATEGORY_DEFAULT));
if (!defaultOnly || filter.hasCategory(Intent.CATEGORY_DEFAULT)) {
final R oneResult = newResult(filter, match, userId);
if (oneResult != null) {
dest.add(oneResult);
if (debug) {
dumpFilter(logPrintWriter, " ", filter);
logPrintWriter.flush();
filter.dump(logPrinter, " ");
}
}
} else {
hasNonDefaults = true;
}
} else {
if (debug) {
String reason;
switch(match) {
case IntentFilter.NO_MATCH_ACTION:
reason = "action";
break;
case IntentFilter.NO_MATCH_CATEGORY:
reason = "category";
break;
case IntentFilter.NO_MATCH_DATA:
reason = "data";
break;
case IntentFilter.NO_MATCH_TYPE:
reason = "type";
break;
default:
reason = "unknown reason";
break;
}
Slog.v(TAG, " Filter did not match: " + reason);
}
}
}
if (debug && hasNonDefaults) {
if (dest.size() == 0) {
Slog.v(TAG, "resolveIntent failed: found match, but none with CATEGORY_DEFAULT");
} else if (dest.size() > 1) {
Slog.v(TAG, "resolveIntent: multiple matches, only some with CATEGORY_DEFAULT");
}
}
}
use of android.util.Printer in project android_frameworks_base by DirtyUnicorns.
the class InputMethodService method dump.
/**
* Performs a dump of the InputMethodService's internal state. Override
* to add your own information to the dump.
*/
@Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
final Printer p = new PrintWriterPrinter(fout);
p.println("Input method service state for " + this + ":");
p.println(" mWindowCreated=" + mWindowCreated + " mWindowAdded=" + mWindowAdded);
p.println(" mWindowVisible=" + mWindowVisible + " mWindowWasVisible=" + mWindowWasVisible + " mInShowWindow=" + mInShowWindow);
p.println(" Configuration=" + getResources().getConfiguration());
p.println(" mToken=" + mToken);
p.println(" mInputBinding=" + mInputBinding);
p.println(" mInputConnection=" + mInputConnection);
p.println(" mStartedInputConnection=" + mStartedInputConnection);
p.println(" mInputStarted=" + mInputStarted + " mInputViewStarted=" + mInputViewStarted + " mCandidatesViewStarted=" + mCandidatesViewStarted);
if (mInputEditorInfo != null) {
p.println(" mInputEditorInfo:");
mInputEditorInfo.dump(p, " ");
} else {
p.println(" mInputEditorInfo: null");
}
p.println(" mShowInputRequested=" + mShowInputRequested + " mLastShowInputRequested=" + mLastShowInputRequested + " mShowInputFlags=0x" + Integer.toHexString(mShowInputFlags));
p.println(" mCandidatesVisibility=" + mCandidatesVisibility + " mFullscreenApplied=" + mFullscreenApplied + " mIsFullscreen=" + mIsFullscreen + " mExtractViewHidden=" + mExtractViewHidden);
if (mExtractedText != null) {
p.println(" mExtractedText:");
p.println(" text=" + mExtractedText.text.length() + " chars" + " startOffset=" + mExtractedText.startOffset);
p.println(" selectionStart=" + mExtractedText.selectionStart + " selectionEnd=" + mExtractedText.selectionEnd + " flags=0x" + Integer.toHexString(mExtractedText.flags));
} else {
p.println(" mExtractedText: null");
}
p.println(" mExtractedToken=" + mExtractedToken);
p.println(" mIsInputViewShown=" + mIsInputViewShown + " mStatusIcon=" + mStatusIcon);
p.println("Last computed insets:");
p.println(" contentTopInsets=" + mTmpInsets.contentTopInsets + " visibleTopInsets=" + mTmpInsets.visibleTopInsets + " touchableInsets=" + mTmpInsets.touchableInsets + " touchableRegion=" + mTmpInsets.touchableRegion);
p.println(" mShouldClearInsetOfPreviousIme=" + mShouldClearInsetOfPreviousIme);
p.println(" mSettingsObserver=" + mSettingsObserver);
}
use of android.util.Printer in project android_frameworks_base by DirtyUnicorns.
the class BatteryStatsImpl method dumpLocked.
public void dumpLocked(Context context, PrintWriter pw, int flags, int reqUid, long histStart) {
if (DEBUG) {
pw.println("mOnBatteryTimeBase:");
mOnBatteryTimeBase.dump(pw, " ");
pw.println("mOnBatteryScreenOffTimeBase:");
mOnBatteryScreenOffTimeBase.dump(pw, " ");
Printer pr = new PrintWriterPrinter(pw);
pr.println("*** Screen timer:");
mScreenOnTimer.logState(pr, " ");
for (int i = 0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) {
pr.println("*** Screen brightness #" + i + ":");
mScreenBrightnessTimer[i].logState(pr, " ");
}
pr.println("*** Interactive timer:");
mInteractiveTimer.logState(pr, " ");
pr.println("*** Power save mode timer:");
mPowerSaveModeEnabledTimer.logState(pr, " ");
pr.println("*** Device idle mode light timer:");
mDeviceIdleModeLightTimer.logState(pr, " ");
pr.println("*** Device idle mode full timer:");
mDeviceIdleModeFullTimer.logState(pr, " ");
pr.println("*** Device light idling timer:");
mDeviceLightIdlingTimer.logState(pr, " ");
pr.println("*** Device idling timer:");
mDeviceIdlingTimer.logState(pr, " ");
pr.println("*** Phone timer:");
mPhoneOnTimer.logState(pr, " ");
for (int i = 0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
pr.println("*** Phone signal strength #" + i + ":");
mPhoneSignalStrengthsTimer[i].logState(pr, " ");
}
pr.println("*** Signal scanning :");
mPhoneSignalScanningTimer.logState(pr, " ");
for (int i = 0; i < NUM_DATA_CONNECTION_TYPES; i++) {
pr.println("*** Data connection type #" + i + ":");
mPhoneDataConnectionsTimer[i].logState(pr, " ");
}
pr.println("*** mMobileRadioPowerState=" + mMobileRadioPowerState);
pr.println("*** Mobile network active timer:");
mMobileRadioActiveTimer.logState(pr, " ");
pr.println("*** Mobile network active adjusted timer:");
mMobileRadioActiveAdjustedTime.logState(pr, " ");
pr.println("*** mWifiRadioPowerState=" + mWifiRadioPowerState);
pr.println("*** Wifi timer:");
mWifiOnTimer.logState(pr, " ");
pr.println("*** WifiRunning timer:");
mGlobalWifiRunningTimer.logState(pr, " ");
for (int i = 0; i < NUM_WIFI_STATES; i++) {
pr.println("*** Wifi state #" + i + ":");
mWifiStateTimer[i].logState(pr, " ");
}
for (int i = 0; i < NUM_WIFI_SUPPL_STATES; i++) {
pr.println("*** Wifi suppl state #" + i + ":");
mWifiSupplStateTimer[i].logState(pr, " ");
}
for (int i = 0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
pr.println("*** Wifi signal strength #" + i + ":");
mWifiSignalStrengthsTimer[i].logState(pr, " ");
}
pr.println("*** Flashlight timer:");
mFlashlightOnTimer.logState(pr, " ");
pr.println("*** Camera timer:");
mCameraOnTimer.logState(pr, " ");
}
super.dumpLocked(context, pw, flags, reqUid, histStart);
}
Aggregations