Commit Graph

28 Commits (d50ecf40b603f8a0e5a73699babce7301c0bd870)

Author SHA1 Message Date
yangfl d3281f4b67 Show a friendly hint for adb installation
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Yu-Chen Lin 78a320a763 Fix utf-8 char path in windows
The file 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server'
exists, however, it will show msg as follow:

    INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
    stat: No such file or directory
    ERROR: 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server' does
    not exist or is not a regular file
    Press any key to continue...

This patch fixes it.

Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont 64bcac9157 Refuse to push a non-regular file server
If SCRCPY_SERVER_PATH points to a directory, then a directory will be
pushed to /data/local/tmp/scrcpy-server.jar.

When executing it, app_process will just abort and leave the directory
on the device, causing scrcpy to always fail.

To avoid the problem, check that the server is a regular file before
pushing it.

Closes #956 <https://github.com/Genymobile/scrcpy/issues/956>
5 years ago
Romain Vimont 73e8ec1b35 Remove path argument from cmd_execute()
It is always equal to argv[0] (or not used on Windows).
5 years ago
Romain Vimont dfd0707a29 Move utilities to util/ 5 years ago
Romain Vimont 1f8ba1ca79 Include config.h everywhere
Ref: <https://github.com/Genymobile/scrcpy/issues/829>

Suggested-by: Louis Kruger <louisk@gmail.com>
5 years ago
Romain Vimont 3ee9560ece Fix comment style
For consistency.
5 years ago
Romain Vimont 3bc1c51b91 Always use SDL_malloc() and SDL_free()
To avoid mixing SDL_malloc()/SDL_strdup() with free(), or malloc() with
SDL_free(), always use the SDL version.
5 years ago
Romain Vimont e443518ed9 Print adb command on error
When the execution of an adb command fails, print the command. This will
help to understand what went wrong.

See <https://github.com/Genymobile/scrcpy/issues/530>.
5 years ago
Romain Vimont eeb8e8420f Use size_t for command length
The size of an array should have type size_t.
5 years ago
Romain Vimont dfed1b250e Replace SDL types by C99 standard types
Scrcpy is a C11 project. Use the C99 standard types instead of the
SDL-specific types:

    SDL_bool -> bool
    SintXX   -> intXX_t
    UintXX   -> uintXX_t
5 years ago
Romain Vimont aeda583a2c Update code style
Limit source code to 80 chars, and declare functions return type and
modifiers on a separate line.

This allows to avoid very long lines, and all function names are
aligned.

(We do this on VLC, and I like it.)
5 years ago
Romain Vimont 39c5e71605 Make the server unlink itself
To clean up the device, the client executed "adb shell rm" once the
server was guaranteed to be started (after the connection succeeded).

This implied to track whether the installation state, and failed if an
additional tunnel was used in "forward" mode:
<https://github.com/Genymobile/scrcpy/issues/386#issuecomment-453936034>

Instead, make the server unlink itself on start.
5 years ago
Romain Vimont 8875955921 Support paths containing spaces on Windows
Quote the arguments of "adb push" to support paths which contain spaces
on Windows.

Fixes <https://github.com/Genymobile/scrcpy/issues/288>.
6 years ago
Romain Vimont ff4430b2a3 Declare fun(void) functions with no parameters
This is not C++.
6 years ago
Romain Vimont 55d33ddd5f Do not handle system-specific values in command.c
The common command.c handled process errors from system-specific int
values (errno).

Rather, expose a new enum process_result to handle error cause in a
generic way.
6 years ago
yuchenlin 6d2d803003 Notify adb missing
There are many user who encounters missing adb.
To stop things happens again, we check it and show
sexy response to user.

Signed-off-by: yuchenlin <npes87184@gmail.com>
6 years ago
Romain Vimont 9c6f9b24f9 Quote apk path on Windows
Windows will parse the string, so the local name must be quoted.
6 years ago
Adonis Najimi e2a2973990 Drag and drop to install apk files from computer
<https://github.com/Genymobile/scrcpy/pull/133>
6 years ago
Romain Vimont 66ec252893 Add an option to enable "show touches"
Add -t/--show-touches option to show physical touches while scrcpy is
running.

See <https://github.com/Genymobile/scrcpy/issues/96>.
6 years ago
Romain Vimont 1038bad385 Make it work over tcpip
"adb reverse" currently does not work over tcpip (i.e. on a device
connected by "adb connect"):
<https://issuetracker.google.com/issues/37066218>

To work around the problem, if the call to "adb reverse" fails, then
fallback to "adb forward", and reverse the client/server roles.

Keep the "adb reverse" mode as the default because it does not involve
connection retries: when using "adb forward", the client must try to
connect successively until the server listens.

Due to the tunnel, every connect() will succeed, so the client must
attempt to read() to detect a connection failure. For this purpose, when
using the "adb forward" mode, the server initially writes a dummy byte,
read by the client.

Fixes <https://github.com/Genymobile/scrcpy/issues/5>.
6 years ago
Romain Vimont 221a7d0826 Clean up the server from temporary folder
The server is copied to /data/local/tmp/scrcpy-server.jar and executed
on the device.

As soon as we are connected, we can unlink (rm) it from /data/local/tmp,
to keep the device clean.
6 years ago
Romain Vimont 08d32e3bae Clean up useless const-casts
The function adb_execute() now expects a "const char *const *" parameter
for the adb command, so there is no need to cast.
6 years ago
Romain Vimont 3ed80a1fac Define macros wrappers for logs
Use macros to wrap SDL_Log* functions with the "application" category.
6 years ago
Romain Vimont 6fe65d9f5c Log with category APPLICATION
All our logs should use APPLICATION category. The logs for other
categories are not printed by default under the "critical" level.
6 years ago
Romain Vimont 28c5cc030b Move server-related code to server.c
The file server.c already existed, but exposed a low-level API. Make it
higher-level, so that scrcpy.c does not handle server details directly.
6 years ago
Romain Vimont 628f88ab89 Use ADB environment variable
Use the ADB environment variable to provide a custom adb path.
6 years ago
Romain Vimont 54d9148a36 Initial commit
Start a new clean history from here.
7 years ago