2788 Commits

Author SHA1 Message Date
Romain Vimont
139b3e688a autodraw 2025-01-07 22:01:12 +01:00
Simon Chan
c27d116a66 Fix AudioRecord package name for Android 16
Since commit 9f91a5eebb4520b9333576e946b3911d0f946a04 in frameworks/av
(AOSP), an AudioRecord can be created only if the declared package name
in the AttributionSource is "shell" (for the shell UID):
 - <7c4e6991ac/services/audiopolicy/permission/NativePermissionController.cpp (129)>
 - <7c4e6991ac/services/audiopolicy/permission/NativePermissionController.cpp (40)>

Refs <9f91a5eebb%5E%21/>
Fixes #5698 <https://github.com/Genymobile/scrcpy/issues/5698>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-23 19:41:25 +01:00
Romain Vimont
eac711ace6 Remove unused rotation and fold listeners
IRotationWatcher and IDisplayFoldListener are no longer used since
commit 39d51ff2cc2f3e201ad433d48372b548e5dd11d3.
2024-12-23 12:51:27 +01:00
Romain Vimont
af15c72f9c Cleanup includes
Improved manually with the help of neovim LSP warnings and iwyu:

    iwyu -Ibuilddir/app/ -Iapp/src/ app/src/XXX.c
2024-12-23 12:19:47 +01:00
Simon Chan
5b1229a55f Support older macOS versions in CI build
Fixes #5649 <https://github.com/Genymobile/scrcpy/issues/5649>
Fixes #5697<https://github.com/Genymobile/scrcpy/pull/5697>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-23 11:58:06 +01:00
Romain Vimont
69858c6f43 Build static linux binary on Ubuntu 20.04
Use the oldest Ubuntu version currently available in GitHub Actions to
ensure maximum compatibility with older systems.

Refs 95c4f03c1bfd566b383780977b3473ebad6477ee
Refs #5689 <https://github.com/Genymobile/scrcpy/issues/5689>
2024-12-23 11:01:42 +01:00
Romain Vimont
e0423653c8 Remove useless null check
The method CameraManager.getCameraIdList() is annotated with @NonNull.

This fixes a warning reported by Android Studio.
2024-12-23 10:58:59 +01:00
Romain Vimont
5387644160 Ignore low-FPS ranges if not available
Do not report an error if the returned FPS ranges array is null.

Refs #5669 <https://github.com/Genymobile/scrcpy/pull/5669>
2024-12-22 21:17:51 +01:00
Simon Chan
2f44da76f4 Filter out non-backward-compatible cameras
PR #5669 <https://github.com/Genymobile/scrcpy/pull/5669>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-22 21:17:05 +01:00
Romain Vimont
95c4f03c1b Build static linux binary on Ubuntu 22.04
On Github Actions, ubuntu-latest now points to ubuntu-24.04, which uses
a newer version of glibc (2.39). As a result, the binaries fail to work
on systems with older versions of glibc, such as Debian Bookworm.

To ensure better compatibility, continue building the static Linux
binary on Ubuntu 22.04 (with glibc 2.35).

Fixes #5689 <https://github.com/Genymobile/scrcpy/issues/5689>
2024-12-22 15:49:46 +01:00
Romain Vimont
fb47b87eeb Fix pipe read return value
The function incorrectly returned false, whereas its return type is
ssize_t.
2024-12-20 20:57:20 +01:00
Romain Vimont
dc2fcc46f5 Add workaround for Pico 4 Ultra
Make ActivityThread.isSystem() return true to avoid a
NullPointerException later.

Refs #5659 comment <https://github.com/Genymobile/scrcpy/issues/5659#issuecomment-2540963953>
Fixes #5659 <https://github.com/Genymobile/scrcpy/issues/5659>
2024-12-14 10:27:38 +01:00
Romain Vimont
69264703b1 Add missing comments in workarounds
The implementation of workarounds uses a lot of reflection code. For
better readability, always write the equivalent using direct Java code.
2024-12-14 10:27:38 +01:00
Colin Kinloch
ec4e826976 Set icon and server env paths for meson devenv
This allows users to compile and run the project in a dev environment.

    meson setup x
    meson compile -C x
    meson devenv -C x
    scrcpy

