From 70f03562e1c4aa7258e395b4325e6efbdf8c09fd Mon Sep 17 00:00:00 2001 From: kari-ts Date: Mon, 9 Dec 2024 13:12:14 -0800 Subject: [PATCH] android: add logging to see what's spamming editPrefs Updates tailscale/tailscale#14125 Signed-off-by: kari-ts --- .../java/com/tailscale/ipn/ui/localapi/Client.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/tailscale/ipn/ui/localapi/Client.kt b/android/src/main/java/com/tailscale/ipn/ui/localapi/Client.kt index 5b12338b35..8fc2110381 100644 --- a/android/src/main/java/com/tailscale/ipn/ui/localapi/Client.kt +++ b/android/src/main/java/com/tailscale/ipn/ui/localapi/Client.kt @@ -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 @@ -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 @@ -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) { val body = Json.encodeToString(options).toByteArray() @@ -102,6 +100,14 @@ class Client(private val scope: CoroutineScope) { } fun editPrefs(prefs: Ipn.MaskedPrefs, responseHandler: (Result) -> 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) }