Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(devices): stream physical Android devices #12765

Closedttmx(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12765/headopened View on GitHub

Showing 3 changed files with 62 additions and 9 deletions.

x
0 of 3 viewed, 3 left
16 additions and 0 deletionsapps/server/src/device/DeviceService.tsModified
View file
@@ -93,6 +93,10 @@
serial: Schema.optional(Schema.String),
error: Schema.optional(Schema.String),
});
+const HubStreamModeResult = Schema.Struct({
+ ok: Schema.Literal(true),
+ mode: Schema.Literal("scrcpy"),
+});
​
export interface DeviceScreenshot {
readonly device: DeviceSummary;
@@ -525,6 +529,17 @@
});
​
+ const ensurePhysicalAndroidStream = Effect.fn("DeviceService.ensurePhysicalAndroidStream")(
+ function* (ready: DeviceReadiness, device: DeviceSummary) {
+ if (device.platform !== "android" || !device.physical) return;
+ const url = `${ready.hub.origin}${vendorPrefix("android")}/api/stream-mode?device=${encodeURIComponent(device.id)}`;
+ const request = HttpClientRequest.put(url).pipe(
+ HttpClientRequest.bodyJsonUnsafe({ mode: "scrcpy" }),
+ );
+ yield* hubJson(request, HubStreamModeResult, "select stream source", BOOT_TIMEOUT);
+ },
+ );
+​
/**
* Boot through the hub so its device list and the streaming helper both see
* the device come up. Android AVDs change id when they boot (AVD name to