diff --git a/app/src/main.c b/app/src/main.c index b2a6bf5e..c61db725 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -5,6 +5,7 @@ #include #include #include +#define SDL_MAIN_HANDLED // avoid link error on Linux Windows Subsystem #include #include "compat.h" diff --git a/app/tests/test_control_event_serialize.c b/app/tests/test_control_event_serialize.c index f6034370..90b75fff 100644 --- a/app/tests/test_control_event_serialize.c +++ b/app/tests/test_control_event_serialize.c @@ -49,13 +49,14 @@ static void test_serialize_text_event(void) { static void test_serialize_long_text_event(void) { struct control_event event; event.type = CONTROL_EVENT_TYPE_TEXT; - char text[TEXT_MAX_LENGTH]; + char text[TEXT_MAX_LENGTH + 1]; memset(text, 'a', sizeof(text)); + text[TEXT_MAX_LENGTH] = '\0'; event.text_event.text = text; unsigned char buf[SERIALIZED_EVENT_MAX_SIZE]; int size = control_event_serialize(&event, buf); - assert(size == 3 + sizeof(text)); + assert(size == 3 + TEXT_MAX_LENGTH); unsigned char expected[3 + TEXT_MAX_LENGTH]; expected[0] = 0x01; // CONTROL_EVENT_TYPE_KEYCODE diff --git a/release.sh b/release.sh index ca632e00..fbd1eb54 100755 --- a/release.sh +++ b/release.sh @@ -1,13 +1,22 @@ #!/bin/bash set -e -# build and test locally +# test locally +TESTDIR=build_test +rm -rf "$TESTDIR" +# run client tests with ASAN enabled +meson "$TESTDIR" -Db_sanitize=address +ninja -C"$TESTDIR" test + +# test server +GRADLE=${GRADLE:-./gradlew} +$GRADLE -p server check + BUILDDIR=build_release rm -rf "$BUILDDIR" meson "$BUILDDIR" --buildtype release --strip -Db_lto=true cd "$BUILDDIR" ninja -ninja test cd - # build Windows releases diff --git a/server/src/main/java/com/genymobile/scrcpy/EventController.java b/server/src/main/java/com/genymobile/scrcpy/EventController.java index 5fa2cab2..341869fa 100644 --- a/server/src/main/java/com/genymobile/scrcpy/EventController.java +++ b/server/src/main/java/com/genymobile/scrcpy/EventController.java @@ -1,7 +1,6 @@ package com.genymobile.scrcpy; import com.genymobile.scrcpy.wrappers.InputManager; -import com.genymobile.scrcpy.wrappers.ServiceManager; import android.graphics.Point; import android.os.SystemClock; diff --git a/server/src/main/java/com/genymobile/scrcpy/IO.java b/server/src/main/java/com/genymobile/scrcpy/IO.java index f1f05105..57c017db 100644 --- a/server/src/main/java/com/genymobile/scrcpy/IO.java +++ b/server/src/main/java/com/genymobile/scrcpy/IO.java @@ -8,7 +8,7 @@ import java.io.FileDescriptor; import java.io.IOException; import java.nio.ByteBuffer; -public class IO { +public final class IO { private IO() { // not instantiable } diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 71f5ab10..8357b061 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -3,7 +3,6 @@ package com.genymobile.scrcpy; import com.genymobile.scrcpy.wrappers.SurfaceControl; import android.graphics.Rect; -import android.media.MediaMuxer; import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index fb2ba461..b782101c 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -4,7 +4,6 @@ import android.graphics.Rect; import java.io.File; import java.io.IOException; -import java.util.Arrays; public final class Server { @@ -49,8 +48,9 @@ public final class Server { @SuppressWarnings("checkstyle:MagicNumber") private static Options createOptions(String... args) { - if (args.length != 5) + if (args.length != 5) { throw new IllegalArgumentException("Expecting 5 parameters"); + } Options options = new Options(); @@ -73,6 +73,7 @@ public final class Server { return options; } + @SuppressWarnings("checkstyle:MagicNumber") private static Rect parseCrop(String crop) { if ("-".equals(crop)) { return null; diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java index aacd5f1a..8f79f51f 100644 --- a/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java +++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/StatusBarManager.java @@ -1,8 +1,6 @@ package com.genymobile.scrcpy.wrappers; -import android.annotation.SuppressLint; import android.os.IInterface; -import android.view.InputEvent; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method;