How to Inspect and Simulate Foldable Device States on Android Using ADB dumpsys device_state

Developing and optimising applications for foldable and dual-screen form factors requires validating how user interfaces adapt across different physical postures. While modern Android devices integrate physical hinges and angle sensors, testing UI reflow during continuous transitions between folded, unfolded, tent, and half-folded modes on physical hardware or test farm instances can be challenging. Android provides low-level control through the Device State Manager and its command-line debugging tool, dumpsys device_state. Using the Android Debug Bridge (ADB), engineers can inspect hardware state identifiers, monitor hinge sensor posture changes, and simulate specific folding states without manually manipulating the physical hardware.

Understanding the Android Device State Manager

The Android framework manages device postures through the DeviceStateManager service. This system daemon receives inputs from underlying hardware sensors—such as hall-effect magnetic sensors, hinge angle sensors, and accelerometers—and maps them to defined integer states. These states define whether the primary screen is active, whether the cover display is enabled, and whether the screen is flat or positioned at a 90-degree angle (often termed tabletop or half-folded posture).

When an application targets responsive layout libraries such as Jetpack WindowManager, it listens for FoldingFeature events derived from these underlying states. When debugging issues where layout transitions fail or visual jitter occurs, inspecting the raw system state via ADB allows you to determine whether the fault stems from hardware sensor thresholds or application-level window configuration listeners.

Inspecting Device State Information with Dumpsys

To inspect the current posture, supported physical states, and override configurations, establish an ADB connection to your test device or emulator and query the device_state service dump:

adb shell dumpsys device_state

The output reports detailed diagnostic blocks explaining the state capabilities of the device:

Device State Manager (device_state):
  mCurrentState=0
  mLastReportedState=0
  mSupportedStates=[0, 1, 2, 3]
  mBaseState=0
  Active Base State: 0 (CLOSED)
  Active Override State: null
  Committed State: 0 (CLOSED)
  Thermal Status: 0 (NONE)
  Registered Callbacks:
    com.android.server.wm.WindowManagerService
    com.android.server.display.DisplayManagerService

The output provides several critical parameters:

  • mCurrentState: The active logical device state determining system UI behaviours and active display panels.
  • mSupportedStates: An array of numeric identifiers representing all valid postures configured by the original equipment manufacturer (OEM).
  • Active Override State: Indicates whether a testing override is actively overriding physical sensor telemetry.
  • mBaseState: The underlying physical state detected by the hardware sensors, regardless of test overrides.

Mapping Supported Device States

Device state identifiers vary across device manufacturers and Android versions, although standard definitions are commonly mapped as follows:

State ID State Name Hardware Posture Description
0 CLOSED Device is fully folded. The external cover display is active while the interior flexible display is disabled.
1 HALF_OPENED Device is propped at an angle (tabletop/tent posture). WindowManager reports a separating hinge fold.
2 OPENED Device is fully unfolded into a flat tablet posture. The large interior display is active.
3 REAR_DISPLAY Dual-screen or camera preview mode where specific camera viewfinders are mirrored to the outer panel.

To verify the exact human-readable mappings defined in your device build, query the system device state command helper:

adb shell cmd device_state print-states

This command outputs the precise numerical identifiers alongside their declared string names, such as 0: CLOSED, 1: HALF_FOLDED, and 2: OPENED.

Simulating Foldable Postures Using Device State Overrides

During automated testing or manual UI inspection, you can command the system to emulate folding transitions without moving the physical hinge. Android provides the cmd device_state state command to force the system into any supported posture.

To force the device into an unfolded posture (for example, state 2):

adb shell cmd device_state state 2

The device displays will transition immediately: the internal primary display activates, window configurations adjust to the larger viewport, and responsive activities adapt their multi-pane fragments.

To simulate a tabletop posture where the device sits half-folded on a desk (state 1):

adb shell cmd device_state state 1

This posture triggers Jetpack WindowManager to report a FoldingFeature.State.HALF_OPENED event with an active occlusion or separating fold boundary. Video players, camera controls, or split dashboards should automatically separate control panels from the media preview canvas.

To return the device to the folded posture (state 0):

adb shell cmd device_state state 0

Resetting State Overrides to Restore Physical Hardware Control

When an override is applied via ADB, physical hinge movements will no longer alter the logical device state because the software test override takes precedence. To remove the software override and return control to the physical sensors, issue the cancel command:

adb shell cmd device_state state reset

You can verify that the override was cleanly purged by running adb shell dumpsys device_state and ensuring that Active Override State: null is reported.

Monitoring Device State Transitions in Real Time

When testing how an application responds to dynamic folding actions, you can monitor logcat output filtered for WindowManager and DeviceStateManager events. Open an ADB logcat session in a separate terminal:

adb logcat -v time -s DeviceStateManagerService WindowManager FoldingFeature

While monitoring this stream, execute state transitions in your primary terminal:

adb shell cmd device_state state 1
sleep 2
adb shell cmd device_state state 2
sleep 2
adb shell cmd device_state state reset

Reviewing the log stream reveals whether your application process receives display configuration updates synchronously, whether activities undergo unnecessary recreation, and whether window bounds calculate correctly around the folding crease.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.