Compare commits
31 Commits
orientatio
...
display_ma
Author | SHA1 | Date | |
---|---|---|---|
fdc58722b3 | |||
5a6b8310ca | |||
c6ff78f414 | |||
40f2560d98 | |||
26aa28c998 | |||
ef79fcbbd2 | |||
9497f39fb4 | |||
bf056b1fee | |||
bd9292931e | |||
140a49b8be | |||
4135c411af | |||
5e061636f6 | |||
5f3fb843f5 | |||
ce8126f322 | |||
d037b02cc2 | |||
89761213c3 | |||
8db4e78b34 | |||
5d4b8a7e6d | |||
eed06b141a | |||
825d7f72c0 | |||
2370298b61 | |||
67f356f881 | |||
c573bd2a33 | |||
acb2988837 | |||
85a94dd4b5 | |||
94031dfe97 | |||
b43a9e8e7a | |||
a9d6cb5837 | |||
2f92686930 | |||
bb88b60227 | |||
25e33566f5 |
@ -1,4 +1,8 @@
|
|||||||
# scrcpy (v2.2)
|
**This GitHub repo (<https://github.com/Genymobile/scrcpy>) is the only official
|
||||||
|
source for the project. Do not download releases from random websites, even if
|
||||||
|
their name contains `scrcpy`.**
|
||||||
|
|
||||||
|
# scrcpy (v2.3.1)
|
||||||
|
|
||||||
<img src="app/data/icon.svg" width="128" height="128" alt="scrcpy" align="right" />
|
<img src="app/data/icon.svg" width="128" height="128" alt="scrcpy" align="right" />
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ Comment=Display and control your Android device
|
|||||||
# For some users, the PATH or ADB environment variables are set from the shell
|
# For some users, the PATH or ADB environment variables are set from the shell
|
||||||
# startup file, like .bashrc or .zshrc… Run an interactive shell to get
|
# startup file, like .bashrc or .zshrc… Run an interactive shell to get
|
||||||
# environment correctly initialized.
|
# environment correctly initialized.
|
||||||
Exec=/bin/sh -c "\"\\$SHELL\" -i -c scrcpy --pause-on-exit=if-error"
|
Exec=/bin/sh -c "\\$SHELL -i -c 'scrcpy --pause-on-exit=if-error'"
|
||||||
Icon=scrcpy
|
Icon=scrcpy
|
||||||
Terminal=true
|
Terminal=true
|
||||||
Type=Application
|
Type=Application
|
||||||
|
@ -5,7 +5,7 @@ Comment=Display and control your Android device
|
|||||||
# For some users, the PATH or ADB environment variables are set from the shell
|
# For some users, the PATH or ADB environment variables are set from the shell
|
||||||
# startup file, like .bashrc or .zshrc… Run an interactive shell to get
|
# startup file, like .bashrc or .zshrc… Run an interactive shell to get
|
||||||
# environment correctly initialized.
|
# environment correctly initialized.
|
||||||
Exec=/bin/sh -c "\"\\$SHELL\" -i -c scrcpy"
|
Exec=/bin/sh -c "\\$SHELL -i -c scrcpy"
|
||||||
Icon=scrcpy
|
Icon=scrcpy
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
|
@ -98,77 +98,24 @@ endif
|
|||||||
|
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
crossbuild_windows = meson.is_cross_build() and host_machine.system() == 'windows'
|
dependencies = [
|
||||||
|
dependency('libavformat', version: '>= 57.33'),
|
||||||
|
dependency('libavcodec', version: '>= 57.37'),
|
||||||
|
dependency('libavutil'),
|
||||||
|
dependency('libswresample'),
|
||||||
|
dependency('sdl2', version: '>= 2.0.5'),
|
||||||
|
]
|
||||||
|
|
||||||
if not crossbuild_windows
|
if v4l2_support
|
||||||
|
dependencies += dependency('libavdevice')
|
||||||
# native build
|
endif
|
||||||
dependencies = [
|
|
||||||
dependency('libavformat', version: '>= 57.33'),
|
|
||||||
dependency('libavcodec', version: '>= 57.37'),
|
|
||||||
dependency('libavutil'),
|
|
||||||
dependency('libswresample'),
|
|
||||||
dependency('sdl2', version: '>= 2.0.5'),
|
|
||||||
]
|
|
||||||
|
|
||||||
if v4l2_support
|
|
||||||
dependencies += dependency('libavdevice')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if usb_support
|
|
||||||
dependencies += dependency('libusb-1.0')
|
|
||||||
endif
|
|
||||||
|
|
||||||
else
|
|
||||||
# cross-compile mingw32 build (from Linux to Windows)
|
|
||||||
prebuilt_sdl2 = meson.get_cross_property('prebuilt_sdl2')
|
|
||||||
sdl2_bin_dir = meson.current_source_dir() + '/prebuilt-deps/data/' + prebuilt_sdl2 + '/bin'
|
|
||||||
sdl2_lib_dir = meson.current_source_dir() + '/prebuilt-deps/data/' + prebuilt_sdl2 + '/lib'
|
|
||||||
sdl2_include_dir = 'prebuilt-deps/data/' + prebuilt_sdl2 + '/include'
|
|
||||||
|
|
||||||
sdl2 = declare_dependency(
|
|
||||||
dependencies: [
|
|
||||||
cc.find_library('SDL2', dirs: sdl2_bin_dir),
|
|
||||||
cc.find_library('SDL2main', dirs: sdl2_lib_dir),
|
|
||||||
],
|
|
||||||
include_directories: include_directories(sdl2_include_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
prebuilt_ffmpeg = meson.get_cross_property('prebuilt_ffmpeg')
|
|
||||||
ffmpeg_bin_dir = meson.current_source_dir() + '/prebuilt-deps/data/' + prebuilt_ffmpeg + '/bin'
|
|
||||||
ffmpeg_include_dir = 'prebuilt-deps/data/' + prebuilt_ffmpeg + '/include'
|
|
||||||
|
|
||||||
ffmpeg = declare_dependency(
|
|
||||||
dependencies: [
|
|
||||||
cc.find_library('avcodec-60', dirs: ffmpeg_bin_dir),
|
|
||||||
cc.find_library('avformat-60', dirs: ffmpeg_bin_dir),
|
|
||||||
cc.find_library('avutil-58', dirs: ffmpeg_bin_dir),
|
|
||||||
cc.find_library('swresample-4', dirs: ffmpeg_bin_dir),
|
|
||||||
],
|
|
||||||
include_directories: include_directories(ffmpeg_include_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
prebuilt_libusb = meson.get_cross_property('prebuilt_libusb')
|
|
||||||
libusb_bin_dir = meson.current_source_dir() + '/prebuilt-deps/data/' + prebuilt_libusb + '/bin'
|
|
||||||
libusb_include_dir = 'prebuilt-deps/data/' + prebuilt_libusb + '/include'
|
|
||||||
|
|
||||||
libusb = declare_dependency(
|
|
||||||
dependencies: [
|
|
||||||
cc.find_library('msys-usb-1.0', dirs: libusb_bin_dir),
|
|
||||||
],
|
|
||||||
include_directories: include_directories(libusb_include_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
ffmpeg,
|
|
||||||
sdl2,
|
|
||||||
libusb,
|
|
||||||
cc.find_library('mingw32')
|
|
||||||
]
|
|
||||||
|
|
||||||
|
if usb_support
|
||||||
|
dependencies += dependency('libusb-1.0')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
|
dependencies += cc.find_library('mingw32')
|
||||||
dependencies += cc.find_library('ws2_32')
|
dependencies += cc.find_library('ws2_32')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
VERSION=6.1-scrcpy-2
|
VERSION=6.1-scrcpy-3
|
||||||
DEP_DIR="ffmpeg-$VERSION"
|
DEP_DIR="ffmpeg-$VERSION"
|
||||||
|
|
||||||
FILENAME="$DEP_DIR".7z
|
FILENAME="$DEP_DIR".7z
|
||||||
SHA256SUM=7f25f638dc24a0f5d4af07a088b6a604cf33548900bbfd2f6ce0bae050b7664d
|
SHA256SUM=b646d18a3d543a4e4c46881568213499f22e4454a464e1552f03f2ac9cc3a05a
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
then
|
then
|
||||||
|
@ -6,9 +6,10 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
DEP_DIR=libusb-1.0.26
|
VERSION=1.0.26
|
||||||
|
DEP_DIR="libusb-$VERSION"
|
||||||
|
|
||||||
FILENAME=libusb-1.0.26-binaries.7z
|
FILENAME="libusb-$VERSION-binaries.7z"
|
||||||
SHA256SUM=9c242696342dbde9cdc47239391f71833939bf9f7aa2bbb28cdaabe890465ec5
|
SHA256SUM=9c242696342dbde9cdc47239391f71833939bf9f7aa2bbb28cdaabe890465ec5
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
@ -17,17 +18,22 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_file "https://github.com/libusb/libusb/releases/download/v1.0.26/$FILENAME" "$FILENAME" "$SHA256SUM"
|
get_file "https://github.com/libusb/libusb/releases/download/v$VERSION/$FILENAME" \
|
||||||
|
"$FILENAME" "$SHA256SUM"
|
||||||
|
|
||||||
mkdir "$DEP_DIR"
|
mkdir "$DEP_DIR"
|
||||||
cd "$DEP_DIR"
|
cd "$DEP_DIR"
|
||||||
|
|
||||||
7z x "../$FILENAME" \
|
7z x "../$FILENAME" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-Win32/bin/msys-usb-1.0.dll \
|
"libusb-$VERSION-binaries/libusb-MinGW-Win32/" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-Win32/include/ \
|
"libusb-$VERSION-binaries/libusb-MinGW-Win32/" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-x64/bin/msys-usb-1.0.dll \
|
"libusb-$VERSION-binaries/libusb-MinGW-x64/" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-x64/include/
|
"libusb-$VERSION-binaries/libusb-MinGW-x64/"
|
||||||
|
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-Win32 .
|
mv "libusb-$VERSION-binaries/libusb-MinGW-Win32" .
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-x64 .
|
mv "libusb-$VERSION-binaries/libusb-MinGW-x64" .
|
||||||
rm -rf libusb-1.0.26-binaries
|
rm -rf "libusb-$VERSION-binaries"
|
||||||
|
|
||||||
|
# Rename the dll to get the same library name on all platforms
|
||||||
|
mv libusb-MinGW-Win32/bin/msys-usb-1.0.dll libusb-MinGW-Win32/bin/libusb-1.0.dll
|
||||||
|
mv libusb-MinGW-x64/bin/msys-usb-1.0.dll libusb-MinGW-x64/bin/libusb-1.0.dll
|
||||||
|
@ -6,10 +6,11 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
DEP_DIR=SDL2-2.28.4
|
VERSION=2.28.5
|
||||||
|
DEP_DIR="SDL2-$VERSION"
|
||||||
|
|
||||||
FILENAME=SDL2-devel-2.28.4-mingw.tar.gz
|
FILENAME="SDL2-devel-$VERSION-mingw.tar.gz"
|
||||||
SHA256SUM=779d091072cf97291f80030f5232d97aa3d48ab0f2c14fe0b9d9a33c593cdc35
|
SHA256SUM=3c0c655c2ebf67cad48fead72761d1601740ded30808952c3274ba223d226c21
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
then
|
then
|
||||||
@ -17,7 +18,8 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_file "https://libsdl.org/release/$FILENAME" "$FILENAME" "$SHA256SUM"
|
get_file "https://github.com/libsdl-org/SDL/releases/download/release-$VERSION/$FILENAME" \
|
||||||
|
"$FILENAME" "$SHA256SUM"
|
||||||
|
|
||||||
mkdir "$DEP_DIR"
|
mkdir "$DEP_DIR"
|
||||||
cd "$DEP_DIR"
|
cd "$DEP_DIR"
|
||||||
|
@ -13,7 +13,7 @@ BEGIN
|
|||||||
VALUE "LegalCopyright", "Romain Vimont, Genymobile"
|
VALUE "LegalCopyright", "Romain Vimont, Genymobile"
|
||||||
VALUE "OriginalFilename", "scrcpy.exe"
|
VALUE "OriginalFilename", "scrcpy.exe"
|
||||||
VALUE "ProductName", "scrcpy"
|
VALUE "ProductName", "scrcpy"
|
||||||
VALUE "ProductVersion", "v2.2"
|
VALUE "ProductVersion", "2.3.1"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
@ -2138,7 +2138,7 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
opts->display_orientation = SC_ORIENTATION_180;
|
opts->display_orientation = SC_ORIENTATION_180;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// rotation 1 was 270° counterclockwise, but orientation
|
// rotation 3 was 270° counterclockwise, but orientation
|
||||||
// is expressed clockwise
|
// is expressed clockwise
|
||||||
opts->display_orientation = SC_ORIENTATION_90;
|
opts->display_orientation = SC_ORIENTATION_90;
|
||||||
break;
|
break;
|
||||||
@ -2154,7 +2154,7 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPT_ORIENTATION:
|
case OPT_ORIENTATION: {
|
||||||
enum sc_orientation orientation;
|
enum sc_orientation orientation;
|
||||||
if (!parse_orientation(optarg, &orientation)) {
|
if (!parse_orientation(optarg, &orientation)) {
|
||||||
return false;
|
return false;
|
||||||
@ -2162,6 +2162,7 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
opts->display_orientation = orientation;
|
opts->display_orientation = orientation;
|
||||||
opts->record_orientation = orientation;
|
opts->record_orientation = orientation;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case OPT_RENDER_DRIVER:
|
case OPT_RENDER_DRIVER:
|
||||||
opts->render_driver = optarg;
|
opts->render_driver = optarg;
|
||||||
break;
|
break;
|
||||||
@ -2531,7 +2532,8 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
if (opts->record_orientation != SC_ORIENTATION_0) {
|
if (opts->record_orientation != SC_ORIENTATION_0) {
|
||||||
if (sc_orientation_is_mirror(opts->record_orientation)) {
|
if (sc_orientation_is_mirror(opts->record_orientation)) {
|
||||||
LOGE("Record orientation only supports rotation, not "
|
LOGE("Record orientation only supports rotation, not "
|
||||||
"flipping: %s", optarg);
|
"flipping: %s",
|
||||||
|
sc_orientation_get_name(opts->record_orientation));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,8 +227,9 @@ run_demuxer(void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Config packets must be merged with the next non-config packet only for
|
// Config packets must be merged with the next non-config packet only for
|
||||||
// video streams
|
// H.26x
|
||||||
bool must_merge_config_packet = codec->type == AVMEDIA_TYPE_VIDEO;
|
bool must_merge_config_packet = raw_codec_id == SC_CODEC_ID_H264
|
||||||
|
|| raw_codec_id == SC_CODEC_ID_H265;
|
||||||
|
|
||||||
struct sc_packet_merger merger;
|
struct sc_packet_merger merger;
|
||||||
|
|
||||||
|
@ -113,10 +113,10 @@ sc_orientation_apply(enum sc_orientation src, enum sc_orientation transform) {
|
|||||||
// In the final result, we want all the hflips then all the rotations,
|
// In the final result, we want all the hflips then all the rotations,
|
||||||
// so we must move hflip2 to the left:
|
// so we must move hflip2 to the left:
|
||||||
//
|
//
|
||||||
// hflip1 × hflip2 × f(rotate1) × rotate2
|
// hflip1 × hflip2 × rotate1' × rotate2
|
||||||
//
|
//
|
||||||
// with f(rotate1) = | rotate1 if src is 0 or 180
|
// with rotate1' = | rotate1 if src is 0° or 180°
|
||||||
// | rotate1 + 180 if src is 90 or 270
|
// | rotate1 + 180° if src is 90° or 270°
|
||||||
|
|
||||||
src_rotation += 2;
|
src_rotation += 2;
|
||||||
}
|
}
|
||||||
|
@ -419,12 +419,21 @@ scrcpy(struct scrcpy_options *options) {
|
|||||||
sdl_set_hints(options->render_driver);
|
sdl_set_hints(options->render_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the video subsystem even if --no-video or --no-video-playback
|
if (options->video_playback ||
|
||||||
// is passed so that clipboard synchronization still works.
|
(options->control && options->clipboard_autosync)) {
|
||||||
// <https://github.com/Genymobile/scrcpy/issues/4418>
|
// Initialize the video subsystem even if --no-video or
|
||||||
if (SDL_Init(SDL_INIT_VIDEO)) {
|
// --no-video-playback is passed so that clipboard synchronization
|
||||||
LOGE("Could not initialize SDL video: %s", SDL_GetError());
|
// still works.
|
||||||
goto end;
|
// <https://github.com/Genymobile/scrcpy/issues/4418>
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO)) {
|
||||||
|
// If it fails, it is an error only if video playback is enabled
|
||||||
|
if (options->video_playback) {
|
||||||
|
LOGE("Could not initialize SDL video: %s", SDL_GetError());
|
||||||
|
goto end;
|
||||||
|
} else {
|
||||||
|
LOGW("Could not initialize SDL video: %s", SDL_GetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->audio_playback) {
|
if (options->audio_playback) {
|
||||||
|
@ -6,7 +6,7 @@ c = 'i686-w64-mingw32-gcc'
|
|||||||
cpp = 'i686-w64-mingw32-g++'
|
cpp = 'i686-w64-mingw32-g++'
|
||||||
ar = 'i686-w64-mingw32-ar'
|
ar = 'i686-w64-mingw32-ar'
|
||||||
strip = 'i686-w64-mingw32-strip'
|
strip = 'i686-w64-mingw32-strip'
|
||||||
pkgconfig = 'i686-w64-mingw32-pkg-config'
|
pkg-config = 'i686-w64-mingw32-pkg-config'
|
||||||
windres = 'i686-w64-mingw32-windres'
|
windres = 'i686-w64-mingw32-windres'
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
@ -14,8 +14,3 @@ system = 'windows'
|
|||||||
cpu_family = 'x86'
|
cpu_family = 'x86'
|
||||||
cpu = 'i686'
|
cpu = 'i686'
|
||||||
endian = 'little'
|
endian = 'little'
|
||||||
|
|
||||||
[properties]
|
|
||||||
prebuilt_ffmpeg = 'ffmpeg-6.1-scrcpy-2/win32'
|
|
||||||
prebuilt_sdl2 = 'SDL2-2.28.4/i686-w64-mingw32'
|
|
||||||
prebuilt_libusb = 'libusb-1.0.26/libusb-MinGW-Win32'
|
|
||||||
|
@ -6,7 +6,7 @@ c = 'x86_64-w64-mingw32-gcc'
|
|||||||
cpp = 'x86_64-w64-mingw32-g++'
|
cpp = 'x86_64-w64-mingw32-g++'
|
||||||
ar = 'x86_64-w64-mingw32-ar'
|
ar = 'x86_64-w64-mingw32-ar'
|
||||||
strip = 'x86_64-w64-mingw32-strip'
|
strip = 'x86_64-w64-mingw32-strip'
|
||||||
pkgconfig = 'x86_64-w64-mingw32-pkg-config'
|
pkg-config = 'x86_64-w64-mingw32-pkg-config'
|
||||||
windres = 'x86_64-w64-mingw32-windres'
|
windres = 'x86_64-w64-mingw32-windres'
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
@ -14,8 +14,3 @@ system = 'windows'
|
|||||||
cpu_family = 'x86'
|
cpu_family = 'x86'
|
||||||
cpu = 'x86_64'
|
cpu = 'x86_64'
|
||||||
endian = 'little'
|
endian = 'little'
|
||||||
|
|
||||||
[properties]
|
|
||||||
prebuilt_ffmpeg = 'ffmpeg-6.1-scrcpy-2/win64'
|
|
||||||
prebuilt_sdl2 = 'SDL2-2.28.4/x86_64-w64-mingw32'
|
|
||||||
prebuilt_libusb = 'libusb-1.0.26/libusb-MinGW-x64'
|
|
||||||
|
@ -233,10 +233,10 @@ install` must be run as root)._
|
|||||||
|
|
||||||
#### Option 2: Use prebuilt server
|
#### Option 2: Use prebuilt server
|
||||||
|
|
||||||
- [`scrcpy-server-v2.2`][direct-scrcpy-server]
|
- [`scrcpy-server-v2.3.1`][direct-scrcpy-server]
|
||||||
<sub>SHA-256: `c85c4aa84305efb69115cd497a120ebdd10258993b4cf123a8245b3d99d49874`</sub>
|
<sub>SHA-256: `f6814822fc308a7a532f253485c9038183c6296a6c5df470a9e383b4f8e7605b`</sub>
|
||||||
|
|
||||||
[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-server-v2.2
|
[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v2.3.1/scrcpy-server-v2.3.1
|
||||||
|
|
||||||
Download the prebuilt server somewhere, and specify its path during the Meson
|
Download the prebuilt server somewhere, and specify its path during the Meson
|
||||||
configuration:
|
configuration:
|
||||||
|
@ -18,6 +18,17 @@ scrcpy --video-source=display --audio-source=mic # force display AND micropho
|
|||||||
scrcpy --video-source=camera --audio-source=output # force camera AND device audio output
|
scrcpy --video-source=camera --audio-source=output # force camera AND device audio output
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Audio can be disabled:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# audio not captured at all
|
||||||
|
scrcpy --video-source=camera --no-audio
|
||||||
|
scrcpy --video-source=camera --no-audio --record=file.mp4
|
||||||
|
|
||||||
|
# audio captured and recorded, but not played
|
||||||
|
scrcpy --video-source=camera --no-audio-playback --record=file.mp4
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## List
|
## List
|
||||||
|
|
||||||
|
@ -21,6 +21,13 @@ This will create a new video device in `/dev/videoN`, where `N` is an integer
|
|||||||
(more [options](https://github.com/umlaeute/v4l2loopback#options) are available
|
(more [options](https://github.com/umlaeute/v4l2loopback#options) are available
|
||||||
to create several devices or devices with specific IDs).
|
to create several devices or devices with specific IDs).
|
||||||
|
|
||||||
|
If you encounter problems detecting your device with Chrome/WebRTC, you can try
|
||||||
|
`exclusive_caps` mode:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo modprobe v4l2loopback exclusive_caps=1
|
||||||
|
```
|
||||||
|
|
||||||
To list the enabled devices:
|
To list the enabled devices:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -130,7 +130,7 @@ scrcpy --orientation=270 # 270° clockwise
|
|||||||
scrcpy --orientation=flip0 # hflip
|
scrcpy --orientation=flip0 # hflip
|
||||||
scrcpy --orientation=flip90 # hflip + 90° clockwise
|
scrcpy --orientation=flip90 # hflip + 90° clockwise
|
||||||
scrcpy --orientation=flip180 # vflip (hflip + 180°)
|
scrcpy --orientation=flip180 # vflip (hflip + 180°)
|
||||||
scrcpy --orientation=flip270 # hflip + 270°
|
scrcpy --orientation=flip270 # hflip + 270° clockwise
|
||||||
```
|
```
|
||||||
|
|
||||||
The orientation can be set separately for display and record if necessary, via
|
The orientation can be set separately for display and record if necessary, via
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
Download the [latest release]:
|
Download the [latest release]:
|
||||||
|
|
||||||
- [`scrcpy-win64-v2.2.zip`][direct-win64] (64-bit)
|
- [`scrcpy-win64-v2.3.1.zip`][direct-win64] (64-bit)
|
||||||
<sub>SHA-256: `9f9da88ac4c8319dcb9bf852f2d9bba942bac663413383419cddf64eaa5685bd`</sub>
|
<sub>SHA-256: `f1f78ac98214078425804e524a1bed515b9d4b8a05b78d210a4ced2b910b262d`</sub>
|
||||||
- [`scrcpy-win32-v2.2.zip`][direct-win32] (32-bit)
|
- [`scrcpy-win32-v2.3.1.zip`][direct-win32] (32-bit)
|
||||||
<sub>SHA-256: `cb84269fc847b8b880e320879492a1ae6c017b42175f03e199530f7a53be9d74`</sub>
|
<sub>SHA-256: `5dffc2d432e9b8b5b0e16f12e71428c37c70d9124cfbe7620df0b41b7efe91ff`</sub>
|
||||||
|
|
||||||
[latest release]: https://github.com/Genymobile/scrcpy/releases/latest
|
[latest release]: https://github.com/Genymobile/scrcpy/releases/latest
|
||||||
[direct-win64]: https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-win64-v2.2.zip
|
[direct-win64]: https://github.com/Genymobile/scrcpy/releases/download/v2.3.1/scrcpy-win64-v2.3.1.zip
|
||||||
[direct-win32]: https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-win32-v2.2.zip
|
[direct-win32]: https://github.com/Genymobile/scrcpy/releases/download/v2.3.1/scrcpy-win32-v2.3.1.zip
|
||||||
|
|
||||||
and extract it.
|
and extract it.
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILDDIR=build-auto
|
BUILDDIR=build-auto
|
||||||
PREBUILT_SERVER_URL=https://github.com/Genymobile/scrcpy/releases/download/v2.2/scrcpy-server-v2.2
|
PREBUILT_SERVER_URL=https://github.com/Genymobile/scrcpy/releases/download/v2.3.1/scrcpy-server-v2.3.1
|
||||||
PREBUILT_SERVER_SHA256=c85c4aa84305efb69115cd497a120ebdd10258993b4cf123a8245b3d99d49874
|
PREBUILT_SERVER_SHA256=f6814822fc308a7a532f253485c9038183c6296a6c5df470a9e383b4f8e7605b
|
||||||
|
|
||||||
echo "[scrcpy] Downloading prebuilt server..."
|
echo "[scrcpy] Downloading prebuilt server..."
|
||||||
wget "$PREBUILT_SERVER_URL" -O scrcpy-server
|
wget "$PREBUILT_SERVER_URL" -O scrcpy-server
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
project('scrcpy', 'c',
|
project('scrcpy', 'c',
|
||||||
version: 'v2.2',
|
version: '2.3.1',
|
||||||
meson_version: '>= 0.48',
|
meson_version: '>= 0.48',
|
||||||
default_options: [
|
default_options: [
|
||||||
'c_std=c11',
|
'c_std=c11',
|
||||||
|
68
release.mk
68
release.mk
@ -69,58 +69,62 @@ prepare-deps:
|
|||||||
@app/prebuilt-deps/prepare-libusb.sh
|
@app/prebuilt-deps/prepare-libusb.sh
|
||||||
|
|
||||||
build-win32: prepare-deps
|
build-win32: prepare-deps
|
||||||
[ -d "$(WIN32_BUILD_DIR)" ] || ( mkdir "$(WIN32_BUILD_DIR)" && \
|
rm -rf "$(WIN32_BUILD_DIR)"
|
||||||
meson setup "$(WIN32_BUILD_DIR)" \
|
mkdir -p "$(WIN32_BUILD_DIR)/local"
|
||||||
--cross-file cross_win32.txt \
|
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win32/. "$(WIN32_BUILD_DIR)/local/"
|
||||||
--buildtype release --strip -Db_lto=true \
|
cp -r app/prebuilt-deps/data/SDL2-2.28.5/i686-w64-mingw32/. "$(WIN32_BUILD_DIR)/local/"
|
||||||
-Dcompile_server=false \
|
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-Win32/. "$(WIN32_BUILD_DIR)/local/"
|
||||||
-Dportable=true )
|
meson setup "$(WIN32_BUILD_DIR)" \
|
||||||
|
--pkg-config-path="$(WIN32_BUILD_DIR)/local/lib/pkgconfig" \
|
||||||
|
-Dc_args="-I$(PWD)/$(WIN32_BUILD_DIR)/local/include" \
|
||||||
|
-Dc_link_args="-L$(PWD)/$(WIN32_BUILD_DIR)/local/lib" \
|
||||||
|
--cross-file=cross_win32.txt \
|
||||||
|
--buildtype=release --strip -Db_lto=true \
|
||||||
|
-Dcompile_server=false \
|
||||||
|
-Dportable=true
|
||||||
ninja -C "$(WIN32_BUILD_DIR)"
|
ninja -C "$(WIN32_BUILD_DIR)"
|
||||||
|
|
||||||
build-win64: prepare-deps
|
build-win64: prepare-deps
|
||||||
[ -d "$(WIN64_BUILD_DIR)" ] || ( mkdir "$(WIN64_BUILD_DIR)" && \
|
rm -rf "$(WIN64_BUILD_DIR)"
|
||||||
meson setup "$(WIN64_BUILD_DIR)" \
|
mkdir -p "$(WIN64_BUILD_DIR)/local"
|
||||||
--cross-file cross_win64.txt \
|
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win64/. "$(WIN64_BUILD_DIR)/local/"
|
||||||
--buildtype release --strip -Db_lto=true \
|
cp -r app/prebuilt-deps/data/SDL2-2.28.5/x86_64-w64-mingw32/. "$(WIN64_BUILD_DIR)/local/"
|
||||||
-Dcompile_server=false \
|
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-x64/. "$(WIN64_BUILD_DIR)/local/"
|
||||||
-Dportable=true )
|
meson setup "$(WIN64_BUILD_DIR)" \
|
||||||
|
--pkg-config-path="$(WIN64_BUILD_DIR)/local/lib/pkgconfig" \
|
||||||
|
-Dc_args="-I$(PWD)/$(WIN64_BUILD_DIR)/local/include" \
|
||||||
|
-Dc_link_args="-L$(PWD)/$(WIN64_BUILD_DIR)/local/lib" \
|
||||||
|
--cross-file=cross_win64.txt \
|
||||||
|
--buildtype=release --strip -Db_lto=true \
|
||||||
|
-Dcompile_server=false \
|
||||||
|
-Dportable=true
|
||||||
ninja -C "$(WIN64_BUILD_DIR)"
|
ninja -C "$(WIN64_BUILD_DIR)"
|
||||||
|
|
||||||
dist-win32: build-server build-win32
|
dist-win32: build-server build-win32
|
||||||
mkdir -p "$(DIST)/$(WIN32_TARGET_DIR)"
|
mkdir -p "$(DIST)/$(WIN32_TARGET_DIR)"
|
||||||
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/data/scrcpy-console.bat "$(DIST)/$(WIN32_TARGET_DIR)"
|
cp app/data/scrcpy-console.bat "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/data/scrcpy-noconsole.vbs "$(DIST)/$(WIN32_TARGET_DIR)"
|
cp app/data/scrcpy-noconsole.vbs "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/data/icon.png "$(DIST)/$(WIN32_TARGET_DIR)"
|
cp app/data/icon.png "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/data/open_a_terminal_here.bat "$(DIST)/$(WIN32_TARGET_DIR)"
|
cp app/data/open_a_terminal_here.bat "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win32/bin/avutil-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win32/bin/avcodec-60.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win32/bin/avformat-60.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win32/bin/swresample-4.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/platform-tools-34.0.5/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-34.0.5/adb.exe "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/SDL2-2.28.4/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp "$(WIN32_BUILD_DIR)"/local/bin/*.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-Win32/bin/msys-usb-1.0.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
|
||||||
|
|
||||||
dist-win64: build-server build-win64
|
dist-win64: build-server build-win64
|
||||||
mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
|
mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
|
||||||
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/data/scrcpy-console.bat "$(DIST)/$(WIN64_TARGET_DIR)"
|
cp app/data/scrcpy-console.bat "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/data/scrcpy-noconsole.vbs "$(DIST)/$(WIN64_TARGET_DIR)"
|
cp app/data/scrcpy-noconsole.vbs "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/data/icon.png "$(DIST)/$(WIN64_TARGET_DIR)"
|
cp app/data/icon.png "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/data/open_a_terminal_here.bat "$(DIST)/$(WIN64_TARGET_DIR)"
|
cp app/data/open_a_terminal_here.bat "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win64/bin/avutil-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win64/bin/avcodec-60.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win64/bin/avformat-60.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-2/win64/bin/swresample-4.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
|
||||||
cp app/prebuilt-deps/data/platform-tools-34.0.5/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-34.0.5/adb.exe "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-34.0.5/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/SDL2-2.28.4/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp "$(WIN64_BUILD_DIR)"/local/bin/*.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-x64/bin/msys-usb-1.0.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
|
||||||
|
|
||||||
zip-win32: dist-win32
|
zip-win32: dist-win32
|
||||||
cd "$(DIST)"; \
|
cd "$(DIST)"; \
|
||||||
|
@ -7,8 +7,8 @@ android {
|
|||||||
applicationId "com.genymobile.scrcpy"
|
applicationId "com.genymobile.scrcpy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 34
|
targetSdkVersion 34
|
||||||
versionCode 200
|
versionCode 20301
|
||||||
versionName "v2.2"
|
versionName "2.3.1"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRCPY_DEBUG=false
|
SCRCPY_DEBUG=false
|
||||||
SCRCPY_VERSION_NAME=v2.2
|
SCRCPY_VERSION_NAME=2.3.1
|
||||||
|
|
||||||
PLATFORM=${ANDROID_PLATFORM:-34}
|
PLATFORM=${ANDROID_PLATFORM:-34}
|
||||||
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-34.0.0}
|
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-34.0.0}
|
||||||
|
@ -11,6 +11,8 @@ public interface AsyncProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void start(TerminationListener listener);
|
void start(TerminationListener listener);
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
void join() throws InterruptedException;
|
void join() throws InterruptedException;
|
||||||
}
|
}
|
||||||
|
@ -289,18 +289,17 @@ public class CameraCapture extends SurfaceCapture {
|
|||||||
List<OutputConfiguration> outputs = Arrays.asList(outputConfig);
|
List<OutputConfiguration> outputs = Arrays.asList(outputConfig);
|
||||||
|
|
||||||
int sessionType = highSpeed ? SessionConfiguration.SESSION_HIGH_SPEED : SessionConfiguration.SESSION_REGULAR;
|
int sessionType = highSpeed ? SessionConfiguration.SESSION_HIGH_SPEED : SessionConfiguration.SESSION_REGULAR;
|
||||||
SessionConfiguration sessionConfig = new SessionConfiguration(sessionType, outputs, cameraExecutor,
|
SessionConfiguration sessionConfig = new SessionConfiguration(sessionType, outputs, cameraExecutor, new CameraCaptureSession.StateCallback() {
|
||||||
new CameraCaptureSession.StateCallback() {
|
@Override
|
||||||
@Override
|
public void onConfigured(CameraCaptureSession session) {
|
||||||
public void onConfigured(CameraCaptureSession session) {
|
future.complete(session);
|
||||||
future.complete(session);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigureFailed(CameraCaptureSession session) {
|
public void onConfigureFailed(CameraCaptureSession session) {
|
||||||
future.completeExceptionally(new CameraAccessException(CameraAccessException.CAMERA_ERROR));
|
future.completeExceptionally(new CameraAccessException(CameraAccessException.CAMERA_ERROR));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
camera.createCaptureSession(sessionConfig);
|
camera.createCaptureSession(sessionConfig);
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public final class CleanUp {
|
public final class CleanUp {
|
||||||
|
|
||||||
public static final String SERVER_PATH = "/data/local/tmp/scrcpy-server.jar";
|
|
||||||
|
|
||||||
// A simple struct to be passed from the main process to the cleanup process
|
// A simple struct to be passed from the main process to the cleanup process
|
||||||
public static class Config implements Parcelable {
|
public static class Config implements Parcelable {
|
||||||
|
|
||||||
@ -135,13 +133,13 @@ public final class CleanUp {
|
|||||||
String[] cmd = {"app_process", "/", CleanUp.class.getName(), config.toBase64()};
|
String[] cmd = {"app_process", "/", CleanUp.class.getName(), config.toBase64()};
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(cmd);
|
ProcessBuilder builder = new ProcessBuilder(cmd);
|
||||||
builder.environment().put("CLASSPATH", SERVER_PATH);
|
builder.environment().put("CLASSPATH", Server.SERVER_PATH);
|
||||||
builder.start();
|
builder.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unlinkSelf() {
|
public static void unlinkSelf() {
|
||||||
try {
|
try {
|
||||||
new File(SERVER_PATH).delete();
|
new File(Server.SERVER_PATH).delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Ln.e("Could not unlink server", e);
|
Ln.e("Could not unlink server", e);
|
||||||
}
|
}
|
||||||
|
@ -318,9 +318,8 @@ public class Controller implements AsyncProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent event = MotionEvent
|
MotionEvent event = MotionEvent.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f,
|
||||||
.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source,
|
DEFAULT_DEVICE_ID, 0, source, 0);
|
||||||
0);
|
|
||||||
return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
|
return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,9 +340,8 @@ public class Controller implements AsyncProcessor {
|
|||||||
coords.setAxisValue(MotionEvent.AXIS_HSCROLL, hScroll);
|
coords.setAxisValue(MotionEvent.AXIS_HSCROLL, hScroll);
|
||||||
coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);
|
coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);
|
||||||
|
|
||||||
MotionEvent event = MotionEvent
|
MotionEvent event = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f,
|
||||||
.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0,
|
DEFAULT_DEVICE_ID, 0, InputDevice.SOURCE_MOUSE, 0);
|
||||||
InputDevice.SOURCE_MOUSE, 0);
|
|
||||||
return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
|
return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
import com.genymobile.scrcpy.wrappers.ClipboardManager;
|
import com.genymobile.scrcpy.wrappers.ClipboardManager;
|
||||||
|
import com.genymobile.scrcpy.wrappers.DisplayControl;
|
||||||
import com.genymobile.scrcpy.wrappers.InputManager;
|
import com.genymobile.scrcpy.wrappers.InputManager;
|
||||||
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||||
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
||||||
@ -11,8 +12,8 @@ import android.graphics.Rect;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.view.IRotationWatcher;
|
|
||||||
import android.view.IDisplayFoldListener;
|
import android.view.IDisplayFoldListener;
|
||||||
|
import android.view.IRotationWatcher;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.InputEvent;
|
import android.view.InputEvent;
|
||||||
import android.view.KeyCharacterMap;
|
import android.view.KeyCharacterMap;
|
||||||
@ -163,6 +164,10 @@ public final class Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDisplayId() {
|
||||||
|
return displayId;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void setMaxSize(int newMaxSize) {
|
public synchronized void setMaxSize(int newMaxSize) {
|
||||||
maxSize = newMaxSize;
|
maxSize = newMaxSize;
|
||||||
screenInfo = ScreenInfo.computeScreenInfo(screenInfo.getReverseVideoRotation(), deviceSize, crop, newMaxSize, lockVideoOrientation);
|
screenInfo = ScreenInfo.computeScreenInfo(screenInfo.getReverseVideoRotation(), deviceSize, crop, newMaxSize, lockVideoOrientation);
|
||||||
@ -315,8 +320,12 @@ public final class Device {
|
|||||||
*/
|
*/
|
||||||
public static boolean setScreenPowerMode(int mode) {
|
public static boolean setScreenPowerMode(int mode) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
// On Android 14, these internal methods have been moved to DisplayControl
|
||||||
|
boolean useDisplayControl =
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && !SurfaceControl.hasPhysicalDisplayIdsMethod();
|
||||||
|
|
||||||
// Change the power mode for all physical displays
|
// Change the power mode for all physical displays
|
||||||
long[] physicalDisplayIds = SurfaceControl.getPhysicalDisplayIds();
|
long[] physicalDisplayIds = useDisplayControl ? DisplayControl.getPhysicalDisplayIds() : SurfaceControl.getPhysicalDisplayIds();
|
||||||
if (physicalDisplayIds == null) {
|
if (physicalDisplayIds == null) {
|
||||||
Ln.e("Could not get physical display ids");
|
Ln.e("Could not get physical display ids");
|
||||||
return false;
|
return false;
|
||||||
@ -324,7 +333,8 @@ public final class Device {
|
|||||||
|
|
||||||
boolean allOk = true;
|
boolean allOk = true;
|
||||||
for (long physicalDisplayId : physicalDisplayIds) {
|
for (long physicalDisplayId : physicalDisplayIds) {
|
||||||
IBinder binder = SurfaceControl.getPhysicalDisplayToken(physicalDisplayId);
|
IBinder binder = useDisplayControl ? DisplayControl.getPhysicalDisplayToken(
|
||||||
|
physicalDisplayId) : SurfaceControl.getPhysicalDisplayToken(physicalDisplayId);
|
||||||
allOk &= SurfaceControl.setDisplayPowerMode(binder, mode);
|
allOk &= SurfaceControl.setDisplayPowerMode(binder, mode);
|
||||||
}
|
}
|
||||||
return allOk;
|
return allOk;
|
||||||
|
@ -51,6 +51,7 @@ public final class DeviceMessageSender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
thread = new Thread(() -> {
|
thread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
|
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||||
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.hardware.display.VirtualDisplay;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
@ -11,6 +13,7 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
|
|||||||
|
|
||||||
private final Device device;
|
private final Device device;
|
||||||
private IBinder display;
|
private IBinder display;
|
||||||
|
private VirtualDisplay virtualDisplay;
|
||||||
|
|
||||||
public ScreenCapture(Device device) {
|
public ScreenCapture(Device device) {
|
||||||
this.device = device;
|
this.device = device;
|
||||||
@ -34,9 +37,29 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
|
|||||||
|
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
SurfaceControl.destroyDisplay(display);
|
SurfaceControl.destroyDisplay(display);
|
||||||
|
display = null;
|
||||||
|
}
|
||||||
|
if (virtualDisplay != null) {
|
||||||
|
virtualDisplay.release();
|
||||||
|
virtualDisplay = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
display = createDisplay();
|
||||||
|
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
|
||||||
|
Ln.d("Display: using SurfaceControl API");
|
||||||
|
} catch (Exception surfaceControlException) {
|
||||||
|
Rect videoRect = screenInfo.getVideoSize().toRect();
|
||||||
|
try {
|
||||||
|
virtualDisplay = ServiceManager.getDisplayManager()
|
||||||
|
.createVirtualDisplay("scrcpy", videoRect.width(), videoRect.height(), device.getDisplayId(), surface);
|
||||||
|
Ln.d("Display: using DisplayManager API");
|
||||||
|
} catch (Exception displayManagerException) {
|
||||||
|
Ln.e("Could not create display using SurfaceControl", surfaceControlException);
|
||||||
|
Ln.e("Could not create display using DisplayManager", displayManagerException);
|
||||||
|
throw new AssertionError("Could not create display");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
display = createDisplay();
|
|
||||||
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,7 +92,7 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
|
|||||||
requestReset();
|
requestReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinder createDisplay() {
|
private static IBinder createDisplay() throws Exception {
|
||||||
// Since Android 12 (preview), secure displays could not be created with shell permissions anymore.
|
// Since Android 12 (preview), secure displays could not be created with shell permissions anymore.
|
||||||
// On Android 12 preview, SDK_INT is still R (not S), but CODENAME is "S".
|
// On Android 12 preview, SDK_INT is still R (not S), but CODENAME is "S".
|
||||||
boolean secure = Build.VERSION.SDK_INT < Build.VERSION_CODES.R || (Build.VERSION.SDK_INT == Build.VERSION_CODES.R && !"S".equals(
|
boolean secure = Build.VERSION.SDK_INT < Build.VERSION_CODES.R || (Build.VERSION.SDK_INT == Build.VERSION_CODES.R && !"S".equals(
|
||||||
|
@ -3,12 +3,21 @@ package com.genymobile.scrcpy;
|
|||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class Server {
|
public final class Server {
|
||||||
|
|
||||||
|
public static final String SERVER_PATH;
|
||||||
|
|
||||||
|
static {
|
||||||
|
String[] classPaths = System.getProperty("java.class.path").split(File.pathSeparator);
|
||||||
|
// By convention, scrcpy is always executed with the absolute path of scrcpy-server.jar as the first item in the classpath
|
||||||
|
SERVER_PATH = classPaths[0];
|
||||||
|
}
|
||||||
|
|
||||||
private static class Completion {
|
private static class Completion {
|
||||||
private int running;
|
private int running;
|
||||||
private boolean fatalError;
|
private boolean fatalError;
|
||||||
|
@ -75,7 +75,7 @@ public final class Settings {
|
|||||||
|
|
||||||
String oldValue = getValue(table, key);
|
String oldValue = getValue(table, key);
|
||||||
if (!value.equals(oldValue)) {
|
if (!value.equals(oldValue)) {
|
||||||
putValue(table, key, value);
|
putValue(table, key, value);
|
||||||
}
|
}
|
||||||
return oldValue;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public final class Workarounds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void apply(boolean audio, boolean camera) {
|
public static void apply(boolean audio, boolean camera) {
|
||||||
|
boolean mustFillConfigurationController = false;
|
||||||
boolean mustFillAppInfo = false;
|
boolean mustFillAppInfo = false;
|
||||||
boolean mustFillAppContext = false;
|
boolean mustFillAppContext = false;
|
||||||
|
|
||||||
@ -85,11 +86,23 @@ public final class Workarounds {
|
|||||||
mustFillAppContext = true;
|
mustFillAppContext = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
// On some Samsung devices, DisplayManagerGlobal.getDisplayInfoLocked() calls ActivityThread.currentActivityThread().getConfiguration(),
|
||||||
|
// which requires a non-null ConfigurationController.
|
||||||
|
// ConfigurationController was introduced in Android 12, so do not attempt to set it on lower versions.
|
||||||
|
// <https://github.com/Genymobile/scrcpy/issues/4467>
|
||||||
|
mustFillConfigurationController = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mustFillConfigurationController) {
|
||||||
|
// Must be call before fillAppContext() because it is necessary to get a valid system context
|
||||||
|
fillConfigurationController();
|
||||||
|
}
|
||||||
if (mustFillAppInfo) {
|
if (mustFillAppInfo) {
|
||||||
Workarounds.fillAppInfo();
|
fillAppInfo();
|
||||||
}
|
}
|
||||||
if (mustFillAppContext) {
|
if (mustFillAppContext) {
|
||||||
Workarounds.fillAppContext();
|
fillAppContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +162,22 @@ public final class Workarounds {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void fillConfigurationController() {
|
||||||
|
try {
|
||||||
|
Class<?> configurationControllerClass = Class.forName("android.app.ConfigurationController");
|
||||||
|
Class<?> activityThreadInternalClass = Class.forName("android.app.ActivityThreadInternal");
|
||||||
|
Constructor<?> configurationControllerConstructor = configurationControllerClass.getDeclaredConstructor(activityThreadInternalClass);
|
||||||
|
configurationControllerConstructor.setAccessible(true);
|
||||||
|
Object configurationController = configurationControllerConstructor.newInstance(ACTIVITY_THREAD);
|
||||||
|
|
||||||
|
Field configurationControllerField = ACTIVITY_THREAD_CLASS.getDeclaredField("mConfigurationController");
|
||||||
|
configurationControllerField.setAccessible(true);
|
||||||
|
configurationControllerField.set(ACTIVITY_THREAD, configurationController);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
Ln.d("Could not fill configuration: " + throwable.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Context getSystemContext() {
|
static Context getSystemContext() {
|
||||||
try {
|
try {
|
||||||
Method getSystemContextMethod = ACTIVITY_THREAD_CLASS.getDeclaredMethod("getSystemContext");
|
Method getSystemContextMethod = ACTIVITY_THREAD_CLASS.getDeclaredMethod("getSystemContext");
|
||||||
|
@ -138,8 +138,8 @@ public final class ClipboardManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addPrimaryClipChangedListener(Method method, int methodVersion, IInterface manager,
|
private static void addPrimaryClipChangedListener(Method method, int methodVersion, IInterface manager, IOnPrimaryClipChangedListener listener)
|
||||||
IOnPrimaryClipChangedListener listener) throws InvocationTargetException, IllegalAccessException {
|
throws InvocationTargetException, IllegalAccessException {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
method.invoke(manager, listener, FakeContext.PACKAGE_NAME);
|
method.invoke(manager, listener, FakeContext.PACKAGE_NAME);
|
||||||
return;
|
return;
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.genymobile.scrcpy.wrappers;
|
||||||
|
|
||||||
|
import com.genymobile.scrcpy.Ln;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
@SuppressLint({"PrivateApi", "SoonBlockedPrivateApi", "BlockedPrivateApi"})
|
||||||
|
@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||||
|
public final class DisplayControl {
|
||||||
|
|
||||||
|
private static final Class<?> CLASS;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Class<?> displayControlClass = null;
|
||||||
|
try {
|
||||||
|
Class<?> classLoaderFactoryClass = Class.forName("com.android.internal.os.ClassLoaderFactory");
|
||||||
|
Method createClassLoaderMethod = classLoaderFactoryClass.getDeclaredMethod("createClassLoader", String.class, String.class, String.class,
|
||||||
|
ClassLoader.class, int.class, boolean.class, String.class);
|
||||||
|
ClassLoader classLoader = (ClassLoader) createClassLoaderMethod.invoke(null, "/system/framework/services.jar", null, null,
|
||||||
|
ClassLoader.getSystemClassLoader(), 0, true, null);
|
||||||
|
|
||||||
|
displayControlClass = classLoader.loadClass("com.android.server.display.DisplayControl");
|
||||||
|
|
||||||
|
Method loadMethod = Runtime.class.getDeclaredMethod("loadLibrary0", Class.class, String.class);
|
||||||
|
loadMethod.setAccessible(true);
|
||||||
|
loadMethod.invoke(Runtime.getRuntime(), displayControlClass, "android_servers");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Ln.e("Could not initialize DisplayControl", e);
|
||||||
|
// Do not throw an exception here, the methods will fail when they are called
|
||||||
|
}
|
||||||
|
CLASS = displayControlClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Method getPhysicalDisplayTokenMethod;
|
||||||
|
private static Method getPhysicalDisplayIdsMethod;
|
||||||
|
|
||||||
|
private DisplayControl() {
|
||||||
|
// only static methods
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Method getGetPhysicalDisplayTokenMethod() throws NoSuchMethodException {
|
||||||
|
if (getPhysicalDisplayTokenMethod == null) {
|
||||||
|
getPhysicalDisplayTokenMethod = CLASS.getMethod("getPhysicalDisplayToken", long.class);
|
||||||
|
}
|
||||||
|
return getPhysicalDisplayTokenMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IBinder getPhysicalDisplayToken(long physicalDisplayId) {
|
||||||
|
try {
|
||||||
|
Method method = getGetPhysicalDisplayTokenMethod();
|
||||||
|
return (IBinder) method.invoke(null, physicalDisplayId);
|
||||||
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Ln.e("Could not invoke method", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Method getGetPhysicalDisplayIdsMethod() throws NoSuchMethodException {
|
||||||
|
if (getPhysicalDisplayIdsMethod == null) {
|
||||||
|
getPhysicalDisplayIdsMethod = CLASS.getMethod("getPhysicalDisplayIds");
|
||||||
|
}
|
||||||
|
return getPhysicalDisplayIdsMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long[] getPhysicalDisplayIds() {
|
||||||
|
try {
|
||||||
|
Method method = getGetPhysicalDisplayIdsMethod();
|
||||||
|
return (long[]) method.invoke(null);
|
||||||
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Ln.e("Could not invoke method", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,14 +5,18 @@ import com.genymobile.scrcpy.DisplayInfo;
|
|||||||
import com.genymobile.scrcpy.Ln;
|
import com.genymobile.scrcpy.Ln;
|
||||||
import com.genymobile.scrcpy.Size;
|
import com.genymobile.scrcpy.Size;
|
||||||
|
|
||||||
|
import android.hardware.display.VirtualDisplay;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
import android.view.Surface;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public final class DisplayManager {
|
public final class DisplayManager {
|
||||||
private final Object manager; // instance of hidden class android.hardware.display.DisplayManagerGlobal
|
private final Object manager; // instance of hidden class android.hardware.display.DisplayManagerGlobal
|
||||||
|
private Method createVirtualDisplayMethod;
|
||||||
|
|
||||||
public DisplayManager(Object manager) {
|
public DisplayManager(Object manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
@ -94,4 +98,17 @@ public final class DisplayManager {
|
|||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Method getCreateVirtualDisplayMethod() throws NoSuchMethodException {
|
||||||
|
if (createVirtualDisplayMethod == null) {
|
||||||
|
createVirtualDisplayMethod = android.hardware.display.DisplayManager.class
|
||||||
|
.getMethod("createVirtualDisplay", String.class, int.class, int.class, int.class, Surface.class);
|
||||||
|
}
|
||||||
|
return createVirtualDisplayMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualDisplay createVirtualDisplay(String name, int width, int height, int displayIdToMirror, Surface surface) throws Exception {
|
||||||
|
Method method = getCreateVirtualDisplayMethod();
|
||||||
|
return (VirtualDisplay) method.invoke(null, name, width, height, displayIdToMirror, surface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public final class PowerManager {
|
|||||||
private Method getIsScreenOnMethod() throws NoSuchMethodException {
|
private Method getIsScreenOnMethod() throws NoSuchMethodException {
|
||||||
if (isScreenOnMethod == null) {
|
if (isScreenOnMethod == null) {
|
||||||
@SuppressLint("ObsoleteSdkInt") // we may lower minSdkVersion in the future
|
@SuppressLint("ObsoleteSdkInt") // we may lower minSdkVersion in the future
|
||||||
String methodName = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? "isInteractive" : "isScreenOn";
|
String methodName = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH ? "isInteractive" : "isScreenOn";
|
||||||
isScreenOnMethod = manager.getClass().getMethod(methodName);
|
isScreenOnMethod = manager.getClass().getMethod(methodName);
|
||||||
}
|
}
|
||||||
return isScreenOnMethod;
|
return isScreenOnMethod;
|
||||||
|
@ -16,6 +16,7 @@ import java.lang.reflect.Method;
|
|||||||
public final class ServiceManager {
|
public final class ServiceManager {
|
||||||
|
|
||||||
private static final Method GET_SERVICE_METHOD;
|
private static final Method GET_SERVICE_METHOD;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
GET_SERVICE_METHOD = Class.forName("android.os.ServiceManager").getDeclaredMethod("getService", String.class);
|
GET_SERVICE_METHOD = Class.forName("android.os.ServiceManager").getDeclaredMethod("getService", String.class);
|
||||||
|
@ -78,12 +78,8 @@ public final class SurfaceControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBinder createDisplay(String name, boolean secure) {
|
public static IBinder createDisplay(String name, boolean secure) throws Exception {
|
||||||
try {
|
return (IBinder) CLASS.getMethod("createDisplay", String.class, boolean.class).invoke(null, name, secure);
|
||||||
return (IBinder) CLASS.getMethod("createDisplay", String.class, boolean.class).invoke(null, name, secure);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Method getGetBuiltInDisplayMethod() throws NoSuchMethodException {
|
private static Method getGetBuiltInDisplayMethod() throws NoSuchMethodException {
|
||||||
@ -139,6 +135,15 @@ public final class SurfaceControl {
|
|||||||
return getPhysicalDisplayIdsMethod;
|
return getPhysicalDisplayIdsMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasPhysicalDisplayIdsMethod() {
|
||||||
|
try {
|
||||||
|
getGetPhysicalDisplayIdsMethod();
|
||||||
|
return true;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static long[] getPhysicalDisplayIds() {
|
public static long[] getPhysicalDisplayIds() {
|
||||||
try {
|
try {
|
||||||
Method method = getGetPhysicalDisplayIdsMethod();
|
Method method = getGetPhysicalDisplayIdsMethod();
|
||||||
|
@ -4,8 +4,8 @@ import com.genymobile.scrcpy.Ln;
|
|||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.os.IInterface;
|
import android.os.IInterface;
|
||||||
import android.view.IRotationWatcher;
|
|
||||||
import android.view.IDisplayFoldListener;
|
import android.view.IDisplayFoldListener;
|
||||||
|
import android.view.IRotationWatcher;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
Reference in New Issue
Block a user