openstf / stf

Control and manage Android devices from your browser.
https://openstf.io
Other
13.17k stars 2.71k forks source link

Guide: Steps for adding Xiaomi devices to STF (e.g. Xiaomi Redmi 4A , MIUI 8.2.6.0) #603

Open sorccu opened 7 years ago

sorccu commented 7 years ago

To add Xiaomi devices to STF, there are extra steps that must be taken.

  1. To enable Developer options, to go SettingsAbout phone and tap on MIUI version until it says developer mode has been turned on.
  2. Go to SettingsMi Account and create or log in to a Mi account. This is required for the next step.
  3. Go to SettingsAdditional settingsDeveloper options. Turn USB debugging (for ADB access), Install via USB (needed for installing STFService.apk) and USB debugging (Security settings) (needed for running minitouch) on. You must have a MI account set up to enable USB debugging (Security settings), otherwise it won't let you.
    • Note: there are reports that some versions of MIUI may require a SIM card or these settings can't be turned on.
  4. Connect the device to your computer. Allow the ADB key and select "Always allow."
  5. Run STF. A dialog will pop up on the device confirming installation of STFService. You must allow the installation to go through. Note that you may need to do this again in the future if the service is updated.
  6. If STF fails to start after installing STFService.apk, go to SettingsPermissionsAutostart and enable STFService.
  7. The device should now work in STF.

Common errors:

If you see an error that says:

Setup had an error Error: /data/local/tmp/STFService.apk could not be installed [INSTALL_CANCELED_BY_USER]

It means that you haven't enabled the Install via USB option.

Steps tested on:

Redmi 4A

iqianxing commented 6 years ago

The device requires sim card in the device. If doesn't, Install via USB (needed for installing STFService.apk) and USB debugging (Security settings) (needed for running minitouch) can't on.

sorccu commented 6 years ago

Hmmmm that's weird, I don't have a SIM card in mine. Which device and MIUI version is it?

iqianxing commented 6 years ago

MIUI 8.5.1.0

sorccu commented 6 years ago

Strange... does it actually tell you that you need a SIM card?

iqianxing commented 6 years ago

Yes , perhaps the os is different in China.

sorccu commented 6 years ago

Possible. I've added your findings to the guide.

lukassos commented 6 years ago

Any update on this matter ? Same issue here. I need sim card inside the phone to install/dev apps on the phone too. I have unpacked new Redmi Note 5A with android 7.1.2 N2G47H (2017-12-01) and MUIU 9.2.1.0 NDFMIEK and the issue persist . In android studio INSTALL_FAILED_USER_RESTRICTED, which implies the admin app has not permitted such operation. And in Xiaomi phone it is part of MIUI as I recall.

sorccu commented 6 years ago

What kind of an update are you looking for? If the manufacturer forces you to set up a SIM card there’s nothing we can do about that.

lukassos commented 6 years ago

You're right. There is nothing you can add to this matter. I have researched about it a bit more and this is really an issue of MIUI 8+. They have added verification on chinese servers and gather unique id (UUID) of the phone on unlock of unknown souce apk. This UUID is generated from sim card secure element and thus you need a sim card indeed. Foremost thanks for really fast answer 😉 So for anybody else reading this, you need any sim card inside. There is no need for sim card to be active on cellular. On the other hand internet connection is required too.

liyaoyao6342 commented 4 years ago

I also encountered this problem on Red mi note8 pro, all the switches suggested above are turned on, can you help me see the problem?

forum77alive commented 4 years ago

MIUI 11 , xiaomi MI9 and xiaomi mi8 lite not working

when i use device and open virtual display - i get this logs:

stf-local_1 | 2020-03-04T14:47:19.564Z INF/device:resources:minirev 313 [4d9c3254] Installing "/app/vendor/minirev/arm64-v8a/minirev" as "/data/local/tmp/minirev"
stf-local_1 | 2020-03-04T14:47:19.590Z INF/device:plugins:forward 313 [4d9c3254] Launching reverse port forwarding service
stf-local_1 | 2020-03-04T14:47:19.600Z INF/device:plugins:forward 313 [4d9c3254] Connecting to reverse port forwarding service
stf-local_1 | 2020-03-04T14:47:19.758Z INF/device 313 [4d9c3254] Fully operational
stf-local_1 | 2020-03-04T14:47:37.984Z IMP/device:plugins:group 313 [4d9c3254] Now owned by "my@email"
stf-local_1 | 2020-03-04T14:47:37.984Z INF/device:plugins:group 313 [4d9c3254] Subscribing to group channel "zy2EVof5TxmiQzznBqT1/g=="
stf-local_1 | 2020-03-04T14:47:38.069Z INF/device:plugins:screen:stream 313 [4d9c3254] Setting frame producer projection to 574x848
stf-local_1 | 2020-03-04T14:47:38.069Z INF/device:plugins:screen:stream 313 [4d9c3254] Requesting frame producer to start
stf-local_1 | 2020-03-04T14:47:38.070Z INF/device:plugins:screen:stream 313 [4d9c3254] Launching screen service
stf-local_1 | 2020-03-04T14:47:38.123Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "PID: 8006"
stf-local_1 | 2020-03-04T14:47:38.123Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: Using projection 1080x2340@391x848/0"
stf-local_1 | 2020-03-04T14:47:38.123Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:241) Creating SurfaceComposerClient"
stf-local_1 | 2020-03-04T14:47:38.124Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:244) Performing SurfaceComposerClient init check"
stf-local_1 | 2020-03-04T14:47:38.124Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:255) Creating virtual display"
stf-local_1 | 2020-03-04T14:47:38.124Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:261) Creating buffer queue"
stf-local_1 | 2020-03-04T14:47:38.124Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:264) Setting buffer options"
stf-local_1 | 2020-03-04T14:47:38.125Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:268) Creating CPU consumer"
stf-local_1 | 2020-03-04T14:47:38.125Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:272) Creating frame waiter"
stf-local_1 | 2020-03-04T14:47:38.125Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "INFO: (external/MY_minicap/src/minicap_29.cpp:276) Publishing virtual display"
stf-local_1 | 2020-03-04T14:47:38.126Z INF/device:plugins:screen:stream 313 [4d9c3254] minicap says: "Vector<> have different types (this=0x7ff8124fc0, rhs=0x7ff8125110)"
stf-local_1 | 2020-03-04T14:47:38.127Z INF/device:plugins:screen:stream 313 [4d9c3254] Connecting to minicap service
stf-local_1 | 2020-03-04T14:47:38.135Z INF/device:plugins:connect 313 [4d9c3254] Listening on port 7457
stf-local_1 | 2020-03-04T14:47:38.137Z IMP/device:plugins:connect 313 [4d9c3254] Remote Connect Started for device "4d9c3254" at "IP_stf_server:7457"
stf-local_1 | 2020-03-04T14:47:38.166Z WRN/device:plugins:screen:stream 313 [4d9c3254] Shell keeping minicap running ended unexpectedly
stf-local_1 | 2020-03-04T14:47:39.652Z INF/device:plugins:screen:stream 313 [4d9c3254] Disconnecting from minicap service
stf-local_1 | 2020-03-04T14:47:39.653Z INF/device:plugins:screen:stream 313 [4d9c3254] Stopping minicap service
stf-local_1 | 2020-03-04T14:47:39.655Z FTL/device:plugins:screen:stream 313 [4d9c3254] Frame producer had an error FailError: Failure: 'closed'
stf-local_1 | at /app/node_modules/adbkit/lib/adb/parser.js:183:29
stf-local_1 | at runCallback (timers.js:789:20)
stf-local_1 | at tryOnImmediate (timers.js:751:5)
stf-local_1 | at processImmediate [as _immediateCallback] (timers.js:722:5)
stf-local_1 | 2020-03-04T14:47:39.655Z FTL/util:lifecycle 313 [4d9c3254] Shutting down due to fatal error
stf-local_1 | 2020-03-04T14:47:39.659Z INF/provider 37 [] Cleaning up device worker "4d9c3254"
stf-local_1 | 2020-03-04T14:47:39.660Z ERR/provider 37 [] Device worker "4d9c3254" died with code 1
stf-local_1 | 2020-03-04T14:47:39.660Z INF/provider 37 [*] Restarting device worker "4d9c3254"
stf-local_1 | 2020-03-04T14:47:40.520Z INF/device:support:push 325 [4d9c3254] Sending output to "tcp://127.0.0.1:7116"
stf-local_1 | 2020-03-04T14:47:40.524Z INF/device 325 [4d9c3254] Preparing device
stf-local_1 | 2020-03-04T14:47:40.975Z INF/device:support:sub 325 [4d9c3254] Receiving input from "tcp://127.0.0.1:7114"
stf-local_1 | 2020-03-04T14:47:40.976Z INF/device:support:sub 325 [4d9c3254] Subscribing to permanent channel "*ALL"
stf-local_1 | 2020-03-04T14:47:41.038Z INF/device:support:properties 325 [4d9c3254] Loading properties
stf-local_1 | 2020-03-04T14:47:41.062Z INF/device:support:sdk 325 [4d9c3254] Supports SDK 29
stf-local_1 | 2020-03-04T14:47:41.063Z INF/device:support:abi 325 [4d9c3254] Supports ABIs arm64-v8a, armeabi-v7a, armeabi
stf-local_1 | 2020-03-04T14:47:41.168Z INF/device:resources:minicap 325 [4d9c3254] Installing "/app/node_modules/minicap-prebuilt-beta/prebuilt/arm64-v8a/bin/minicap" as "/data/local/tmp/minicap"
stf-local_1 | 2020-03-04T14:47:41.168Z INF/device:resources:minicap 325 [4d9c3254] Installing "/app/node_modules/minicap-prebuilt-beta/prebuilt/arm64-v8a/lib/android-29/minicap.so" as "/data/local/tmp/minicap.so"
stf-local_1 | 2020-03-04T14:47:41.225Z INF/device:resources:service 325 [4d9c3254] Checking whether we need to install STFService
stf-local_1 | 2020-03-04T14:47:41.257Z INF/device:resources:service 325 [4d9c3254] Running version check
stf-local_1 | 2020-03-04T14:47:41.464Z INF/device:resources:service 325 [4d9c3254] Installing STFService

