Refine output of "dumpsys window displays/windows"

- Prints the window title instead of dumping the whole window in
  InsetsSourceProvider.
- Stops printing mFakeControl, because it is the same in each
  InsetsSourceProvider.
- Removes redundant blanks after '='.
- Refines indentation.
- Prints requested visibility while dumping WindowState instead of
  printing the raw mRequestedInsetsState.

Fix: 184237588
Test: check the output of "dumpsys window -a"
Change-Id: I3e0ac2335c29b7f2449b890b4070c62d77ff7f7f
This commit is contained in:
Tiger Huang
2021-04-01 20:38:50 +08:00
parent 6c63ebbb9e
commit 2664c3863b
5 changed files with 46 additions and 34 deletions

View File

@@ -34,6 +34,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.WindowConfiguration;
import android.graphics.Insets;
@@ -808,7 +809,7 @@ public class InsetsState implements Parcelable {
dest.writeTypedObject(mRoundedCorners, flags);
}
public static final @android.annotation.NonNull Creator<InsetsState> CREATOR = new Creator<InsetsState>() {
public static final @NonNull Creator<InsetsState> CREATOR = new Creator<InsetsState>() {
public InsetsState createFromParcel(Parcel in) {
return new InsetsState(in);
@@ -842,5 +843,16 @@ public class InsetsState implements Parcelable {
+ ", mSources= { " + joiner
+ " }";
}
public @NonNull String toSourceVisibilityString() {
StringJoiner joiner = new StringJoiner(", ");
for (int i = 0; i < SIZE; i++) {
InsetsSource source = mSources[i];
if (source != null) {
joiner.add(typeToString(i) + ": " + (source.isVisible() ? "visible" : "invisible"));
}
}
return joiner.toString();
}
}

View File

@@ -240,6 +240,7 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
@Override
public void dump(PrintWriter pw, String prefix) {
super.dump(pw, prefix);
prefix = prefix + " ";
pw.print(prefix);
pw.print("mImeShowing=");
pw.print(mImeShowing);

View File

@@ -63,7 +63,7 @@ import java.util.function.Consumer;
/**
* Controller for a specific inset source on the server. It's called provider as it provides the
* {@link InsetsSource} to the client that uses it in {@link InsetsSourceConsumer}.
* {@link InsetsSource} to the client that uses it in {@link android.view.InsetsSourceConsumer}.
*/
class InsetsSourceProvider {
@@ -452,40 +452,36 @@ class InsetsSourceProvider {
}
public void dump(PrintWriter pw, String prefix) {
pw.println(prefix + "InsetsSourceProvider");
pw.print(prefix + " mSource="); mSource.dump(prefix + " ", pw);
pw.println(prefix + getClass().getSimpleName());
prefix = prefix + " ";
pw.print(prefix + "mSource="); mSource.dump("", pw);
if (mControl != null) {
pw.print(prefix + " mControl=");
mControl.dump(prefix + " ", pw);
pw.print(prefix + "mControl=");
mControl.dump("", pw);
}
pw.print(prefix + " mFakeControl="); mFakeControl.dump(prefix + " ", pw);
pw.print(" mIsLeashReadyForDispatching="); pw.print(mIsLeashReadyForDispatching);
pw.print(" mImeOverrideFrame="); pw.print(mImeOverrideFrame.toString());
pw.print(prefix);
pw.print("mIsLeashReadyForDispatching="); pw.print(mIsLeashReadyForDispatching);
pw.print(" mImeOverrideFrame="); pw.print(mImeOverrideFrame.toShortString());
pw.println();
if (mWin != null) {
pw.print(prefix + " mWin=");
mWin.dump(pw, prefix + " ", false /* dumpAll */);
pw.print(prefix + "mWin=");
pw.println(mWin);
}
if (mAdapter != null) {
pw.print(prefix + " mAdapter=");
mAdapter.dump(pw, prefix + " ");
pw.print(prefix + "mAdapter=");
mAdapter.dump(pw, "");
}
if (mControlTarget != null) {
pw.print(prefix + " mControlTarget=");
if (mControlTarget.getWindow() != null) {
mControlTarget.getWindow().dump(pw, prefix + " ", false /* dumpAll */);
}
pw.print(prefix + "mControlTarget=");
pw.println(mControlTarget.getWindow());
}
if (mPendingControlTarget != null) {
pw.print(prefix + " mPendingControlTarget=");
if (mPendingControlTarget.getWindow() != null) {
mPendingControlTarget.getWindow().dump(pw, prefix + " ", false /* dumpAll */);
}
pw.print(prefix + "mPendingControlTarget=");
pw.println(mPendingControlTarget.getWindow());
}
if (mFakeControlTarget != null) {
pw.print(prefix + " mFakeControlTarget=");
if (mFakeControlTarget.getWindow() != null) {
mFakeControlTarget.getWindow().dump(pw, prefix + " ", false /* dumpAll */);
}
pw.print(prefix + "mFakeControlTarget=");
pw.println(mFakeControlTarget.getWindow());
}
}
@@ -575,8 +571,9 @@ class InsetsSourceProvider {
@Override
public void dump(PrintWriter pw, String prefix) {
pw.println(prefix + "ControlAdapter");
pw.print(prefix + " mCapturedLeash="); pw.print(mCapturedLeash);
pw.print(prefix + "ControlAdapter mCapturedLeash=");
pw.print(mCapturedLeash);
pw.println();
}
@Override

View File

@@ -573,18 +573,17 @@ class InsetsStateController {
void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "WindowInsetsStateController");
mState.dump(prefix + " ", pw);
pw.println(prefix + " " + "Control map:");
prefix = prefix + " ";
mState.dump(prefix, pw);
pw.println(prefix + "Control map:");
for (int i = mTypeControlTargetMap.size() - 1; i >= 0; i--) {
pw.print(prefix + " ");
pw.println(InsetsState.typeToString(mTypeControlTargetMap.keyAt(i)) + " -> "
+ mTypeControlTargetMap.valueAt(i));
}
pw.println(prefix + " " + "InsetsSourceProviders map:");
pw.println(prefix + "InsetsSourceProviders:");
for (int i = mProviders.size() - 1; i >= 0; i--) {
pw.print(prefix + " ");
pw.println(InsetsState.typeToString(mProviders.keyAt(i)) + " -> ");
mProviders.valueAt(i).dump(pw, prefix);
mProviders.valueAt(i).dump(pw, prefix + " ");
}
}
}

View File

@@ -4281,7 +4281,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
pw.println(prefix + "mEmbeddedDisplayContents=" + mEmbeddedDisplayContents);
}
if (dumpAll) {
pw.println(prefix + "mRequestedInsetsState: " + mRequestedInsetsState);
final String visibilityString = mRequestedInsetsState.toSourceVisibilityString();
if (!visibilityString.isEmpty()) {
pw.println(prefix + "Requested visibility: " + visibilityString);
}
}
}