queryLifecycleState function
Best-effort query of the app's lifecycle state via ext.fdb.lifecycle.
Never throws. Bounded by timeout. Uses findFlutterIsolateId rather
than checkFdbHelper because the latter walks the whole element tree,
which can be slow enough on big screens to blow the budget.
Implementation
Future<LifecycleQueryResult> queryLifecycleState({Duration timeout = lifecycleQueryTimeout}) async {
try {
return await _queryLifecycleState().timeout(timeout);
} catch (e) {
// Foreground detection is advisory — never fail the calling command.
return classifyLifecycleQueryError(e, appAlive: _isAppAlive());
}
}