Skip to content

Commit

Permalink
Fix android service mode
Browse files Browse the repository at this point in the history
  • Loading branch information
problematicconsumer committed Dec 21, 2023
1 parent c95b551 commit f62f299
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions android/app/src/main/kotlin/com/hiddify/hiddify/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object Settings {
set(value) = preferences.edit().putString(SettingsKey.ACTIVE_PROFILE_NAME, value).apply()

var serviceMode: String
get() = preferences.getString(SettingsKey.SERVICE_MODE, ServiceMode.NORMAL)!!
get() = preferences.getString(SettingsKey.SERVICE_MODE, ServiceMode.VPN)!!
set(value) = preferences.edit().putString(SettingsKey.SERVICE_MODE, value).apply()

var configOptions: String
Expand Down Expand Up @@ -94,12 +94,15 @@ object Settings {

suspend fun rebuildServiceMode(): Boolean {
var newMode = ServiceMode.NORMAL
try {
if (needVPNService()) {
newMode = ServiceMode.VPN
}
} catch (_: Exception) {
if (serviceMode == ServiceMode.VPN) {
newMode = ServiceMode.VPN
}
// try {
// if (needVPNService()) {
// newMode = ServiceMode.VPN
// }
// } catch (_: Exception) {
// }
if (serviceMode == newMode) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion libcore

0 comments on commit f62f299

Please sign in to comment.