This is an alternative to `./run x`.

PR #5658 <https://github.com/Genymobile/scrcpy/pull/5658>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-12 18:15:26 +01:00
Romain Vimont
17e205e54f Replace meson join_paths() by '/'
A new '/' operator was introduced in Meson 0.49 to replace join_paths():
 - <https://mesonbuild.com/Reference-manual_functions.html#join_paths>
 - <https://mesonbuild.com/Syntax.html#string-path-building>

Refs #5658 <https://github.com/Genymobile/scrcpy/pull/5658>
2024-12-12 18:15:26 +01:00
Romain Vimont
f751274b17 Define both pkg-config and pkgconfig for meson
In Meson cross-files, "pkgconfig" was deprecated in favor of
"pkg-config" in meson 1.3.0.

The new name is used since 85a94dd4b563e961304b2d9082932c5c1cc2e582 to
avoid a warning, but then it fails with older versions of meson.

To avoid the problem, define both pkg-config and pkgconfig.

> For backward compatibility it is still allowed to define both with the
> same value, in that case no deprecation warning is printed.

<https://mesonbuild.com/Release-notes-for-1-3-0.html#machine-files-pkgconfig-field-deprecated-and-replaced-by-pkgconfig>
2024-12-12 18:09:31 +01:00
Romain Vimont
6469054b15 Revert "Remove apt update on GitHub Actions"
This reverts commit 678025b31672c230575fe2dbc4a0d487d5010bb1.

This avoids spurious errors on the CI:

    E: Unable to fetch some archives, maybe run apt-get update or try
    with --fix-missing?
2024-12-12 18:09:31 +01:00
Romain Vimont
0e2d084751 Update links to 3.1 v3.1 2024-12-09 22:42:34 +01:00
Romain Vimont
754f4fc6fe Bump version to 3.1 2024-12-09 22:29:51 +01:00
Romain Vimont
aca6d30af5 Include dav1d in releases
Scrcpy supports AV1, but no decoder was provided in binary releases.

Include dav1d:
 - <https://www.videolan.org/projects/dav1d.html>
 - <https://code.videolan.org/videolan/dav1d>

Fixes #4744 <https://github.com/Genymobile/scrcpy/issues/4744>
PR #5644 <https://github.com/Genymobile/scrcpy/pull/5644>
2024-12-09 19:07:18 +01:00
Romain Vimont
f2018e026c Remove broken macOS flags
Due to a typo (a space was missing before the second '-L'), the
resulting LDFLAGS value was broken:

    "-L/opt/homebrew/opt/zlib/lib-L/opt/homebrew/opt/libiconv/lib"

This proves that the flag was useless. Remove it.

Refs #5517 comment <https://github.com/Genymobile/scrcpy/pull/5517#issuecomment-2495522201>
PR #5644 <https://github.com/Genymobile/scrcpy/pull/5644>
2024-12-09 19:07:03 +01:00
Simon Chan
a507b4f559 Fix DisplayControl classpath
Use the full system server classpath to load DisplayControl, so that
turning the screen off on Android 14+ does not crash on certain devices.

Refs #4544 comment <https://github.com/Genymobile/scrcpy/issues/4544#issuecomment-2526999714>
Fixes #4544 <https://github.com/Genymobile/scrcpy/issues/4544>
Fixes #5274 <https://github.com/Genymobile/scrcpy/issues/5274>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-09 10:29:20 +01:00
Romain Vimont
a9aadc95df Start cleanup process with setsid()
Reimplement c59a3c3169973abb4ce236e06990d58ae6567481 using Os.setsid().

Refs #5613 comment <https://github.com/Genymobile/scrcpy/pull/5613#issuecomment-2527045669>

Suggested-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
2024-12-09 09:33:08 +01:00
Romain Vimont
28b5bfb90e Revert "Start cleanup process with setsid or nohup"
This reverts commit c59a3c3169973abb4ce236e06990d58ae6567481.

