Fix android build connection
This commit is contained in:
@@ -38,6 +38,13 @@ object Settings {
|
|||||||
get() = preferences.getString(SettingsKey.CONFIG_OPTIONS, "") ?: ""
|
get() = preferences.getString(SettingsKey.CONFIG_OPTIONS, "") ?: ""
|
||||||
set(value) = preferences.edit().putString(SettingsKey.CONFIG_OPTIONS, value).apply()
|
set(value) = preferences.edit().putString(SettingsKey.CONFIG_OPTIONS, value).apply()
|
||||||
|
|
||||||
|
var debugMode: Boolean
|
||||||
|
get() = preferences.getBoolean(SettingsKey.DEBUG_MODE, false)
|
||||||
|
set(value) = preferences.edit().putBoolean(SettingsKey.DEBUG_MODE, value).apply()
|
||||||
|
|
||||||
|
val enableTun: Boolean
|
||||||
|
get() = preferences.getBoolean(SettingsKey.ENABLE_TUN, true)
|
||||||
|
|
||||||
var disableMemoryLimit: Boolean
|
var disableMemoryLimit: Boolean
|
||||||
get() = preferences.getBoolean(SettingsKey.DISABLE_MEMORY_LIMIT, false)
|
get() = preferences.getBoolean(SettingsKey.DISABLE_MEMORY_LIMIT, false)
|
||||||
set(value) = preferences.edit().putBoolean(SettingsKey.DISABLE_MEMORY_LIMIT, value).apply()
|
set(value) = preferences.edit().putBoolean(SettingsKey.DISABLE_MEMORY_LIMIT, value).apply()
|
||||||
@@ -73,6 +80,7 @@ object Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun needVPNService(): Boolean {
|
private suspend fun needVPNService(): Boolean {
|
||||||
|
if(enableTun) return true
|
||||||
val filePath = activeConfigPath
|
val filePath = activeConfigPath
|
||||||
if (filePath.isBlank()) return false
|
if (filePath.isBlank()) return false
|
||||||
val content = JSONObject(File(filePath).readText())
|
val content = JSONObject(File(filePath).readText())
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ class BoxService(
|
|||||||
private const val TAG = "A/BoxService"
|
private const val TAG = "A/BoxService"
|
||||||
|
|
||||||
private var initializeOnce = false
|
private var initializeOnce = false
|
||||||
|
private lateinit var workingDir: File
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
if (initializeOnce) return
|
if (initializeOnce) return
|
||||||
val baseDir = Application.application.filesDir
|
val baseDir = Application.application.filesDir
|
||||||
baseDir.mkdirs()
|
baseDir.mkdirs()
|
||||||
val workingDir = Application.application.getExternalFilesDir(null) ?: return
|
workingDir = Application.application.getExternalFilesDir(null) ?: return
|
||||||
workingDir.mkdirs()
|
workingDir.mkdirs()
|
||||||
val tempDir = Application.application.cacheDir
|
val tempDir = Application.application.cacheDir
|
||||||
tempDir.mkdirs()
|
tempDir.mkdirs()
|
||||||
@@ -156,6 +157,10 @@ class BoxService(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Settings.debugMode) {
|
||||||
|
File(workingDir, "current-config.json").writeText(content)
|
||||||
|
}
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
binder.broadcast {
|
binder.broadcast {
|
||||||
it.onServiceResetLogs(listOf())
|
it.onServiceResetLogs(listOf())
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ interface PlatformInterfaceWrapper : PlatformInterface {
|
|||||||
error("invalid argument")
|
error("invalid argument")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun closeTun() {
|
|
||||||
error("invalid argument")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun useProcFS(): Boolean {
|
override fun useProcFS(): Boolean {
|
||||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
|
return Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,10 +150,6 @@ class VPNService : VpnService(), PlatformInterfaceWrapper {
|
|||||||
return pfd.fd
|
return pfd.fd
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun closeTun() {
|
|
||||||
service.onRevoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun writeLog(message: String) = service.writeLog(message)
|
override fun writeLog(message: String) = service.writeLog(message)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@ object SettingsKey {
|
|||||||
const val PER_APP_PROXY_LIST = "per_app_proxy_list"
|
const val PER_APP_PROXY_LIST = "per_app_proxy_list"
|
||||||
const val PER_APP_PROXY_UPDATE_ON_CHANGE = "per_app_proxy_update_on_change"
|
const val PER_APP_PROXY_UPDATE_ON_CHANGE = "per_app_proxy_update_on_change"
|
||||||
|
|
||||||
|
const val DEBUG_MODE = "${KEY_PREFIX}debug_mode"
|
||||||
|
const val ENABLE_TUN = "${KEY_PREFIX}enable-tun"
|
||||||
const val DISABLE_MEMORY_LIMIT = "${KEY_PREFIX}disable_memory_limit"
|
const val DISABLE_MEMORY_LIMIT = "${KEY_PREFIX}disable_memory_limit"
|
||||||
const val SYSTEM_PROXY_ENABLED = "${KEY_PREFIX}system_proxy_enabled"
|
const val SYSTEM_PROXY_ENABLED = "${KEY_PREFIX}system_proxy_enabled"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user