It goes on forever.

RmondJone commented 4 years ago

I did all the steps you said

N/device:plugins:data 90521 [7dk7ylv8feuotsfm] Unable to find device data { serial: '7dk7ylv8feuotsfm',
  platform: 'Android',
  manufacturer: 'XIAOMI',
  operator: null,
  model: ' Note 8 Pro',
  version: '9',
  abi: 'arm64-v8a',
  sdk: '28',
  product: 'begonia',
  cpuPlatform: 'mt6785',
  openGLESVersion: '3.2',
  display: 
   { id: 0,
     width: 1080,
     height: 2340,
     xdpi: 394.71600341796875,
     ydpi: 394.71600341796875,
     fps: 60.25,
     density: 2.75,
     rotation: 0,
     secure: true,
     size: 6.529271093831765,
     url: 'ws://192.168.27.180:7568' },
  phone: { imei: '99001405964062', network: 'UNKNOWN' } }
2020-03-09T05:35:33.378Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Touch origin is top left
2020-03-09T05:35:33.379Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Requesting touch consumer to start
2020-03-09T05:35:33.380Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.389Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.400Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.400Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.401Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.401Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.402Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.405Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.407Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.408Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.416Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.427Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.427Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.427Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.428Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.428Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.430Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.431Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.432Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.440Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.451Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.452Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.452Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.453Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.453Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.454Z INF/provider 88493 [*] Providing 4 of 5 device(s); waiting for "7dk7ylv8feuotsfm"
2020-03-09T05:35:33.455Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.456Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.457Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.465Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.475Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.475Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.476Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.476Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.477Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.478Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.480Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Will not apply desired state due to too many failures
2020-03-09T05:35:33.481Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.483Z FTL/device 90521 [7dk7ylv8feuotsfm] Setup had an error Error: Failed more than 3 times in 10000ms
    at TouchConsumer._failLimitExceeded (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:230:26)
    at FailCounter.emit (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/eventemitter3/index.js:117:35)
    at FailCounter.inc (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/util/failcounter.js:29:10)
    at TouchConsumer._outputEnded (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:223:24)
    at RiskyStream.emit (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/eventemitter3/index.js:115:35)
    at RiskyStream.<anonymous> (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/util/riskystream.js:14:12)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
From previous event:
    at startConsumer (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:511:14)
    at /Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:526:12
    at SerialSyrup.ParallelSyrup.invoke (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/stf-syrup/lib/parallel.js:54:24)
    at /Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/stf-syrup/lib/serial.js:43:33
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
2020-03-09T05:35:33.484Z FTL/util:lifecycle 90521 [7dk7ylv8feuotsfm] Shutting down due to fatal error
2020-03-09T05:35:33.493Z INF/provider 88493 [*] Cleaning up device worker "7dk7ylv8feuotsfm"
2020-03-09T05:35:33.493Z ERR/provider 88493 [*] Device worker "7dk7ylv8feuotsfm" died with code 1
2020-03-09T05:35:33.493Z INF/provider 88493 [*] Restarting device worker "7dk7ylv8feuotsfm"
yuyangcq commented 3 years ago