The next commit will use Os.setsid() instead.
2024-12-09 09:29:29 +01:00
Romain Vimont
65256d7cc7 Upgrade SDL (2.30.10) 2024-12-08 18:17:07 +01:00
Romain Vimont
328bb74f80 Log gamepad added/removed
Add a log when a gamepad is added or removed.

PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 18:16:57 +01:00
Withoutruless
7418fd0662 Use Xbox 360 gamepad name
Some games do not work without a known gamepad name.

Fixes #5362 <https://github.com/Genymobile/scrcpy/issues/5362>
Refs #5623 comment <https://github.com/Genymobile/scrcpy/pull/5623#issuecomment-2525685323>
PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2024-12-08 17:01:03 +01:00
Romain Vimont
0a09518a49 Use Xbox 360 gamepad USB ids
Use the vendorId and productId of an Xbox 360 controller for better
support (the HID gamepad protocol used in scrcpy is similar to that of
the Xbox 360 controller).

Fixes #5362 <https://github.com/Genymobile/scrcpy/issues/5362>
PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 11:00:18 +01:00
Romain Vimont
27a5934a1d Define UHID vendorId and productId from the client
Let the client choose the USB ids, that it transmits in UHID_CREATE
requests.

PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 11:00:18 +01:00
Romain Vimont
86a68fac6c Fix gamepad axis initial values
By default, initialize axis to 0, which is represented by 0x8000 as a
16-bit unsigned value.

PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 11:00:18 +01:00
Romain Vimont
1786f28e6f Fix gamepad HID descriptor
Use Z and Rz for L2/R2, which are more widely supported than
Brake/Accelerator.

The right stick must then be bound to Rx and Ry.

Fixes #5362 <https://github.com/Genymobile/scrcpy/issues/5362>
PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 11:00:18 +01:00
Romain Vimont
9cf4d52721 Fix HID gamepad comments
PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 11:00:18 +01:00
Romain Vimont
4bd1c5981d Split gamepad device added/removed events
Use two separate callbacks for gamepad device added and gamepad device
removed.

It looks cleaner.

PR #5623 <https://github.com/Genymobile/scrcpy/pull/5623>
2024-12-08 11:00:18 +01:00
Romain Vimont
c59a3c3169 Start cleanup process with setsid or nohup
If available, start the cleanup process in a new session to reduce the
likelihood of it being terminated along with the scrcpy server process
on some devices.

The binaries setsid and nohup are often available, but it is not
guaranteed.

Refs #5601 <https://github.com/Genymobile/scrcpy/issues/5601>
PR #5613 <https://github.com/Genymobile/scrcpy/pull/5613>
2024-12-08 10:58:22 +01:00
Romain Vimont
2780e0bd7b Do not interrupt cleanup configuration
Some options, such as --show-touches or --stay-awake, modify Android
settings and must be restored upon exit.

If scrcpy terminates (e.g. due to an early error) in the middle of the
clean up configuration, the device may be left in an inconsistent state
(some settings might be changed but not restored).

This issue can be reproduced with high probability by forcing scrcpy to
fail:

    scrcpy --show-touches --video-encoder=fail

To prevent this problem, ensure that the clean up thread is not
interrupted until the clean up process is started.

Refs #5601 <https://github.com/Genymobile/scrcpy/issues/5601>
PR #5613 <https://github.com/Genymobile/scrcpy/pull/5613>
2024-12-08 10:58:07 +01:00
Romain Vimont
6c6607d404 Add --no-vd-destroy-content
Add an option to disable the following flag for virtual displays:

    DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL

With this option, when the virtual display is closed, the running apps
are moved to the main display rather than being destroyed.

PR #5615 <https://github.com/Genymobile/scrcpy/pull/5615>
2024-12-08 09:33:03 +01:00
Romain Vimont
988174805c Fix boolean assignment
On --no-vd-system-decoration, the boolean option must be set to false.

It was wrongly assigned from optarg (this worked because optarg is NULL
at this point, so it was converted to false).

PR #5615 <https://github.com/Genymobile/scrcpy/pull/5615>
2024-12-08 09:26:53 +01:00
Romain Vimont
f90dc216d1 Refactor virtual display properties initialization
Following the changes from the previous commit, the behavior is now
identical when mirroring the main display or using the SurfaceControl
API.

