mirror of
https://github.com/openflocon/Flocon.git
synced 2026-05-10 00:20:47 +00:00
fix: network config at startup (#205)
Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
parent
5a670b7b9e
commit
2f6f5c3ebe
2 changed files with 19 additions and 4 deletions
|
|
@ -14,6 +14,7 @@ import kotlinx.coroutines.delay
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
object Flocon : FloconApp() {
|
||||
|
||||
|
|
@ -55,9 +56,15 @@ object Flocon : FloconApp() {
|
|||
// if success, just send a bonjour
|
||||
client.send("bonjour", method = "bonjour", body = "bonjour")
|
||||
} catch (t: Throwable) {
|
||||
//t.printStackTrace()
|
||||
delay(3_000)
|
||||
start(client)
|
||||
if(t.message?.contains("CLEARTEXT communication to localhost not permitted by network security policy") == true) {
|
||||
withContext(Dispatchers.Main) {
|
||||
client.displayClearTextError()
|
||||
}
|
||||
} else {
|
||||
//t.printStackTrace()
|
||||
delay(3_000)
|
||||
start(client)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package io.github.openflocon.flocon.client
|
|||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import io.github.openflocon.flocon.FloconApp
|
||||
import io.github.openflocon.flocon.Protocol
|
||||
import io.github.openflocon.flocon.core.FloconPlugin
|
||||
|
|
@ -28,7 +30,7 @@ import kotlinx.coroutines.SupervisorJob
|
|||
import kotlinx.coroutines.launch
|
||||
|
||||
internal class FloconClientImpl(
|
||||
appContext: Context,
|
||||
private val appContext: Context,
|
||||
) : FloconApp.Client {
|
||||
|
||||
private val FLOCON_PORT = 9023
|
||||
|
|
@ -185,4 +187,10 @@ internal class FloconClientImpl(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun displayClearTextError() {
|
||||
|
||||
Toast.makeText(appContext, "Cannot start Flocon : ClearText Issue, see Logcat", Toast.LENGTH_LONG).show()
|
||||
Log.e("Flocon", "Flocon uses ClearText communication to the server, it seems you already have a network-security-config setup on your project, please ensure you allowed cleartext communication on your debug app https://github.com/openflocon/Flocon?tab=readme-ov-file#-why-flocon-cant-see-your-device-calls-and-how-to-fix-it-")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue