When automating tests on Xiaomi devices, the device's background power consumption setting may be interfering with our automation app.
You will need to disable this setting, by disabling Xiaomi's UIAutomator battery usage control.
You can do this by heading to your device's settings:
Then battery & performance:
Select Manage apps battery usage:
Select Choose apps from Manage apps' battery usage:
Select Installed apps and choose UIAutomator, and then tap No restrictions: