adb shell dumpsys window

Android Debug Bridge: Dump System Windows

By Robert Martin
AD

The adb shell dumpsys window command is a powerful diagnostic tool for Android developers and power users who need deep visibility into the current state of the device's user interface. This command interacts directly with the WindowManager service, providing a real-time snapshot of how windows, layouts, and input focus are organized on the device. For anyone working with complex applications or debugging tricky UI bugs, understanding this output is often faster than guessing based on symptoms alone.

In practice, running this command reveals a wealth of information about your screen, including the hierarchy of active views, the dimensions of different display areas, and the configuration of the status and navigation bars. It serves as a window into the very fabric of what the device is currently rendering, which is indispensable when an app is misbehaving or the system seems unresponsive. Mastering this command allows you to move beyond simple logcat filtering and inspect the actual window composition pipeline.

Understanding the Window Manager Service

At the core of the Android UI stack is the WindowManager service, which acts as the central conductor for all drawing and interaction on the screen. The dumpsys window command queries this specific service, asking it to report on every window it currently manages and the policies it is enforcing. This includes everything from the system dialogs to the full-screen activities of your foreground app, making it a comprehensive source of truth for the UI layer.

AD
a kitchen sink sitting under a window next to a window sill with a curtain over it
a kitchen sink sitting under a window next to a window sill with a curtain over it
an open window on the side of a building
an open window on the side of a building
a bottle sitting on top of a window sill in front of a glass block
a bottle sitting on top of a window sill in front of a glass block

When the system or an app encounters a problem related to drawing, orientation, or touch input, developers often turn to this command to find the root cause. It provides low-level details about tokens, display IDs, and layer ordering that are not visible in standard logs. By learning to interpret this data, you gain the ability to diagnose issues that would otherwise require guesswork or extensive experimentation.

View Hierarchy and Z-Order

One of the most critical pieces of information in the output is the view hierarchy, which is presented as a nested tree of display objects. This tree shows the parent-child relationships between different UI elements, allowing you to see exactly how the screen is constructed at a given moment. You can trace the flow of drawing commands from the root down to the smallest interactive widget.

a round window with green leaves in it
a round window with green leaves in it
a white window sitting on the side of a brick building
a white window sitting on the side of a brick building
a white window with blinds on the outside
a white window with blinds on the outside

The Z-order, or the layering of windows, is also explicitly defined in this section, determining which elements appear on top of others. This is vital for understanding overlapping views, dialogs that obscure activities, or touch events being consumed by the wrong window. Analyzing the Z-order helps resolve visual glitches and input handling conflicts that are hard to reproduce in a debugger.

Display Cutouts and Configuration

The command also reports on the physical characteristics of the display, such as the presence of notches, holes, or curved edges, known as display cutouts. This information is essential for ensuring that your app's content does not get obscured by these hardware features. You can verify that your insets are being calculated correctly and that your UI is respecting the system window insets.

AD

Furthermore, the output details the current configuration, including screen resolution, density, and orientation. This helps confirm whether the system is scaling your app correctly or if there is a mismatch between the resources and the device. Seeing this configuration in real-time is invaluable for testing responsive layouts across different device types and settings.

the window is covered with white blinds
the window is covered with white blinds
♱
♱
Dummies Guide To New Home Windows
Dummies Guide To New Home Windows
an open window with vines growing out of the windowsill and in front of it
an open window with vines growing out of the windowsill and in front of it
a cat sitting on the window sill in front of a house with brown shutters
a cat sitting on the window sill in front of a house with brown shutters
an open window in the corner of a room with a view of a grassy yard
an open window in the corner of a room with a view of a grassy yard

Practical Usage and Common Flags

Using the command is straightforward, but knowing the right flags to append is what unlocks its full potential. The basic command provides a high-level overview, but adding options allows you to filter the noise and focus on specific details you are investigating. This makes the massive output manageable and directly relevant to the problem at hand.

Developers often pipe this command to other tools or grep specific keywords to narrow down the results. Whether you are looking for a specific token, checking the state of the status bar, or verifying the layout of a custom view, there is usually a flag or combination of flags that will make the process more efficient. Let us look at a few of the most useful variations in action.

AD

Filtering with cmd window

The `cmd window` subcommand provides a more modern and direct way to interact with the WindowManager. By using specific operation codes, you can perform actions such as taking screenshots, setting the focused display, or changing the system orientation. This is particularly useful for automation scripts or when you need to trigger a specific state without manually interacting with the device.

an open window in the corner of a room with grass and dirt on the ground
an open window in the corner of a room with grass and dirt on the ground
an open window with brown shutters on the side of a white house next to shrubbery
an open window with brown shutters on the side of a white house next to shrubbery
the double hung windows are shown in black and white, with yellow circles above them
the double hung windows are shown in black and white, with yellow circles above them
a kitchen with white cabinets and flowers in the window sill on the counter top
a kitchen with white cabinets and flowers in the window sill on the counter top
a kitchen window with white roman shades and snowflakes
a kitchen window with white roman shades and snowflakes
a white sink sitting under a bathroom window next to a toilet paper dispenser
a white sink sitting under a bathroom window next to a toilet paper dispenser
a cat sitting on top of a window sill in front of two large windows
a cat sitting on top of a window sill in front of two large windows
A window on a foggy day
A window on a foggy day
Beautiful Queenslander windows
Beautiful Queenslander windows
Windows
Windows
Lake house
Lake house
the window is covered with water and rain drops on it's glass, as well as brass handles
the window is covered with water and rain drops on it's glass, as well as brass handles
a living room with two windows covered in white sheer curtains and a clock on the wall
a living room with two windows covered in white sheer curtains and a clock on the wall

For instance, you can use these commands to simulate system events or to quickly gather information about the current top activity. This level of control is essential for advanced testing scenarios where you need to reproduce a specific sequence of UI states. It turns a passive observation tool into an active debugging instrument.

Piping to grep for Specific Data

Because the raw output of `dumpsys window` can be extremely verbose, combining it with `grep` is a standard practice for finding relevant data quickly. You can search for keywords like `mCurrentFocus` to identify which window currently has user input, or `mFocusedApp` to see the application that is currently in the foreground.

AD

This technique allows you to strip away the irrelevant layers of information and zoom in on the exact token or activity you are interested in. For troubleshooting ANRs or memory issues, being able to isolate the specific window state is often the fastest path to a solution. It transforms a wall of text into a targeted data source.

Troubleshooting Common UI Issues

When an app fails to display correctly or the system UI behaves erratically, the window state is usually the first place to look. The output can reveal if a window is stuck in a defunct state, if the layout bounds are incorrect, or if there is a conflict between system decorations and the app's content view. These insights are often the difference between a quick fix and a prolonged debugging session.

For example, if the soft keyboard is not appearing, checking the window focus and the layout insets can show whether the system is recognizing the input field. Similarly, if transitions between activities are broken, the window manager's state history can provide clues about what went wrong in the last transaction. The command essentially provides a forensic snapshot of the UI at the time of the issue.

By correlating the output of this command with logcat messages, you can build a complete picture of the failure chain. This holistic approach allows you to see not just what happened, but why it happened at the system level. It is the definitive method for resolving complex and intermittent UI bugs that standard logging cannot explain.

Exploring the details of your device's window state transforms the way you interact with and debug Android applications, turning abstract UI problems into concrete data you can analyze. The more you practice interpreting these outputs, the more intuitive the visual system architecture becomes, allowing you to build more robust and reliable experiences.

AD