Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --tcpip option to automate TCP/IP (wireless) connections #2827

Merged
merged 13 commits into from
Nov 29, 2021
Merged

Add --tcpip option to automate TCP/IP (wireless) connections #2827

merged 13 commits into from
Nov 29, 2021

Commits on Nov 29, 2021

  1. Expose flags for process execution

    Let the caller decide if stdout and stderr must be inherited on process
    creation, i.e. if stdout and stderr of the child process should be
    printed in the scrcpy console.
    
    This allows to get output and errors for specific adb commands depending
    on the context.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    f801d8b View commit details
    Browse the repository at this point in the history
  2. Use flags for adb commands

    Explicitly indicate, for each adb call, if stdout and stderr must be
    inherited.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    e3d4aa8 View commit details
    Browse the repository at this point in the history
  3. Add adb flag to disable execution error logs

    In addition to disable stdout and stderr of the child process, add a
    flag to disable the error log printed by scrcpy if the command failed.
    
    This will we useful for commands which are expected to fail in some
    cases (like "adb disconnect" if the device is not connected).
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    e6e6f86 View commit details
    Browse the repository at this point in the history
  4. Add adb connect and disconnect

    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    bfce224 View commit details
    Browse the repository at this point in the history
  5. Workaround "adb connect" error detection

    "adb connect" always returns successfully (with exit code 0), even in
    case of failure.
    
    As a workaround, capture its output and check if it starts with
    "connected".
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    3bf6fd2 View commit details
    Browse the repository at this point in the history
  6. Add util function to locate a column in a string

    This will help to parse the result of "adb shell ip route" to find the
    device IP address.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    b52f87a View commit details
    Browse the repository at this point in the history
  7. Add util function to remove trailing '\r'

    Depending on the platform and adb versions, the lines output by adb
    could end with "\r\r\n". This util function helps to remove all trailing
    '\r'.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    b7e6317 View commit details
    Browse the repository at this point in the history
  8. Add function to find the device IP address

    Parse the result of "adb shell ip route" to find the device IP address.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    f609b40 View commit details
    Browse the repository at this point in the history
  9. Add function to switch device to TCP/IP mode

    Expose a function to execute "adb tcpip <port>".
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    8543d84 View commit details
    Browse the repository at this point in the history
  10. Add function to read an adb property

    This will allow to read the property "service.adb.tcp.port" to know if
    the TCP/IP mode is enabled on the device, and which listening port is
    used.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    800ba33 View commit details
    Browse the repository at this point in the history
  11. Extract interruptible sleep for server

    This improves readability, and makes the function reusable.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    3b310f8 View commit details
    Browse the repository at this point in the history
  12. Add --tcpip feature

    Expose an option to automatically configure and reconnect the device
    over TCP/IP, to simplify wireless connection without using adb
    explicitly.
    
    There are two variants:
     - If a destination address is provided, then scrcpy connects to this
       address before starting. The device must listen on the given TCP port
       (default is 5555).
     - If no destination address is provided, then scrcpy attempts to find
       the IP address of the current device (typically connected over USB),
       enables TCP/IP mode, then connects to this address before starting.
    
    PR #2827 <#2827>
    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    19858e6 View commit details
    Browse the repository at this point in the history
  13. Document --tcpip in README

    rom1v committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    1a6caeb View commit details
    Browse the repository at this point in the history