DalaDev.AppReset (dala_dev v0.4.0)

Copy Markdown View Source

Force-stops Dala app processes on connected devices and optionally wipes their app data — a clean-slate reset without reinstalling.

Exists because a plain Activity restart is not a full restart on Android: BeamForegroundService outlives the Activity, so the BEAM keeps running with old NIFs and BEAMs loaded (see docs/reference/issues.md #11). A reset force-stops both packages — the project bundle and the dala wrapper package (com.dala.<app>) that hosts the foreground service — then clears the logcat buffer so the next launch's output is easy to read.

Summary

Functions

adb argument lists that wipe each package's data (pm clear).

Returns the Android packages to stop: the project bundle id plus the dala wrapper package (com.dala.<app>). Deduplicated — when the bundle id is already the wrapper form there is exactly one entry.

adb argument lists that stop the app and clear the logcat buffer. Pure — no adb calls. Exposed for testing.

simctl argument lists for an iOS simulator: terminate the app (ignored when not running) plus uninstall when wiping data. Pure — no simctl calls.

Resets one device. Returns {:ok, summary} or {:error, reason}.

Resets matching devices (all connected by default).

Resets an explicit device list. Public test seam used by reset_all/1.

Types

opts()

@type opts() :: keyword()

result()

@type result() :: {:ok, String.t()} | {:error, String.t()}

Functions

android_clear_data_commands(serial, packages)

@spec android_clear_data_commands(String.t(), [String.t()]) :: [[String.t()]]

adb argument lists that wipe each package's data (pm clear).

android_packages(opts \\ [])

@spec android_packages(opts()) :: [String.t()]

Returns the Android packages to stop: the project bundle id plus the dala wrapper package (com.dala.<app>). Deduplicated — when the bundle id is already the wrapper form there is exactly one entry.

android_stop_commands(serial, packages)

@spec android_stop_commands(String.t(), [String.t()]) :: [[String.t()]]

adb argument lists that stop the app and clear the logcat buffer. Pure — no adb calls. Exposed for testing.

ios_sim_commands(udid, bundle_id, clear_data?)

@spec ios_sim_commands(String.t(), String.t(), boolean()) :: [
  {[String.t()], boolean()}
]

simctl argument lists for an iOS simulator: terminate the app (ignored when not running) plus uninstall when wiping data. Pure — no simctl calls.

reset(device, opts)

@spec reset(DalaDev.Device.t(), opts()) :: result()

Resets one device. Returns {:ok, summary} or {:error, reason}.

Options:

  • :clear_data - also wipe app data (pm clear / simctl uninstall)
  • :bundle_id - override the resolved bundle id

reset_all(opts \\ [])

@spec reset_all(opts()) :: [{String.t(), result()}]

Resets matching devices (all connected by default).

Options: :device, :clear_data, :bundle_id, plus the test seams :devices (explicit device list) and :exec (command executor override — receives tagged {:adb, args} / {:xcrun, args}, returns {:ok, out} / {:error, out_or_reason}).

Returns a list of {label, result} tuples in discovery order.

reset_devices(devices, opts)

@spec reset_devices([DalaDev.Device.t()], opts()) :: [{String.t(), result()}]

Resets an explicit device list. Public test seam used by reset_all/1.