# Cloud emulators & real phones

Source: https://olef.dev/docs/cloud/devices

**Outcome:** give your local `olef` commands, CI jobs, or coding agent on-demand Android emulators and real physical phones without provisioning VMs or managing a USB rack.

:::note[Access & billing]
Olef Cloud is currently access-gated; physical phones through Google Cloud's Developer Device Platform (DDP) are in preview. Commands that allocate billed compute or storage confirm spend caps before creating resources.
:::

## 1. Standalone cloud emulators (`ocloud emulator`)

Named cloud emulators keep their apps, accounts, and Quick Boot state on disk while stopped (billed for compute only while running). You can attach any running cloud emulator to local `adb` so every `olef` command drives it directly:

```bash
ocloud emulator create staging-36
ocloud emulator boot staging-36 --attach
olef -d cloud:staging-36 ui dump
ocloud emulator viewer staging-36          # hosted browser viewer URL
ocloud emulator stop staging-36            # saves Quick Boot state, stops compute billing
```

Save and restore clean states before destructive tests, or share an emulator with teammates in your organization:

```bash
ocloud emulator snapshot save staging-36 logged-in
ocloud emulator snapshot load staging-36 logged-in
ocloud emulator share staging-36
```

Need a clean disposable emulator for one script or CI step? Use the crash-safe wrapper, which unconditionally detaches on exit or signal:

```bash
ocloud emulator run staging-36 -- olef test run tests/olef
```

## 2. Real physical phones (Google Cloud DDP, preview)

Reserve real Android phones from Google Cloud's Developer Device Platform and drive them like a local USB device. Sessions can be billed to your own Google Cloud project (`ddp.project` in `.olef/config.json`) or to your Olef Cloud account where enabled (`"billing": "olef"`):

```bash
ocloud devices catalog --physical --available   # specs like ddp:tokay-36
ocloud devices reserve ddp:tokay-36             # attached as 127.0.0.1:<port>
olef -d ddp:tokay-36 app apply                  # any olef command works on it
ocloud devices leases                           # time left, idle time, estimated cost
ocloud devices release ddp:tokay-36
```

In CI or automated scripts, prefer the RAII billing wrapper so a crash or `Ctrl-C` never leaves a paid phone leased:

```bash
ocloud devices run ddp:tokay-36 -- olef test run tests/olef --junit-out build/junit.xml
```

Spend protection is built in: set `ddp.budget_usd_per_day` in `.olef/config.json`, or approve the first daily reservation interactively (default daily cap `$10`). Idle leases release automatically after `ddp.idle_release_ms` (default 10 minutes). See [Configuration](https://olef.dev/docs/concepts/configuration#remote-devices-google-cloud-ddp-preview) for full settings.

## 3. Workspace SSH, port forwards, previews & desktop

A linked cloud workspace is a full Linux development environment, not just an emulator host. Use `ocloud` to interact with it directly:

```bash
ocloud run -- olef app apply               # run remotely and sync project files back
ocloud ssh                                 # plain ssh via short-lived certificate over TCP 443
ocloud ssh-config                          # writes ~/.olef/ssh/config (`ssh olef-<workspace>`)
ocloud forward 8080                        # forward a workspace port to 127.0.0.1
ocloud preview open 5173                   # private browser preview URL (*.olef.site)
ocloud desktop                             # XFCE graphical desktop, terminal, and Chrome
```

Every connection rides outbound HTTPS/WebSockets on TCP 443—no inbound ports or VPN tunnels required. See [Restricted networks & proxies](https://olef.dev/docs/concepts/cloud-network) and [`ocloud emulator`](https://olef.dev/docs/reference/ocloud/emulator) / [`ocloud devices`](https://olef.dev/docs/reference/ocloud/devices).
