Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions app/data/runnopush.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@echo off
setlocal enabledelayedexpansion

:: 获取脚本目录并设置服务器路径
set "SCRIPT_DIR=%~dp0"
set "SERVER_PATH=%SCRIPT_DIR%scrcpy-server"

call :logd "脚本目录: %SCRIPT_DIR%"
call :logd "正在扫描设备..."

:: 获取设备列表并显示名称
set count=0
for /f "tokens=1" %%i in ('adb devices ^| findstr "device$"') do (
set /a count+=1
set "dev!count!=%%i"

:: 获取设备型号名称,直接存入变量
for /f "tokens=*" %%m in ('adb -s %%i shell getprop ro.product.model') do (
set "model_name=%%m"
)
echo !count!. %%i - [!model_name!]
)

if %count%==0 (
call :logd "未找到可用设备。"
pause
exit /b
)

:: 选择逻辑
if %count%==1 (
set "target_device=!dev1!"
) else (
echo 请选择设备序号:
choice /c 123456789 /n /m "输入序号 (1-%count%): "
set "idx=!errorlevel!"

set "target_device="
for /l %%k in (1,1,%count%) do (
if !idx! equ %%k (
set "target_device=!dev%%k!"
)
)
)

if "!target_device!"=="" (
call :logd "错误:未正确选择设备。"
pause
exit /b
)

call :logd "已选择目标设备: !target_device!"

:: 推送
adb -s "!target_device!" push "%SERVER_PATH%" /data/local/tmp/scrcpy-server.jar
if %errorlevel% neq 0 (
call :logd "推送失败。"
pause
exit /b
)

:: 启动
call :logd "启动 scrcpy..."
scrcpy --no-audio --video-codec=h264 --max-size=1280 --no-push -s "!target_device!"
exit /b

:logd
echo [%date:~5,10% %time:~0,8%] [LOG]: %~1
exit /b
9 changes: 9 additions & 0 deletions app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ enum {
OPT_KEEP_ACTIVE,
OPT_BACKGROUND_COLOR,
OPT_RENDER_FIT,
OPT_NO_PUSH,
};

struct sc_option {
Expand Down Expand Up @@ -145,6 +146,11 @@ struct sc_getopt_adapter {
};

static const struct sc_option options[] = {
{
.longopt_id = OPT_NO_PUSH,
.longopt = "no-push",
.text = "no push scrcpy server file.",
},
{
.longopt_id = OPT_ALWAYS_ON_TOP,
.longopt = "always-on-top",
Expand Down Expand Up @@ -2917,6 +2923,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
case 'x':
opts->flex_display = true;
break;
case OPT_NO_PUSH:
opts->no_push = true;
break;
default:
// getopt prints the error message on stderr
return false;
Expand Down
1 change: 1 addition & 0 deletions app/src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const struct scrcpy_options scrcpy_options_default = {
.camera_torch = false,
.keep_active = false,
.flex_display = false,
.no_push = false,
};

enum sc_orientation
Expand Down
1 change: 1 addition & 0 deletions app/src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ struct scrcpy_options {
bool camera_torch;
bool keep_active;
bool flex_display;
bool no_push;
};

extern const struct scrcpy_options scrcpy_options_default;
Expand Down
1 change: 1 addition & 0 deletions app/src/scrcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ scrcpy(struct scrcpy_options *options) {
.keep_active = options->keep_active,
.flex_display = options->flex_display,
.list = options->list,
.no_push = options->no_push,
};

static const struct sc_server_callbacks cbs = {
Expand Down
10 changes: 7 additions & 3 deletions app/src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,13 @@ run_server(void *data) {
assert(serial);
LOGD("Device serial: %s", serial);

ok = push_server(&server->intr, serial);
if (!ok) {
goto error_connection_failed;
if(!params-> no_push){
ok = push_server(&server->intr, serial);
if (!ok) {
goto error_connection_failed;
}
}else{
LOGI("Do not push service files.");
}

// If --list-* is passed, then the server just prints the requested data
Expand Down
1 change: 1 addition & 0 deletions app/src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct sc_server_params {
bool vd_system_decorations;
bool keep_active;
bool flex_display;
bool no_push;
uint8_t list;
};

Expand Down
1 change: 1 addition & 0 deletions release/build_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ cp app/data/scrcpy-noconsole.vbs "$WINXX_BUILD_DIR/dist/"
cp app/data/scrcpy.png "$WINXX_BUILD_DIR/dist/"
cp app/data/disconnected.png "$WINXX_BUILD_DIR/dist/"
cp app/data/open_a_terminal_here.bat "$WINXX_BUILD_DIR/dist/"
cp app/data/runnopush.bat "$WINXX_BUILD_DIR/dist/"
cp "$DEPS_INSTALL_DIR"/bin/*.dll "$WINXX_BUILD_DIR/dist/"
cp -r "$ADB_INSTALL_DIR"/. "$WINXX_BUILD_DIR/dist/"