Rename 'uid' to 'scid'
A random identifier is generated to differentiate multiple running
scrcpy instances. Rename it from 'uid' to 'scid' (scrcpy id) not to
confuse it with Linux UID.
Fixes #3729 <https://github.com/Genymobile/scrcpy/issues/3729>
Refs 4315be1648
This commit is contained in:
@@ -46,17 +46,17 @@ public final class DesktopConnection implements Closeable {
|
||||
return localSocket;
|
||||
}
|
||||
|
||||
private static String getSocketName(int uid) {
|
||||
if (uid == -1) {
|
||||
// If no UID is set, use "scrcpy" to simplify using scrcpy-server alone
|
||||
private static String getSocketName(int scid) {
|
||||
if (scid == -1) {
|
||||
// If no SCID is set, use "scrcpy" to simplify using scrcpy-server alone
|
||||
return SOCKET_NAME_PREFIX;
|
||||
}
|
||||
|
||||
return SOCKET_NAME_PREFIX + String.format("_%08x", uid);
|
||||
return SOCKET_NAME_PREFIX + String.format("_%08x", scid);
|
||||
}
|
||||
|
||||
public static DesktopConnection open(int uid, boolean tunnelForward, boolean control, boolean sendDummyByte) throws IOException {
|
||||
String socketName = getSocketName(uid);
|
||||
public static DesktopConnection open(int scid, boolean tunnelForward, boolean control, boolean sendDummyByte) throws IOException {
|
||||
String socketName = getSocketName(scid);
|
||||
|
||||
LocalSocket videoSocket;
|
||||
LocalSocket controlSocket = null;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
public class Options {
|
||||
|
||||
private Ln.Level logLevel = Ln.Level.DEBUG;
|
||||
private int uid = -1; // 31-bit non-negative value, or -1
|
||||
private int scid = -1; // 31-bit non-negative value, or -1
|
||||
private int maxSize;
|
||||
private VideoCodec codec = VideoCodec.H264;
|
||||
private int bitRate = 8000000;
|
||||
@@ -41,12 +41,12 @@ public class Options {
|
||||
this.logLevel = logLevel;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
public int getScid() {
|
||||
return scid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
public void setScid(int scid) {
|
||||
this.scid = scid;
|
||||
}
|
||||
|
||||
public int getMaxSize() {
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class Server {
|
||||
|
||||
Thread initThread = startInitThread(options);
|
||||
|
||||
int uid = options.getUid();
|
||||
int scid = options.getScid();
|
||||
boolean tunnelForward = options.isTunnelForward();
|
||||
boolean control = options.getControl();
|
||||
boolean sendDummyByte = options.getSendDummyByte();
|
||||
@@ -84,7 +84,7 @@ public final class Server {
|
||||
Workarounds.fillAppInfo();
|
||||
}
|
||||
|
||||
try (DesktopConnection connection = DesktopConnection.open(uid, tunnelForward, control, sendDummyByte)) {
|
||||
try (DesktopConnection connection = DesktopConnection.open(scid, tunnelForward, control, sendDummyByte)) {
|
||||
VideoCodec codec = options.getCodec();
|
||||
if (options.getSendDeviceMeta()) {
|
||||
Size videoSize = device.getScreenInfo().getVideoSize();
|
||||
@@ -158,12 +158,12 @@ public final class Server {
|
||||
String key = arg.substring(0, equalIndex);
|
||||
String value = arg.substring(equalIndex + 1);
|
||||
switch (key) {
|
||||
case "uid":
|
||||
int uid = Integer.parseInt(value, 0x10);
|
||||
if (uid < -1) {
|
||||
throw new IllegalArgumentException("uid may not be negative (except -1 for 'none'): " + uid);
|
||||
case "scid":
|
||||
int scid = Integer.parseInt(value, 0x10);
|
||||
if (scid < -1) {
|
||||
throw new IllegalArgumentException("scid may not be negative (except -1 for 'none'): " + scid);
|
||||
}
|
||||
options.setUid(uid);
|
||||
options.setScid(scid);
|
||||
break;
|
||||
case "log_level":
|
||||
Ln.Level level = Ln.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
|
||||
Reference in New Issue
Block a user