mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2025-12-14 23:59:40 +05:00
fix startVpn crashes
This commit is contained in:
Submodule app/src/main/cpp/byedpi updated: ed76be1dad...45d8c7ec7a
@@ -37,9 +37,9 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
super.onStartCommand(intent, flags, startId)
|
|
||||||
return when (intent?.action) {
|
return when (intent?.action) {
|
||||||
"START_VPN" -> {
|
"START_VPN" -> {
|
||||||
|
startForeground(NOTIFICATION_ID, createNotification())
|
||||||
setupProxy()
|
setupProxy()
|
||||||
START_STICKY
|
START_STICKY
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,8 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
else -> {
|
else -> {
|
||||||
START_NOT_STICKY
|
START_NOT_STICKY
|
||||||
}
|
}
|
||||||
|
}.also { result ->
|
||||||
|
super.onStartCommand(intent, flags, startId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +101,6 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
|
|
||||||
private fun setupProxy() {
|
private fun setupProxy() {
|
||||||
if (getActiveStrategy(sharedPreferences).isNotEmpty()) {
|
if (getActiveStrategy(sharedPreferences).isNotEmpty()) {
|
||||||
startForeground(NOTIFICATION_ID, createNotification())
|
|
||||||
try {
|
try {
|
||||||
startSocksProxy()
|
startSocksProxy()
|
||||||
startByeDpi()
|
startByeDpi()
|
||||||
@@ -107,14 +108,15 @@ class ByeDpiVpnService : VpnService() {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("proxy", "Failed to start")
|
Log.e("proxy", "Failed to start")
|
||||||
status = ServiceStatus.Failed
|
status = ServiceStatus.Failed
|
||||||
|
stopSelf()
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@ByeDpiVpnService,
|
this@ByeDpiVpnService,
|
||||||
getString(R.string.toast_no_strategy_selected),
|
getString(R.string.toast_no_strategy_selected),
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
|
stopSelf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user