Merge pull request #920 into dev
Compare server and client version at the start of scrcpy
This commit is contained in:
commit
af3027a85b
2 changed files with 19 additions and 8 deletions
|
@ -131,6 +131,7 @@ execute_server(struct server *server, const struct server_params *params) {
|
||||||
#endif
|
#endif
|
||||||
"/", // unused
|
"/", // unused
|
||||||
"com.genymobile.scrcpy.Server",
|
"com.genymobile.scrcpy.Server",
|
||||||
|
SCRCPY_VERSION,
|
||||||
max_size_string,
|
max_size_string,
|
||||||
bit_rate_string,
|
bit_rate_string,
|
||||||
server->tunnel_forward ? "true" : "false",
|
server->tunnel_forward ? "true" : "false",
|
||||||
|
|
|
@ -67,29 +67,39 @@ public final class Server {
|
||||||
|
|
||||||
@SuppressWarnings("checkstyle:MagicNumber")
|
@SuppressWarnings("checkstyle:MagicNumber")
|
||||||
private static Options createOptions(String... args) {
|
private static Options createOptions(String... args) {
|
||||||
if (args.length != 6) {
|
if (args.length < 1) {
|
||||||
throw new IllegalArgumentException("Expecting 6 parameters");
|
throw new IllegalArgumentException("Missing client version");
|
||||||
|
}
|
||||||
|
|
||||||
|
String clientVersion = args[0];
|
||||||
|
if (!clientVersion.equals(BuildConfig.VERSION_NAME)) {
|
||||||
|
throw new IllegalArgumentException("The server version (" + clientVersion + ") does not match the client "
|
||||||
|
+ "(" + BuildConfig.VERSION_NAME + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 7) {
|
||||||
|
throw new IllegalArgumentException("Expecting 7 parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
int maxSize = Integer.parseInt(args[0]) & ~7; // multiple of 8
|
int maxSize = Integer.parseInt(args[1]) & ~7; // multiple of 8
|
||||||
options.setMaxSize(maxSize);
|
options.setMaxSize(maxSize);
|
||||||
|
|
||||||
int bitRate = Integer.parseInt(args[1]);
|
int bitRate = Integer.parseInt(args[2]);
|
||||||
options.setBitRate(bitRate);
|
options.setBitRate(bitRate);
|
||||||
|
|
||||||
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
|
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
|
||||||
boolean tunnelForward = Boolean.parseBoolean(args[2]);
|
boolean tunnelForward = Boolean.parseBoolean(args[3]);
|
||||||
options.setTunnelForward(tunnelForward);
|
options.setTunnelForward(tunnelForward);
|
||||||
|
|
||||||
Rect crop = parseCrop(args[3]);
|
Rect crop = parseCrop(args[4]);
|
||||||
options.setCrop(crop);
|
options.setCrop(crop);
|
||||||
|
|
||||||
boolean sendFrameMeta = Boolean.parseBoolean(args[4]);
|
boolean sendFrameMeta = Boolean.parseBoolean(args[5]);
|
||||||
options.setSendFrameMeta(sendFrameMeta);
|
options.setSendFrameMeta(sendFrameMeta);
|
||||||
|
|
||||||
boolean control = Boolean.parseBoolean(args[5]);
|
boolean control = Boolean.parseBoolean(args[6]);
|
||||||
options.setControl(control);
|
options.setControl(control);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
|
Loading…
Reference in a new issue