Wake up Android with use adb or Eclipse (just before debug)?

后端 未结 9 628
温柔的废话
温柔的废话 2021-01-31 04:45

How to wake up Android with use adb - I want to wake up (if asleep) Android terminal before debugging every new version of application.

Typical flow is: 1. I do some cha

9条回答
  •  梦如初夏
    2021-01-31 04:50

    I used the following to wake up remote devices for automated tests. If the screen isn't on, then it will press the power button followed by the menu button.

    (
      cd ${platform-tools};
      ./adb shell dumpsys power | grep -i 'SCREEN_ON' >/dev/null;
      if [ $? -eq 0 ]; then
        echo "Screen is on...";
      else
        echo "Pressing buttons to wake-up...";
        # http://developer.android.com/reference/android/view/KeyEvent.html
        ./adb shell input keyevent 26; # Power
        ./adb shell input keyevent 82; # Menu
        echo "Pausing for state to settle...";
        sleep 1;
        ./adb shell dumpsys power | grep -i 'SCREEN_ON';
      fi;
      echo '---';
      ./adb shell dumpsys power | grep -i 'SCREEN'
    )
    

提交回复
热议问题