Factorize the code to perform the initialization in a single location.

Refs #5605 <https://github.com/Genymobile/scrcpy/issues/5605>
PR #5614 <https://github.com/Genymobile/scrcpy/pull/5614>
2024-12-07 20:09:14 +01:00
Romain Vimont
97fa77c76c Inject main display events to the original display
When mirroring a secondary display, touch and scroll events must be sent
to the mirroring virtual display id (with coordinates relative to the
virtual display size), rather than to the original display (with
coordinates relative to the original display size).

This behavior, introduced by d19396718ee0c0ba7fb578f595a6553c0458da59,
was also applied for the main display for consistency. However, it
causes some UI elements to become unclickable.

To minimize inconveniences, restore the previous behavior when mirroring
the main display: send all events to the original display id (0) with
coordinates relative to the original display size.

Fixes #5545 <https://github.com/Genymobile/scrcpy/issues/5545>
Fixes #5605 <https://github.com/Genymobile/scrcpy/issues/5605>
Fixes #5616 <https://github.com/Genymobile/scrcpy/issues/5616>
Refs #4598 <https://github.com/Genymobile/scrcpy/issues/4598>
Refs #5137 <https://github.com/Genymobile/scrcpy/issues/5137>
Refs #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
PR #5614 <https://github.com/Genymobile/scrcpy/pull/5614>
2024-12-07 20:08:49 +01:00
Romain Vimont
baa10ed0a3 Update links to 3.0.2 v3.0.2 2024-12-04 22:48:27 +01:00
Romain Vimont
2ed2247e8f Bump version to 3.0.2
The version was not bumped for 3.0.1.
2024-12-04 22:35:25 +01:00
Romain Vimont
5febb1e9fb Update links to 3.0.1 v3.0.1 2024-12-04 21:46:06 +01:00
Romain Vimont
5c3626ed47 Handle broken pipe errors specifically
Since 9555d3a537a828731ad89ef5258ba537acf8cc11, a capture/encoding error
was sometimes logged on exit.
2024-12-04 18:38:23 +01:00
Romain Vimont
0e473eb005 Reset TCP/IP connection with a '+' prefix
When running scrcpy with --tcpip=xx.xx.xx.xx, to make sure a new working
connection is established, it was first disconnected by a call to:

    adb disconnect <addr>

However, this caused all running instances connected to that address to
be killed. Running several instances of scrcpy on the same device is now
useful with virtual displays, so change the default behavior to NOT
disconnect.

To force a reconnection, a '+' prefix can be added:

    scrcpy --tcpip=+192.168.0.x

Fixes #5562 <https://github.com/Genymobile/scrcpy/issues/5562>
2024-12-04 13:16:51 +01:00
Romain Vimont
b26b4fb745 Document launchers in virtual displays
Mention how to start a launcher in a virtual display.

Refs #5592 <https://github.com/Genymobile/scrcpy/issues/5592>
2024-12-04 13:10:35 +01:00
Romain Vimont
9555d3a537 Retry capture on IOException
If the capture fails with an IOException, retry with a lower resolution.

Fixes #5539 <https://github.com/Genymobile/scrcpy/issues/5539>
2024-12-03 23:06:33 +01:00
Romain Vimont
aea6a371aa Remove scrcpy wrapper script for static builds
All portable builds now use the files located in the same directory as
the scrcpy executable by default.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
dc6c279b1e Log adb executable path
Log the ADB executable path (at the DEBUG level) if it is not the
default one.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
6d0ac3626d Use local adb in portable builds
For non-Windows portable builds, use the absolute path to the adb
executable located in the same directory as scrcpy.

On Windows, just use "adb", which is sufficient to use the local one.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00
Romain Vimont
beee42fb06 Load ADB value using sc_get_env()
Contrary to getenv(), the result of sc_get_env() is encoded in UTF-8 on
all platforms. Since it is allocated, it requires an explicit init() and
destroy() functions.

PR #5560 <https://github.com/Genymobile/scrcpy/pull/5560>
2024-12-02 18:23:18 +01:00