mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 20:15:04 +00:00
update:server删除由server自己负责
This commit is contained in:
parent
de54f1bbc3
commit
6e5f02fcb4
5 changed files with 18 additions and 34 deletions
|
@ -10,9 +10,7 @@
|
|||
|
||||
#define DEVICE_SERVER_PATH "/data/local/tmp/scrcpy-server.jar"
|
||||
#define DEVICE_NAME_FIELD_LENGTH 64
|
||||
//#define SOCKET_NAME "qtscrcpy" //jar需要同步修改
|
||||
#define SOCKET_NAME "scrcpy"
|
||||
|
||||
#define SOCKET_NAME "qtscrcpy"
|
||||
|
||||
Server::Server(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -28,10 +26,7 @@ Server::Server(QObject *parent) : QObject(parent)
|
|||
if (m_deviceSocket->isValid() && readInfo(deviceName, deviceSize)) {
|
||||
// we don't need the server socket anymore
|
||||
// just m_deviceSocket is ok
|
||||
m_serverSocket.close();
|
||||
// the server is started, we can clean up the jar from the temporary folder
|
||||
removeServer();
|
||||
m_serverCopiedToDevice = false;
|
||||
m_serverSocket.close();
|
||||
// we don't need the adb tunnel anymore
|
||||
disableTunnelReverse();
|
||||
m_tunnelEnabled = false;
|
||||
|
@ -70,21 +65,6 @@ bool Server::pushServer()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Server::removeServer()
|
||||
{
|
||||
AdbProcess* adb = new AdbProcess();
|
||||
if (!adb) {
|
||||
return false;
|
||||
}
|
||||
connect(adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
|
||||
if (AdbProcess::AER_SUCCESS_START != processResult) {
|
||||
sender()->deleteLater();
|
||||
}
|
||||
});
|
||||
adb->removePath(m_serial, DEVICE_SERVER_PATH);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Server::enableTunnelReverse()
|
||||
{
|
||||
if (m_workProcess.isRuning()) {
|
||||
|
@ -217,10 +197,7 @@ bool Server::connectTo()
|
|||
success = false;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
// the server is started, we can clean up the jar from the temporary folder
|
||||
removeServer();
|
||||
m_serverCopiedToDevice = false;
|
||||
if (success) {
|
||||
// we don't need the adb tunnel anymore
|
||||
disableTunnelForward();
|
||||
m_tunnelEnabled = false;
|
||||
|
@ -262,11 +239,7 @@ void Server::stop()
|
|||
}
|
||||
m_tunnelForward = false;
|
||||
m_tunnelEnabled = false;
|
||||
}
|
||||
if (m_serverCopiedToDevice) {
|
||||
removeServer();
|
||||
m_serverCopiedToDevice = false;
|
||||
}
|
||||
}
|
||||
m_serverSocket.close();
|
||||
}
|
||||
|
||||
|
@ -363,7 +336,6 @@ void Server::onWorkProcessResult(AdbProcess::ADB_EXEC_RESULT processResult)
|
|||
switch (m_serverStartStep) {
|
||||
case SSS_PUSH:
|
||||
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
||||
m_serverCopiedToDevice = true;
|
||||
#if 1
|
||||
m_serverStartStep = SSS_ENABLE_TUNNEL_REVERSE;
|
||||
#else
|
||||
|
|
|
@ -66,7 +66,6 @@ private:
|
|||
quint16 m_localPort = 0;
|
||||
bool m_tunnelEnabled = false;
|
||||
bool m_tunnelForward = false; // use "adb forward" instead of "adb reverse"
|
||||
bool m_serverCopiedToDevice = false;
|
||||
quint16 m_maxSize = 0;
|
||||
quint32 m_bitRate = 0;
|
||||
QString m_crop = "";
|
||||
|
|
|
@ -14,7 +14,7 @@ public final class DesktopConnection implements Closeable {
|
|||
|
||||
private static final int DEVICE_NAME_FIELD_LENGTH = 64;
|
||||
|
||||
private static final String SOCKET_NAME = "scrcpy";
|
||||
private static final String SOCKET_NAME = "qtscrcpy";
|
||||
|
||||
private final LocalSocket socket;
|
||||
private final InputStream inputStream;
|
||||
|
|
|
@ -2,10 +2,14 @@ package com.genymobile.scrcpy;
|
|||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class Server {
|
||||
|
||||
private static final String SERVER_PATH = "/data/local/tmp/scrcpy-server.jar";
|
||||
|
||||
private Server() {
|
||||
// not instantiable
|
||||
}
|
||||
|
@ -82,6 +86,14 @@ public final class Server {
|
|||
return new Rect(x, y, x + width, y + height);
|
||||
}
|
||||
|
||||
private static void unlinkSelf() {
|
||||
try {
|
||||
new File(SERVER_PATH).delete();
|
||||
} catch (Exception e) {
|
||||
Ln.e("Cannot unlink server", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
|
@ -90,6 +102,7 @@ public final class Server {
|
|||
}
|
||||
});
|
||||
|
||||
unlinkSelf();
|
||||
Options options = createOptions(args);
|
||||
scrcpy(options);
|
||||
}
|
||||
|
|
BIN
third_party/scrcpy-server.jar
vendored
BIN
third_party/scrcpy-server.jar
vendored
Binary file not shown.
Loading…
Add table
Reference in a new issue