How to lock Android screen via ADB?

后端 未结 8 993
长发绾君心
长发绾君心 2021-01-30 03:20

Is there a way to lock the Android screen via the ADB?

I find ways to lock the display in an apk, but I want to lock the screen from the PC via ADB, to simulate a displ

8条回答
  •  独厮守ぢ
    2021-01-30 03:46

    Cool, I just found KEYCODE_POWER which is 26.

    so it works by sending:

    adb shell input keyevent 26
    

    which locks the screen if the screen is unlocked. If the screen is already locked, it wakes up the device.

    My guess is that the only way to ensure that the screen is locked (off), is to unlock (we use keyevent 82 (menu), then lock it with the power button keyevent. Does anyone have any idea if this is true?

提交回复
热议问题