Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions android/src/main/java/com/tailscale/ipn/ui/localapi/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ class Client(private val scope: CoroutineScope) {
// Access libtailscale.Application lazily
private val app: libtailscale.Application by lazy { App.get().getLibtailscaleApp() }

init {
// Force the lazy `app` property to evaluate now, at construction time, instead of
// waiting for something to read it. This guarantees App.get() (and therefore
// Request.setApp()) has run before this Client can be used to execute a Request,
// even if the very first caller is a background WorkManager task on a cold-started
// process that never otherwise touches App.get(). Without this, `app` was declared
// but never read anywhere in this class, so it never actually forced initialization
// (see #563, which added this property with that intent but never wired it up).
app
}

fun start(options: Ipn.Options, responseHandler: (Result<Unit>) -> Unit) {
val body = Json.encodeToString(options).toByteArray()
return post(Endpoint.START, body, responseHandler = responseHandler)
Expand Down