App.kt: fix Quick tailscale (#256)

-Once we edit prefs with wantRunning, also update QuickToggleService
-Start Notifier in App so that we are observing tile status

Closes #ENG-2869

Updates tailscale/corp#18202

Signed-off-by: kari-ts <kari@tailscale.com>
pull/257/head
kari-ts 8 months ago committed by GitHub
parent 61fb6bbf8e
commit 4baec5ff80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -119,6 +119,7 @@ class App : Application(), libtailscale.AppContext {
app = Libtailscale.start(dataDir, directFileDir.absolutePath, this) app = Libtailscale.start(dataDir, directFileDir.absolutePath, this)
Request.setApp(app) Request.setApp(app)
Notifier.setApp(app) Notifier.setApp(app)
Notifier.start(applicationScope)
connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
setAndRegisterNetworkCallbacks() setAndRegisterNetworkCallbacks()
createNotificationChannel( createNotificationChannel(
@ -141,9 +142,13 @@ class App : Application(), libtailscale.AppContext {
fun setWantRunning(wantRunning: Boolean) { fun setWantRunning(wantRunning: Boolean) {
val callback: (Result<Ipn.Prefs>) -> Unit = { result -> val callback: (Result<Ipn.Prefs>) -> Unit = { result ->
result.exceptionOrNull()?.let { error -> result.fold(
Log.e(TAG, "Set want running: failed to update preferences: ${error.message}") onSuccess = { _ ->
} setTileStatus(wantRunning)
},
onFailure = { error ->
Log.d("TAG", "Set want running: failed to update preferences: ${error.message}")
})
} }
Client(applicationScope) Client(applicationScope)
.editPrefs(Ipn.MaskedPrefs().apply { WantRunning = wantRunning }, callback) .editPrefs(Ipn.MaskedPrefs().apply { WantRunning = wantRunning }, callback)

Loading…
Cancel
Save