DeviceDiscovery class

Finds running Flutter apps + booted devices so attach can auto-fill omitted args. Pure host inspection: ps for VM URIs, xcrun simctl for iOS sims, adb devices for Android.

Constructors

DeviceDiscovery({String adbPath = 'adb'})
const

Properties

adbPath → String
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

androidPackageForPid(String serial, int pid) → Future<String?>
The Android package whose process is pid on serial, or null when adb cannot tell.
appInfoForDevice(String udid) → Future<(String?, String?)?>
(CFBundleIdentifier, display name) of the user app running on iOS udid, found by its Containers/Bundle/Application/…app process — device-global, NOT correlated to our VM. Fallback only, for when the project dir is unknown; prefer appInfoForProject.
appInfoForProject(String projectDir) → Future<(String?, String?)?>
(CFBundleIdentifier, display name) from the app flutter built for projectDir. Tied to the exact project behind our VM (projectDirForVm), so it can't grab a different app that also ran on the device. Null when no built product exists (e.g. attached to an app we didn't build here).
correlate(Uri vmUri, DevicePlatform platform) → Future<AppDeviceLink?>
describeRunningApps(DiscoveryResult scan) → Future<List<RunningApp>>
Recover the device an app runs on from its VM service URI — when several sims share 127.0.0.1 the port is ambiguous, but the listening process reveals its sim. Describe every running app in scan: device (iOS via the flutter_tools process chain, Android via adb forward) plus bundle identity when the app's Info.plist is reachable. Best-effort per app; never throws.
foregroundPackage(String serial) → Future<String?>
Whether deviceId is still booted / connected — the cheap check behind deviceGone, so a closed simulator is named instead of guessed at. The package in front on Android device serial (e.g. the launcher), or null when adb cannot tell.
goneReasons(Iterable<({String id, DevicePlatform platform})> devices) → Future<Map<String, String>>
Why each of devices is gone from the host, keyed by id; one adb devices and one simctl list at most, run together. A device the host could not be asked about, and a physical iPhone, is left out.
isDevicePresent(String deviceId, DevicePlatform platform) → Future<bool>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
projectDirForVm(Uri vmUri) → Future<String?>
Flutter project root behind a running app: the cwd of the DDS serving vmUri (its listener, or the DDS fronting that raw VM port) or of its flutter run parent, when that folder is a Flutter app.
scan() → Future<DiscoveryResult>
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

appBundlePathsForDevice(String output, String udid) → List<String>
Distinct …app bundle paths for udid found in ps output. More than one means multiple apps share the sim — the caller treats that as ambiguous. Static + pure so it's unit-testable without a live ps.
flutterBundlesFirst(List<String> paths, {required bool isFlutter(String id)}) → List<String>
The Flutter apps among paths when there are any: a VM service belongs to one, so another app on the simulator (glint's own XCTest runner host, a system helper) must not make the device ambiguous.
linkFromCommandLine(String cmd, List<BootedDevice> booted, Future<(String?, String?)?> readBundle(String udid)) → Future<AppDeviceLink?>
Pure: the device link a process command line reveals, if any.