NOTES

Android related stuffs

Automated Debugging

You can run ADB over USB or WiFi, but WiFi is preferred because

1.   Prepare phone for WiFi debug.

  1. Enable Developer options (normally hidden), by tapping Build number 7 times.
  2. Disable Auto Blocker.
  3. Enable Wireless debugging.

2.   Pair phone and desktop.

On Wireless debugging section, you’ll see

  1. Tap Pair device with pairing code, and you get a popup with
    • Wi-Fi pairing code — eg. 123456
    • IP address & Port — eg. 192.168.1.25:44444
  2. adb pair 192.168.1.25:44444
    • Enter the pairing code — eg. 123456.
  3. adb connect 192.168.1.25:22222
    • Use the phone port, not the pairing port just used.
    • Phone should say “Currently connected”.
  4. adb devices
    • The phone IP:port should be listed
  5. scrcpy
    • You can type/click on desktop, and the phone will act on those inputs.
    • Screenshot for Samsung Galaxy A16 Samsung-Galaxy-A16.png

3.   Send keyboard/mouse input to phone.

You can send keyboard/mouse input to the phone using ADB, instead of manually typing and clicking.

  1. To jump to Distrowatch website from the front page,
    adb shell input text KEYCODE_HOME          --- go to front page
    adb shell input tap 540 1120               --- tap Google Search
    adb shell input text "distrowatch.com"     --- type "distrowatch.com"
    adb shell input keyevent KEYCODE_ENTER     --- press <Enter>
    
  2. There are other keycodes:
    • 3 buttons at the bottom (app list, home, back)
      KEYCODE_RECENT_APPS or KEYCODE_APP_SWITCH
      KEYCODE_HOME
      KEYCODE_BACK 
      
    • phone related
      KEYCODE_0 ... KEYCODE_9
      KEYCODE_STAR
      KEYCODE_POUND
      KEYCODE_CALL
      KEYCODE_ENDCALL
      
    • text entry
      KEYCODE_A ... KEYCODE_Z
      KEYCODE_AT
      KEYCODE_PERIOD
      KEYCODE_PLUS
      KEYCODE_MINUS
      KEYCODE_SLASH
      KEYCODE_SPACE
      KEYCODE_DEl
      KEYCODE_TAB
      KEYCODE_ENTER
      

4.   Determine X and Y positions.

  1. Enable Pointer location.
    • X,Y positions of screen touch will be printed at the top of screen.
  2. adb shell getevent -l
    • ABS_MT_POSITION_X — x position in hex
    • ABS_MT_POSITION_Y — y position in hex