Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/agent-device/edge-request-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,28 @@ describe("the agent-device front's request rules", () => {
expect(reached()).toBe(1);
});

it("`--device` naming the leased phone's own model, which the catalog does not list, reaches the phone daemon as `serial` of the phone, with no `device`", async () => {
const rig = await setUpWithPhone({ phoneModel: "SM-S911U" });
await granted(rig, 1, { physical: true, platform: "android" });
const snapshots = () =>
rig.phone
.rpcRequests("agent_device.command")
.filter((request) => request.params?.["command"] === "snapshot");

await runCommand(rig, "snapshot", 1, { flags: { device: "sm-s911u" } });

const sent = snapshots();
expect(sent).toHaveLength(1);
const flags = flagsOf(sent[0]?.params ?? {});
expect(flags["serial"]).toBe(phoneSerial);
expect(flags).not.toHaveProperty("device");
await refused(
rig,
() => runCommand(rig, "snapshot", 1, { flags: { device: "SM-S918U" } }),
simlockPicks,
);
});

it("`--device` with the leased device's id, and its name with `_` for a space, extra spaces and other letter case, are forwarded unchanged", async () => {
const rig: Rig = await setUp();
rig.fake.nameDeviceInNextReply({ name: "Sim Lock Phone" });
Expand Down
2 changes: 2 additions & 0 deletions src/agent-device/front/request-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ function ruleDeviceSet(unit: Unit): void {

async function namesLeasedModel(check: Check, leased: TokenDevice, name: string): Promise<boolean> {
if (leased.platform === undefined || leased.model === undefined) return false;
// why: an enrolled phone's model need not be in the virtual catalog, and the lease already fixes the device, so its own model names it.
if (name.toLowerCase() === leased.model.toLowerCase()) return true;
try {
const { platforms } = await check.context.dispatch(
"catalog.get",
Expand Down
7 changes: 5 additions & 2 deletions src/agent-device/test-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import {
export const phoneSerial = "R58Y61A60HN";

// why: one Android driver serving a virtual Pixel 8 and an enrolled, present phone, so a test can lease either through the same worker.
export async function setUpWithPhone(options: SetUpOptions = {}): Promise<Rig> {
export async function setUpWithPhone({
phoneModel = "Pixel 8",
...options
}: SetUpOptions & { readonly phoneModel?: string } = {}): Promise<Rig> {
const rig = await setUp({
...options,
drivers: (clock) => [
Expand All @@ -31,7 +34,7 @@ export async function setUpWithPhone(options: SetUpOptions = {}): Promise<Rig> {
knownModels: ["Pixel 8"],
modelClasses: { "Pixel 8": "phone" },
physicalDevices: [
{ class: "phone", ids: [phoneSerial], model: "Pixel 8", osVersion: "15" },
{ class: "phone", ids: [phoneSerial], model: phoneModel, osVersion: "15" },
],
platform: "android",
}),
Expand Down
4 changes: 2 additions & 2 deletions website/src/content/docs/docs/using-devices/agent-device.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ If every matching device is taken, `open` waits up to 330 seconds, then fails wi
- **`close` gives the device back.** Simlock ends the lease and deletes the device; the next agent gets a new one.
- **`install` sends the app from your machine.** agent-device uploads it. A path on the worker is refused.
- **`devices` lists only your devices**, and nothing before `open`.
- **Simlock picks the device.** Do not pass `--udid` or `--serial`. Simlock answers `boot` on a leased device itself; its `id` is the device's UDID on iOS or serial on Android. The agent-device `leaseId` is the Simlock lease id, usable with `/v1/leases/<id>/…`.
- **Simlock picks the device.** Do not pass `--udid` or `--serial`. After `open`, `--device` may name only the leased device: its name, its model in any letter case (an enrolled phone's model too, even when the catalog does not list it), or a catalog alias of that model. `test --device` takes only the names or ids of devices you hold. Simlock answers `boot` on a leased device itself; its `id` is the device's UDID on iOS or serial on Android. The agent-device `leaseId` is the Simlock lease id, usable with `/v1/leases/<id>/…`.
- **A `batch`** can nest at most 8 levels deep and hold at most 1000 steps in all.
- **`orientation` on an iPhone or iPad simulator** (not a foldable iPhone Duo) is done by Simlock, and replies `Rotation requested: landscape-left (unconfirmed)`: it was sent, but nothing confirms it happened. Use `portrait`, `portrait-upside-down`, `landscape-left` or `landscape-right`, or `upside-down`, `left` and `right`. On every other device, and as a `batch` step, agent-device rotates as it normally does.

Expand Down Expand Up @@ -239,7 +239,7 @@ Sign-in errors (`UNAUTHENTICATED`, `FORBIDDEN`) and errors from outside Simlock,
| `refused: name --platform ios or android` | Pass `--platform` to `open`. |
| `refused: boot names no lease; open a device first` | Run `open` before `boot`. |
| `refused: this lease has ended; open a device` | Run `open` again. |
| `refused: simlock picks the device` | Drop `--udid`, `--serial` or a `--device` that names another device. |
| `refused: simlock picks the device` | Drop `--udid`, `--serial` or a `--device` that names another device. The leased device's name or model is accepted, except by `test`, which takes names and ids only. |
| `refused: simlock chooses the device set; run disconnect, then connect proxy without --ios-simulator-device-set` | Do as the message says. |
| `refused: send the app from your machine as an upload` | Give `install` a path on your machine. |
| `No active proxy device lease for this session; run open first.` | The session has no lease, often because parallel agents share one session. Set `AGENT_DEVICE_SESSION` per agent, then `open`. |
Expand Down
Loading