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

Loading…
Cancel
Save