usb 테더링를 계속 쓰게 될 일이 생겨서 찾아보았다. 폰에 따라 usb 테더링을 켜면 ADB(Android Debug Bridge)를 못쓰게 되는 경우가 있는 것 같다. 나는 펌웨어를 변경했더니 usb 테더링이 켜져 있는 상태에서 adb를 쓸 수 있게 되었다. usb 테더링을 켰을때 adb를 쓸수 없다면, usb 테더링을 끄기 어려울 것이다.

adb는 여기에서 받을 수 있다.
연결 상태 확인 | adb devices |
화면 저장 | adb shell screencap -p /sdcard/screen.png |
파일 이동(폰->pc) | adb pull /sdcard/screen.png |
파일 삭제 | adb shell rm /sdcard/screen.png |
화면 켜기 | adb shell input keyevent KEYCODE_WAKEUP |
잠금해제(드래그일 경우) | adb shell input touchscreen swipe 100 100 500 100 100 |
홈 화면 이동 | adb shell input keyevent 4 |
테더링 설정 이동 | adb shell am start -n com.android.settings/.TetherSettings |
탭 키 입력 | adb shell input keyevent 20 |
엔터 키 입력 | adb shell input keyevent 23 |
나는 시스템변수에 넣지 않고 adb.exe 파일이 있는 폴더에 직접 들어가서 실행하는 것을 선호한다.
시간이 걸리는 명령들은 중간에 지연시켜줘야 제대로 실행이 된다. 명령프롬프트는 timeout 1, 파워쉘은 sleep 1로 1초 지연시킬수 있다. 위 명령들을 조합하여 아래 같이 쓸 수 있다. usb 테더링 버튼의 위치가 다를 경우, 조금 변경해야될 수 있다. adb 명령어로 usb 테더링이 켜져있는지 확인하는 방법은 못 찾아서 화면캡쳐를 통해 보는 방법을 써야한다.
안드로이드 버전에 따라 아예 쓰지 못하는 경우도 있을 것 같다.
화면 캡쳐
adb shell screencap -p /sdcard/screen.png && adb pull /sdcard/screen.png && adb shell rm /sdcard/screen.png
usb 테더링 켜기/끄기
adb shell input keyevent 3 && timeout 1 && adb shell input touchscreen swipe 100 100 500 100 100 && adb shell am start -n com.android.settings/.TetherSettings && adb shell input keyevent 20 && adb shell input keyevent 20 && adb shell input keyevent 20 && adb shell input keyevent 20 && adb shell input keyevent 23