PatchbayKeepAwakeBridge class final

Opt-in "keep the screen awake" switch with a framework-owned lease.

Why this exists. A device that sleeps mid-session takes the whole UI plane with it: every ui.* and navigation.* request starts answering *LifecycleNotResumed, and after a while the OS freezes the process and the CLI only sees appUnresponsive. Android has an external fix that does not touch the App (adb shell svc power stayon usb); iOS真机 has none — no devicectl, no libimobiledevice equivalent — so on iOS this switch is the only way to keep a long manual session alive.

Why it is off by default. Holding the screen awake changes the behaviour of the App being observed, and screen-off behaviour is itself something a consumer tests. So nothing is engaged until an operator asks, and the ask is bounded: an engagement carries a lease, and when the lease runs out the bridge releases on its own.

Why the lease is the disconnect story. Neither transport gives the App a connection lifecycle — a VM Service extension answers requests and has no idea a CLI died, and a killed terminal sends no goodbye. A hold released only by an explicit off would therefore survive every crashed session and keep the device lit until the battery ran out. The lease inverts that: an operator who is still there renews it, and one who is gone stops renewing, so disconnect and lease expiry are the same event as far as the App can honestly tell. dispose covers the other end — the App tearing the debug surface down while a hold is live.

The reported state is always PatchbayFactSource.appRecorded: it says what the App asked the host to do, never that the screen is in fact lit. Only the consumer's own delegate touches the platform, and Patchbay does not read it back.

Constructors

PatchbayKeepAwakeBridge({required PatchbayGateEvaluator gates, required bool isAppResumed(), required PatchbayLifecycleStateReader lifecycleState, PatchbayKeepAwakeDelegate? delegate, Set<String> gateIds = const <String>{}, String newRequestId()?})

Properties

enabled bool
Whether the App is currently asking the host to hold the screen awake.
no setter
gateIds Set<String>
Consumer gates declared for ui.keepAwake.set, published in the catalog.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
wired bool
Whether a consumer delegate was injected at the composition root.
no setter

Methods

dispose() → void
Releases a live hold as the App tears the debug surface down.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(PatchbayKeepAwakeRequestWire request, {String? requestId}) Future<PatchbayInvocation>
Engages, renews or releases the hold.
status({String? requestId}) Future<PatchbayInvocation>
Reads the current state without touching it.
toString() String
A string representation of this object.
inherited

Operators

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

Constants

defaultLease → const Duration
The lease an engagement takes when the caller names none.
maxLease → const Duration
The longest lease this bridge accepts.