Skip to content

Commit

Permalink
android: add logging to see what's spamming editPrefs
Browse files Browse the repository at this point in the history
Updates tailscale/tailscale#14125

Signed-off-by: kari-ts <[email protected]>
  • Loading branch information
kari-ts committed Dec 9, 2024
1 parent 45ddef1 commit 70f0356
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions android/src/main/java/com/tailscale/ipn/ui/localapi/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.tailscale.ipn.ui.localapi

import android.content.Context
import com.tailscale.ipn.App
import com.tailscale.ipn.ui.model.BugReportID
import com.tailscale.ipn.ui.model.Errors
import com.tailscale.ipn.ui.model.Ipn
Expand All @@ -13,7 +14,6 @@ import com.tailscale.ipn.ui.model.StableNodeID
import com.tailscale.ipn.ui.model.Tailcfg
import com.tailscale.ipn.ui.util.InputStreamAdapter
import com.tailscale.ipn.util.TSLog
import com.tailscale.ipn.App
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -69,9 +69,7 @@ class Client(private val scope: CoroutineScope) {
private val TAG = Client::class.simpleName

// Access libtailscale.Application lazily
private val app: libtailscale.Application by lazy {
App.get().getLibtailscaleApp()
}
private val app: libtailscale.Application by lazy { App.get().getLibtailscaleApp() }

fun start(options: Ipn.Options, responseHandler: (Result<Unit>) -> Unit) {
val body = Json.encodeToString(options).toByteArray()
Expand Down Expand Up @@ -102,6 +100,14 @@ class Client(private val scope: CoroutineScope) {
}

fun editPrefs(prefs: Ipn.MaskedPrefs, responseHandler: (Result<Ipn.Prefs>) -> Unit) {
// Log the stack trace for debugging purposes for
// https://github.com/tailscale/tailscale/issues/14125
val stackTrace =
Thread.currentThread().stackTrace.joinToString("\n") { element ->
"at ${element.className}.${element.methodName}(${element.fileName}:${element.lineNumber})"
}
TSLog.d("editPrefs", "Called editPrefs with prefs: $prefs\nStack trace:\n$stackTrace")

val body = Json.encodeToString(prefs).toByteArray()
return patch(Endpoint.PREFS, body, responseHandler = responseHandler)
}
Expand Down

0 comments on commit 70f0356

Please sign in to comment.