Skip to content

Display and control your Android device

Rename 'uid' to 'scid'

Romain Vimont439a1fd4ed3d
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index bf4bb199..8932dd1d 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -273,8 +273,9 @@ sc_server_on_disconnected(struct sc_server *server, void *userdata) {
// event
}
+// Generate a scrcpy id to differentiate multiple running scrcpy instances
static uint32_t
-scrcpy_generate_uid() {
+scrcpy_generate_scid() {
struct sc_rand rand;
sc_rand_init(&rand);
// Only use 31 bits to avoid issues with signed values on the Java-side
@@ -314,10 +315,10 @@ scrcpy(struct scrcpy_options *options) {
struct sc_acksync *acksync = NULL;
- uint32_t uid = scrcpy_generate_uid();
+ uint32_t scid = scrcpy_generate_scid();
struct sc_server_params params = {
- .uid = uid,
+ .scid = scid,
.req_serial = options->serial,
.select_usb = options->select_usb,
.select_tcpip = options->select_tcpip,
diff --git a/app/src/server.c b/app/src/server.c
index 74d318c8..96bff77e 100644
--- a/app/src/server.c
+++ b/app/src/server.c
@@ -213,7 +213,7 @@ execute_server(struct sc_server *server,
cmd[count++] = p; \
}
- ADD_PARAM("uid=%08x", params->uid);
+ ADD_PARAM("scid=%08x", params->scid);
ADD_PARAM("log_level=%s", log_level_to_server_string(params->log_level));
ADD_PARAM("bit_rate=%" PRIu32, params->bit_rate);
@@ -787,7 +787,7 @@ run_server(void *data) {
LOGD("Device serial: %s", serial);
int r = asprintf(&server->device_socket_name, SC_SOCKET_NAME_PREFIX "%08x",
- params->uid);
+ params->scid);
if (r == -1) {
LOG_OOM();
goto error_connection_failed;
diff --git a/app/src/server.h b/app/src/server.h
index 950ad532..d6b1401e 100644
--- a/app/src/server.h
+++ b/app/src/server.h
@@ -22,7 +22,7 @@ struct sc_server_info {
};
struct sc_server_params {
- uint32_t uid;
+ uint32_t scid;
const char *req_serial;
enum sc_log_level log_level;
enum sc_codec codec;
diff --git a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java
index 7f287a6a..1f8f46e4 100644
--- a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java
+++ b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java
@@ -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;
diff --git a/server/src/main/java/com/genymobile/scrcpy/Options.java b/server/src/main/java/com/genymobile/scrcpy/Options.java
index 474e5cf2..5c59ec8e 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Options.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Options.java
@@ -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() {
diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java
index cfb45e33..d7a99576 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Server.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java
@@ -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));