Skip to content

Display and control your Android device

Fix java code style

Romain Vimontc573bd2a33c8
diff --git a/server/src/main/java/com/genymobile/scrcpy/AsyncProcessor.java b/server/src/main/java/com/genymobile/scrcpy/AsyncProcessor.java
index b9b6745c..d5da6a90 100644
--- a/server/src/main/java/com/genymobile/scrcpy/AsyncProcessor.java
+++ b/server/src/main/java/com/genymobile/scrcpy/AsyncProcessor.java
@@ -11,6 +11,8 @@ public interface AsyncProcessor {
}
void start(TerminationListener listener);
+
void stop();
+
void join() throws InterruptedException;
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java b/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java
index b9da3658..a1003829 100644
--- a/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java
+++ b/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java
@@ -289,18 +289,17 @@ public class CameraCapture extends SurfaceCapture {
List<OutputConfiguration> outputs = Arrays.asList(outputConfig);
int sessionType = highSpeed ? SessionConfiguration.SESSION_HIGH_SPEED : SessionConfiguration.SESSION_REGULAR;
- SessionConfiguration sessionConfig = new SessionConfiguration(sessionType, outputs, cameraExecutor,
- new CameraCaptureSession.StateCallback() {
- @Override
- public void onConfigured(CameraCaptureSession session) {
- future.complete(session);
- }
-
- @Override
- public void onConfigureFailed(CameraCaptureSession session) {
- future.completeExceptionally(new CameraAccessException(CameraAccessException.CAMERA_ERROR));
- }
- });
+ SessionConfiguration sessionConfig = new SessionConfiguration(sessionType, outputs, cameraExecutor, new CameraCaptureSession.StateCallback() {
+ @Override
+ public void onConfigured(CameraCaptureSession session) {
+ future.complete(session);
+ }
+
+ @Override
+ public void onConfigureFailed(CameraCaptureSession session) {
+ future.completeExceptionally(new CameraAccessException(CameraAccessException.CAMERA_ERROR));
+ }
+ });
camera.createCaptureSession(sessionConfig);
diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java
index 733a2032..3b0e9031 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java
@@ -318,9 +318,8 @@ public class Controller implements AsyncProcessor {
}
}
- MotionEvent event = MotionEvent
- .obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source,
- 0);
+ MotionEvent event = MotionEvent.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f,
+ DEFAULT_DEVICE_ID, 0, source, 0);
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_VSCROLL, vScroll);
- MotionEvent event = MotionEvent
- .obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0,
- InputDevice.SOURCE_MOUSE, 0);
+ MotionEvent event = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f,
+ DEFAULT_DEVICE_ID, 0, InputDevice.SOURCE_MOUSE, 0);
return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
index 4ab689b0..9fbe9239 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Device.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Device.java
@@ -11,8 +11,8 @@ import android.graphics.Rect;
import android.os.Build;
import android.os.IBinder;
import android.os.SystemClock;
-import android.view.IRotationWatcher;
import android.view.IDisplayFoldListener;
+import android.view.IRotationWatcher;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.KeyCharacterMap;
diff --git a/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java b/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java
index 628c1d3c..94e842ee 100644
--- a/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java
+++ b/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java
@@ -51,6 +51,7 @@ public final class DeviceMessageSender {
}
}
}
+
public void start() {
thread = new Thread(() -> {
try {
diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java
index 2a8387e0..e4a95140 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Server.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java
@@ -11,6 +11,7 @@ import java.util.List;
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
diff --git a/server/src/main/java/com/genymobile/scrcpy/Settings.java b/server/src/main/java/com/genymobile/scrcpy/Settings.java
index 1d38814d..1b5e5f98 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Settings.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Settings.java
@@ -75,7 +75,7 @@ public final class Settings {
String oldValue = getValue(table, key);
if (!value.equals(oldValue)) {
- putValue(table, key, value);
+ putValue(table, key, value);
}
return oldValue;
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index eae66858..783a3407 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -138,8 +138,8 @@ public final class ClipboardManager {
}
}
- private static void addPrimaryClipChangedListener(Method method, int methodVersion, IInterface manager,
- IOnPrimaryClipChangedListener listener) throws InvocationTargetException, IllegalAccessException {
+ private static void addPrimaryClipChangedListener(Method method, int methodVersion, IInterface manager, IOnPrimaryClipChangedListener listener)
+ throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
method.invoke(manager, listener, FakeContext.PACKAGE_NAME);
return;
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/PowerManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/PowerManager.java
index 8ff074b3..93722687 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/PowerManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/PowerManager.java
@@ -20,7 +20,7 @@ public final class PowerManager {
private Method getIsScreenOnMethod() throws NoSuchMethodException {
if (isScreenOnMethod == null) {
@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);
}
return isScreenOnMethod;
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java
index ae04a6d2..85602c19 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ServiceManager.java
@@ -16,6 +16,7 @@ import java.lang.reflect.Method;
public final class ServiceManager {
private static final Method GET_SERVICE_METHOD;
+
static {
try {
GET_SERVICE_METHOD = Class.forName("android.os.ServiceManager").getDeclaredMethod("getService", String.class);
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/WindowManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/WindowManager.java
index ce748855..a746be5c 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/WindowManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/WindowManager.java
@@ -4,8 +4,8 @@ import com.genymobile.scrcpy.Ln;
import android.annotation.TargetApi;
import android.os.IInterface;
-import android.view.IRotationWatcher;
import android.view.IDisplayFoldListener;
+import android.view.IRotationWatcher;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;