First you need to run this command:
> adb shell dumpsys battery unplug
Then turn off the screen (this step is critical), otherwise the device remains in the ACTIVE state.
After that, run this command until the device status changes to IDLE :
> adb shell dumpsys deviceidle step Stepped to: IDLE_PENDING > adb shell dumpsys deviceidle step Stepped to: SENSING > adb shell dumpsys deviceidle step Stepped to: LOCATING > adb shell dumpsys deviceidle step Stepped to: IDLE
source share