Search code examples
androidadbpocoxiaomi

Swipe screen Xiaomi Poco 5X remotely


Setup:

  • Xiaomi Poco 5X dev phone with remote access adb to it.
  • Vyzor installed however can only view screen because Xiaomi requires additional debugging flags be enabled

Problem: The phone only requires a swipe to unlock. I manage to turn on the screen with :

adb -s XXXXX shell svc power stayon true

However, when trying to swipe :

adb -s XXXXX shell "input touchscreen swipe 126 459 913 472"
Exception occurred while executing 'touchscreen':
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
        at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:914)
        at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:866)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:1091)
        at com.android.server.input.InputShellCommand.injectMotionEvent(InputShellCommand.java:138)
        at com.android.server.input.InputShellCommand.sendSwipe(InputShellCommand.java:370)
        at com.android.server.input.InputShellCommand.runSwipe(InputShellCommand.java:354)
        at com.android.server.input.InputShellCommand.onCommand(InputShellCommand.java:194)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.input.InputManagerService.onShellCommand(InputManagerService.java:3551)
        at android.os.Binder.shellCommand(Binder.java:956)
        at android.os.Binder.onTransact(Binder.java:840)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:1144)
        at android.os.Binder.execTransactInternal(Binder.java:1190)
        at android.os.Binder.execTransact(Binder.java:1149)

Any ideas?


Solution

  • You can try something like this swipe example from AndroidViewClient/culebra

    #! /usr/bin/env python3
    
    from com.dtmilano.android.viewclient import ViewClient
    
    helper = ViewClient.view_client_helper()
    
    
    helper.ui_device.swipe(segments=[(300, 300), (600, 1200), (600, 300), (300, 300)], segment_steps=50)
    

    of course you need to adapt the coordinates.

    Here is the result from previous command when Keep is the top activity (so we can actually see it drawing)

    enter image description here