mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 06:08:53 +00:00
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
2 changed files with 10 additions and 4 deletions
|
@ -14,8 +14,6 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public final class CleanUp {
|
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
|
// A simple struct to be passed from the main process to the cleanup process
|
||||||
public static class Config implements Parcelable {
|
public static class Config implements Parcelable {
|
||||||
|
|
||||||
|
@ -135,13 +133,13 @@ public final class CleanUp {
|
||||||
String[] cmd = {"app_process", "/", CleanUp.class.getName(), config.toBase64()};
|
String[] cmd = {"app_process", "/", CleanUp.class.getName(), config.toBase64()};
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(cmd);
|
ProcessBuilder builder = new ProcessBuilder(cmd);
|
||||||
builder.environment().put("CLASSPATH", SERVER_PATH);
|
builder.environment().put("CLASSPATH", Server.SERVER_PATH);
|
||||||
builder.start();
|
builder.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unlinkSelf() {
|
public static void unlinkSelf() {
|
||||||
try {
|
try {
|
||||||
new File(SERVER_PATH).delete();
|
new File(Server.SERVER_PATH).delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Ln.e("Could not unlink server", e);
|
Ln.e("Could not unlink server", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,20 @@ package com.genymobile.scrcpy;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class Server {
|
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 static class Completion {
|
||||||
private int running;
|
private int running;
|
||||||
private boolean fatalError;
|
private boolean fatalError;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue