From ed8a1b3573a06b45658946191ebe3d8f310852bc Mon Sep 17 00:00:00 2001 From: kari-ts <135075563+kari-ts@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:12:14 -0800 Subject: [PATCH] android: initialize appInstance early (#561) Also log if get() is still being accessed before onCreate initializes appInstance so we can understand if this is still happening. Also remove a debug log that I forgot to delete. Updates tailscale/tailscale#14125 Signed-off-by: kari-ts --- android/src/main/java/com/tailscale/ipn/App.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/tailscale/ipn/App.kt b/android/src/main/java/com/tailscale/ipn/App.kt index 453a5f4..3e6af12 100644 --- a/android/src/main/java/com/tailscale/ipn/App.kt +++ b/android/src/main/java/com/tailscale/ipn/App.kt @@ -92,6 +92,8 @@ class App : UninitializedApp(), libtailscale.AppContext, ViewModelStoreOwner { override fun onCreate() { super.onCreate() + appInstance = this + setUnprotectedInstance(this) createNotificationChannel( STATUS_CHANNEL_ID, getString(R.string.vpn_status), @@ -107,8 +109,6 @@ class App : UninitializedApp(), libtailscale.AppContext, ViewModelStoreOwner { getString(R.string.health_channel_name), getString(R.string.health_channel_description), NotificationManagerCompat.IMPORTANCE_HIGH) - appInstance = this - setUnprotectedInstance(this) } override fun onTerminate() { @@ -427,7 +427,6 @@ open class UninitializedApp : Application() { fun restartVPN() { // Register a receiver to listen for the completion of stopVPN - TSLog.d("KARI", "hi") val stopReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) {