MobDev.TaskTargets (mob_dev v0.7.8)

Copy Markdown View Source

Shared device-selection policy for tasks that can change device state.

A named device is always explicit. Broad selection keeps physical devices behind :all_physical; :all_devices means development emulators and simulators. Combined :all_devices and :all_physical selects every connected device. With no scope flags, exactly one non-physical device may be selected automatically; multiple development devices are an ambiguity error.

resolve/3 honours agent-device leases passed as :leases (MobDev.DeviceLeases): every selection the user did not name skips devices another session has claimed, and a named device that is claimed is used with a warning. A device chosen automatically is always printed.

Summary

Functions

Filter devices by the identifiers accepted by MobDev.Device.match_id?/2.

Resolve a device snapshot into the exact targets for one task run.

Select devices from an already-discovered snapshot.

Types

selection_error()

@type selection_error() ::
  :no_devices
  | :ambiguous_devices
  | :no_matching_devices
  | :no_dev_devices
  | :no_physical_devices
  | :all_claimed

Functions

filter_by_id(devices, ids)

@spec filter_by_id([MobDev.Device.t()], [String.t()]) :: [MobDev.Device.t()]

Filter devices by the identifiers accepted by MobDev.Device.match_id?/2.

resolve(all, device_ids, opts)

@spec resolve([MobDev.Device.t()], [String.t()], keyword()) ::
  {:ok, [MobDev.Device.t()]} | {:error, selection_error(), map()}

Resolve a device snapshot into the exact targets for one task run.

opts[:leases] is the MobDev.DeviceLeases snapshot to honour (default: no claims). Skipped, warned-about and auto-selected devices are printed.

select(all, device_ids, opts)

@spec select([MobDev.Device.t()], [String.t()], keyword()) :: [MobDev.Device.t()]

Select devices from an already-discovered snapshot.

Precedence is named devices, both broad flags, development devices, physical devices, then safe single-development-device auto-selection.