Linux机器使用docker搭建STF,Windows安装SDK后,使用USB连接安卓设备 首先在Windows暴露5037端口 然后在Linux使用命令:stf provider --name localhost.localdomain --min-port 7400 --max-port 7700 --connect-sub tcp://172.50.1.159:7114 --connect-push tcp://172.50.1.159:7116 --group-timeout 900 --public-ip 172.50.1.159 --storage-url http://172.50.1.159:7100/ --adb-host 172.17.244.11 --adb-port 5037 --vnc-initial-size 600x800 --mute-master never --allow-remote

就一直停在“ tcp://172.50.1.159:7114”接收输入,过了几分钟就报错了,这个是什么原因? 2021-05-26_104418 2021-05-26_105530

namedlock commented 1 year ago

I did all the steps you said

N/device:plugins:data 90521 [7dk7ylv8feuotsfm] Unable to find device data { serial: '7dk7ylv8feuotsfm',
  platform: 'Android',
  manufacturer: 'XIAOMI',
  operator: null,
  model: ' Note 8 Pro',
  version: '9',
  abi: 'arm64-v8a',
  sdk: '28',
  product: 'begonia',
  cpuPlatform: 'mt6785',
  openGLESVersion: '3.2',
  display: 
   { id: 0,
     width: 1080,
     height: 2340,
     xdpi: 394.71600341796875,
     ydpi: 394.71600341796875,
     fps: 60.25,
     density: 2.75,
     rotation: 0,
     secure: true,
     size: 6.529271093831765,
     url: 'ws://192.168.27.180:7568' },
  phone: { imei: '99001405964062', network: 'UNKNOWN' } }
2020-03-09T05:35:33.378Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Touch origin is top left
2020-03-09T05:35:33.379Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Requesting touch consumer to start
2020-03-09T05:35:33.380Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.389Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.400Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.400Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.401Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.401Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.402Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.405Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.407Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.408Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.416Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.427Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.427Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.427Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.428Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.428Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.430Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.431Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.432Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.440Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.451Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.452Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.452Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.453Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.453Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.454Z INF/provider 88493 [*] Providing 4 of 5 device(s); waiting for "7dk7ylv8feuotsfm"
2020-03-09T05:35:33.455Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.456Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.457Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Launching touch service
2020-03-09T05:35:33.465Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Connecting to minitouch service
2020-03-09T05:35:33.475Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "open: Permission denied"
2020-03-09T05:35:33.475Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event2 for inspectionopen: Permission denied"
2020-03-09T05:35:33.476Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event0 for inspectionopen: Permission denied"
2020-03-09T05:35:33.476Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] minitouch says: "Unable to open device /dev/input/event1 for inspectionUnable to find a suitable touch device"
2020-03-09T05:35:33.477Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Shell keeping minitouch running ended unexpectedly
2020-03-09T05:35:33.478Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Disconnecting from minitouch service
2020-03-09T05:35:33.480Z WRN/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Will not apply desired state due to too many failures
2020-03-09T05:35:33.481Z INF/device:plugins:touch 90521 [7dk7ylv8feuotsfm] Stopping minitouch service
2020-03-09T05:35:33.483Z FTL/device 90521 [7dk7ylv8feuotsfm] Setup had an error Error: Failed more than 3 times in 10000ms
    at TouchConsumer._failLimitExceeded (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:230:26)
    at FailCounter.emit (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/eventemitter3/index.js:117:35)
    at FailCounter.inc (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/util/failcounter.js:29:10)
    at TouchConsumer._outputEnded (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:223:24)
    at RiskyStream.emit (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/eventemitter3/index.js:115:35)
    at RiskyStream.<anonymous> (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/util/riskystream.js:14:12)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
From previous event:
    at startConsumer (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:511:14)
    at /Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/lib/units/device/plugins/touch/index.js:526:12
    at SerialSyrup.ParallelSyrup.invoke (/Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/stf-syrup/lib/parallel.js:54:24)
    at /Users/jinwenwu/.nvm/versions/node/v8.16.2/lib/node_modules/stf/node_modules/stf-syrup/lib/serial.js:43:33
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
2020-03-09T05:35:33.484Z FTL/util:lifecycle 90521 [7dk7ylv8feuotsfm] Shutting down due to fatal error
2020-03-09T05:35:33.493Z INF/provider 88493 [*] Cleaning up device worker "7dk7ylv8feuotsfm"
2020-03-09T05:35:33.493Z ERR/provider 88493 [*] Device worker "7dk7ylv8feuotsfm" died with code 1
2020-03-09T05:35:33.493Z INF/provider 88493 [*] Restarting device worker "7dk7ylv8feuotsfm"

It seems MI OS's power saving strategy produce this error. I chose no restriction strategy for power saving, and it works.