Standardized file naming
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package com.v2ray.ang.service
|
package com.v2ray.ang.handler
|
||||||
|
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
@@ -12,12 +12,10 @@ import android.os.Build
|
|||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.ANG_PACKAGE
|
|
||||||
import com.v2ray.ang.AppConfig.TAG_DIRECT
|
|
||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
import com.v2ray.ang.dto.ProfileItem
|
import com.v2ray.ang.dto.ProfileItem
|
||||||
import com.v2ray.ang.extension.toSpeedString
|
import com.v2ray.ang.extension.toSpeedString
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
import com.v2ray.ang.ui.MainActivity
|
import com.v2ray.ang.ui.MainActivity
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -27,7 +25,7 @@ import kotlinx.coroutines.isActive
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
object NotificationService {
|
object NotificationManager {
|
||||||
private const val NOTIFICATION_ID = 1
|
private const val NOTIFICATION_ID = 1
|
||||||
private const val NOTIFICATION_PENDING_INTENT_CONTENT = 0
|
private const val NOTIFICATION_PENDING_INTENT_CONTENT = 0
|
||||||
private const val NOTIFICATION_PENDING_INTENT_STOP_V2RAY = 1
|
private const val NOTIFICATION_PENDING_INTENT_STOP_V2RAY = 1
|
||||||
@@ -50,7 +48,7 @@ object NotificationService {
|
|||||||
lastQueryTime = System.currentTimeMillis()
|
lastQueryTime = System.currentTimeMillis()
|
||||||
var lastZeroSpeed = false
|
var lastZeroSpeed = false
|
||||||
val outboundTags = currentConfig?.getAllOutboundTags()
|
val outboundTags = currentConfig?.getAllOutboundTags()
|
||||||
outboundTags?.remove(TAG_DIRECT)
|
outboundTags?.remove(AppConfig.TAG_DIRECT)
|
||||||
|
|
||||||
speedNotificationJob = CoroutineScope(Dispatchers.IO).launch {
|
speedNotificationJob = CoroutineScope(Dispatchers.IO).launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
@@ -66,15 +64,15 @@ object NotificationService {
|
|||||||
proxyTotal += up + down
|
proxyTotal += up + down
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val directUplink = V2RayServiceManager.queryStats(TAG_DIRECT, AppConfig.UPLINK)
|
val directUplink = V2RayServiceManager.queryStats(AppConfig.TAG_DIRECT, AppConfig.UPLINK)
|
||||||
val directDownlink = V2RayServiceManager.queryStats(TAG_DIRECT, AppConfig.DOWNLINK)
|
val directDownlink = V2RayServiceManager.queryStats(AppConfig.TAG_DIRECT, AppConfig.DOWNLINK)
|
||||||
val zeroSpeed = proxyTotal == 0L && directUplink == 0L && directDownlink == 0L
|
val zeroSpeed = proxyTotal == 0L && directUplink == 0L && directDownlink == 0L
|
||||||
if (!zeroSpeed || !lastZeroSpeed) {
|
if (!zeroSpeed || !lastZeroSpeed) {
|
||||||
if (proxyTotal == 0L) {
|
if (proxyTotal == 0L) {
|
||||||
appendSpeedString(text, outboundTags?.firstOrNull(), 0.0, 0.0)
|
appendSpeedString(text, outboundTags?.firstOrNull(), 0.0, 0.0)
|
||||||
}
|
}
|
||||||
appendSpeedString(
|
appendSpeedString(
|
||||||
text, TAG_DIRECT, directUplink / sinceLastQueryInSeconds,
|
text, AppConfig.TAG_DIRECT, directUplink / sinceLastQueryInSeconds,
|
||||||
directDownlink / sinceLastQueryInSeconds
|
directDownlink / sinceLastQueryInSeconds
|
||||||
)
|
)
|
||||||
updateNotification(text.toString(), proxyTotal, directDownlink + directUplink)
|
updateNotification(text.toString(), proxyTotal, directDownlink + directUplink)
|
||||||
@@ -102,12 +100,12 @@ object NotificationService {
|
|||||||
val contentPendingIntent = PendingIntent.getActivity(service, NOTIFICATION_PENDING_INTENT_CONTENT, startMainIntent, flags)
|
val contentPendingIntent = PendingIntent.getActivity(service, NOTIFICATION_PENDING_INTENT_CONTENT, startMainIntent, flags)
|
||||||
|
|
||||||
val stopV2RayIntent = Intent(AppConfig.BROADCAST_ACTION_SERVICE)
|
val stopV2RayIntent = Intent(AppConfig.BROADCAST_ACTION_SERVICE)
|
||||||
stopV2RayIntent.`package` = ANG_PACKAGE
|
stopV2RayIntent.`package` = AppConfig.ANG_PACKAGE
|
||||||
stopV2RayIntent.putExtra("key", AppConfig.MSG_STATE_STOP)
|
stopV2RayIntent.putExtra("key", AppConfig.MSG_STATE_STOP)
|
||||||
val stopV2RayPendingIntent = PendingIntent.getBroadcast(service, NOTIFICATION_PENDING_INTENT_STOP_V2RAY, stopV2RayIntent, flags)
|
val stopV2RayPendingIntent = PendingIntent.getBroadcast(service, NOTIFICATION_PENDING_INTENT_STOP_V2RAY, stopV2RayIntent, flags)
|
||||||
|
|
||||||
val restartV2RayIntent = Intent(AppConfig.BROADCAST_ACTION_SERVICE)
|
val restartV2RayIntent = Intent(AppConfig.BROADCAST_ACTION_SERVICE)
|
||||||
restartV2RayIntent.`package` = ANG_PACKAGE
|
restartV2RayIntent.`package` = AppConfig.ANG_PACKAGE
|
||||||
restartV2RayIntent.putExtra("key", AppConfig.MSG_STATE_RESTART)
|
restartV2RayIntent.putExtra("key", AppConfig.MSG_STATE_RESTART)
|
||||||
val restartV2RayPendingIntent = PendingIntent.getBroadcast(service, NOTIFICATION_PENDING_INTENT_RESTART_V2RAY, restartV2RayIntent, flags)
|
val restartV2RayPendingIntent = PendingIntent.getBroadcast(service, NOTIFICATION_PENDING_INTENT_RESTART_V2RAY, restartV2RayIntent, flags)
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.v2ray.ang.util
|
package com.v2ray.ang.handler
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
@@ -7,11 +7,12 @@ import com.v2ray.ang.AppConfig
|
|||||||
import com.v2ray.ang.dto.EConfigType
|
import com.v2ray.ang.dto.EConfigType
|
||||||
import com.v2ray.ang.dto.ProfileItem
|
import com.v2ray.ang.dto.ProfileItem
|
||||||
import com.v2ray.ang.fmt.Hysteria2Fmt
|
import com.v2ray.ang.fmt.Hysteria2Fmt
|
||||||
import com.v2ray.ang.handler.SpeedtestManager
|
|
||||||
import com.v2ray.ang.service.ProcessService
|
import com.v2ray.ang.service.ProcessService
|
||||||
|
import com.v2ray.ang.util.JsonUtil
|
||||||
|
import com.v2ray.ang.util.Utils
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
object PluginUtil {
|
object PluginServiceManager {
|
||||||
private const val HYSTERIA2 = "libhysteria2.so"
|
private const val HYSTERIA2 = "libhysteria2.so"
|
||||||
|
|
||||||
private val procService: ProcessService by lazy {
|
private val procService: ProcessService by lazy {
|
||||||
@@ -137,4 +138,4 @@ object PluginUtil {
|
|||||||
Log.e(AppConfig.TAG, "Failed to stop Hysteria2 process", e)
|
Log.e(AppConfig.TAG, "Failed to stop Hysteria2 process", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.v2ray.ang.service
|
package com.v2ray.ang.handler
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
@@ -11,11 +11,7 @@ import androidx.core.app.NotificationManagerCompat
|
|||||||
import androidx.work.CoroutineWorker
|
import androidx.work.CoroutineWorker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.SUBSCRIPTION_UPDATE_CHANNEL
|
|
||||||
import com.v2ray.ang.AppConfig.SUBSCRIPTION_UPDATE_CHANNEL_NAME
|
|
||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
import com.v2ray.ang.handler.AngConfigManager.updateConfigViaSub
|
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
|
||||||
|
|
||||||
object SubscriptionUpdater {
|
object SubscriptionUpdater {
|
||||||
|
|
||||||
@@ -24,7 +20,7 @@ object SubscriptionUpdater {
|
|||||||
|
|
||||||
private val notificationManager = NotificationManagerCompat.from(applicationContext)
|
private val notificationManager = NotificationManagerCompat.from(applicationContext)
|
||||||
private val notification =
|
private val notification =
|
||||||
NotificationCompat.Builder(applicationContext, SUBSCRIPTION_UPDATE_CHANNEL)
|
NotificationCompat.Builder(applicationContext, AppConfig.SUBSCRIPTION_UPDATE_CHANNEL)
|
||||||
.setWhen(0)
|
.setWhen(0)
|
||||||
.setTicker("Update")
|
.setTicker("Update")
|
||||||
.setContentTitle(context.getString(R.string.title_pref_auto_update_subscription))
|
.setContentTitle(context.getString(R.string.title_pref_auto_update_subscription))
|
||||||
@@ -46,18 +42,18 @@ object SubscriptionUpdater {
|
|||||||
val subItem = sub.second
|
val subItem = sub.second
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
notification.setChannelId(SUBSCRIPTION_UPDATE_CHANNEL)
|
notification.setChannelId(AppConfig.SUBSCRIPTION_UPDATE_CHANNEL)
|
||||||
val channel =
|
val channel =
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
SUBSCRIPTION_UPDATE_CHANNEL,
|
AppConfig.SUBSCRIPTION_UPDATE_CHANNEL,
|
||||||
SUBSCRIPTION_UPDATE_CHANNEL_NAME,
|
AppConfig.SUBSCRIPTION_UPDATE_CHANNEL_NAME,
|
||||||
NotificationManager.IMPORTANCE_MIN
|
NotificationManager.IMPORTANCE_MIN
|
||||||
)
|
)
|
||||||
notificationManager.createNotificationChannel(channel)
|
notificationManager.createNotificationChannel(channel)
|
||||||
}
|
}
|
||||||
notificationManager.notify(3, notification.build())
|
notificationManager.notify(3, notification.build())
|
||||||
Log.i(AppConfig.TAG, "subscription automatic update: ---${subItem.remarks}")
|
Log.i(AppConfig.TAG, "subscription automatic update: ---${subItem.remarks}")
|
||||||
updateConfigViaSub(Pair(sub.first, subItem))
|
AngConfigManager.updateConfigViaSub(Pair(sub.first, subItem))
|
||||||
notification.setContentText("Updating ${subItem.remarks}")
|
notification.setContentText("Updating ${subItem.remarks}")
|
||||||
}
|
}
|
||||||
notificationManager.cancel(3)
|
notificationManager.cancel(3)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.v2ray.ang.service
|
package com.v2ray.ang.handler
|
||||||
|
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
@@ -13,12 +13,11 @@ import com.v2ray.ang.R
|
|||||||
import com.v2ray.ang.dto.EConfigType
|
import com.v2ray.ang.dto.EConfigType
|
||||||
import com.v2ray.ang.dto.ProfileItem
|
import com.v2ray.ang.dto.ProfileItem
|
||||||
import com.v2ray.ang.extension.toast
|
import com.v2ray.ang.extension.toast
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.service.ServiceControl
|
||||||
import com.v2ray.ang.handler.SettingsManager
|
import com.v2ray.ang.service.V2RayProxyOnlyService
|
||||||
import com.v2ray.ang.handler.SpeedtestManager
|
import com.v2ray.ang.service.V2RayVpnService
|
||||||
import com.v2ray.ang.handler.V2rayConfigManager
|
|
||||||
import com.v2ray.ang.util.MessageUtil
|
import com.v2ray.ang.util.MessageUtil
|
||||||
import com.v2ray.ang.util.PluginUtil
|
import com.v2ray.ang.handler.PluginServiceManager
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import go.Seq
|
import go.Seq
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -163,16 +162,16 @@ object V2RayServiceManager {
|
|||||||
|
|
||||||
if (coreController.isRunning == false) {
|
if (coreController.isRunning == false) {
|
||||||
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_FAILURE, "")
|
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_FAILURE, "")
|
||||||
NotificationService.cancelNotification()
|
NotificationManager.cancelNotification()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_SUCCESS, "")
|
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_SUCCESS, "")
|
||||||
NotificationService.showNotification(currentConfig)
|
NotificationManager.showNotification(currentConfig)
|
||||||
NotificationService.startSpeedNotification(currentConfig)
|
NotificationManager.startSpeedNotification(currentConfig)
|
||||||
|
|
||||||
PluginUtil.runPlugin(service, config, result.socksPort)
|
PluginServiceManager.runPlugin(service, config, result.socksPort)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(AppConfig.TAG, "Failed to startup service", e)
|
Log.e(AppConfig.TAG, "Failed to startup service", e)
|
||||||
return false
|
return false
|
||||||
@@ -199,14 +198,14 @@ object V2RayServiceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_STOP_SUCCESS, "")
|
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_STOP_SUCCESS, "")
|
||||||
NotificationService.cancelNotification()
|
NotificationManager.cancelNotification()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
service.unregisterReceiver(mMsgReceive)
|
service.unregisterReceiver(mMsgReceive)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(AppConfig.TAG, "Failed to unregister broadcast receiver", e)
|
Log.e(AppConfig.TAG, "Failed to unregister broadcast receiver", e)
|
||||||
}
|
}
|
||||||
PluginUtil.stopPlugin()
|
PluginServiceManager.stopPlugin()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -364,14 +363,14 @@ object V2RayServiceManager {
|
|||||||
when (intent?.action) {
|
when (intent?.action) {
|
||||||
Intent.ACTION_SCREEN_OFF -> {
|
Intent.ACTION_SCREEN_OFF -> {
|
||||||
Log.i(AppConfig.TAG, "SCREEN_OFF, stop querying stats")
|
Log.i(AppConfig.TAG, "SCREEN_OFF, stop querying stats")
|
||||||
NotificationService.stopSpeedNotification(currentConfig)
|
NotificationManager.stopSpeedNotification(currentConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent.ACTION_SCREEN_ON -> {
|
Intent.ACTION_SCREEN_ON -> {
|
||||||
Log.i(AppConfig.TAG, "SCREEN_ON, start querying stats")
|
Log.i(AppConfig.TAG, "SCREEN_ON, start querying stats")
|
||||||
NotificationService.startSpeedNotification(currentConfig)
|
NotificationManager.startSpeedNotification(currentConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
import com.v2ray.ang.service.V2RayServiceManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
|
|
||||||
class BootReceiver : BroadcastReceiver() {
|
class BootReceiver : BroadcastReceiver() {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.service.V2RayServiceManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
|
|
||||||
class TaskerReceiver : BroadcastReceiver() {
|
class TaskerReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import android.os.Build
|
|||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
import com.v2ray.ang.service.V2RayServiceManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
|
|
||||||
class WidgetProvider : AppWidgetProvider() {
|
class WidgetProvider : AppWidgetProvider() {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
import com.v2ray.ang.util.MessageUtil
|
import com.v2ray.ang.util.MessageUtil
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import java.lang.ref.SoftReference
|
import java.lang.ref.SoftReference
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.io.File
|
|||||||
/**
|
/**
|
||||||
* Manages the tun2socks process that handles VPN traffic
|
* Manages the tun2socks process that handles VPN traffic
|
||||||
*/
|
*/
|
||||||
class Tun2SocksManager(
|
class Tun2SocksService(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val vpnInterface: ParcelFileDescriptor,
|
private val vpnInterface: ParcelFileDescriptor,
|
||||||
private val isRunningProvider: () -> Boolean,
|
private val isRunningProvider: () -> Boolean,
|
||||||
@@ -7,6 +7,7 @@ import android.os.Build
|
|||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.v2ray.ang.handler.SettingsManager
|
import com.v2ray.ang.handler.SettingsManager
|
||||||
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
import com.v2ray.ang.util.MyContextWrapper
|
import com.v2ray.ang.util.MyContextWrapper
|
||||||
import java.lang.ref.SoftReference
|
import java.lang.ref.SoftReference
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG_SUCCESS
|
|||||||
import com.v2ray.ang.dto.EConfigType
|
import com.v2ray.ang.dto.EConfigType
|
||||||
import com.v2ray.ang.extension.serializable
|
import com.v2ray.ang.extension.serializable
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
|
import com.v2ray.ang.handler.PluginServiceManager
|
||||||
import com.v2ray.ang.handler.SpeedtestManager
|
import com.v2ray.ang.handler.SpeedtestManager
|
||||||
import com.v2ray.ang.handler.V2rayConfigManager
|
import com.v2ray.ang.handler.V2rayConfigManager
|
||||||
import com.v2ray.ang.util.MessageUtil
|
import com.v2ray.ang.util.MessageUtil
|
||||||
import com.v2ray.ang.util.PluginUtil
|
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import go.Seq
|
import go.Seq
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -78,7 +78,7 @@ class V2RayTestService : Service() {
|
|||||||
|
|
||||||
val config = MmkvManager.decodeServerConfig(guid) ?: return retFailure
|
val config = MmkvManager.decodeServerConfig(guid) ?: return retFailure
|
||||||
if (config.configType == EConfigType.HYSTERIA2) {
|
if (config.configType == EConfigType.HYSTERIA2) {
|
||||||
val delay = PluginUtil.realPingHy2(this, config)
|
val delay = PluginServiceManager.realPingHy2(this, config)
|
||||||
return delay
|
return delay
|
||||||
} else {
|
} else {
|
||||||
val configResult = V2rayConfigManager.getV2rayConfig4Speedtest(this, guid)
|
val configResult = V2rayConfigManager.getV2rayConfig4Speedtest(this, guid)
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ import com.v2ray.ang.AppConfig.LOOPBACK
|
|||||||
import com.v2ray.ang.AppConfig.VPN_MTU
|
import com.v2ray.ang.AppConfig.VPN_MTU
|
||||||
import com.v2ray.ang.BuildConfig
|
import com.v2ray.ang.BuildConfig
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
|
import com.v2ray.ang.handler.NotificationManager
|
||||||
import com.v2ray.ang.handler.SettingsManager
|
import com.v2ray.ang.handler.SettingsManager
|
||||||
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
import com.v2ray.ang.util.MyContextWrapper
|
import com.v2ray.ang.util.MyContextWrapper
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import java.lang.ref.SoftReference
|
import java.lang.ref.SoftReference
|
||||||
@@ -28,7 +30,7 @@ import java.lang.ref.SoftReference
|
|||||||
class V2RayVpnService : VpnService(), ServiceControl {
|
class V2RayVpnService : VpnService(), ServiceControl {
|
||||||
private lateinit var mInterface: ParcelFileDescriptor
|
private lateinit var mInterface: ParcelFileDescriptor
|
||||||
private var isRunning = false
|
private var isRunning = false
|
||||||
private var tun2SocksManager: Tun2SocksManager? = null
|
private var tun2SocksService: Tun2SocksService? = null
|
||||||
|
|
||||||
/**destroy
|
/**destroy
|
||||||
* Unfortunately registerDefaultNetworkCallback is going to return our VPN interface: https://android.googlesource.com/platform/frameworks/base/+/dda156ab0c5d66ad82bdcf76cda07cbc0a9c8a2e
|
* Unfortunately registerDefaultNetworkCallback is going to return our VPN interface: https://android.googlesource.com/platform/frameworks/base/+/dda156ab0c5d66ad82bdcf76cda07cbc0a9c8a2e
|
||||||
@@ -85,7 +87,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
NotificationService.cancelNotification()
|
NotificationManager.cancelNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
@@ -271,7 +273,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
|||||||
* Starts the tun2socks process with the appropriate parameters.
|
* Starts the tun2socks process with the appropriate parameters.
|
||||||
*/
|
*/
|
||||||
private fun runTun2socks() {
|
private fun runTun2socks() {
|
||||||
tun2SocksManager = Tun2SocksManager(
|
tun2SocksService = Tun2SocksService(
|
||||||
context = applicationContext,
|
context = applicationContext,
|
||||||
vpnInterface = mInterface,
|
vpnInterface = mInterface,
|
||||||
isRunningProvider = { isRunning },
|
isRunningProvider = { isRunning },
|
||||||
@@ -299,8 +301,8 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tun2SocksManager?.stopTun2Socks()
|
tun2SocksService?.stopTun2Socks()
|
||||||
tun2SocksManager = null
|
tun2SocksService = null
|
||||||
|
|
||||||
V2RayServiceManager.stopCoreLoop()
|
V2RayServiceManager.stopCoreLoop()
|
||||||
|
|
||||||
@@ -320,3 +322,4 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import com.v2ray.ang.handler.AngConfigManager
|
|||||||
import com.v2ray.ang.handler.MigrateManager
|
import com.v2ray.ang.handler.MigrateManager
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
import com.v2ray.ang.helper.SimpleItemTouchHelperCallback
|
import com.v2ray.ang.helper.SimpleItemTouchHelperCallback
|
||||||
import com.v2ray.ang.service.V2RayServiceManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import com.v2ray.ang.viewmodel.MainViewModel
|
import com.v2ray.ang.viewmodel.MainViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.v2ray.ang.handler.AngConfigManager
|
|||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
import com.v2ray.ang.helper.ItemTouchHelperAdapter
|
import com.v2ray.ang.helper.ItemTouchHelperAdapter
|
||||||
import com.v2ray.ang.helper.ItemTouchHelperViewHolder
|
import com.v2ray.ang.helper.ItemTouchHelperViewHolder
|
||||||
import com.v2ray.ang.service.V2RayServiceManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.v2ray.ang.ui
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
import com.v2ray.ang.service.V2RayServiceManager
|
import com.v2ray.ang.handler.V2RayServiceManager
|
||||||
|
|
||||||
class ScSwitchActivity : BaseActivity() {
|
class ScSwitchActivity : BaseActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import com.v2ray.ang.AppConfig.VPN
|
|||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
import com.v2ray.ang.extension.toLongEx
|
import com.v2ray.ang.extension.toLongEx
|
||||||
import com.v2ray.ang.handler.MmkvManager
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
import com.v2ray.ang.service.SubscriptionUpdater
|
import com.v2ray.ang.handler.SubscriptionUpdater
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
import com.v2ray.ang.viewmodel.SettingsViewModel
|
import com.v2ray.ang.viewmodel.SettingsViewModel
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|||||||
Reference in New Issue
Block a user