@ -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 )