diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-04-22 18:33:57 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-04-22 18:33:57 -0700 |
commit | 0b8ffd17bc6641fc522db3e842a868b6cdbf6d82 (patch) | |
tree | ef8d5d562a1c8d61b997ed7ed522dc9034e85548 | |
parent | 56137a258410bd08ecd0d9478f82816e1d0c6609 (diff) | |
parent | 1d442e0d990b581357f33f5463c7c5cb49b551e8 (diff) | |
download | frameworks_base-0b8ffd17bc6641fc522db3e842a868b6cdbf6d82.zip frameworks_base-0b8ffd17bc6641fc522db3e842a868b6cdbf6d82.tar.gz frameworks_base-0b8ffd17bc6641fc522db3e842a868b6cdbf6d82.tar.bz2 |
Merge change 460 into donut
* changes:
More optimization of dumpsys output.
29 files changed, 1364 insertions, 730 deletions
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index 1bed706..cb660c7 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -440,9 +440,13 @@ public final class PendingIntent implements Parcelable { @Override public String toString() { - return "PendingIntent{" - + Integer.toHexString(System.identityHashCode(this)) - + " target " + (mTarget != null ? mTarget.asBinder() : null) + "}"; + StringBuilder sb = new StringBuilder(128); + sb.append("PendingIntent{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(": "); + sb.append(mTarget != null ? mTarget.asBinder() : null); + sb.append('}'); + return sb.toString(); } public int describeContents() { diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index e82a86c..b3e81d7 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -4390,12 +4390,35 @@ public class Intent implements Parcelable { @Override public String toString() { - StringBuilder b = new StringBuilder(); + StringBuilder b = new StringBuilder(128); - b.append("Intent {"); - if (mAction != null) b.append(" action=").append(mAction); + b.append("Intent { "); + toShortString(b, true, true); + b.append(" }"); + + return b.toString(); + } + + /** @hide */ + public String toShortString(boolean comp, boolean extras) { + StringBuilder b = new StringBuilder(128); + toShortString(b, comp, extras); + return b.toString(); + } + + /** @hide */ + public void toShortString(StringBuilder b, boolean comp, boolean extras) { + boolean first = true; + if (mAction != null) { + b.append("act=").append(mAction); + first = false; + } if (mCategories != null) { - b.append(" categories={"); + if (!first) { + b.append(' '); + } + first = false; + b.append("cat=["); Iterator<String> i = mCategories.iterator(); boolean didone = false; while (i.hasNext()) { @@ -4403,20 +4426,48 @@ public class Intent implements Parcelable { didone = true; b.append(i.next()); } - b.append("}"); + b.append("]"); + } + if (mData != null) { + if (!first) { + b.append(' '); + } + first = false; + b.append("dat=").append(mData); + } + if (mType != null) { + if (!first) { + b.append(' '); + } + first = false; + b.append("typ=").append(mType); + } + if (mFlags != 0) { + if (!first) { + b.append(' '); + } + first = false; + b.append("flg=0x").append(Integer.toHexString(mFlags)); + } + if (comp && mComponent != null) { + if (!first) { + b.append(' '); + } + first = false; + b.append("cmp=").append(mComponent.flattenToShortString()); + } + if (extras && mExtras != null) { + if (!first) { + b.append(' '); + } + first = false; + b.append("(has extras)"); } - if (mData != null) b.append(" data=").append(mData); - if (mType != null) b.append(" type=").append(mType); - if (mFlags != 0) b.append(" flags=0x").append(Integer.toHexString(mFlags)); - if (mComponent != null) b.append(" comp=").append(mComponent.toShortString()); - if (mExtras != null) b.append(" (has extras)"); - b.append(" }"); - - return b.toString(); } public String toURI() { - StringBuilder uri = new StringBuilder(mData != null ? mData.toString() : ""); + StringBuilder uri = new StringBuilder(128); + if (mData != null) uri.append(mData.toString()); uri.append("#Intent;"); diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java index 9b190df..e5c5dc8 100644 --- a/core/java/android/content/IntentFilter.java +++ b/core/java/android/content/IntentFilter.java @@ -1254,47 +1254,71 @@ public class IntentFilter implements Parcelable { } public void dump(Printer du, String prefix) { + StringBuilder sb = new StringBuilder(256); if (mActions.size() > 0) { Iterator<String> it = mActions.iterator(); while (it.hasNext()) { - du.println(prefix + "Action: \"" + it.next() + "\""); + sb.setLength(0); + sb.append(prefix); sb.append("Action: \""); + sb.append(it.next()); sb.append("\""); + du.println(sb.toString()); } } if (mCategories != null) { Iterator<String> it = mCategories.iterator(); while (it.hasNext()) { - du.println(prefix + "Category: \"" + it.next() + "\""); + sb.setLength(0); + sb.append(prefix); sb.append("Category: \""); + sb.append(it.next()); sb.append("\""); + du.println(sb.toString()); } } if (mDataSchemes != null) { Iterator<String> it = mDataSchemes.iterator(); while (it.hasNext()) { - du.println(prefix + "Data Scheme: \"" + it.next() + "\""); + sb.setLength(0); + sb.append(prefix); sb.append("Scheme: \""); + sb.append(it.next()); sb.append("\""); + du.println(sb.toString()); } } if (mDataAuthorities != null) { Iterator<AuthorityEntry> it = mDataAuthorities.iterator(); while (it.hasNext()) { AuthorityEntry ae = it.next(); - du.println(prefix + "Data Authority: \"" + ae.mHost + "\":" - + ae.mPort + (ae.mWild ? " WILD" : "")); + sb.setLength(0); + sb.append(prefix); sb.append("Authority: \""); + sb.append(ae.mHost); sb.append("\": "); + sb.append(ae.mPort); + if (ae.mWild) sb.append(" WILD"); + du.println(sb.toString()); } } if (mDataPaths != null) { Iterator<PatternMatcher> it = mDataPaths.iterator(); while (it.hasNext()) { PatternMatcher pe = it.next(); - du.println(prefix + "Data Path: \"" + pe + "\""); + sb.setLength(0); + sb.append(prefix); sb.append("Path: \""); + sb.append(pe); sb.append("\""); + du.println(sb.toString()); } } if (mDataTypes != null) { Iterator<String> it = mDataTypes.iterator(); while (it.hasNext()) { - du.println(prefix + "Data Type: \"" + it.next() + "\""); + sb.setLength(0); + sb.append(prefix); sb.append("Type: \""); + sb.append(it.next()); sb.append("\""); + du.println(sb.toString()); } } - du.println(prefix + "mPriority=" + mPriority - + ", mHasPartialTypes=" + mHasPartialTypes); + if (mPriority != 0 || mHasPartialTypes) { + sb.setLength(0); + sb.append(prefix); sb.append("mPriority="); sb.append(mPriority); + sb.append(", mHasPartialTypes="); sb.append(mHasPartialTypes); + du.println(sb.toString()); + } } public static final Parcelable.Creator<IntentFilter> CREATOR diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 2dcb483..963d311 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -64,6 +64,48 @@ public class PackageParser { private static final Object mSync = new Object(); private static WeakReference<byte[]> mReadBuffer; + static class ParsePackageItemArgs { + final Package owner; + final String[] outError; + final int nameRes; + final int labelRes; + final int iconRes; + + String tag; + TypedArray sa; + + ParsePackageItemArgs(Package _owner, String[] _outError, + int _nameRes, int _labelRes, int _iconRes) { + owner = _owner; + outError = _outError; + nameRes = _nameRes; + labelRes = _labelRes; + iconRes = _iconRes; + } + } + + static class ParseComponentArgs extends ParsePackageItemArgs { + final String[] sepProcesses; + final int processRes; + final int enabledRes; + int flags; + + ParseComponentArgs(Package _owner, String[] _outError, + int _nameRes, int _labelRes, int _iconRes, + String[] _sepProcesses, int _processRes,int _enabledRes) { + super(_owner, _outError, _nameRes, _labelRes, _iconRes); + sepProcesses = _sepProcesses; + processRes = _processRes; + enabledRes = _enabledRes; + } + } + + private ParsePackageItemArgs mParseInstrumentationArgs; + private ParseComponentArgs mParseActivityArgs; + private ParseComponentArgs mParseActivityAliasArgs; + private ParseComponentArgs mParseServiceArgs; + private ParseComponentArgs mParseProviderArgs; + /** If set to true, we will only allow package files that exactly match * the DTD. Otherwise, we try to get as much from the package as we * can without failing. This should normally be set to false, to @@ -557,6 +599,11 @@ public class PackageParser { throws XmlPullParserException, IOException { AttributeSet attrs = parser; + mParseInstrumentationArgs = null; + mParseActivityArgs = null; + mParseServiceArgs = null; + mParseProviderArgs = null; + String pkgName = parsePackageName(parser, attrs, flags, outError); if (pkgName == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME; @@ -593,8 +640,6 @@ public class PackageParser { } sa.recycle(); - final int innerDepth = parser.getDepth(); - int outerDepth = parser.getDepth(); while ((type=parser.next()) != parser.END_DOCUMENT && (type != parser.END_TAG || parser.getDepth() > outerDepth)) { @@ -950,20 +995,24 @@ public class PackageParser { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestInstrumentation); - Instrumentation a = new Instrumentation(owner); - - if (!parsePackageItemInfo(owner, a.info, outError, "<instrumentation>", sa, - com.android.internal.R.styleable.AndroidManifestInstrumentation_name, - com.android.internal.R.styleable.AndroidManifestInstrumentation_label, - com.android.internal.R.styleable.AndroidManifestInstrumentation_icon)) { + if (mParseInstrumentationArgs == null) { + mParseInstrumentationArgs = new ParsePackageItemArgs(owner, outError, + com.android.internal.R.styleable.AndroidManifestInstrumentation_name, + com.android.internal.R.styleable.AndroidManifestInstrumentation_label, + com.android.internal.R.styleable.AndroidManifestInstrumentation_icon); + mParseInstrumentationArgs.tag = "<instrumentation>"; + } + + mParseInstrumentationArgs.sa = sa; + + Instrumentation a = new Instrumentation(mParseInstrumentationArgs, + new InstrumentationInfo()); + if (outError[0] != null) { sa.recycle(); mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } - a.component = new ComponentName(owner.applicationInfo.packageName, - a.info.name); - String str; str = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestInstrumentation_targetPackage); @@ -1140,7 +1189,7 @@ public class PackageParser { owner.providers.add(p); } else if (tagName.equals("activity-alias")) { - Activity a = parseActivityAlias(owner, res, parser, attrs, flags, outError, false); + Activity a = parseActivityAlias(owner, res, parser, attrs, flags, outError); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; @@ -1239,22 +1288,29 @@ public class PackageParser { return outError[0] == null; } - + private Activity parseActivity(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError, boolean receiver) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestActivity); - Activity a = new Activity(owner); - - if (!parseComponentInfo(owner, flags, a.info, outError, - receiver ? "<receiver>" : "<activity>", sa, - com.android.internal.R.styleable.AndroidManifestActivity_name, - com.android.internal.R.styleable.AndroidManifestActivity_label, - com.android.internal.R.styleable.AndroidManifestActivity_icon, - com.android.internal.R.styleable.AndroidManifestActivity_process, - com.android.internal.R.styleable.AndroidManifestActivity_enabled)) { + if (mParseActivityArgs == null) { + mParseActivityArgs = new ParseComponentArgs(owner, outError, + com.android.internal.R.styleable.AndroidManifestActivity_name, + com.android.internal.R.styleable.AndroidManifestActivity_label, + com.android.internal.R.styleable.AndroidManifestActivity_icon, + mSeparateProcesses, + com.android.internal.R.styleable.AndroidManifestActivity_process, + com.android.internal.R.styleable.AndroidManifestActivity_enabled); + } + + mParseActivityArgs.tag = receiver ? "<receiver>" : "<activity>"; + mParseActivityArgs.sa = sa; + mParseActivityArgs.flags = flags; + + Activity a = new Activity(mParseActivityArgs, new ActivityInfo()); + if (outError[0] != null) { sa.recycle(); return null; } @@ -1266,9 +1322,6 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestActivity_exported, false); } - a.component = new ComponentName(owner.applicationInfo.packageName, - a.info.name); - a.info.theme = sa.getResourceId( com.android.internal.R.styleable.AndroidManifestActivity_theme, 0); @@ -1412,8 +1465,8 @@ public class PackageParser { } private Activity parseActivityAlias(Package owner, Resources res, - XmlPullParser parser, AttributeSet attrs, int flags, String[] outError, - boolean receiver) throws XmlPullParserException, IOException { + XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) + throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestActivityAlias); @@ -1432,7 +1485,20 @@ public class PackageParser { return null; } - Activity a = new Activity(owner); + if (mParseActivityAliasArgs == null) { + mParseActivityAliasArgs = new ParseComponentArgs(owner, outError, + com.android.internal.R.styleable.AndroidManifestActivityAlias_name, + com.android.internal.R.styleable.AndroidManifestActivityAlias_label, + com.android.internal.R.styleable.AndroidManifestActivityAlias_icon, + mSeparateProcesses, + 0, + com.android.internal.R.styleable.AndroidManifestActivityAlias_enabled); + mParseActivityAliasArgs.tag = "<activity-alias>"; + } + + mParseActivityAliasArgs.sa = sa; + mParseActivityAliasArgs.flags = flags; + Activity target = null; final int NA = owner.activities.size(); @@ -1451,26 +1517,21 @@ public class PackageParser { return null; } - a.info.targetActivity = targetActivity; - - a.info.configChanges = target.info.configChanges; - a.info.flags = target.info.flags; - a.info.icon = target.info.icon; - a.info.labelRes = target.info.labelRes; - a.info.launchMode = target.info.launchMode; - a.info.nonLocalizedLabel = target.info.nonLocalizedLabel; - a.info.processName = target.info.processName; - a.info.screenOrientation = target.info.screenOrientation; - a.info.taskAffinity = target.info.taskAffinity; - a.info.theme = target.info.theme; - - if (!parseComponentInfo(owner, flags, a.info, outError, - receiver ? "<receiver>" : "<activity>", sa, - com.android.internal.R.styleable.AndroidManifestActivityAlias_name, - com.android.internal.R.styleable.AndroidManifestActivityAlias_label, - com.android.internal.R.styleable.AndroidManifestActivityAlias_icon, - 0, - com.android.internal.R.styleable.AndroidManifestActivityAlias_enabled)) { + ActivityInfo info = new ActivityInfo(); + info.targetActivity = targetActivity; + info.configChanges = target.info.configChanges; + info.flags = target.info.flags; + info.icon = target.info.icon; + info.labelRes = target.info.labelRes; + info.nonLocalizedLabel = target.info.nonLocalizedLabel; + info.launchMode = target.info.launchMode; + info.processName = target.info.processName; + info.screenOrientation = target.info.screenOrientation; + info.taskAffinity = target.info.taskAffinity; + info.theme = target.info.theme; + + Activity a = new Activity(mParseActivityAliasArgs, info); + if (outError[0] != null) { sa.recycle(); return null; } @@ -1482,9 +1543,6 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestActivityAlias_exported, false); } - a.component = new ComponentName(owner.applicationInfo.packageName, - a.info.name); - String str; str = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestActivityAlias_permission); @@ -1548,14 +1606,22 @@ public class PackageParser { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestProvider); - Provider p = new Provider(owner); - - if (!parseComponentInfo(owner, flags, p.info, outError, "<provider>", sa, - com.android.internal.R.styleable.AndroidManifestProvider_name, - com.android.internal.R.styleable.AndroidManifestProvider_label, - com.android.internal.R.styleable.AndroidManifestProvider_icon, - com.android.internal.R.styleable.AndroidManifestProvider_process, - com.android.internal.R.styleable.AndroidManifestProvider_enabled)) { + if (mParseProviderArgs == null) { + mParseProviderArgs = new ParseComponentArgs(owner, outError, + com.android.internal.R.styleable.AndroidManifestProvider_name, + com.android.internal.R.styleable.AndroidManifestProvider_label, + com.android.internal.R.styleable.AndroidManifestProvider_icon, + mSeparateProcesses, + com.android.internal.R.styleable.AndroidManifestProvider_process, + com.android.internal.R.styleable.AndroidManifestProvider_enabled); + mParseProviderArgs.tag = "<provider>"; + } + + mParseProviderArgs.sa = sa; + mParseProviderArgs.flags = flags; + + Provider p = new Provider(mParseProviderArgs, new ProviderInfo()); + if (outError[0] != null) { sa.recycle(); return null; } @@ -1563,9 +1629,6 @@ public class PackageParser { p.info.exported = sa.getBoolean( com.android.internal.R.styleable.AndroidManifestProvider_exported, true); - p.component = new ComponentName(owner.applicationInfo.packageName, - p.info.name); - String cpname = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestProvider_authorities); @@ -1706,14 +1769,22 @@ public class PackageParser { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestService); - Service s = new Service(owner); - - if (!parseComponentInfo(owner, flags, s.info, outError, "<service>", sa, - com.android.internal.R.styleable.AndroidManifestService_name, - com.android.internal.R.styleable.AndroidManifestService_label, - com.android.internal.R.styleable.AndroidManifestService_icon, - com.android.internal.R.styleable.AndroidManifestService_process, - com.android.internal.R.styleable.AndroidManifestService_enabled)) { + if (mParseServiceArgs == null) { + mParseServiceArgs = new ParseComponentArgs(owner, outError, + com.android.internal.R.styleable.AndroidManifestService_name, + com.android.internal.R.styleable.AndroidManifestService_label, + com.android.internal.R.styleable.AndroidManifestService_icon, + mSeparateProcesses, + com.android.internal.R.styleable.AndroidManifestService_process, + com.android.internal.R.styleable.AndroidManifestService_enabled); + mParseServiceArgs.tag = "<service>"; + } + + mParseServiceArgs.sa = sa; + mParseServiceArgs.flags = flags; + + Service s = new Service(mParseServiceArgs, new ServiceInfo()); + if (outError[0] != null) { sa.recycle(); return null; } @@ -1725,9 +1796,6 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestService_exported, false); } - s.component = new ComponentName(owner.applicationInfo.packageName, - s.info.name); - String str = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestService_permission); if (str == null) { @@ -2084,16 +2152,75 @@ public class PackageParser { public static class Component<II extends IntentInfo> { public final Package owner; - public final ArrayList<II> intents = new ArrayList<II>(0); - public ComponentName component; + public final ArrayList<II> intents; + public final ComponentName component; + public final String componentShortName; public Bundle metaData; public Component(Package _owner) { owner = _owner; + intents = null; + component = null; + componentShortName = null; + } + + public Component(final ParsePackageItemArgs args, final PackageItemInfo outInfo) { + owner = args.owner; + intents = new ArrayList<II>(0); + String name = args.sa.getNonResourceString(args.nameRes); + if (name == null) { + component = null; + componentShortName = null; + args.outError[0] = args.tag + " does not specify android:name"; + return; + } + + outInfo.name + = buildClassName(owner.applicationInfo.packageName, name, args.outError); + if (outInfo.name == null) { + component = null; + componentShortName = null; + args.outError[0] = args.tag + " does not have valid android:name"; + return; + } + + component = new ComponentName(owner.applicationInfo.packageName, + outInfo.name); + componentShortName = component.flattenToShortString(); + + int iconVal = args.sa.getResourceId(args.iconRes, 0); + if (iconVal != 0) { + outInfo.icon = iconVal; + outInfo.nonLocalizedLabel = null; + } + + TypedValue v = args.sa.peekValue(args.labelRes); + if (v != null && (outInfo.labelRes=v.resourceId) == 0) { + outInfo.nonLocalizedLabel = v.coerceToString(); + } + + outInfo.packageName = owner.packageName; + } + + public Component(final ParseComponentArgs args, final ComponentInfo outInfo) { + this(args, (PackageItemInfo)outInfo); + if (args.outError[0] != null) { + return; + } + + if (args.processRes != 0) { + outInfo.processName = buildProcessName(owner.applicationInfo.packageName, + owner.applicationInfo.processName, args.sa.getNonResourceString(args.processRes), + args.flags, args.sepProcesses, args.outError); + } + outInfo.enabled = args.sa.getBoolean(args.enabledRes, true); } public Component(Component<II> clone) { owner = clone.owner; + intents = clone.intents; + component = clone.component; + componentShortName = clone.componentShortName; metaData = clone.metaData; } } @@ -2192,14 +2319,14 @@ public class PackageParser { } public final static class Activity extends Component<ActivityIntentInfo> { - public final ActivityInfo info = - new ActivityInfo(); + public final ActivityInfo info; - public Activity(Package _owner) { - super(_owner); - info.applicationInfo = owner.applicationInfo; + public Activity(final ParseComponentArgs args, final ActivityInfo _info) { + super(args, _info); + info = _info; + info.applicationInfo = args.owner.applicationInfo; } - + public String toString() { return "Activity{" + Integer.toHexString(System.identityHashCode(this)) @@ -2221,14 +2348,14 @@ public class PackageParser { } public final static class Service extends Component<ServiceIntentInfo> { - public final ServiceInfo info = - new ServiceInfo(); + public final ServiceInfo info; - public Service(Package _owner) { - super(_owner); - info.applicationInfo = owner.applicationInfo; + public Service(final ParseComponentArgs args, final ServiceInfo _info) { + super(args, _info); + info = _info; + info.applicationInfo = args.owner.applicationInfo; } - + public String toString() { return "Service{" + Integer.toHexString(System.identityHashCode(this)) @@ -2252,13 +2379,13 @@ public class PackageParser { public final ProviderInfo info; public boolean syncable; - public Provider(Package _owner) { - super(_owner); - info = new ProviderInfo(); - info.applicationInfo = owner.applicationInfo; + public Provider(final ParseComponentArgs args, final ProviderInfo _info) { + super(args, _info); + info = _info; + info.applicationInfo = args.owner.applicationInfo; syncable = false; } - + public Provider(Provider existingProvider) { super(existingProvider); this.info = existingProvider.info; @@ -2291,13 +2418,13 @@ public class PackageParser { } public final static class Instrumentation extends Component { - public final InstrumentationInfo info = - new InstrumentationInfo(); + public final InstrumentationInfo info; - public Instrumentation(Package _owner) { - super(_owner); + public Instrumentation(final ParsePackageItemArgs args, final InstrumentationInfo _info) { + super(args, _info); + info = _info; } - + public String toString() { return "Instrumentation{" + Integer.toHexString(System.identityHashCode(this)) diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index 956b15a..bb3486c 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -144,11 +144,29 @@ public final class Configuration implements Parcelable, Comparable<Configuration } public String toString() { - return "{ scale=" + fontScale + " imsi=" + mcc + "/" + mnc - + " locale=" + locale - + " touch=" + touchscreen + " key=" + keyboard + "/" - + keyboardHidden + "/" + hardKeyboardHidden - + " nav=" + navigation + " orien=" + orientation + " }"; + StringBuilder sb = new StringBuilder(128); + sb.append("{ scale="); + sb.append(fontScale); + sb.append(" imsi="); + sb.append(mcc); + sb.append("/"); + sb.append(mnc); + sb.append(" loc="); + sb.append(locale); + sb.append(" touch="); + sb.append(touchscreen); + sb.append(" keys="); + sb.append(keyboard); + sb.append("/"); + sb.append(keyboardHidden); + sb.append("/"); + sb.append(hardKeyboardHidden); + sb.append(" nav="); + sb.append(navigation); + sb.append(" orien="); + sb.append(orientation); + sb.append('}'); + return sb.toString(); } /** diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index 39d36de..333ba73 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -113,7 +113,7 @@ public abstract class BatteryStats implements Parcelable { private static final String DATA_CONNECTION_TIME_DATA = "dct"; private static final String DATA_CONNECTION_COUNT_DATA = "dcc"; - private final StringBuilder mFormatBuilder = new StringBuilder(8); + private final StringBuilder mFormatBuilder = new StringBuilder(32); private final Formatter mFormatter = new Formatter(mFormatBuilder); /** @@ -522,7 +522,7 @@ public abstract class BatteryStats implements Parcelable { public abstract Map<String, ? extends Timer> getKernelWakelockStats(); - private final static void formatTime(StringBuilder out, long seconds) { + private final static void formatTimeRaw(StringBuilder out, long seconds) { long days = seconds / (60 * 60 * 24); if (days != 0) { out.append(days); @@ -550,22 +550,18 @@ public abstract class BatteryStats implements Parcelable { } } - private final static String formatTime(long time) { + private final static void formatTime(StringBuilder sb, long time) { long sec = time / 100; - StringBuilder sb = new StringBuilder(); - formatTime(sb, sec); + formatTimeRaw(sb, sec); sb.append((time - (sec * 100)) * 10); sb.append("ms "); - return sb.toString(); } - private final static String formatTimeMs(long time) { + private final static void formatTimeMs(StringBuilder sb, long time) { long sec = time / 1000; - StringBuilder sb = new StringBuilder(); - formatTime(sb, sec); + formatTimeRaw(sb, sec); sb.append(time - (sec * 1000)); sb.append("ms "); - return sb.toString(); } private final String formatRatioLocked(long num, long den) { @@ -616,8 +612,8 @@ public abstract class BatteryStats implements Parcelable { int count = timer.getCountLocked(which); if (totalTimeMillis != 0) { sb.append(linePrefix); - sb.append(formatTimeMs(totalTimeMillis)); - sb.append(name != null ? name : ""); + formatTimeMs(sb, totalTimeMillis); + if (name != null) sb.append(name); sb.append(' '); sb.append('('); sb.append(count); @@ -916,7 +912,7 @@ public abstract class BatteryStats implements Parcelable { } @SuppressWarnings("unused") - private final void dumpLocked(Printer pw, String prefix, int which) { + private final void dumpLocked(PrintWriter pw, String prefix, int which) { final long rawUptime = SystemClock.uptimeMillis() * 1000; final long rawRealtime = SystemClock.elapsedRealtime() * 1000; final long batteryUptime = getBatteryUptime(rawUptime); @@ -932,33 +928,41 @@ public abstract class BatteryStats implements Parcelable { SparseArray<? extends Uid> uidStats = getUidStats(); final int NU = uidStats.size(); - pw.println(prefix - + " Time on battery: " - + formatTimeMs(whichBatteryRealtime / 1000) + "(" - + formatRatioLocked(whichBatteryRealtime, totalRealtime) - + ") realtime, " - + formatTimeMs(whichBatteryUptime / 1000) - + "(" + formatRatioLocked(whichBatteryUptime, totalRealtime) - + ") uptime"); - pw.println(prefix - + " Total run time: " - + formatTimeMs(totalRealtime / 1000) - + "realtime, " - + formatTimeMs(totalUptime / 1000) - + "uptime, "); + sb.setLength(0); + sb.append(prefix); + sb.append(" Time on battery: "); + formatTimeMs(sb, whichBatteryRealtime / 1000); sb.append("("); + sb.append(formatRatioLocked(whichBatteryRealtime, totalRealtime)); + sb.append(") realtime, "); + formatTimeMs(sb, whichBatteryUptime / 1000); + sb.append("("); sb.append(formatRatioLocked(whichBatteryUptime, totalRealtime)); + sb.append(") uptime"); + pw.println(sb.toString()); + sb.setLength(0); + sb.append(prefix); + sb.append(" Total run time: "); + formatTimeMs(sb, totalRealtime / 1000); + sb.append("realtime, "); + formatTimeMs(sb, totalUptime / 1000); + sb.append("uptime, "); + pw.println(sb.toString()); final long screenOnTime = getScreenOnTime(batteryRealtime, which); final long phoneOnTime = getPhoneOnTime(batteryRealtime, which); final long wifiRunningTime = getWifiRunningTime(batteryRealtime, which); final long wifiOnTime = getWifiOnTime(batteryRealtime, which); final long bluetoothOnTime = getBluetoothOnTime(batteryRealtime, which); - pw.println(prefix - + " Screen on: " + formatTimeMs(screenOnTime / 1000) - + "(" + formatRatioLocked(screenOnTime, whichBatteryRealtime) - + "), Input events: " + getInputEventCount(which) - + ", Active phone call: " + formatTimeMs(phoneOnTime / 1000) - + "(" + formatRatioLocked(phoneOnTime, whichBatteryRealtime) + ")"); sb.setLength(0); + sb.append(prefix); + sb.append(" Screen on: "); formatTimeMs(sb, screenOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(screenOnTime, whichBatteryRealtime)); + sb.append("), Input events: "); sb.append(getInputEventCount(which)); + sb.append(", Active phone call: "); formatTimeMs(sb, phoneOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(phoneOnTime, whichBatteryRealtime)); + sb.append(")"); + pw.println(sb.toString()); + sb.setLength(0); + sb.append(prefix); sb.append(" Screen brightnesses: "); boolean didOne = false; for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { @@ -970,7 +974,7 @@ public abstract class BatteryStats implements Parcelable { didOne = true; sb.append(SCREEN_BRIGHTNESS_NAMES[i]); sb.append(" "); - sb.append(formatTimeMs(time/1000)); + formatTimeMs(sb, time/1000); sb.append("("); sb.append(formatRatioLocked(time, screenOnTime)); sb.append(")"); @@ -1030,16 +1034,19 @@ public abstract class BatteryStats implements Parcelable { } } - pw.println(prefix - + " Total received: " + formatBytesLocked(rxTotal) - + ", Total sent: " + formatBytesLocked(txTotal)); - pw.println(prefix - + " Total full wakelock time: " + formatTimeMs( - (fullWakeLockTimeTotalMicros + 500) / 1000) - + ", Total partial waklock time: " + formatTimeMs( - (partialWakeLockTimeTotalMicros + 500) / 1000)); + pw.print(prefix); + pw.print(" Total received: "); pw.print(formatBytesLocked(rxTotal)); + pw.print(", Total sent: "); pw.println(formatBytesLocked(txTotal)); + sb.setLength(0); + sb.append(prefix); + sb.append(" Total full wakelock time: "); formatTimeMs(sb, + (fullWakeLockTimeTotalMicros + 500) / 1000); + sb.append(", Total partial waklock time: "); formatTimeMs(sb, + (partialWakeLockTimeTotalMicros + 500) / 1000); + pw.println(sb.toString()); sb.setLength(0); + sb.append(prefix); sb.append(" Signal levels: "); didOne = false; for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) { @@ -1051,7 +1058,7 @@ public abstract class BatteryStats implements Parcelable { didOne = true; sb.append(SIGNAL_STRENGTH_NAMES[i]); sb.append(" "); - sb.append(formatTimeMs(time/1000)); + formatTimeMs(sb, time/1000); sb.append("("); sb.append(formatRatioLocked(time, whichBatteryRealtime)); sb.append(") "); @@ -1062,6 +1069,7 @@ public abstract class BatteryStats implements Parcelable { pw.println(sb.toString()); sb.setLength(0); + sb.append(prefix); sb.append(" Radio types: "); didOne = false; for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) { @@ -1073,7 +1081,7 @@ public abstract class BatteryStats implements Parcelable { didOne = true; sb.append(DATA_CONNECTION_NAMES[i]); sb.append(" "); - sb.append(formatTimeMs(time/1000)); + formatTimeMs(sb, time/1000); sb.append("("); sb.append(formatRatioLocked(time, whichBatteryRealtime)); sb.append(") "); @@ -1083,29 +1091,32 @@ public abstract class BatteryStats implements Parcelable { if (!didOne) sb.append("No activity"); pw.println(sb.toString()); - pw.println(prefix - + " Wifi on: " + formatTimeMs(wifiOnTime / 1000) - + "(" + formatRatioLocked(wifiOnTime, whichBatteryRealtime) - + "), Wifi running: " + formatTimeMs(wifiRunningTime / 1000) - + "(" + formatRatioLocked(wifiRunningTime, whichBatteryRealtime) - + "), Bluetooth on: " + formatTimeMs(bluetoothOnTime / 1000) - + "(" + formatRatioLocked(bluetoothOnTime, whichBatteryRealtime)+ ")"); + sb.setLength(0); + sb.append(prefix); + sb.append(" Wifi on: "); formatTimeMs(sb, wifiOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(wifiOnTime, whichBatteryRealtime)); + sb.append("), Wifi running: "); formatTimeMs(sb, wifiRunningTime / 1000); + sb.append("("); sb.append(formatRatioLocked(wifiRunningTime, whichBatteryRealtime)); + sb.append("), Bluetooth on: "); formatTimeMs(sb, bluetoothOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(bluetoothOnTime, whichBatteryRealtime)); + sb.append(")"); + pw.println(sb.toString()); pw.println(" "); if (which == STATS_UNPLUGGED) { if (getIsOnBattery()) { - pw.println(prefix + " Device is currently unplugged"); - pw.println(prefix + " Discharge cycle start level: " + - getDischargeStartLevel()); - pw.println(prefix + " Discharge cycle current level: " + - getDischargeCurrentLevel()); + pw.print(prefix); pw.println(" Device is currently unplugged"); + pw.print(prefix); pw.print(" Discharge cycle start level: "); + pw.println(getDischargeStartLevel()); + pw.print(prefix); pw.print(" Discharge cycle current level: "); + pw.println(getDischargeCurrentLevel()); } else { - pw.println(prefix + " Device is currently plugged into power"); - pw.println(prefix + " Last discharge cycle start level: " + - getDischargeStartLevel()); - pw.println(prefix + " Last discharge cycle end level: " + - getDischargeCurrentLevel()); + pw.print(prefix); pw.println(" Device is currently plugged into power"); + pw.print(prefix); pw.print(" Last discharge cycle start level: "); + pw.println(getDischargeStartLevel()); + pw.print(prefix); pw.print(" Last discharge cycle end level: "); + pw.println(getDischargeCurrentLevel()); } pw.println(" "); } @@ -1124,8 +1135,9 @@ public abstract class BatteryStats implements Parcelable { long wifiTurnedOnTime = u.getWifiTurnedOnTime(batteryRealtime, which); if (tcpReceived != 0 || tcpSent != 0) { - pw.println(prefix + " Network: " + formatBytesLocked(tcpReceived) + " received, " - + formatBytesLocked(tcpSent) + " sent"); + pw.print(prefix); pw.print(" Network: "); + pw.print(formatBytesLocked(tcpReceived)); pw.print(" received, "); + pw.print(formatBytesLocked(tcpSent)); pw.println(" sent"); } if (u.hasUserActivity()) { @@ -1152,18 +1164,20 @@ public abstract class BatteryStats implements Parcelable { if (fullWifiLockOnTime != 0 || scanWifiLockOnTime != 0 || wifiTurnedOnTime != 0) { - pw.println(prefix + " Turned Wifi On Time: " - + formatTimeMs(wifiTurnedOnTime / 1000) - + "(" + formatRatioLocked(wifiTurnedOnTime, - whichBatteryRealtime)+ ")"); - pw.println(prefix + " Full Wifi Lock Time: " - + formatTimeMs(fullWifiLockOnTime / 1000) - + "(" + formatRatioLocked(fullWifiLockOnTime, - whichBatteryRealtime)+ ")"); - pw.println(prefix + " Scan Wifi Lock Time: " - + formatTimeMs(scanWifiLockOnTime / 1000) - + "(" + formatRatioLocked(scanWifiLockOnTime, - whichBatteryRealtime)+ ")"); + sb.setLength(0); + sb.append(prefix); sb.append(" Turned Wifi On: "); + formatTimeMs(sb, wifiTurnedOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(wifiTurnedOnTime, + whichBatteryRealtime)); sb.append(")\n"); + sb.append(prefix); sb.append(" Full Wifi Lock: "); + formatTimeMs(sb, fullWifiLockOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(fullWifiLockOnTime, + whichBatteryRealtime)); sb.append(")\n"); + sb.append(prefix); sb.append(" Scan Wifi Lock: "); + formatTimeMs(sb, scanWifiLockOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(scanWifiLockOnTime, + whichBatteryRealtime)); sb.append(")"); + pw.println(sb.toString()); } Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); @@ -1217,7 +1231,7 @@ public abstract class BatteryStats implements Parcelable { int count = timer.getCountLocked(which); //timer.logState(); if (totalTime != 0) { - sb.append(formatTimeMs(totalTime)); + formatTimeMs(sb, totalTime); sb.append("realtime ("); sb.append(count); sb.append(" times)"); @@ -1247,10 +1261,15 @@ public abstract class BatteryStats implements Parcelable { starts = ps.getStarts(which); if (userTime != 0 || systemTime != 0 || starts != 0) { - pw.println(prefix + " Proc " + ent.getKey() + ":"); - pw.println(prefix + " CPU: " + formatTime(userTime) + "user + " - + formatTime(systemTime) + "kernel"); - pw.println(prefix + " " + starts + " process starts"); + sb.setLength(0); + sb.append(prefix); sb.append(" Proc "); + sb.append(ent.getKey()); sb.append(":\n"); + sb.append(prefix); sb.append(" CPU: "); + formatTime(sb, userTime); sb.append("usr + "); + formatTime(sb, systemTime); sb.append("krn\n"); + sb.append(prefix); sb.append(" "); sb.append(starts); + sb.append(" proc starts"); + pw.println(sb.toString()); uidActivity = true; } } @@ -1260,12 +1279,13 @@ public abstract class BatteryStats implements Parcelable { if (packageStats.size() > 0) { for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg> ent : packageStats.entrySet()) { - pw.println(prefix + " Apk " + ent.getKey() + ":"); + pw.print(prefix); pw.print(" Apk "); pw.print(ent.getKey()); pw.println(":"); boolean apkActivity = false; Uid.Pkg ps = ent.getValue(); int wakeups = ps.getWakeups(which); if (wakeups != 0) { - pw.println(prefix + " " + wakeups + " wakeup alarms"); + pw.print(prefix); pw.print(" "); + pw.print(wakeups); pw.println(" wakeup alarms"); apkActivity = true; } Map<String, ? extends Uid.Pkg.Serv> serviceStats = ps.getServiceStats(); @@ -1277,24 +1297,28 @@ public abstract class BatteryStats implements Parcelable { int starts = ss.getStarts(which); int launches = ss.getLaunches(which); if (startTime != 0 || starts != 0 || launches != 0) { - pw.println(prefix + " Service " + sent.getKey() + ":"); - pw.println(prefix + " Created for: " - + formatTimeMs(startTime / 1000) - + " uptime"); - pw.println(prefix + " Starts: " + starts - + ", launches: " + launches); + sb.setLength(0); + sb.append(prefix); sb.append(" Service "); + sb.append(sent.getKey()); sb.append(":\n"); + sb.append(prefix); sb.append(" Created for: "); + formatTimeMs(sb, startTime / 1000); + sb.append(" uptime\n"); + sb.append(prefix); sb.append(" Starts: "); + sb.append(starts); + sb.append(", launches: "); sb.append(launches); + pw.println(sb.toString()); apkActivity = true; } } } if (!apkActivity) { - pw.println(prefix + " (nothing executed)"); + pw.print(prefix); pw.println(" (nothing executed)"); } uidActivity = true; } } if (!uidActivity) { - pw.println(prefix + " (nothing executed)"); + pw.print(prefix); pw.println(" (nothing executed)"); } } } @@ -1305,7 +1329,7 @@ public abstract class BatteryStats implements Parcelable { * @param pw a Printer to receive the dump output. */ @SuppressWarnings("unused") - public void dumpLocked(Printer pw) { + public void dumpLocked(PrintWriter pw) { pw.println("Total Statistics (Current and Historic):"); pw.println(" System starts: " + getStartCount() + ", currently on battery: " + getIsOnBattery()); diff --git a/core/java/android/view/animation/Transformation.java b/core/java/android/view/animation/Transformation.java index f9e85bf..cf210c8 100644 --- a/core/java/android/view/animation/Transformation.java +++ b/core/java/android/view/animation/Transformation.java @@ -18,6 +18,8 @@ package android.view.animation; import android.graphics.Matrix; +import java.io.PrintWriter; + /** * Defines the transformation to be applied at * one point in time of an Animation. @@ -134,14 +136,38 @@ public class Transformation { @Override public String toString() { - return "Transformation{alpha=" + mAlpha + " matrix=" - + mMatrix.toShortString() + "}"; + StringBuilder sb = new StringBuilder(64); + sb.append("Transformation"); + toShortString(sb); + return sb.toString(); } /** * Return a string representation of the transformation in a compact form. */ public String toShortString() { - return "{alpha=" + mAlpha + " matrix=" + mMatrix.toShortString() + "}"; + StringBuilder sb = new StringBuilder(64); + toShortString(sb); + return sb.toString(); + } + + /** + * @hide + */ + public void toShortString(StringBuilder sb) { + sb.append("{alpha="); sb.append(mAlpha); + sb.append(" matrix="); mMatrix.toShortString(sb); + sb.append('}'); + } + + /** + * Print short string, to optimize dumping. + * @hide + */ + public void printShortString(PrintWriter pw) { + pw.print("{alpha="); pw.print(mAlpha); + pw.print(" matrix="); + mMatrix.printShortString(pw); + pw.print('}'); } } diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 58a9be85..77649f0 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -25,6 +25,7 @@ import android.os.Process; import android.os.SystemClock; import android.telephony.TelephonyManager; import android.util.Log; +import android.util.PrintWriterPrinter; import android.util.Printer; import android.util.SparseArray; @@ -32,6 +33,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -3096,32 +3098,33 @@ public final class BatteryStatsImpl extends BatteryStats { } }; - public void dumpLocked(Printer pw) { + public void dumpLocked(PrintWriter pw) { if (DEBUG) { - pw.println("*** Screen timer:"); - mScreenOnTimer.logState(pw, " "); + Printer pr = new PrintWriterPrinter(pw); + pr.println("*** Screen timer:"); + mScreenOnTimer.logState(pr, " "); for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { - pw.println("*** Screen brightness #" + i + ":"); - mScreenBrightnessTimer[i].logState(pw, " "); + pr.println("*** Screen brightness #" + i + ":"); + mScreenBrightnessTimer[i].logState(pr, " "); } - pw.println("*** Input event counter:"); - mInputEventCounter.logState(pw, " "); - pw.println("*** Phone timer:"); - mPhoneOnTimer.logState(pw, " "); + pr.println("*** Input event counter:"); + mInputEventCounter.logState(pr, " "); + pr.println("*** Phone timer:"); + mPhoneOnTimer.logState(pr, " "); for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) { - pw.println("*** Signal strength #" + i + ":"); - mPhoneSignalStrengthsTimer[i].logState(pw, " "); + pr.println("*** Signal strength #" + i + ":"); + mPhoneSignalStrengthsTimer[i].logState(pr, " "); } for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) { - pw.println("*** Data connection type #" + i + ":"); - mPhoneDataConnectionsTimer[i].logState(pw, " "); - } - pw.println("*** Wifi timer:"); - mWifiOnTimer.logState(pw, " "); - pw.println("*** WifiRunning timer:"); - mWifiRunningTimer.logState(pw, " "); - pw.println("*** Bluetooth timer:"); - mBluetoothOnTimer.logState(pw, " "); + pr.println("*** Data connection type #" + i + ":"); + mPhoneDataConnectionsTimer[i].logState(pr, " "); + } + pr.println("*** Wifi timer:"); + mWifiOnTimer.logState(pr, " "); + pr.println("*** WifiRunning timer:"); + mWifiRunningTimer.logState(pr, " "); + pr.println("*** Bluetooth timer:"); + mBluetoothOnTimer.logState(pr, " "); } super.dumpLocked(pw); } diff --git a/graphics/java/android/graphics/Matrix.java b/graphics/java/android/graphics/Matrix.java index 2681eae..f549900 100644 --- a/graphics/java/android/graphics/Matrix.java +++ b/graphics/java/android/graphics/Matrix.java @@ -16,6 +16,8 @@ package android.graphics; +import java.io.PrintWriter; + /** * The Matrix class holds a 3x3 matrix for transforming coordinates. @@ -539,17 +541,49 @@ public class Matrix { } public String toString() { - return "Matrix{" + toShortString() + "}"; + StringBuilder sb = new StringBuilder(64); + sb.append("Matrix{"); + toShortString(sb); + sb.append('}'); + return sb.toString(); } public String toShortString() { + StringBuilder sb = new StringBuilder(64); + toShortString(sb); + return sb.toString(); + } + + /** + * @hide + */ + public void toShortString(StringBuilder sb) { + float[] values = new float[9]; + getValues(values); + sb.append('['); + sb.append(values[0]); sb.append(", "); sb.append(values[1]); sb.append(", "); + sb.append(values[2]); sb.append("]["); + sb.append(values[3]); sb.append(", "); sb.append(values[4]); sb.append(", "); + sb.append(values[5]); sb.append("]["); + sb.append(values[6]); sb.append(", "); sb.append(values[7]); sb.append(", "); + sb.append(values[8]); sb.append(']'); + } + + /** + * Print short string, to optimize dumping. + * @hide + */ + public void printShortString(PrintWriter pw) { float[] values = new float[9]; getValues(values); - return "[" + - values[0] + ", " + values[1] + ", " + values[2] + "][" + - values[3] + ", " + values[4] + ", " + values[5] + "][" + - values[6] + ", " + values[7] + ", " + values[8] + "]"; + pw.print('['); + pw.print(values[0]); pw.print(", "); pw.print(values[1]); pw.print(", "); + pw.print(values[2]); pw.print("]["); + pw.print(values[3]); pw.print(", "); pw.print(values[4]); pw.print(", "); + pw.print(values[5]); pw.print("]["); + pw.print(values[6]); pw.print(", "); pw.print(values[7]); pw.print(", "); + pw.print(values[8]); pw.print(']'); } diff --git a/graphics/java/android/graphics/Rect.java b/graphics/java/android/graphics/Rect.java index 2005344..7022acf 100644 --- a/graphics/java/android/graphics/Rect.java +++ b/graphics/java/android/graphics/Rect.java @@ -19,6 +19,8 @@ package android.graphics; import android.os.Parcel; import android.os.Parcelable; +import java.io.PrintWriter; + /** * Rect holds four integer coordinates for a rectangle. The rectangle is * represented by the coordinates of its 4 edges (left, top, right bottom). @@ -78,14 +80,40 @@ public final class Rect implements Parcelable { } public String toString() { - return "Rect(" + left + ", " + top + " - " + right + ", " + bottom + ")"; + StringBuilder sb = new StringBuilder(32); + sb.append("Rect("); sb.append(left); sb.append(", "); + sb.append(top); sb.append(" - "); sb.append(right); + sb.append(", "); sb.append(bottom); sb.append(")"); + return sb.toString(); } /** * Return a string representation of the rectangle in a compact form. */ public String toShortString() { - return "[" + left + "," + top + "][" + right + "," + bottom + "]"; + return toShortString(new StringBuilder(32)); + } + + /** + * Return a string representation of the rectangle in a compact form. + * @hide + */ + public String toShortString(StringBuilder sb) { + sb.setLength(0); + sb.append('['); sb.append(left); sb.append(','); + sb.append(top); sb.append("]["); sb.append(right); + sb.append(','); sb.append(bottom); sb.append(']'); + return sb.toString(); + } + + /** + * Print short representation to given writer. + * @hide + */ + public void printShortString(PrintWriter pw) { + pw.print('['); pw.print(left); pw.print(','); + pw.print(top); pw.print("]["); pw.print(right); + pw.print(','); pw.print(bottom); pw.print(']'); } /** diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index d66c6e5..9c4ace1 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -413,41 +413,45 @@ class AlarmManagerService extends IAlarmManager.Stub { synchronized (mLock) { pw.println("Current Alarm Manager state:"); - if (mRtcWakeupAlarms.size() > 0) { + if (mRtcWakeupAlarms.size() > 0 || mRtcAlarms.size() > 0) { pw.println(" "); - pw.println(" Realtime wakeup alarms that are scheduled:"); - dumpAlarmList(pw, mRtcWakeupAlarms, " ", "RTC_WAKEUP"); - } - if (mRtcAlarms.size() > 0) { - pw.println(" "); - pw.println(" Realtime alarms that are scheduled:"); - dumpAlarmList(pw, mRtcAlarms, " ", "RTC"); - } - if (mElapsedRealtimeWakeupAlarms.size() > 0) { - pw.println(" "); - pw.println(" Elapsed realtime wakeup alarms that are scheduled:"); - dumpAlarmList(pw, mElapsedRealtimeWakeupAlarms, " ", "ELAPSED_REALTIME_WAKEUP"); + pw.print(" Realtime wakeup (now="); + pw.print(System.currentTimeMillis()); pw.println("):"); + if (mRtcWakeupAlarms.size() > 0) { + dumpAlarmList(pw, mRtcWakeupAlarms, " ", "RTC_WAKEUP"); + } + if (mRtcAlarms.size() > 0) { + dumpAlarmList(pw, mRtcAlarms, " ", "RTC"); + } } - if (mElapsedRealtimeAlarms.size() > 0) { + if (mElapsedRealtimeWakeupAlarms.size() > 0 || mElapsedRealtimeAlarms.size() > 0) { pw.println(" "); - pw.println(" Elapsed realtime alarms that are scheduled:"); - dumpAlarmList(pw, mElapsedRealtimeAlarms, " ", "ELAPSED_REALTIME"); + pw.print(" Elapsed realtime wakeup (now="); + pw.print(SystemClock.elapsedRealtime()); pw.println("):"); + if (mElapsedRealtimeWakeupAlarms.size() > 0) { + dumpAlarmList(pw, mElapsedRealtimeWakeupAlarms, " ", "ELAPSED_WAKEUP"); + } + if (mElapsedRealtimeAlarms.size() > 0) { + dumpAlarmList(pw, mElapsedRealtimeAlarms, " ", "ELAPSED"); + } } pw.println(" "); - pw.println(" Broadcast ref count: " + mBroadcastRefCount); + pw.print(" Broadcast ref count: "); pw.println(mBroadcastRefCount); pw.println(" "); pw.println(" Alarm Stats:"); for (Map.Entry<String, BroadcastStats> be : mBroadcastStats.entrySet()) { BroadcastStats bs = be.getValue(); - pw.println(" " + be.getKey()); - pw.println(" " + bs.aggregateTime + "ms running, " - + bs.numWakeup + " wakeups"); + pw.print(" "); pw.println(be.getKey()); + pw.print(" "); pw.print(bs.aggregateTime); + pw.print("ms running, "); pw.print(bs.numWakeup); + pw.println(" wakeups"); for (Map.Entry<Intent.FilterComparison, FilterStats> fe : bs.filterStats.entrySet()) { - pw.println(" " + fe.getValue().count + " alarms: " - + fe.getKey().getIntent()); + pw.print(" "); pw.print(fe.getValue().count); + pw.print(" alarms: "); + pw.println(fe.getKey().getIntent().toShortString(true, false)); } } } @@ -456,7 +460,8 @@ class AlarmManagerService extends IAlarmManager.Stub { private static final void dumpAlarmList(PrintWriter pw, ArrayList<Alarm> list, String prefix, String label) { for (int i=list.size()-1; i>=0; i--) { Alarm a = list.get(i); - pw.println(prefix + label + " #" + i + ":"); + pw.print(prefix); pw.print(label); pw.print(" #"); pw.print(i); + pw.print(": "); pw.println(a); a.dump(pw, prefix + " "); } } @@ -561,18 +566,24 @@ class AlarmManagerService extends IAlarmManager.Stub { @Override public String toString() { - return "Alarm{" - + Integer.toHexString(System.identityHashCode(this)) - + " type " + type + " " + operation.getTargetPackage() + "}"; + StringBuilder sb = new StringBuilder(128); + sb.append("Alarm{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" type "); + sb.append(type); + sb.append(" "); + sb.append(operation.getTargetPackage()); + sb.append('}'); + return sb.toString(); } public void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "type=" + type + " when=" + when - + " repeatInterval=" + repeatInterval - + " count=" + count); - pw.println(prefix + "operation=" + operation); + pw.print(prefix); pw.print("type="); pw.print(type); + pw.print(" when="); pw.print(when); + pw.print(" repeatInterval="); pw.print(repeatInterval); + pw.print(" count="); pw.println(count); + pw.print(prefix); pw.print("operation="); pw.println(operation); } } diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index de5d0ac..bb420a6 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -151,34 +151,57 @@ class AppWidgetService extends IAppWidgetService.Stub synchronized (mAppWidgetIds) { int N = mInstalledProviders.size(); - pw.println("Providers: (size=" + N + ")"); + pw.println("Providers:"); for (int i=0; i<N; i++) { Provider p = mInstalledProviders.get(i); AppWidgetProviderInfo info = p.info; - pw.println(" [" + i + "] provder=" + info.provider - + " min=(" + info.minWidth + "x" + info.minHeight + ")" - + " updatePeriodMillis=" + info.updatePeriodMillis - + " initialLayout=" + info.initialLayout + " zombie=" + p.zombie); + pw.print(" ["); pw.print(i); pw.print("] provider "); + pw.print(info.provider.flattenToShortString()); + pw.println(':'); + pw.print(" min=("); pw.print(info.minWidth); + pw.print("x"); pw.print(info.minHeight); + pw.print(") updatePeriodMillis="); + pw.print(info.updatePeriodMillis); + pw.print(" initialLayout=#"); + pw.print(Integer.toHexString(info.initialLayout)); + pw.print(" zombie="); pw.println(p.zombie); } N = mAppWidgetIds.size(); - pw.println("AppWidgetIds: (size=" + N + ")"); + pw.println(" "); + pw.println("AppWidgetIds:"); for (int i=0; i<N; i++) { AppWidgetId id = mAppWidgetIds.get(i); - pw.println(" [" + i + "] appWidgetId=" + id.appWidgetId - + " host=" + id.host.hostId + "/" + id.host.packageName + " provider=" - + (id.provider == null ? "null" : id.provider.info.provider) - + " host.callbacks=" + (id.host != null ? id.host.callbacks : "(no host)") - + " views=" + id.views); + pw.print(" ["); pw.print(i); pw.print("] id="); + pw.println(id.appWidgetId);; + pw.print(" hostId="); + pw.print(id.host.hostId); pw.print(' '); + pw.print(id.host.packageName); pw.print('/'); + pw.println(id.host.uid); + if (id.provider != null) { + pw.print(" provider="); + pw.println(id.provider.info.provider.flattenToShortString()); + } + if (id.host != null) { + pw.print(" host.callbacks="); pw.println(id.host.callbacks); + } + if (id.views != null) { + pw.print(" views="); pw.println(id.views); + } } N = mHosts.size(); - pw.println("Hosts: (size=" + N + ")"); + pw.println(" "); + pw.println("Hosts:"); for (int i=0; i<N; i++) { Host host = mHosts.get(i); - pw.println(" [" + i + "] packageName=" + host.packageName + " uid=" + host.uid - + " hostId=" + host.hostId + " callbacks=" + host.callbacks - + " instances.size=" + host.instances.size() + " zombie=" + host.zombie); + pw.print(" ["); pw.print(i); pw.print("] hostId="); + pw.print(host.hostId); pw.print(' '); + pw.print(host.packageName); pw.print('/'); + pw.print(host.uid); pw.println(':'); + pw.print(" callbacks="); pw.println(host.callbacks); + pw.print(" instances.size="); pw.print(host.instances.size()); + pw.print(" zombie="); pw.println(host.zombie); } } } diff --git a/services/java/com/android/server/IntentResolver.java b/services/java/com/android/server/IntentResolver.java index b534ef1..72efca5 100644 --- a/services/java/com/android/server/IntentResolver.java +++ b/services/java/com/android/server/IntentResolver.java @@ -16,6 +16,7 @@ package com.android.server; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -89,11 +90,11 @@ public class IntentResolver<F extends IntentFilter, R extends Object> { } } - void dumpMap(Printer out, String prefix, Map<String, ArrayList<F>> map) { + void dumpMap(PrintWriter out, String prefix, Map<String, ArrayList<F>> map) { String eprefix = prefix + " "; String fprefix = prefix + " "; for (Map.Entry<String, ArrayList<F>> e : map.entrySet()) { - out.println(eprefix + e.getKey() + ":"); + out.print(eprefix); out.print(e.getKey()); out.println(":"); ArrayList<F> a = e.getValue(); final int N = a.size(); for (int i=0; i<N; i++) { @@ -102,24 +103,25 @@ public class IntentResolver<F extends IntentFilter, R extends Object> { } } - public void dump(Printer out, String prefix) { - out.println(prefix + "Full MIME Types:"); - dumpMap(out, prefix+" ", mTypeToFilter); - out.println(prefix); - out.println(prefix + "Base MIME Types:"); - dumpMap(out, prefix+" ", mBaseTypeToFilter); - out.println(prefix); - out.println(prefix + "Wild MIME Types:"); - dumpMap(out, prefix+" ", mWildTypeToFilter); - out.println(prefix); - out.println(prefix + "Schemes:"); - dumpMap(out, prefix+" ", mSchemeToFilter); - out.println(prefix); - out.println(prefix + "Non-Data Actions:"); - dumpMap(out, prefix+" ", mActionToFilter); - out.println(prefix); - out.println(prefix + "MIME Typed Actions:"); - dumpMap(out, prefix+" ", mTypedActionToFilter); + public void dump(PrintWriter out, String prefix) { + String innerPrefix = prefix + " "; + out.print(prefix); out.println("Full MIME Types:"); + dumpMap(out, innerPrefix, mTypeToFilter); + out.println(" "); + out.print(prefix); out.println("Base MIME Types:"); + dumpMap(out, innerPrefix, mBaseTypeToFilter); + out.println(" "); + out.print(prefix); out.println("Wild MIME Types:"); + dumpMap(out, innerPrefix, mWildTypeToFilter); + out.println(" "); + out.print(prefix); out.println("Schemes:"); + dumpMap(out, innerPrefix, mSchemeToFilter); + out.println(" "); + out.print(prefix); out.println("Non-Data Actions:"); + dumpMap(out, innerPrefix, mActionToFilter); + out.println(" "); + out.print(prefix); out.println("MIME Typed Actions:"); + dumpMap(out, innerPrefix, mTypedActionToFilter); } private class IteratorWrapper implements Iterator<F> { @@ -275,8 +277,8 @@ public class IntentResolver<F extends IntentFilter, R extends Object> { Collections.sort(results, mResolvePrioritySorter); } - protected void dumpFilter(Printer out, String prefix, F filter) { - out.println(prefix + filter); + protected void dumpFilter(PrintWriter out, String prefix, F filter) { + out.print(prefix); out.println(filter); } private final int register_mime_types(F filter, String prefix) { diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 9e062f4..159bc76 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -2932,11 +2932,12 @@ class PackageManagerService extends IPackageManager.Stub { } @Override - protected void dumpFilter(Printer out, String prefix, + protected void dumpFilter(PrintWriter out, String prefix, PackageParser.ActivityIntentInfo filter) { - out.println(prefix - + Integer.toHexString(System.identityHashCode(filter.activity)) - + " " + filter.activity.component.flattenToShortString()); + out.print(prefix); out.print( + Integer.toHexString(System.identityHashCode(filter.activity))); + out.print(' '); + out.println(filter.activity.componentShortName); } // List<ResolveInfo> filterEnabled(List<ResolveInfo> resolveInfoList) { @@ -3064,11 +3065,12 @@ class PackageManagerService extends IPackageManager.Stub { } @Override - protected void dumpFilter(Printer out, String prefix, + protected void dumpFilter(PrintWriter out, String prefix, PackageParser.ServiceIntentInfo filter) { - out.println(prefix - + Integer.toHexString(System.identityHashCode(filter.service)) - + " " + filter.service.component.flattenToShortString()); + out.print(prefix); out.print( + Integer.toHexString(System.identityHashCode(filter.service))); + out.print(' '); + out.println(filter.service.componentShortName); } // List<ResolveInfo> filterEnabled(List<ResolveInfo> resolveInfoList) { @@ -4578,80 +4580,83 @@ class PackageManagerService extends IPackageManager.Stub { return; } - Printer printer = new PrintWriterPrinter(pw); synchronized (mPackages) { pw.println("Activity Resolver Table:"); - mActivities.dump(printer, " "); + mActivities.dump(pw, " "); pw.println(" "); pw.println("Receiver Resolver Table:"); - mReceivers.dump(printer, " "); + mReceivers.dump(pw, " "); pw.println(" "); pw.println("Service Resolver Table:"); - mServices.dump(printer, " "); + mServices.dump(pw, " "); pw.println(" "); pw.println("Preferred Activities:"); - mSettings.mPreferredActivities.dump(printer, " "); + mSettings.mPreferredActivities.dump(pw, " "); pw.println(" "); pw.println("Preferred Packages:"); { for (PackageSetting ps : mSettings.mPreferredPackages) { - pw.println(" " + ps.name); + pw.print(" "); pw.println(ps.name); } } pw.println(" "); pw.println("Permissions:"); { for (BasePermission p : mSettings.mPermissions.values()) { - pw.println(" Permission [" + p.name + "] (" - + Integer.toHexString(System.identityHashCode(p)) - + "):"); - pw.println(" sourcePackage=" + p.sourcePackage); - pw.println(" uid=" + p.uid - + " gids=" + arrayToString(p.gids) - + " type=" + p.type); + pw.print(" Permission ["); pw.print(p.name); pw.print("] ("); + pw.print(Integer.toHexString(System.identityHashCode(p))); + pw.println("):"); + pw.print(" sourcePackage="); pw.println(p.sourcePackage); + pw.print(" uid="); pw.print(p.uid); + pw.print(" gids="); pw.print(arrayToString(p.gids)); + pw.print(" type="); pw.println(p.type); } } pw.println(" "); pw.println("Packages:"); { for (PackageSetting ps : mSettings.mPackages.values()) { - pw.println(" Package [" + ps.name + "] (" - + Integer.toHexString(System.identityHashCode(ps)) - + "):"); - pw.println(" userId=" + ps.userId - + " gids=" + arrayToString(ps.gids)); - pw.println(" sharedUser=" + ps.sharedUser); - pw.println(" pkg=" + ps.pkg); - pw.println(" codePath=" + ps.codePathString); - pw.println(" resourcePath=" + ps.resourcePathString); + pw.print(" Package ["); pw.print(ps.name); pw.print("] ("); + pw.print(Integer.toHexString(System.identityHashCode(ps))); + pw.println("):"); + pw.print(" userId="); pw.print(ps.userId); + pw.print(" gids="); pw.println(arrayToString(ps.gids)); + pw.print(" sharedUser="); pw.println(ps.sharedUser); + pw.print(" pkg="); pw.println(ps.pkg); + pw.print(" codePath="); pw.println(ps.codePathString); + pw.print(" resourcePath="); pw.println(ps.resourcePathString); if (ps.pkg != null) { - pw.println(" dataDir=" + ps.pkg.applicationInfo.dataDir); + pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir); } - pw.println(" timeStamp=" + ps.getTimeStampStr()); - pw.println(" signatures=" + ps.signatures); - pw.println(" permissionsFixed=" + ps.permissionsFixed - + " pkgFlags=0x" + Integer.toHexString(ps.pkgFlags) - + " installStatus=" + ps.installStatus - + " enabled=" + ps.enabled); + pw.print(" timeStamp="); pw.println(ps.getTimeStampStr()); + pw.print(" signatures="); pw.println(ps.signatures); + pw.print(" permissionsFixed="); pw.print(ps.permissionsFixed); + pw.print(" pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags)); + pw.print(" installStatus="); pw.print(ps.installStatus); + pw.print(" enabled="); pw.println(ps.enabled); if (ps.disabledComponents.size() > 0) { pw.println(" disabledComponents:"); for (String s : ps.disabledComponents) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } } if (ps.enabledComponents.size() > 0) { pw.println(" enabledComponents:"); for (String s : ps.enabledComponents) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } } - pw.println(" grantedPermissions:"); - for (String s : ps.grantedPermissions) { - pw.println(" " + s); + if (ps.grantedPermissions.size() > 0) { + pw.println(" grantedPermissions:"); + for (String s : ps.grantedPermissions) { + pw.print(" "); pw.println(s); + } } - pw.println(" loadedPermissions:"); - for (String s : ps.loadedPermissions) { - pw.println(" " + s); + if (ps.loadedPermissions.size() > 0) { + pw.println(" loadedPermissions:"); + for (String s : ps.loadedPermissions) { + pw.print(" "); pw.println(s); + } } } } @@ -4659,18 +4664,18 @@ class PackageManagerService extends IPackageManager.Stub { pw.println("Shared Users:"); { for (SharedUserSetting su : mSettings.mSharedUsers.values()) { - pw.println(" SharedUser [" + su.name + "] (" - + Integer.toHexString(System.identityHashCode(su)) - + "):"); - pw.println(" userId=" + su.userId - + " gids=" + arrayToString(su.gids)); + pw.print(" SharedUser ["); pw.print(su.name); pw.print("] ("); + pw.print(Integer.toHexString(System.identityHashCode(su))); + pw.println("):"); + pw.print(" userId="); pw.print(su.userId); + pw.print(" gids="); pw.println(arrayToString(su.gids)); pw.println(" grantedPermissions:"); for (String s : su.grantedPermissions) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } pw.println(" loadedPermissions:"); for (String s : su.loadedPermissions) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } } } @@ -5302,16 +5307,19 @@ class PackageManagerService extends IPackageManager.Stub { private final IntentResolver<PreferredActivity, PreferredActivity> mPreferredActivities = new IntentResolver<PreferredActivity, PreferredActivity>() { @Override - protected void dumpFilter(Printer out, String prefix, + protected void dumpFilter(PrintWriter out, String prefix, PreferredActivity filter) { - out.println(prefix - + Integer.toHexString(System.identityHashCode(filter)) - + " " + filter.mActivity.flattenToShortString() - + " match=0x" + Integer.toHexString(filter.mMatch)); + out.print(prefix); out.print( + Integer.toHexString(System.identityHashCode(filter))); + out.print(' '); + out.print(filter.mActivity.flattenToShortString()); + out.print(" match=0x"); + out.println( Integer.toHexString(filter.mMatch)); if (filter.mSetComponents != null) { - out.println(prefix + " Selected from:"); + out.print(prefix); out.println(" Selected from:"); for (int i=0; i<filter.mSetComponents.length; i++) { - out.println(prefix + " " + filter.mSetComponents[i]); + out.print(prefix); out.print(" "); + out.println(filter.mSetComponents[i]); } } } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index b0fcb1c..321b17e 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -5175,6 +5175,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo final IInputContext mInputContext; final int mUid; final int mPid; + final String mStringName; SurfaceSession mSurfaceSession; int mNumWindow = 0; boolean mClientDead = false; @@ -5198,6 +5199,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mInputContext = inputContext; mUid = Binder.getCallingUid(); mPid = Binder.getCallingPid(); + StringBuilder sb = new StringBuilder(); + sb.append("Session{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" uid "); + sb.append(mUid); + sb.append("}"); + mStringName = sb.toString(); + synchronized (mWindowMap) { if (mInputMethodManager == null && mHaveInputMethods) { IBinder b = ServiceManager.getService( @@ -5377,20 +5386,24 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "mNumWindow=" + mNumWindow - + " mClientDead=" + mClientDead - + " mSurfaceSession=" + mSurfaceSession); - pw.println(prefix + "mPendingPointerWindow=" + mPendingPointerWindow - + " mPendingPointerMove=" + mPendingPointerMove); - pw.println(prefix + "mPendingTrackballWindow=" + mPendingTrackballWindow - + " mPendingTrackballMove=" + mPendingTrackballMove); + pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow); + pw.print(" mClientDead="); pw.print(mClientDead); + pw.print(" mSurfaceSession="); pw.println(mSurfaceSession); + if (mPendingPointerWindow != null || mPendingPointerMove != null) { + pw.print(prefix); + pw.print("mPendingPointerWindow="); pw.print(mPendingPointerWindow); + pw.print(" mPendingPointerMove="); pw.println(mPendingPointerMove); + } + if (mPendingTrackballWindow != null || mPendingTrackballMove != null) { + pw.print(prefix); + pw.print("mPendingTrackballWindow="); pw.print(mPendingTrackballWindow); + pw.print(" mPendingTrackballMove="); pw.println(mPendingTrackballMove); + } } @Override public String toString() { - return "Session{" - + Integer.toHexString(System.identityHashCode(this)) + "}"; + return mStringName; } } @@ -6458,67 +6471,114 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "mSession=" + mSession - + " mClient=" + mClient.asBinder()); - pw.println(prefix + "mAttrs=" + mAttrs); - pw.println(prefix + "mAttachedWindow=" + mAttachedWindow - + " mLayoutAttached=" + mLayoutAttached - + " mIsImWindow=" + mIsImWindow); - pw.println(prefix + "mBaseLayer=" + mBaseLayer - + " mSubLayer=" + mSubLayer - + " mAnimLayer=" + mLayer + "+" - + (mTargetAppToken != null ? mTargetAppToken.animLayerAdjustment - : (mAppToken != null ? mAppToken.animLayerAdjustment : 0)) - + "=" + mAnimLayer - + " mLastLayer=" + mLastLayer); - pw.println(prefix + "mSurface=" + mSurface); - pw.println(prefix + "mToken=" + mToken); - pw.println(prefix + "mRootToken=" + mRootToken); - pw.println(prefix + "mAppToken=" + mAppToken); - pw.println(prefix + "mTargetAppToken=" + mTargetAppToken); - pw.println(prefix + "mViewVisibility=0x" + Integer.toHexString(mViewVisibility) - + " mPolicyVisibility=" + mPolicyVisibility - + " (after=" + mPolicyVisibilityAfterAnim - + ") mAttachedHidden=" + mAttachedHidden - + " mLastHidden=" + mLastHidden - + " mHaveFrame=" + mHaveFrame); - pw.println(prefix + "Requested w=" + mRequestedWidth + " h=" + mRequestedHeight - + " x=" + mReqXPos + " y=" + mReqYPos); - pw.println(prefix + "mGivenContentInsets=" + mGivenContentInsets.toShortString() - + " mGivenVisibleInsets=" + mGivenVisibleInsets.toShortString() - + " mTouchableInsets=" + mTouchableInsets - + " pending=" + mGivenInsetsPending); - pw.println(prefix + "mShownFrame=" + mShownFrame.toShortString() - + " last=" + mLastShownFrame.toShortString()); - pw.println(prefix + "mFrame=" + mFrame.toShortString() - + " last=" + mLastFrame.toShortString()); - pw.println(prefix + "mContainingFrame=" + mContainingFrame.toShortString() - + " mDisplayFrame=" + mDisplayFrame.toShortString()); - pw.println(prefix + "mContentFrame=" + mContentFrame.toShortString() - + " mVisibleFrame=" + mVisibleFrame.toShortString()); - pw.println(prefix + "mContentInsets=" + mContentInsets.toShortString() - + " last=" + mLastContentInsets.toShortString() - + " mVisibleInsets=" + mVisibleInsets.toShortString() - + " last=" + mLastVisibleInsets.toShortString()); - pw.println(prefix + "mShownAlpha=" + mShownAlpha - + " mAlpha=" + mAlpha + " mLastAlpha=" + mLastAlpha); - pw.println(prefix + "mAnimating=" + mAnimating - + " mLocalAnimating=" + mLocalAnimating - + " mAnimationIsEntrance=" + mAnimationIsEntrance - + " mAnimation=" + mAnimation); - pw.println(prefix + "XForm: has=" + mHasTransformation - + " " + mTransformation.toShortString()); - pw.println(prefix + "mDrawPending=" + mDrawPending - + " mCommitDrawPending=" + mCommitDrawPending - + " mReadyToShow=" + mReadyToShow - + " mHasDrawn=" + mHasDrawn); - pw.println(prefix + "mExiting=" + mExiting - + " mRemoveOnExit=" + mRemoveOnExit - + " mDestroying=" + mDestroying - + " mRemoved=" + mRemoved); - pw.println(prefix + "mOrientationChanging=" + mOrientationChanging - + " mAppFreezing=" + mAppFreezing); + StringBuilder sb = new StringBuilder(64); + + pw.print(prefix); pw.print("mSession="); pw.print(mSession); + pw.print(" mClient="); pw.println(mClient.asBinder()); + pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); + if (mAttachedWindow != null || mLayoutAttached) { + pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); + pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); + } + if (mIsImWindow) { + pw.print(prefix); pw.print("mIsImWindow="); pw.println(mIsImWindow); + } + pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); + pw.print(" mSubLayer="); pw.print(mSubLayer); + pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); + pw.print((mTargetAppToken != null ? mTargetAppToken.animLayerAdjustment + : (mAppToken != null ? mAppToken.animLayerAdjustment : 0))); + pw.print("="); pw.print(mAnimLayer); + pw.print(" mLastLayer="); pw.println(mLastLayer); + if (mSurface != null) { + pw.print(prefix); pw.print("mSurface="); pw.println(mSurface); + } + pw.print(prefix); pw.print("mToken="); pw.println(mToken); + pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); + if (mAppToken != null) { + pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); + } + if (mTargetAppToken != null) { + pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); + } + pw.print(prefix); pw.print("mViewVisibility=0x"); + pw.print(Integer.toHexString(mViewVisibility)); + pw.print(" mLastHidden="); pw.print(mLastHidden); + pw.print(" mHaveFrame="); pw.println(mHaveFrame); + if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) { + pw.print(prefix); pw.print("mPolicyVisibility="); + pw.print(mPolicyVisibility); + pw.print(" mPolicyVisibilityAfterAnim="); + pw.print(mPolicyVisibilityAfterAnim); + pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); + } + pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); + pw.print(" h="); pw.print(mRequestedHeight); + pw.print(" x="); pw.print(mReqXPos); + pw.print(" y="); pw.println(mReqYPos); + pw.print(prefix); pw.print("mGivenContentInsets="); + mGivenContentInsets.printShortString(pw); + pw.print(" mGivenVisibleInsets="); + mGivenVisibleInsets.printShortString(pw); + pw.println(); + if (mTouchableInsets != 0 || mGivenInsetsPending) { + pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); + pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); + } + pw.print(prefix); pw.print("mShownFrame="); + mShownFrame.printShortString(pw); + pw.print(" last="); mLastShownFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); + pw.print(" last="); mLastFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mContainingFrame="); + mContainingFrame.printShortString(pw); + pw.print(" mDisplayFrame="); + mDisplayFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mContentFrame="); mContentFrame.printShortString(pw); + pw.print(" mVisibleFrame="); mVisibleFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mContentInsets="); mContentInsets.printShortString(pw); + pw.print(" last="); mLastContentInsets.printShortString(pw); + pw.print(" mVisibleInsets="); mVisibleInsets.printShortString(pw); + pw.print(" last="); mLastVisibleInsets.printShortString(pw); + pw.println(); + if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) { + pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha); + pw.print(" mAlpha="); pw.print(mAlpha); + pw.print(" mLastAlpha="); pw.println(mLastAlpha); + } + if (mAnimating || mLocalAnimating || mAnimationIsEntrance + || mAnimation != null) { + pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating); + pw.print(" mLocalAnimating="); pw.print(mLocalAnimating); + pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance); + pw.print(" mAnimation="); pw.println(mAnimation); + } + if (mHasTransformation || mHasLocalTransformation) { + pw.print(prefix); pw.print("XForm: has="); + pw.print(mHasTransformation); + pw.print(" hasLocal="); pw.print(mHasLocalTransformation); + pw.print(" "); mTransformation.printShortString(pw); + pw.println(); + } + pw.print(prefix); pw.print("mDrawPending="); pw.print(mDrawPending); + pw.print(" mCommitDrawPending="); pw.print(mCommitDrawPending); + pw.print(" mReadyToShow="); pw.print(mReadyToShow); + pw.print(" mHasDrawn="); pw.println(mHasDrawn); + if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { + pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); + pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); + pw.print(" mDestroying="); pw.print(mDestroying); + pw.print(" mRemoved="); pw.println(mRemoved); + } + if (mOrientationChanging || mAppFreezing) { + pw.print(prefix); pw.print("mOrientationChanging="); + pw.print(mOrientationChanging); + pw.print(" mAppFreezing="); pw.println(mAppFreezing); + } } @Override @@ -6544,6 +6604,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // not be removed when all windows are removed. final boolean explicit; + // For printing. + String stringName; + // If this is an AppWindowToken, this is non-null. AppWindowToken appWindowToken; @@ -6566,18 +6629,23 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "token=" + token); - pw.println(prefix + "windows=" + windows); - pw.println(prefix + "windowType=" + windowType + " hidden=" + hidden - + " hasVisible=" + hasVisible); + pw.print(prefix); pw.print("token="); pw.println(token); + pw.print(prefix); pw.print("windows="); pw.println(windows); + pw.print(prefix); pw.print("windowType="); pw.print(windowType); + pw.print(" hidden="); pw.print(hidden); + pw.print(" hasVisible="); pw.println(hasVisible); } @Override public String toString() { - return "WindowToken{" - + Integer.toHexString(System.identityHashCode(this)) - + " token=" + token + "}"; + if (stringName == null) { + StringBuilder sb = new StringBuilder(); + sb.append("WindowToken{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" token="); sb.append(token); sb.append('}'); + stringName = sb.toString(); + } + return stringName; } }; @@ -6865,38 +6933,66 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo void dump(PrintWriter pw, String prefix) { super.dump(pw, prefix); - pw.println(prefix + "app=" + (appToken != null)); - pw.println(prefix + "allAppWindows=" + allAppWindows); - pw.println(prefix + "groupId=" + groupId - + " requestedOrientation=" + requestedOrientation); - pw.println(prefix + "hiddenRequested=" + hiddenRequested - + " clientHidden=" + clientHidden - + " willBeHidden=" + willBeHidden - + " reportedVisible=" + reportedVisible); - pw.println(prefix + "paused=" + paused - + " freezingScreen=" + freezingScreen); - pw.println(prefix + "numInterestingWindows=" + numInterestingWindows - + " numDrawnWindows=" + numDrawnWindows - + " inPendingTransaction=" + inPendingTransaction - + " allDrawn=" + allDrawn); - pw.println(prefix + "animating=" + animating - + " animation=" + animation); - pw.println(prefix + "animLayerAdjustment=" + animLayerAdjustment - + " transformation=" + transformation.toShortString()); - pw.println(prefix + "startingData=" + startingData - + " removed=" + removed - + " firstWindowDrawn=" + firstWindowDrawn); - pw.println(prefix + "startingWindow=" + startingWindow - + " startingView=" + startingView - + " startingDisplayed=" + startingDisplayed - + " startingMoved" + startingMoved); + if (appToken != null) { + pw.print(prefix); pw.println("app=true"); + } + if (allAppWindows.size() > 0) { + pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows); + } + pw.print(prefix); pw.print("groupId="); pw.print(groupId); + pw.print(" requestedOrientation="); pw.println(requestedOrientation); + pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); + pw.print(" clientHidden="); pw.print(clientHidden); + pw.print(" willBeHidden="); pw.print(willBeHidden); + pw.print(" reportedVisible="); pw.println(reportedVisible); + if (paused || freezingScreen) { + pw.print(prefix); pw.print("paused="); pw.print(paused); + pw.print(" freezingScreen="); pw.println(freezingScreen); + } + if (numInterestingWindows != 0 || numDrawnWindows != 0 + || inPendingTransaction || allDrawn) { + pw.print(prefix); pw.print("numInterestingWindows="); + pw.print(numInterestingWindows); + pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); + pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); + pw.print(" allDrawn="); pw.println(allDrawn); + } + if (animating || animation != null) { + pw.print(prefix); pw.print("animating="); pw.print(animating); + pw.print(" animation="); pw.println(animation); + } + if (animLayerAdjustment != 0) { + pw.print(prefix); pw.print("animLayerAdjustment="); pw.println(animLayerAdjustment); + } + if (hasTransformation) { + pw.print(prefix); pw.print("hasTransformation="); pw.print(hasTransformation); + pw.print(" transformation="); transformation.printShortString(pw); + pw.println(); + } + if (startingData != null || removed || firstWindowDrawn) { + pw.print(prefix); pw.print("startingData="); pw.print(startingData); + pw.print(" removed="); pw.print(removed); + pw.print(" firstWindowDrawn="); pw.println(firstWindowDrawn); + } + if (startingWindow != null || startingView != null + || startingDisplayed || startingMoved) { + pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); + pw.print(" startingView="); pw.print(startingView); + pw.print(" startingDisplayed="); pw.print(startingDisplayed); + pw.print(" startingMoved"); pw.println(startingMoved); + } } @Override public String toString() { - return "AppWindowToken{" - + Integer.toHexString(System.identityHashCode(this)) - + " token=" + token + "}"; + if (stringName == null) { + StringBuilder sb = new StringBuilder(); + sb.append("AppWindowToken{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" token="); sb.append(token); sb.append('}'); + stringName = sb.toString(); + } + return stringName; } } @@ -8652,7 +8748,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println("Current Window Manager state:"); for (int i=mWindows.size()-1; i>=0; i--) { WindowState w = (WindowState)mWindows.get(i); - pw.println(" Window #" + i + ":"); + pw.print(" Window #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } if (mInputMethodDialogs.size() > 0) { @@ -8660,7 +8757,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Input method dialogs:"); for (int i=mInputMethodDialogs.size()-1; i>=0; i--) { WindowState w = mInputMethodDialogs.get(i); - pw.println(" IM Dialog #" + i + ": " + w); + pw.print(" IM Dialog #"); pw.print(i); pw.print(": "); pw.println(w); } } if (mPendingRemove.size() > 0) { @@ -8668,7 +8765,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Remove pending for:"); for (int i=mPendingRemove.size()-1; i>=0; i--) { WindowState w = mPendingRemove.get(i); - pw.println(" Remove #" + i + ":"); + pw.print(" Remove #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8677,7 +8775,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Windows force removing:"); for (int i=mForceRemoves.size()-1; i>=0; i--) { WindowState w = mForceRemoves.get(i); - pw.println(" Removing #" + i + ":"); + pw.print(" Removing #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8686,7 +8785,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Windows waiting to destroy their surface:"); for (int i=mDestroySurface.size()-1; i>=0; i--) { WindowState w = mDestroySurface.get(i); - pw.println(" Destroy #" + i + ":"); + pw.print(" Destroy #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8695,7 +8795,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Windows losing focus:"); for (int i=mLosingFocus.size()-1; i>=0; i--) { WindowState w = mLosingFocus.get(i); - pw.println(" Losing #" + i + ":"); + pw.print(" Losing #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8705,7 +8806,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Iterator<Session> it = mSessions.iterator(); while (it.hasNext()) { Session s = it.next(); - pw.println(" Session " + s); + pw.print(" Session "); pw.print(s); pw.println(':'); s.dump(pw, " "); } } @@ -8715,7 +8816,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Iterator<WindowToken> it = mTokenMap.values().iterator(); while (it.hasNext()) { WindowToken token = it.next(); - pw.println(" Token " + token.token); + pw.print(" Token "); pw.print(token.token); pw.println(':'); token.dump(pw, " "); } } @@ -8723,14 +8824,16 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" "); pw.println(" Window token list:"); for (int i=0; i<mTokenList.size(); i++) { - pw.println(" WindowToken #" + i + ": " + mTokenList.get(i)); + pw.print(" #"); pw.print(i); pw.print(": "); + pw.println(mTokenList.get(i)); } } if (mAppTokens.size() > 0) { pw.println(" "); pw.println(" Application tokens in Z order:"); for (int i=mAppTokens.size()-1; i>=0; i--) { - pw.println(" AppWindowToken #" + i + ": " + mAppTokens.get(i)); + pw.print(" App #"); pw.print(i); pw.print(": "); + pw.println(mAppTokens.get(i)); } } if (mFinishedStarting.size() > 0) { @@ -8738,7 +8841,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Finishing start of application tokens:"); for (int i=mFinishedStarting.size()-1; i>=0; i--) { WindowToken token = mFinishedStarting.get(i); - pw.println(" Finish Starting App Token #" + i + ":"); + pw.print(" Finished Starting #"); pw.print(i); + pw.print(' '); pw.print(token); pw.println(':'); token.dump(pw, " "); } } @@ -8747,7 +8851,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Exiting tokens:"); for (int i=mExitingTokens.size()-1; i>=0; i--) { WindowToken token = mExitingTokens.get(i); - pw.println(" Exiting Token #" + i + ":"); + pw.print(" Exiting #"); pw.print(i); + pw.print(' '); pw.print(token); pw.println(':'); token.dump(pw, " "); } } @@ -8756,54 +8861,59 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Exiting application tokens:"); for (int i=mExitingAppTokens.size()-1; i>=0; i--) { WindowToken token = mExitingAppTokens.get(i); - pw.println(" Exiting App Token #" + i + ":"); + pw.print(" Exiting App #"); pw.print(i); + pw.print(' '); pw.print(token); pw.println(':'); token.dump(pw, " "); } } pw.println(" "); - pw.println(" mCurrentFocus=" + mCurrentFocus); - pw.println(" mLastFocus=" + mLastFocus); - pw.println(" mFocusedApp=" + mFocusedApp); - pw.println(" mInputMethodTarget=" + mInputMethodTarget); - pw.println(" mInputMethodWindow=" + mInputMethodWindow); - pw.println(" mInTouchMode=" + mInTouchMode); - pw.println(" mSystemBooted=" + mSystemBooted - + " mDisplayEnabled=" + mDisplayEnabled); - pw.println(" mLayoutNeeded=" + mLayoutNeeded - + " mBlurShown=" + mBlurShown); - pw.println(" mDimShown=" + mDimShown - + " current=" + mDimCurrentAlpha - + " target=" + mDimTargetAlpha - + " delta=" + mDimDeltaPerMs - + " lastAnimTime=" + mLastDimAnimTime); - pw.println(" mInputMethodAnimLayerAdjustment=" - + mInputMethodAnimLayerAdjustment); - pw.println(" mDisplayFrozen=" + mDisplayFrozen - + " mWindowsFreezingScreen=" + mWindowsFreezingScreen - + " mAppsFreezingScreen=" + mAppsFreezingScreen); - pw.println(" mRotation=" + mRotation - + ", mForcedAppOrientation=" + mForcedAppOrientation - + ", mRequestedRotation=" + mRequestedRotation); - pw.println(" mAnimationPending=" + mAnimationPending - + " mWindowAnimationScale=" + mWindowAnimationScale - + " mTransitionWindowAnimationScale=" + mTransitionAnimationScale); - pw.println(" mNextAppTransition=0x" - + Integer.toHexString(mNextAppTransition) - + ", mAppTransitionReady=" + mAppTransitionReady - + ", mAppTransitionTimeout=" + mAppTransitionTimeout); - pw.println(" mStartingIconInTransition=" + mStartingIconInTransition - + ", mSkipAppTransitionAnimation=" + mSkipAppTransitionAnimation); - pw.println(" mOpeningApps=" + mOpeningApps); - pw.println(" mClosingApps=" + mClosingApps); - pw.println(" DisplayWidth=" + mDisplay.getWidth() - + " DisplayHeight=" + mDisplay.getHeight()); + pw.print(" mCurrentFocus="); pw.println(mCurrentFocus); + pw.print(" mLastFocus="); pw.println(mLastFocus); + pw.print(" mFocusedApp="); pw.println(mFocusedApp); + pw.print(" mInputMethodTarget="); pw.println(mInputMethodTarget); + pw.print(" mInputMethodWindow="); pw.println(mInputMethodWindow); + pw.print(" mInTouchMode="); pw.println(mInTouchMode); + pw.print(" mSystemBooted="); pw.print(mSystemBooted); + pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled); + pw.print(" mLayoutNeeded="); pw.print(mLayoutNeeded); + pw.print(" mBlurShown="); pw.println(mBlurShown); + pw.print(" mDimShown="); pw.print(mDimShown); + pw.print(" current="); pw.print(mDimCurrentAlpha); + pw.print(" target="); pw.print(mDimTargetAlpha); + pw.print(" delta="); pw.print(mDimDeltaPerMs); + pw.print(" lastAnimTime="); pw.println(mLastDimAnimTime); + pw.print(" mInputMethodAnimLayerAdjustment="); + pw.println(mInputMethodAnimLayerAdjustment); + pw.print(" mDisplayFrozen="); pw.print(mDisplayFrozen); + pw.print(" mWindowsFreezingScreen="); pw.print(mWindowsFreezingScreen); + pw.print(" mAppsFreezingScreen="); pw.println(mAppsFreezingScreen); + pw.print(" mRotation="); pw.print(mRotation); + pw.print(", mForcedAppOrientation="); pw.print(mForcedAppOrientation); + pw.print(", mRequestedRotation="); pw.println(mRequestedRotation); + pw.print(" mAnimationPending="); pw.print(mAnimationPending); + pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale); + pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale); + pw.print(" mNextAppTransition=0x"); + pw.print(Integer.toHexString(mNextAppTransition)); + pw.print(", mAppTransitionReady="); pw.print(mAppTransitionReady); + pw.print(", mAppTransitionTimeout="); pw.println( mAppTransitionTimeout); + pw.print(" mStartingIconInTransition="); pw.print(mStartingIconInTransition); + pw.print(", mSkipAppTransitionAnimation="); pw.println(mSkipAppTransitionAnimation); + if (mOpeningApps.size() > 0) { + pw.print(" mOpeningApps="); pw.println(mOpeningApps); + } + if (mClosingApps.size() > 0) { + pw.print(" mClosingApps="); pw.println(mClosingApps); + } + pw.print(" DisplayWidth="); pw.print(mDisplay.getWidth()); + pw.print(" DisplayHeight="); pw.println(mDisplay.getHeight()); pw.println(" KeyWaiter state:"); - pw.println(" mLastWin=" + mKeyWaiter.mLastWin - + " mLastBinder=" + mKeyWaiter.mLastBinder); - pw.println(" mFinished=" + mKeyWaiter.mFinished - + " mGotFirstWindow=" + mKeyWaiter.mGotFirstWindow - + " mEventDispatching=" + mKeyWaiter.mEventDispatching - + " mTimeToSwitch=" + mKeyWaiter.mTimeToSwitch); + pw.print(" mLastWin="); pw.print(mKeyWaiter.mLastWin); + pw.print(" mLastBinder="); pw.println(mKeyWaiter.mLastBinder); + pw.print(" mFinished="); pw.print(mKeyWaiter.mFinished); + pw.print(" mGotFirstWindow="); pw.print(mKeyWaiter.mGotFirstWindow); + pw.print(" mEventDispatching="); pw.print(mKeyWaiter.mEventDispatching); + pw.print(" mTimeToSwitch="); pw.println(mKeyWaiter.mTimeToSwitch); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index a3c23d3..b04f5a8 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -7890,24 +7890,24 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return; } pw.println("Activities in Current Activity Manager State:"); - dumpHistoryList(pw, mHistory, " ", "History", true); + dumpHistoryList(pw, mHistory, " ", "Hist", true); pw.println(" "); pw.println(" Running activities (most recent first):"); - dumpHistoryList(pw, mLRUActivities, " ", "Running", false); + dumpHistoryList(pw, mLRUActivities, " ", "Run", false); if (mWaitingVisibleActivities.size() > 0) { pw.println(" "); pw.println(" Activities waiting for another to become visible:"); - dumpHistoryList(pw, mWaitingVisibleActivities, " ", "Waiting", false); + dumpHistoryList(pw, mWaitingVisibleActivities, " ", "Wait", false); } if (mStoppingActivities.size() > 0) { pw.println(" "); pw.println(" Activities waiting to stop:"); - dumpHistoryList(pw, mStoppingActivities, " ", "Stopping", false); + dumpHistoryList(pw, mStoppingActivities, " ", "Stop", false); } if (mFinishingActivities.size() > 0) { pw.println(" "); pw.println(" Activities waiting to finish:"); - dumpHistoryList(pw, mFinishingActivities, " ", "Finishing", false); + dumpHistoryList(pw, mFinishingActivities, " ", "Fin", false); } pw.println(" "); @@ -7922,7 +7922,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen final int N = mRecentTasks.size(); for (int i=0; i<N; i++) { - pw.println(" Recent Task #" + i); + TaskRecord tr = mRecentTasks.get(i); + pw.print(" * Recent #"); pw.print(i); pw.print(": "); + pw.println(tr); mRecentTasks.get(i).dump(pw, " "); } } @@ -7944,8 +7946,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; } ProcessRecord r = procs.valueAt(ia); - pw.print(r.persistent ? " *PERSISTENT* Process [" : " Process ["); - pw.print(r.processName); pw.print("] UID "); pw.println(procs.keyAt(ia)); + pw.print(r.persistent ? " *PERS*" : " *APP*"); + pw.print(" UID "); pw.print(procs.keyAt(ia)); + pw.print(" "); pw.println(r); r.dump(pw, " "); if (r.persistent) { numPers++; @@ -7958,7 +7961,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Running processes (most recent first):"); dumpProcessList(pw, mLRUProcesses, " ", - "Running Norm Proc", "Running PERS Proc", true); + "App ", "PERS", true); needSep = true; } @@ -7968,8 +7971,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" PID mappings:"); for (int i=0; i<mPidsSelfLocked.size(); i++) { - pw.println(" PID #" + mPidsSelfLocked.keyAt(i) - + ": " + mPidsSelfLocked.valueAt(i)); + pw.print(" PID #"); pw.print(mPidsSelfLocked.keyAt(i)); + pw.print(": "); pw.println(mPidsSelfLocked.valueAt(i)); } } } @@ -7979,8 +7982,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Foreground Processes:"); for (int i=0; i<mForegroundProcesses.size(); i++) { - pw.println(" PID #" + mForegroundProcesses.keyAt(i) - + ": " + mForegroundProcesses.valueAt(i)); + pw.print(" PID #"); pw.print(mForegroundProcesses.keyAt(i)); + pw.print(": "); pw.println(mForegroundProcesses.valueAt(i)); } } @@ -7989,7 +7992,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Persisent processes that are starting:"); dumpProcessList(pw, mPersistentStartingProcesses, " ", - "Starting Initial Proc", "Restarting PERS Proc", false); + "Starting Norm", "Restarting PERS", false); } if (mStartingProcesses.size() > 0) { @@ -7997,7 +8000,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Processes that are starting:"); dumpProcessList(pw, mStartingProcesses, " ", - "Starting Norm Proc", "Starting PERS Proc", false); + "Starting Norm", "Starting PERS", false); } if (mRemovedProcesses.size() > 0) { @@ -8005,7 +8008,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Processes that are being removed:"); dumpProcessList(pw, mRemovedProcesses, " ", - "Removed Norm Proc", "Removed PERS Proc", false); + "Removed Norm", "Removed PERS", false); } if (mProcessesOnHold.size() > 0) { @@ -8013,7 +8016,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Processes that are on old until the system is ready:"); dumpProcessList(pw, mProcessesOnHold, " ", - "OnHold Norm Proc", "OnHold PERS Proc", false); + "OnHold Norm", "OnHold PERS", false); } if (mProcessCrashTimes.getMap().size() > 0) { @@ -8026,10 +8029,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen SparseArray<Long> uids = procs.getValue(); final int N = uids.size(); for (int i=0; i<N; i++) { - pw.println(" Process " + procs.getKey() - + " uid " + uids.keyAt(i) - + ": last crashed " - + (now-uids.valueAt(i)) + " ms ago"); + pw.print(" Process "); pw.print(procs.getKey()); + pw.print(" uid "); pw.print(uids.keyAt(i)); + pw.print(": last crashed "); + pw.print((now-uids.valueAt(i))); + pw.println(" ms ago"); } } } @@ -8043,9 +8047,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen SparseArray<Long> uids = procs.getValue(); final int N = uids.size(); for (int i=0; i<N; i++) { - pw.println(" Bad process " + procs.getKey() - + " uid " + uids.keyAt(i) - + ": crashed at time " + uids.valueAt(i)); + pw.print(" Bad process "); pw.print(procs.getKey()); + pw.print(" uid "); pw.print(uids.keyAt(i)); + pw.print(": crashed at time "); + pw.println(uids.valueAt(i)); } } } @@ -8144,14 +8149,14 @@ public final class ActivityManagerService extends ActivityManagerNative implemen Iterator it = mRegisteredReceivers.values().iterator(); while (it.hasNext()) { ReceiverList r = (ReceiverList)it.next(); - pw.println(" Receiver " + r.receiver); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } } pw.println(" "); pw.println("Receiver Resolver Table:"); - mReceiverResolver.dump(new PrintWriterPrinter(pw), " "); + mReceiverResolver.dump(pw, " "); if (mParallelBroadcasts.size() > 0 || mOrderedBroadcasts.size() > 0 || mPendingBroadcast != null) { @@ -8185,13 +8190,23 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (mStickyBroadcasts != null) { pw.println(" "); pw.println(" Sticky broadcasts:"); + StringBuilder sb = new StringBuilder(128); for (Map.Entry<String, ArrayList<Intent>> ent : mStickyBroadcasts.entrySet()) { - pw.println(" Sticky action " + ent.getKey() + ":"); + pw.print(" * Sticky action "); pw.print(ent.getKey()); + pw.println(":"); ArrayList<Intent> intents = ent.getValue(); final int N = intents.size(); for (int i=0; i<N; i++) { - pw.println(" " + intents.get(i)); + sb.setLength(0); + sb.append(" Intent: "); + intents.get(i).toShortString(sb, true, false); + pw.println(sb.toString()); + Bundle bundle = intents.get(i).getExtras(); + if (bundle != null) { + pw.print(" "); + pw.println(bundle.toString()); + } } } } @@ -8222,7 +8237,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen Iterator<ServiceRecord> it = mServices.values().iterator(); while (it.hasNext()) { ServiceRecord r = it.next(); - pw.println(" Service " + r.shortName); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8233,7 +8248,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" Pending services:"); for (int i=0; i<mPendingServices.size(); i++) { ServiceRecord r = mPendingServices.get(i); - pw.println(" Pending Service " + r.shortName); + pw.print(" * Pending "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8244,7 +8259,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" Restarting services:"); for (int i=0; i<mRestartingServices.size(); i++) { ServiceRecord r = mRestartingServices.get(i); - pw.println(" Restarting Service " + r.shortName); + pw.print(" * Restarting "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8255,7 +8270,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" Stopping services:"); for (int i=0; i<mStoppingServices.size(); i++) { ServiceRecord r = mStoppingServices.get(i); - pw.println(" Stopping Service " + r.shortName); + pw.print(" * Stopping "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8268,8 +8283,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen = mServiceConnections.values().iterator(); while (it.hasNext()) { ConnectionRecord r = it.next(); - pw.println(" " + r.binding.service.shortName - + " -> " + r.conn.asBinder()); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } } @@ -8292,27 +8306,28 @@ public final class ActivityManagerService extends ActivityManagerNative implemen boolean needSep = false; - if (mProvidersByName.size() > 0) { - pw.println(" Published content providers (by name):"); - Iterator it = mProvidersByName.entrySet().iterator(); + if (mProvidersByClass.size() > 0) { + if (needSep) pw.println(" "); + pw.println(" Published content providers (by class):"); + Iterator it = mProvidersByClass.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry)it.next(); ContentProviderRecord r = (ContentProviderRecord)e.getValue(); - pw.println(" Provider " + (String)e.getKey()); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } needSep = true; } - if (mProvidersByClass.size() > 0) { - if (needSep) pw.println(" "); - pw.println(" Published content providers (by class):"); - Iterator it = mProvidersByClass.entrySet().iterator(); + if (mProvidersByName.size() > 0) { + pw.println(" "); + pw.println(" Authority to provider mappings:"); + Iterator it = mProvidersByName.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry)it.next(); ContentProviderRecord r = (ContentProviderRecord)e.getValue(); - pw.println(" Provider " + (String)e.getKey()); - r.dump(pw, " "); + pw.print(" "); pw.print(e.getKey()); pw.print(": "); + pw.println(r); } needSep = true; } @@ -8321,21 +8336,25 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (needSep) pw.println(" "); pw.println(" Launching content providers:"); for (int i=mLaunchingProviders.size()-1; i>=0; i--) { - pw.println(" Provider #" + i + ":"); - ((ContentProviderRecord)mLaunchingProviders.get(i)).dump(pw, " "); + pw.print(" Launching #"); pw.print(i); pw.print(": "); + pw.println(mLaunchingProviders.get(i)); } needSep = true; } - pw.println(); - pw.println("Granted Uri Permissions:"); - for (int i=0; i<mGrantedUriPermissions.size(); i++) { - int uid = mGrantedUriPermissions.keyAt(i); - HashMap<Uri, UriPermission> perms - = mGrantedUriPermissions.valueAt(i); - pw.println(" Uris granted to uid " + uid + ":"); - for (UriPermission perm : perms.values()) { - perm.dump(pw, " "); + if (mGrantedUriPermissions.size() > 0) { + pw.println(); + pw.println("Granted Uri Permissions:"); + for (int i=0; i<mGrantedUriPermissions.size(); i++) { + int uid = mGrantedUriPermissions.keyAt(i); + HashMap<Uri, UriPermission> perms + = mGrantedUriPermissions.valueAt(i); + pw.print(" * UID "); pw.print(uid); + pw.println(" holds:"); + for (UriPermission perm : perms.values()) { + pw.print(" "); pw.println(perm); + perm.dump(pw, " "); + } } } } @@ -8353,7 +8372,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return; } - pw.println("Intent Senders in Current Activity Manager State:"); + pw.println("Pending Intents in Current Activity Manager State:"); if (this.mIntentSenderRecords.size() > 0) { Iterator<WeakReference<PendingIntentRecord>> it @@ -8362,10 +8381,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen WeakReference<PendingIntentRecord> ref = it.next(); PendingIntentRecord rec = ref != null ? ref.get(): null; if (rec != null) { - pw.println(" IntentSender " + rec); + pw.print(" * "); pw.println(rec); rec.dump(pw, " "); } else { - pw.println(" IntentSender " + ref); + pw.print(" * "); pw.print(ref); } } } @@ -8377,24 +8396,21 @@ public final class ActivityManagerService extends ActivityManagerNative implemen TaskRecord lastTask = null; for (int i=list.size()-1; i>=0; i--) { HistoryRecord r = (HistoryRecord)list.get(i); + final boolean full = complete || !r.inHistory; if (lastTask != r.task) { lastTask = r.task; - if (complete || !r.inHistory) { + pw.print(prefix); + pw.print(full ? "* " : " "); + pw.println(lastTask); + if (full) { lastTask.dump(pw, prefix + " "); - } else { - pw.print(prefix); - pw.print(" "); - pw.println(lastTask); } } - if (complete || !r.inHistory) { - pw.print(prefix); pw.print(" "); pw.print(label); - pw.print(" #"); pw.print(i); pw.println(":"); + pw.print(prefix); pw.print(full ? " * " : " "); pw.print(label); + pw.print(" #"); pw.print(i); pw.print(": "); + pw.println(r); + if (full) { r.dump(pw, prefix + " "); - } else { - pw.print(prefix); pw.print(" "); pw.print(label); - pw.print(" #"); pw.print(i); pw.print(": "); - pw.println(r); } } } diff --git a/services/java/com/android/server/am/AppBindRecord.java b/services/java/com/android/server/am/AppBindRecord.java index ce6f6dc..9c57360 100644 --- a/services/java/com/android/server/am/AppBindRecord.java +++ b/services/java/com/android/server/am/AppBindRecord.java @@ -32,9 +32,12 @@ class AppBindRecord { // All ConnectionRecord for this client. void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); pw.println(prefix + "service=" + service); pw.println(prefix + "client=" + client); + dumpInIntentBind(pw, prefix); + } + + void dumpInIntentBind(PrintWriter pw, String prefix) { if (connections.size() > 0) { pw.println(prefix + "Per-process Connections:"); Iterator<ConnectionRecord> it = connections.iterator(); diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java index e265f43..ddc3e68 100644 --- a/services/java/com/android/server/am/BatteryStatsService.java +++ b/services/java/com/android/server/am/BatteryStatsService.java @@ -302,7 +302,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub { } } if (isCheckin) mStats.dumpCheckinLocked(pw, args); - else mStats.dumpLocked(new PrintWriterPrinter(pw)); + else mStats.dumpLocked(pw); } } } diff --git a/services/java/com/android/server/am/BroadcastFilter.java b/services/java/com/android/server/am/BroadcastFilter.java index cd7f720..0eeb393 100644 --- a/services/java/com/android/server/am/BroadcastFilter.java +++ b/services/java/com/android/server/am/BroadcastFilter.java @@ -18,6 +18,7 @@ package com.android.server.am; import android.content.IntentFilter; import android.util.PrintWriterPrinter; +import android.util.Printer; import java.io.PrintWriter; @@ -33,19 +34,25 @@ class BroadcastFilter extends IntentFilter { requiredPermission = _requiredPermission; } - public void dumpLocal(PrintWriter pw, String prefix) { - super.dump(new PrintWriterPrinter(pw), prefix); - } - public void dump(PrintWriter pw, String prefix) { - dumpLocal(pw, prefix); - pw.println(prefix + "requiredPermission=" + requiredPermission); + dumpInReceiverList(pw, new PrintWriterPrinter(pw), prefix); receiverList.dumpLocal(pw, prefix); } + public void dumpInReceiverList(PrintWriter pw, Printer pr, String prefix) { + super.dump(pr, prefix); + if (requiredPermission != null) { + pw.print(prefix); pw.print("requiredPermission="); pw.println(requiredPermission); + } + } + public String toString() { - return "BroadcastFilter{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + receiverList + "}"; + StringBuilder sb = new StringBuilder(); + sb.append("BroadcastFilter{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(receiverList); + sb.append('}'); + return sb.toString(); } } diff --git a/services/java/com/android/server/am/ConnectionRecord.java b/services/java/com/android/server/am/ConnectionRecord.java index b4c7df1..b3343dd 100644 --- a/services/java/com/android/server/am/ConnectionRecord.java +++ b/services/java/com/android/server/am/ConnectionRecord.java @@ -31,9 +31,10 @@ class ConnectionRecord { String stringName; // Caching of toString. void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); pw.println(prefix + "binding=" + binding); - pw.println(prefix + "activity=" + activity); + if (activity != null) { + pw.println(prefix + "activity=" + activity); + } pw.println(prefix + "conn=" + conn.asBinder() + " flags=0x" + Integer.toHexString(flags)); } diff --git a/services/java/com/android/server/am/ContentProviderRecord.java b/services/java/com/android/server/am/ContentProviderRecord.java index 2b9e006..c764635 100644 --- a/services/java/com/android/server/am/ContentProviderRecord.java +++ b/services/java/com/android/server/am/ContentProviderRecord.java @@ -54,19 +54,27 @@ class ContentProviderRecord extends ContentProviderHolder { } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "package=" + info.applicationInfo.packageName - + " process=" + info.processName); - pw.println(prefix + "app=" + app); - pw.println(prefix + "launchingApp=" + launchingApp); - pw.println(prefix + "provider=" + provider); - pw.println(prefix + "name=" + info.authority); - pw.println(prefix + "isSyncable=" + info.isSyncable); - pw.println(prefix + "multiprocess=" + info.multiprocess - + " initOrder=" + info.initOrder - + " uid=" + uid); - pw.println(prefix + "clients=" + clients); - pw.println(prefix + "externals=" + externals); + pw.print(prefix); pw.print("package="); + pw.print(info.applicationInfo.packageName); + pw.print("process="); pw.println(info.processName); + pw.print(prefix); pw.print("app="); pw.println(app); + if (launchingApp != null) { + pw.print(prefix); pw.print("launchingApp="); pw.println(launchingApp); + } + pw.print(prefix); pw.print("uid="); pw.print(uid); + pw.print(" provider="); pw.println(provider); + pw.print(prefix); pw.print("name="); pw.println(info.authority); + if (info.isSyncable || info.multiprocess || info.initOrder != 0) { + pw.print(prefix); pw.print("isSyncable="); pw.print(info.isSyncable); + pw.print("multiprocess="); pw.print(info.multiprocess); + pw.print(" initOrder="); pw.println(info.initOrder); + } + if (clients.size() > 0) { + pw.print(prefix); pw.print("clients="); pw.println(clients); + } + if (externals != 0) { + pw.print(prefix); pw.print("externals="); pw.println(externals); + } } public String toString() { diff --git a/services/java/com/android/server/am/HistoryRecord.java b/services/java/com/android/server/am/HistoryRecord.java index a2fd62b..1488791 100644 --- a/services/java/com/android/server/am/HistoryRecord.java +++ b/services/java/com/android/server/am/HistoryRecord.java @@ -103,7 +103,6 @@ class HistoryRecord extends IApplicationToken.Stub { String stringName; // for caching of toString(). void dump(PrintWriter pw, String prefix) { - pw.print(prefix); pw.println(this); pw.print(prefix); pw.print("packageName="); pw.print(packageName); pw.print(" processName="); pw.println(processName); pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid); @@ -112,9 +111,10 @@ class HistoryRecord extends IApplicationToken.Stub { pw.print(prefix); pw.print("frontOfTask="); pw.print(frontOfTask); pw.print(" task="); pw.println(task); pw.print(prefix); pw.print("taskAffinity="); pw.println(taskAffinity); - pw.print(prefix); pw.print("realActivity="); pw.println(realActivity); - pw.print(prefix); pw.print("dir="); pw.print(baseDir); - pw.print(" res="); pw.print(resDir); + pw.print(prefix); pw.print("realActivity="); + pw.println(realActivity.flattenToShortString()); + pw.print(prefix); pw.print("base="); pw.print(baseDir); + if (!resDir.equals(baseDir)) pw.print(" res="); pw.print(resDir); pw.print(" data="); pw.println(dataDir); pw.print(prefix); pw.print("labelRes=0x"); pw.print(Integer.toHexString(labelRes)); @@ -504,7 +504,7 @@ class HistoryRecord extends IApplicationToken.Stub { sb.append("HistoryRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(' '); - sb.append(intent.getComponent().toShortString()); + sb.append(intent.getComponent().flattenToShortString()); sb.append('}'); return stringName = sb.toString(); } diff --git a/services/java/com/android/server/am/IntentBindRecord.java b/services/java/com/android/server/am/IntentBindRecord.java index 24c3943..3a5ca66 100644 --- a/services/java/com/android/server/am/IntentBindRecord.java +++ b/services/java/com/android/server/am/IntentBindRecord.java @@ -45,22 +45,30 @@ class IntentBindRecord { /** Set when the service's onUnbind() has asked to be told about new clients. */ boolean doRebind; + String stringName; // caching of toString + void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "service=" + service); - pw.println(prefix + "intent=" + intent.getIntent()); - pw.println(prefix + "binder=" + binder - + " requested=" + requested - + " received=" + received - + " hasBound=" + hasBound - + " doRebind=" + doRebind); + pw.print(prefix); pw.print("service="); pw.println(service); + dumpInService(pw, prefix); + } + + void dumpInService(PrintWriter pw, String prefix) { + pw.print(prefix); pw.print("intent={"); + pw.print(intent.getIntent().toShortString(true, false)); + pw.println('}'); + pw.print(prefix); pw.print("binder="); pw.println(binder); + pw.print(prefix); pw.print("requested="); pw.print(requested); + pw.print(" received="); pw.print(received); + pw.print(" hasBound="); pw.print(hasBound); + pw.print(" doRebind="); pw.println(doRebind); if (apps.size() > 0) { - pw.println(prefix + "Application Bindings:"); Iterator<AppBindRecord> it = apps.values().iterator(); while (it.hasNext()) { AppBindRecord a = it.next(); - pw.println(prefix + "Client " + a.client); - a.dump(pw, prefix + " "); + pw.print(prefix); pw.print("* Client AppBindRecord{"); + pw.print(Integer.toHexString(System.identityHashCode(a))); + pw.print(' '); pw.print(a.client); pw.println('}'); + a.dumpInIntentBind(pw, prefix + " "); } } } @@ -71,9 +79,19 @@ class IntentBindRecord { } public String toString() { - return "IntentBindRecord{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + service.name.toShortString() - + ":" + intent + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("IntentBindRecord{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(service.shortName); + sb.append(':'); + if (intent != null) { + intent.getIntent().toShortString(sb, false, false); + } + sb.append('}'); + return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java index b18aaf7..4381392 100644 --- a/services/java/com/android/server/am/PendingIntentRecord.java +++ b/services/java/com/android/server/am/PendingIntentRecord.java @@ -36,6 +36,8 @@ class PendingIntentRecord extends IIntentSender.Stub { boolean sent = false; boolean canceled = false; + String stringName; + final static class Key { final int type; final String packageName; @@ -142,7 +144,7 @@ class PendingIntentRecord extends IIntentSender.Stub { public String toString() { return "Key{" + typeName() + " pkg=" + packageName - + " intent=" + requestIntent + " flags=0x" + + " intent=" + requestIntent.toShortString(true, false) + " flags=0x" + Integer.toHexString(flags) + "}"; } @@ -260,19 +262,38 @@ class PendingIntentRecord extends IIntentSender.Stub { } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + "packageName=" + key.packageName - + " type=" + key.typeName() - + " flags=0x" + Integer.toHexString(key.flags)); - pw.println(prefix + "activity=" + key.activity + " who=" + key.who); - pw.println(prefix + "requestCode=" + key.requestCode - + " requestResolvedType=" + key.requestResolvedType); - pw.println(prefix + "requestIntent=" + key.requestIntent); - pw.println(prefix + "sent=" + sent + " canceled=" + canceled); + pw.print(prefix); pw.print("uid="); pw.print(uid); + pw.print(" packageName="); pw.print(key.packageName); + pw.print(" type="); pw.print(key.typeName()); + pw.print(" flags=0x"); pw.println(Integer.toHexString(key.flags)); + if (key.activity != null || key.who != null) { + pw.print(prefix); pw.print("activity="); pw.print(key.activity); + pw.print(" who="); pw.println(key.who); + } + if (key.requestCode != 0 || key.requestResolvedType != null) { + pw.print(prefix); pw.print("requestCode="); pw.print(key.requestCode); + pw.print(" requestResolvedType="); pw.println(key.requestResolvedType); + } + pw.print(prefix); pw.print("requestIntent="); + pw.println(key.requestIntent.toShortString(true, true)); + if (sent || canceled) { + pw.print(prefix); pw.print("sent="); pw.print(sent); + pw.print(" canceled="); pw.println(canceled); + } } public String toString() { - return "IntentSenderRecord{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + key.packageName + " " + key.typeName() + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("PendingIntentRecord{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(key.packageName); + sb.append(' '); + sb.append(key.typeName()); + sb.append('}'); + return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java index d2667e7..b76547a 100644 --- a/services/java/com/android/server/am/ProcessRecord.java +++ b/services/java/com/android/server/am/ProcessRecord.java @@ -106,7 +106,6 @@ class ProcessRecord implements Watchdog.PssRequestor { ActivityManager.ProcessErrorStateInfo notRespondingReport; void dump(PrintWriter pw, String prefix) { - pw.print(prefix); pw.println(this); if (info.className != null) { pw.print(prefix); pw.print("class="); pw.println(info.className); } diff --git a/services/java/com/android/server/am/ReceiverList.java b/services/java/com/android/server/am/ReceiverList.java index b8bf30c..0facefc 100644 --- a/services/java/com/android/server/am/ReceiverList.java +++ b/services/java/com/android/server/am/ReceiverList.java @@ -18,9 +18,12 @@ package com.android.server.am; import android.app.IIntentReceiver; import android.content.Intent; +import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.util.PrintWriterPrinter; +import android.util.Printer; import java.io.PrintWriter; import java.util.ArrayList; @@ -64,22 +67,26 @@ class ReceiverList extends ArrayList<BroadcastFilter> } void dumpLocal(PrintWriter pw, String prefix) { - pw.println(prefix + "receiver=IBinder " - + Integer.toHexString(System.identityHashCode(receiver.asBinder()))); - pw.println(prefix + "app=" + app + " pid=" + pid + " uid=" + uid); - pw.println(prefix + "curBroadcast=" + curBroadcast - + " linkedToDeath=" + linkedToDeath); + pw.print(prefix); pw.print("app="); pw.print(app); + pw.print(" pid="); pw.print(pid); pw.print(" uid="); pw.println(uid); + if (curBroadcast != null || linkedToDeath) { + pw.print(prefix); pw.print("curBroadcast="); pw.print(curBroadcast); + pw.print(" linkedToDeath="); pw.println(linkedToDeath); + } } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); + Printer pr = new PrintWriterPrinter(pw); dumpLocal(pw, prefix); String p2 = prefix + " "; final int N = size(); for (int i=0; i<N; i++) { BroadcastFilter bf = get(i); - pw.println(prefix + "Filter #" + i + ": " + bf); - bf.dump(pw, p2); + pw.print(prefix); pw.print("Filter #"); pw.print(i); + pw.print(": BroadcastFilter{"); + pw.print(Integer.toHexString(System.identityHashCode(bf))); + pw.println('}'); + bf.dumpInReceiverList(pw, pr, p2); } } @@ -96,7 +103,7 @@ class ReceiverList extends ArrayList<BroadcastFilter> sb.append((app != null ? app.processName : "(unknown name)")); sb.append('/'); sb.append(uid); - sb.append(" client "); + sb.append((receiver.asBinder() instanceof Binder) ? " local:" : " remote:"); sb.append(Integer.toHexString(System.identityHashCode(receiver.asBinder()))); sb.append('}'); return stringName = sb.toString(); diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java index a8fc761..fc93b69 100644 --- a/services/java/com/android/server/am/ServiceRecord.java +++ b/services/java/com/android/server/am/ServiceRecord.java @@ -80,40 +80,46 @@ class ServiceRecord extends Binder { String stringName; // caching of toString void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "intent=" + intent.getIntent()); - pw.println(prefix + "packageName=" + packageName); - pw.println(prefix + "processName=" + processName); - pw.println(prefix + "permission=" + permission); - pw.println(prefix + "baseDir=" + baseDir+ " resDir=" + resDir + " dataDir=" + dataDir); - pw.println(prefix + "app=" + app); - pw.println(prefix + "isForeground=" + isForeground - + " lastActivity=" + lastActivity); - pw.println(prefix + "startRequested=" + startRequested - + " startId=" + lastStartId - + " executeNesting=" + executeNesting - + " executingStart=" + executingStart - + " crashCount=" + crashCount); - pw.println(prefix + "totalRestartCount=" + totalRestartCount - + " restartCount=" + restartCount - + " restartDelay=" + restartDelay - + " restartTime=" + restartTime - + " nextRestartTime=" + nextRestartTime); + pw.print(prefix); pw.print("intent={"); + pw.print(intent.getIntent().toShortString(true, false)); + pw.println('}'); + pw.print(prefix); pw.print("packageName="); pw.println(packageName); + pw.print(prefix); pw.print("processName="); pw.println(processName); + if (permission != null) { + pw.print(prefix); pw.print("permission="); pw.println(permission); + } + pw.print(prefix); pw.print("baseDir="); pw.print(baseDir); + if (!resDir.equals(baseDir)) pw.print(" resDir="); pw.print(resDir); + pw.print(" dataDir="); pw.println(dataDir); + pw.print(prefix); pw.print("app="); pw.println(app); + pw.print(prefix); pw.print("isForeground="); pw.print(isForeground); + pw.print(" lastActivity="); pw.println(lastActivity); + pw.print(prefix); pw.print("startRequested="); pw.print(startRequested); + pw.print(" startId="); pw.print(lastStartId); + pw.print(" executeNesting="); pw.print(executeNesting); + pw.print(" executingStart="); pw.print(executingStart); + pw.print(" crashCount="); pw.println(crashCount); + pw.print(prefix); pw.print("totalRestartCount="); pw.print(totalRestartCount); + pw.print(" restartCount="); pw.print(restartCount); + pw.print(" restartDelay="); pw.print(restartDelay); + pw.print(" restartTime="); pw.print(restartTime); + pw.print(" nextRestartTime="); pw.println(nextRestartTime); if (bindings.size() > 0) { - pw.println(prefix + "Bindings:"); Iterator<IntentBindRecord> it = bindings.values().iterator(); while (it.hasNext()) { IntentBindRecord b = it.next(); - pw.println(prefix + "Binding " + b); - b.dump(pw, prefix + " "); + pw.print(prefix); pw.print("* IntentBindRecord{"); + pw.print(Integer.toHexString(System.identityHashCode(b))); + pw.println("}:"); + b.dumpInService(pw, prefix + " "); } } if (connections.size() > 0) { - pw.println(prefix + "All Connections:"); + pw.print(prefix); pw.println("All Connections:"); Iterator<ConnectionRecord> it = connections.values().iterator(); while (it.hasNext()) { ConnectionRecord c = it.next(); - pw.println(prefix + " " + c); + pw.print(prefix); pw.print(" "); pw.println(c); } } } @@ -165,11 +171,9 @@ class ServiceRecord extends Binder { return stringName; } StringBuilder sb = new StringBuilder(128); - sb.append("ServiceRecord{"); - sb.append(Integer.toHexString(System.identityHashCode(this))); - sb.append(' '); - sb.append(shortName); - sb.append('}'); + sb.append("ServiceRecord{") + .append(Integer.toHexString(System.identityHashCode(this))) + .append(' ').append(shortName).append('}'); return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/TaskRecord.java b/services/java/com/android/server/am/TaskRecord.java index aab3736..bcb8f54 100644 --- a/services/java/com/android/server/am/TaskRecord.java +++ b/services/java/com/android/server/am/TaskRecord.java @@ -36,6 +36,8 @@ class TaskRecord { boolean rootWasReset; // True if the intent at the root of the task had // the FLAG_ACTIVITY_RESET_TASK_IF_NEEDED flag. + String stringName; // caching of toString() result. + TaskRecord(int _taskId, ActivityInfo info, Intent _intent, boolean _clearOnBackground) { taskId = _taskId; @@ -53,6 +55,8 @@ class TaskRecord { } void setIntent(Intent _intent, ActivityInfo info) { + stringName = null; + if (info.targetActivity == null) { intent = _intent; realActivity = _intent != null ? _intent.getComponent() : null; @@ -82,23 +86,63 @@ class TaskRecord { } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "clearOnBackground=" + clearOnBackground - + " numActivities=" + numActivities - + " rootWasReset=" + rootWasReset); - pw.println(prefix + "affinity=" + affinity); - pw.println(prefix + "intent=" + intent); - pw.println(prefix + "affinityIntent=" + affinityIntent); - pw.println(prefix + "origActivity=" + origActivity); - pw.println(prefix + "lastActiveTime=" + lastActiveTime - +" (inactive for " + (getInactiveDuration()/1000) + "s)"); + if (clearOnBackground || numActivities != 0 || rootWasReset) { + pw.print(prefix); pw.print("clearOnBackground="); pw.print(clearOnBackground); + pw.print(" numActivities="); pw.print(numActivities); + pw.print(" rootWasReset="); pw.println(rootWasReset); + } + if (affinity != null) { + pw.print(prefix); pw.print("affinity="); pw.println(affinity); + } + if (intent != null) { + StringBuilder sb = new StringBuilder(128); + sb.append(prefix); sb.append("intent={"); + intent.toShortString(sb, true, false); + sb.append('}'); + pw.println(sb.toString()); + } + if (affinityIntent != null) { + StringBuilder sb = new StringBuilder(128); + sb.append(prefix); sb.append("affinityIntent={"); + affinityIntent.toShortString(sb, true, false); + sb.append('}'); + pw.println(sb.toString()); + } + if (origActivity != null) { + pw.print(prefix); pw.print("origActivity="); + pw.println(origActivity.flattenToShortString()); + } + if (realActivity != null) { + pw.print(prefix); pw.print("realActivity="); + pw.println(realActivity.flattenToShortString()); + } + pw.print(prefix); pw.print("lastActiveTime="); pw.print(lastActiveTime); + pw.print(" (inactive for "); + pw.print((getInactiveDuration()/1000)); pw.println("s)"); } public String toString() { - return "Task{" + taskId + " " - + (affinity != null ? affinity - : (intent != null ? intent.getComponent().flattenToShortString() - : affinityIntent != null ? affinityIntent.getComponent().flattenToShortString() : "??")) - + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("TaskRecord{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" #"); + sb.append(taskId); + if (affinity != null) { + sb.append(" A "); + sb.append(affinity); + } else if (intent != null) { + sb.append(" I "); + sb.append(intent.getComponent().flattenToShortString()); + } else if (affinityIntent != null) { + sb.append(" aI "); + sb.append(affinityIntent.getComponent().flattenToShortString()); + } else { + sb.append(" ??"); + } + sb.append('}'); + return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/UriPermission.java b/services/java/com/android/server/am/UriPermission.java index fb7a745..ffa8a2a 100644 --- a/services/java/com/android/server/am/UriPermission.java +++ b/services/java/com/android/server/am/UriPermission.java @@ -30,6 +30,8 @@ class UriPermission { final HashSet<HistoryRecord> readActivities = new HashSet<HistoryRecord>(); final HashSet<HistoryRecord> writeActivities = new HashSet<HistoryRecord>(); + String stringName; + UriPermission(int _uid, Uri _uri) { uid = _uid; uri = _uri; @@ -65,18 +67,29 @@ class UriPermission { } public String toString() { - return "UriPermission{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + uri + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("UriPermission{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(uri); + sb.append('}'); + return stringName = sb.toString(); } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + " modeFlags=0x" + Integer.toHexString(modeFlags) - + " uid=" + uid - + " globalModeFlags=0x" - + Integer.toHexString(globalModeFlags)); - pw.println(prefix + " readActivities=" + readActivities); - pw.println(prefix + " writeActivities=" + writeActivities); + pw.print(prefix); pw.print("modeFlags=0x"); + pw.print(Integer.toHexString(modeFlags)); + pw.print(" uid="); pw.print(uid); + pw.print(" globalModeFlags=0x"); + pw.println(Integer.toHexString(globalModeFlags)); + if (readActivities.size() != 0) { + pw.print(prefix); pw.print("readActivities="); pw.println(readActivities); + } + if (writeActivities.size() != 0) { + pw.print(prefix); pw.print("writeActivities="); pw.println(writeActivities); + } } } |