Do not hardcode server path on the device
The path can be retrieved from the classpath. PR #4416 <https://github.com/Genymobile/scrcpy/pull/4416> Co-authored-by: Romain Vimont <rom@rom1v.com> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
85a94dd4b5
commit
acb2988837
@ -14,8 +14,6 @@ import java.io.IOException;
|
||||
*/
|
||||
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
|
||||
public static class Config implements Parcelable {
|
||||
|
||||
@ -135,13 +133,13 @@ public final class CleanUp {
|
||||
String[] cmd = {"app_process", "/", CleanUp.class.getName(), config.toBase64()};
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(cmd);
|
||||
builder.environment().put("CLASSPATH", SERVER_PATH);
|
||||
builder.environment().put("CLASSPATH", Server.SERVER_PATH);
|
||||
builder.start();
|
||||
}
|
||||
|
||||
public static void unlinkSelf() {
|
||||
try {
|
||||
new File(SERVER_PATH).delete();
|
||||
new File(Server.SERVER_PATH).delete();
|
||||
} catch (Exception e) {
|
||||
Ln.e("Could not unlink server", e);
|
||||
}
|
||||
|
@ -3,12 +3,20 @@ package com.genymobile.scrcpy;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
SERVER_PATH = classPaths[0];
|
||||
}
|
||||
|
||||
private static class Completion {
|
||||
private int running;
|
||||
private boolean fatalError;
|
||||
|
Loading…
x
Reference in New Issue
Block a user