From 3b8615fad0803fde6da35637d822ca24b2b059f7 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 1 May 2026 18:48:43 +0800 Subject: [PATCH] Rename V2Ray components to Core Refactor: rename handler package/classes and services from V2Ray*/V2ray* to Core*/Core (e.g. V2rayConfigManager -> CoreConfigManager, V2RayNativeManager -> CoreNativeManager, V2RayServiceManager -> CoreServiceManager, and service classes V2RayVpnService/V2RayProxyOnlyService/V2RayTestService -> CoreVpnService/CoreProxyOnlyService/CoreTestService). Update AndroidManifest service entries and all imports/usages across the app (notifications, receivers, widgets, UI, services, workers) to reference the renamed classes and package (com.v2ray.ang.core). Comments and references were adjusted to match the new names; no functional logic changes intended. --- V2rayNG/app/src/main/AndroidManifest.xml | 6 ++--- .../CoreConfigManager.kt} | 9 ++++---- .../CoreNativeManager.kt} | 6 ++--- .../CoreServiceManager.kt} | 22 +++++++++++-------- .../com/v2ray/ang/handler/AngConfigManager.kt | 3 ++- .../v2ray/ang/handler/NotificationManager.kt | 13 ++++++----- .../com/v2ray/ang/receiver/BootReceiver.kt | 4 ++-- .../com/v2ray/ang/receiver/TaskerReceiver.kt | 8 +++---- .../com/v2ray/ang/receiver/WidgetProvider.kt | 10 ++++----- ...OnlyService.kt => CoreProxyOnlyService.kt} | 10 ++++----- ...V2RayTestService.kt => CoreTestService.kt} | 8 +++---- .../{V2RayVpnService.kt => CoreVpnService.kt} | 10 ++++----- .../com/v2ray/ang/service/QSTileService.kt | 10 ++++----- .../ang/service/RealPingWorkerService.kt | 8 +++---- .../java/com/v2ray/ang/ui/AboutActivity.kt | 4 ++-- .../com/v2ray/ang/ui/CheckUpdateActivity.kt | 4 ++-- .../java/com/v2ray/ang/ui/MainActivity.kt | 8 +++---- .../java/com/v2ray/ang/ui/ScStartActivity.kt | 6 ++--- .../java/com/v2ray/ang/ui/ScStopActivity.kt | 6 ++--- .../java/com/v2ray/ang/ui/ScSwitchActivity.kt | 8 +++---- .../java/com/v2ray/ang/util/MessageUtil.kt | 4 ++-- 21 files changed, 87 insertions(+), 80 deletions(-) rename V2rayNG/app/src/main/java/com/v2ray/ang/{handler/V2rayConfigManager.kt => core/CoreConfigManager.kt} (99%) rename V2rayNG/app/src/main/java/com/v2ray/ang/{handler/V2RayNativeManager.kt => core/CoreNativeManager.kt} (97%) rename V2rayNG/app/src/main/java/com/v2ray/ang/{handler/V2RayServiceManager.kt => core/CoreServiceManager.kt} (96%) rename V2rayNG/app/src/main/java/com/v2ray/ang/service/{V2RayProxyOnlyService.kt => CoreProxyOnlyService.kt} (89%) rename V2rayNG/app/src/main/java/com/v2ray/ang/service/{V2RayTestService.kt => CoreTestService.kt} (92%) rename V2rayNG/app/src/main/java/com/v2ray/ang/service/{V2RayVpnService.kt => CoreVpnService.kt} (98%) diff --git a/V2rayNG/app/src/main/AndroidManifest.xml b/V2rayNG/app/src/main/AndroidManifest.xml index 59a167b3..e53a660d 100644 --- a/V2rayNG/app/src/main/AndroidManifest.xml +++ b/V2rayNG/app/src/main/AndroidManifest.xml @@ -168,7 +168,7 @@ android:exported="false" /> diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2rayConfigManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt similarity index 99% rename from V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2rayConfigManager.kt rename to V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt index 2ffb2a90..3d4ae9d6 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2rayConfigManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt @@ -1,10 +1,9 @@ -package com.v2ray.ang.handler +package com.v2ray.ang.core import android.content.Context import android.text.TextUtils import com.google.gson.JsonArray import com.v2ray.ang.AppConfig -import com.v2ray.ang.core.CoreOutboundBuilder import com.v2ray.ang.dto.ConfigResult import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.dto.RulesetItem @@ -12,13 +11,15 @@ import com.v2ray.ang.dto.V2rayConfig import com.v2ray.ang.enums.EConfigType import com.v2ray.ang.enums.NetworkType import com.v2ray.ang.extension.isNotNullEmpty +import com.v2ray.ang.handler.MmkvManager +import com.v2ray.ang.handler.SettingsManager import com.v2ray.ang.util.HttpUtil import com.v2ray.ang.util.JsonUtil import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.PackageUidResolver import com.v2ray.ang.util.Utils -object V2rayConfigManager { +object CoreConfigManager { private var initConfigCache: String? = null private var initConfigCacheWithTun: String? = null @@ -1091,7 +1092,7 @@ object V2rayConfigManager { /** * Converts a profile item to an outbound configuration. * - * Delegates to [com.v2ray.ang.core.CoreOutboundBuilder] which owns all per-protocol + * Delegates to [CoreOutboundBuilder] which owns all per-protocol * conversion logic, keeping this manager focused on config orchestration. * * @param profileItem The profile item to convert diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2RayNativeManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreNativeManager.kt similarity index 97% rename from V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2RayNativeManager.kt rename to V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreNativeManager.kt index 93038c33..af89bfa2 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2RayNativeManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreNativeManager.kt @@ -1,4 +1,4 @@ -package com.v2ray.ang.handler +package com.v2ray.ang.core import android.content.Context import com.v2ray.ang.AppConfig @@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean * Thread-safe singleton wrapper for Libv2ray native methods. * Provides initialization protection and unified API for V2Ray core operations. */ -object V2RayNativeManager { +object CoreNativeManager { private val initialized = AtomicBoolean(false) /** @@ -88,4 +88,4 @@ object V2RayNativeManager { throw e } } -} +} \ No newline at end of file diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2RayServiceManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt similarity index 96% rename from V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2RayServiceManager.kt rename to V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt index 90c4060e..3129dd1d 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/V2RayServiceManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt @@ -1,4 +1,4 @@ -package com.v2ray.ang.handler +package com.v2ray.ang.core import android.app.Service import android.content.BroadcastReceiver @@ -16,8 +16,12 @@ import com.v2ray.ang.contracts.ServiceControl import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.enums.EConfigType import com.v2ray.ang.extension.toast -import com.v2ray.ang.service.V2RayProxyOnlyService -import com.v2ray.ang.service.V2RayVpnService +import com.v2ray.ang.handler.MmkvManager +import com.v2ray.ang.handler.NotificationManager +import com.v2ray.ang.handler.SettingsManager +import com.v2ray.ang.handler.SpeedtestManager +import com.v2ray.ang.service.CoreProxyOnlyService +import com.v2ray.ang.service.CoreVpnService import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.MessageUtil import com.v2ray.ang.util.Utils @@ -30,9 +34,9 @@ import libv2ray.ProcessFinder import java.lang.ref.SoftReference import java.net.InetSocketAddress -object V2RayServiceManager { +object CoreServiceManager { - private val coreController: CoreController = V2RayNativeManager.newCoreController(CoreCallback()) + private val coreController: CoreController = CoreNativeManager.newCoreController(CoreCallback()) private val mMsgReceive = ReceiveMessageHandler() private var currentConfig: ProfileItem? = null private var processFinder: XrayProcessFinder? = null @@ -41,7 +45,7 @@ object V2RayServiceManager { set(value) { field = value val service = value?.get()?.getService() - V2RayNativeManager.initCoreEnv(service) + CoreNativeManager.initCoreEnv(service) if (service != null && processFinder == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { processFinder = XrayProcessFinder(service) coreController.registerProcessFinder(processFinder) @@ -144,10 +148,10 @@ object V2RayServiceManager { val isVpnMode = SettingsManager.isVpnMode() val intent = if (isVpnMode) { LogUtil.i(AppConfig.TAG, "StartCore-Manager: Starting VPN service") - Intent(context.applicationContext, V2RayVpnService::class.java) + Intent(context.applicationContext, CoreVpnService::class.java) } else { LogUtil.i(AppConfig.TAG, "StartCore-Manager: Starting Proxy service") - Intent(context.applicationContext, V2RayProxyOnlyService::class.java) + Intent(context.applicationContext, CoreProxyOnlyService::class.java) } try { @@ -187,7 +191,7 @@ object V2RayServiceManager { } LogUtil.i(AppConfig.TAG, "StartCore-Manager: Starting core loop for ${config.remarks}") - val result = V2rayConfigManager.getV2rayConfig(service, guid) + val result = CoreConfigManager.getV2rayConfig(service, guid) LogUtil.d(AppConfig.TAG, result.content) if (!result.status) { LogUtil.e(AppConfig.TAG, "StartCore-Manager: Failed to get V2Ray config") diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/AngConfigManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/AngConfigManager.kt index e8758012..dc6ad9cb 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/AngConfigManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/AngConfigManager.kt @@ -6,6 +6,7 @@ import android.text.TextUtils import com.v2ray.ang.AppConfig import com.v2ray.ang.AppConfig.HY2 import com.v2ray.ang.R +import com.v2ray.ang.core.CoreConfigManager import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.dto.SubscriptionCache import com.v2ray.ang.dto.SubscriptionItem @@ -111,7 +112,7 @@ object AngConfigManager { fun shareFullContent2Clipboard(context: Context, guid: String?): Int { try { if (guid == null) return -1 - val result = V2rayConfigManager.getV2rayConfig(context, guid) + val result = CoreConfigManager.getV2rayConfig(context, guid) if (result.status) { Utils.setClipboard(context, result.content) } else { diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt index 51c66edb..cf671ff2 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt @@ -13,6 +13,7 @@ import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat import com.v2ray.ang.AppConfig import com.v2ray.ang.R +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.dto.ProfileItem import com.v2ray.ang.extension.toSpeedString import com.v2ray.ang.ui.MainActivity @@ -44,7 +45,7 @@ object NotificationManager { */ fun startSpeedNotification(currentConfig: ProfileItem?) { if (MmkvManager.decodeSettingsBool(AppConfig.PREF_SPEED_ENABLED) != true) return - if (speedNotificationJob != null || V2RayServiceManager.isRunning() == false) return + if (speedNotificationJob != null || CoreServiceManager.isRunning() == false) return var lastZeroSpeed = false val outboundTags = currentConfig?.getAllOutboundTags() @@ -67,15 +68,15 @@ object NotificationManager { var proxyTotal = 0L val text = StringBuilder() outboundTags?.forEach { - val up = V2RayServiceManager.queryStats(it, AppConfig.UPLINK) - val down = V2RayServiceManager.queryStats(it, AppConfig.DOWNLINK) + val up = CoreServiceManager.queryStats(it, AppConfig.UPLINK) + val down = CoreServiceManager.queryStats(it, AppConfig.DOWNLINK) if (up + down > 0) { appendSpeedString(text, it, up / sinceLastQueryInSeconds, down / sinceLastQueryInSeconds) proxyTotal += up + down } } - val directUplink = V2RayServiceManager.queryStats(AppConfig.TAG_DIRECT, AppConfig.UPLINK) - val directDownlink = V2RayServiceManager.queryStats(AppConfig.TAG_DIRECT, AppConfig.DOWNLINK) + val directUplink = CoreServiceManager.queryStats(AppConfig.TAG_DIRECT, AppConfig.UPLINK) + val directDownlink = CoreServiceManager.queryStats(AppConfig.TAG_DIRECT, AppConfig.DOWNLINK) val zeroSpeed = proxyTotal == 0L && directUplink == 0L && directDownlink == 0L if (!zeroSpeed || !lastZeroSpeed) { if (proxyTotal == 0L) { @@ -251,6 +252,6 @@ object NotificationManager { * @return The service instance. */ private fun getService(): Service? { - return V2RayServiceManager.serviceControl?.get()?.getService() + return CoreServiceManager.serviceControl?.get()?.getService() } } \ No newline at end of file diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/BootReceiver.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/BootReceiver.kt index c34c067f..a88289bd 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/BootReceiver.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/BootReceiver.kt @@ -6,7 +6,7 @@ import android.content.Intent import com.v2ray.ang.AppConfig import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.handler.SubscriptionUpdater -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.util.LogUtil class BootReceiver : BroadcastReceiver() { @@ -37,7 +37,7 @@ class BootReceiver : BroadcastReceiver() { } LogUtil.i(AppConfig.TAG, "BootReceiver: Starting V2Ray service") - V2RayServiceManager.startVService(context) + CoreServiceManager.startVService(context) SubscriptionUpdater.sync(context) } } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/TaskerReceiver.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/TaskerReceiver.kt index f7e805ff..4f48eb03 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/TaskerReceiver.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/TaskerReceiver.kt @@ -5,7 +5,7 @@ import android.content.Context import android.content.Intent import android.text.TextUtils import com.v2ray.ang.AppConfig -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.util.LogUtil class TaskerReceiver : BroadcastReceiver() { @@ -28,12 +28,12 @@ class TaskerReceiver : BroadcastReceiver() { return } else if (switch) { if (guid == AppConfig.TASKER_DEFAULT_GUID) { - V2RayServiceManager.startVServiceFromToggle(context) + CoreServiceManager.startVServiceFromToggle(context) } else { - V2RayServiceManager.startVService(context, guid) + CoreServiceManager.startVService(context, guid) } } else { - V2RayServiceManager.stopVService(context) + CoreServiceManager.stopVService(context) } } catch (e: Exception) { LogUtil.e(AppConfig.TAG, "Error processing Tasker broadcast", e) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/WidgetProvider.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/WidgetProvider.kt index 2e19d6dc..d63b6ac0 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/WidgetProvider.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/receiver/WidgetProvider.kt @@ -9,7 +9,7 @@ import android.content.Intent import android.widget.RemoteViews import com.v2ray.ang.AppConfig import com.v2ray.ang.R -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager class WidgetProvider : AppWidgetProvider() { /** @@ -22,7 +22,7 @@ class WidgetProvider : AppWidgetProvider() { */ override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { super.onUpdate(context, appWidgetManager, appWidgetIds) - updateWidgetBackground(context, appWidgetManager, appWidgetIds, V2RayServiceManager.isRunning()) + updateWidgetBackground(context, appWidgetManager, appWidgetIds, CoreServiceManager.isRunning()) } /** @@ -67,10 +67,10 @@ class WidgetProvider : AppWidgetProvider() { override fun onReceive(context: Context, intent: Intent) { super.onReceive(context, intent) if (AppConfig.BROADCAST_ACTION_WIDGET_CLICK == intent.action) { - if (V2RayServiceManager.isRunning()) { - V2RayServiceManager.stopVService(context) + if (CoreServiceManager.isRunning()) { + CoreServiceManager.stopVService(context) } else { - V2RayServiceManager.startVServiceFromToggle(context) + CoreServiceManager.startVServiceFromToggle(context) } } else if (AppConfig.BROADCAST_ACTION_ACTIVITY == intent.action) { AppWidgetManager.getInstance(context)?.let { manager -> diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayProxyOnlyService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreProxyOnlyService.kt similarity index 89% rename from V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayProxyOnlyService.kt rename to V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreProxyOnlyService.kt index 284160dd..5d1a7e35 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayProxyOnlyService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreProxyOnlyService.kt @@ -7,19 +7,19 @@ import android.os.IBinder import com.v2ray.ang.AppConfig import com.v2ray.ang.contracts.ServiceControl import com.v2ray.ang.handler.SettingsManager -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.MyContextWrapper import java.lang.ref.SoftReference -class V2RayProxyOnlyService : Service(), ServiceControl { +class CoreProxyOnlyService : Service(), ServiceControl { /** * Initializes the service. */ override fun onCreate() { super.onCreate() LogUtil.i(AppConfig.TAG, "StartCore-Proxy: Service created") - V2RayServiceManager.serviceControl = SoftReference(this) + CoreServiceManager.serviceControl = SoftReference(this) } /** @@ -31,7 +31,7 @@ class V2RayProxyOnlyService : Service(), ServiceControl { */ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { LogUtil.i(AppConfig.TAG, "StartCore-Proxy: Service command received") - V2RayServiceManager.startCoreLoop(null) + CoreServiceManager.startCoreLoop(null) return START_STICKY } @@ -40,7 +40,7 @@ class V2RayProxyOnlyService : Service(), ServiceControl { */ override fun onDestroy() { super.onDestroy() - V2RayServiceManager.stopCoreLoop() + CoreServiceManager.stopCoreLoop() } /** diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt similarity index 92% rename from V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt rename to V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt index 179f8e25..862b973f 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayTestService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreTestService.kt @@ -9,11 +9,11 @@ import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG_CANCEL import com.v2ray.ang.dto.TestServiceMessage import com.v2ray.ang.extension.serializable import com.v2ray.ang.handler.MmkvManager -import com.v2ray.ang.handler.V2RayNativeManager +import com.v2ray.ang.core.CoreNativeManager import com.v2ray.ang.util.MessageUtil import java.util.Collections -class V2RayTestService : Service() { +class CoreTestService : Service() { // manage active batch workers so each batch is independent and cancellable private val activeWorkers = Collections.synchronizedList(mutableListOf()) @@ -23,7 +23,7 @@ class V2RayTestService : Service() { */ override fun onCreate() { super.onCreate() - V2RayNativeManager.initCoreEnv(this) + CoreNativeManager.initCoreEnv(this) } /** @@ -69,7 +69,7 @@ class V2RayTestService : Service() { lateinit var worker: RealPingWorkerService worker = RealPingWorkerService(this, guidsList) { status -> // notify UI and remove the worker from active list when finished - MessageUtil.sendMsg2UI(this@V2RayTestService, AppConfig.MSG_MEASURE_CONFIG_FINISH, status) + MessageUtil.sendMsg2UI(this@CoreTestService, AppConfig.MSG_MEASURE_CONFIG_FINISH, status) activeWorkers.remove(worker) } activeWorkers.add(worker) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayVpnService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt similarity index 98% rename from V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayVpnService.kt rename to V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt index c7e1c97e..bf8f4d7a 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/V2RayVpnService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt @@ -23,14 +23,14 @@ import com.v2ray.ang.contracts.Tun2SocksControl import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.handler.NotificationManager import com.v2ray.ang.handler.SettingsManager -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.MyContextWrapper import com.v2ray.ang.util.Utils import java.lang.ref.SoftReference @SuppressLint("VpnServicePolicy") -class V2RayVpnService : VpnService(), ServiceControl { +class CoreVpnService : VpnService(), ServiceControl { private lateinit var mInterface: ParcelFileDescriptor private var isRunning = false private var tun2SocksService: Tun2SocksControl? = null @@ -77,7 +77,7 @@ class V2RayVpnService : VpnService(), ServiceControl { LogUtil.i(AppConfig.TAG, "StartCore-VPN: Service created") val policy = StrictMode.ThreadPolicy.Builder().permitAll().build() StrictMode.setThreadPolicy(policy) - V2RayServiceManager.serviceControl = SoftReference(this) + CoreServiceManager.serviceControl = SoftReference(this) } override fun onRevoke() { @@ -128,7 +128,7 @@ class V2RayVpnService : VpnService(), ServiceControl { LogUtil.e(AppConfig.TAG, "StartCore-VPN: Interface not initialized") return } - if (!V2RayServiceManager.startCoreLoop(mInterface)) { + if (!CoreServiceManager.startCoreLoop(mInterface)) { LogUtil.e(AppConfig.TAG, "StartCore-VPN: Failed to start core loop") stopAllService() return @@ -361,7 +361,7 @@ class V2RayVpnService : VpnService(), ServiceControl { tun2SocksService?.stopTun2Socks() tun2SocksService = null - V2RayServiceManager.stopCoreLoop() + CoreServiceManager.stopCoreLoop() if (isForced) { //stopSelf has to be called ahead of mInterface.close(). otherwise v2ray core cannot be stooped diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/QSTileService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/QSTileService.kt index 293097bd..75019ee5 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/QSTileService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/QSTileService.kt @@ -10,7 +10,7 @@ import android.service.quicksettings.TileService import androidx.core.content.ContextCompat import com.v2ray.ang.AppConfig import com.v2ray.ang.R -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.MessageUtil import com.v2ray.ang.util.Utils @@ -29,7 +29,7 @@ class QSTileService : TileService() { qsTile?.label = getString(R.string.app_name) } else if (state == Tile.STATE_ACTIVE) { qsTile?.state = Tile.STATE_ACTIVE - qsTile?.label = V2RayServiceManager.getRunningServerName() + qsTile?.label = CoreServiceManager.getRunningServerName() } qsTile?.updateTile() @@ -42,7 +42,7 @@ class QSTileService : TileService() { override fun onStartListening() { super.onStartListening() - if (V2RayServiceManager.isRunning()) { + if (CoreServiceManager.isRunning()) { setState(Tile.STATE_ACTIVE) } else { setState(Tile.STATE_INACTIVE) @@ -75,11 +75,11 @@ class QSTileService : TileService() { super.onClick() when (qsTile.state) { Tile.STATE_INACTIVE -> { - V2RayServiceManager.startVServiceFromToggle(this) + CoreServiceManager.startVServiceFromToggle(this) } Tile.STATE_ACTIVE -> { - V2RayServiceManager.stopVService(this) + CoreServiceManager.stopVService(this) } } } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt index fd7a45ea..c52a50cd 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt @@ -3,8 +3,8 @@ package com.v2ray.ang.service import android.content.Context import com.v2ray.ang.AppConfig import com.v2ray.ang.handler.SettingsManager -import com.v2ray.ang.handler.V2RayNativeManager -import com.v2ray.ang.handler.V2rayConfigManager +import com.v2ray.ang.core.CoreNativeManager +import com.v2ray.ang.core.CoreConfigManager import com.v2ray.ang.util.MessageUtil import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineName @@ -77,11 +77,11 @@ class RealPingWorkerService( private fun startRealPing(guid: String): Long { val retFailure = -1L - val configResult = V2rayConfigManager.getV2rayConfig4Speedtest(context, guid) + val configResult = CoreConfigManager.getV2rayConfig4Speedtest(context, guid) if (!configResult.status) { return retFailure } - return V2RayNativeManager.measureOutboundDelay(configResult.content, SettingsManager.getDelayTestUrl()) + return CoreNativeManager.measureOutboundDelay(configResult.content, SettingsManager.getDelayTestUrl()) } } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt index 70b80ca3..50bc9c48 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/AboutActivity.kt @@ -5,7 +5,7 @@ import com.v2ray.ang.AppConfig import com.v2ray.ang.BuildConfig import com.v2ray.ang.R import com.v2ray.ang.databinding.ActivityAboutBinding -import com.v2ray.ang.handler.V2RayNativeManager +import com.v2ray.ang.core.CoreNativeManager import com.v2ray.ang.util.Utils class AboutActivity : BaseActivity() { @@ -42,7 +42,7 @@ class AboutActivity : BaseActivity() { Utils.openUri(this, AppConfig.APP_PRIVACY_POLICY) } - "v${BuildConfig.VERSION_NAME} (${V2RayNativeManager.getLibVersion()})".also { + "v${BuildConfig.VERSION_NAME} (${CoreNativeManager.getLibVersion()})".also { binding.tvVersion.text = it } BuildConfig.APPLICATION_ID.also { diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/CheckUpdateActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/CheckUpdateActivity.kt index 3a69803a..26985338 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/CheckUpdateActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/CheckUpdateActivity.kt @@ -13,7 +13,7 @@ import com.v2ray.ang.extension.toastError import com.v2ray.ang.extension.toastSuccess import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.handler.UpdateCheckerManager -import com.v2ray.ang.handler.V2RayNativeManager +import com.v2ray.ang.core.CoreNativeManager import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.Utils import kotlinx.coroutines.launch @@ -36,7 +36,7 @@ class CheckUpdateActivity : BaseActivity() { } binding.checkPreRelease.isChecked = MmkvManager.decodeSettingsBool(AppConfig.PREF_CHECK_UPDATE_PRE_RELEASE, false) - "v${BuildConfig.VERSION_NAME} (${V2RayNativeManager.getLibVersion()})".also { + "v${BuildConfig.VERSION_NAME} (${CoreNativeManager.getLibVersion()})".also { binding.tvVersion.text = it } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt index 4c8a8466..d943c527 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt @@ -32,7 +32,7 @@ import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.handler.SettingsChangeManager import com.v2ray.ang.handler.SettingsManager import com.v2ray.ang.handler.SubscriptionUpdater -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.Utils import com.v2ray.ang.viewmodel.MainViewModel @@ -137,7 +137,7 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect applyRunningState(isLoading = true, isRunning = false) if (mainViewModel.isRunning.value == true) { - V2RayServiceManager.stopVService(this) + CoreServiceManager.stopVService(this) } else if (SettingsManager.isVpnMode()) { val intent = VpnService.prepare(this) if (intent == null) { @@ -164,12 +164,12 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect toast(R.string.title_file_chooser) return } - V2RayServiceManager.startVService(this) + CoreServiceManager.startVService(this) } fun restartV2Ray() { if (mainViewModel.isRunning.value == true) { - V2RayServiceManager.stopVService(this) + CoreServiceManager.stopVService(this) } lifecycleScope.launch { delay(500) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStartActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStartActivity.kt index 6bbc1225..02a69ef9 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStartActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStartActivity.kt @@ -2,7 +2,7 @@ package com.v2ray.ang.ui import android.os.Bundle import com.v2ray.ang.R -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager class ScStartActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -11,8 +11,8 @@ class ScStartActivity : BaseActivity() { setContentView(R.layout.activity_none) - if (!V2RayServiceManager.isRunning()) { - V2RayServiceManager.startVServiceFromToggle(this) + if (!CoreServiceManager.isRunning()) { + CoreServiceManager.startVServiceFromToggle(this) } finish() } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStopActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStopActivity.kt index 58f24ac8..2fdb692d 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStopActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScStopActivity.kt @@ -2,7 +2,7 @@ package com.v2ray.ang.ui import android.os.Bundle import com.v2ray.ang.R -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager class ScStopActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -11,8 +11,8 @@ class ScStopActivity : BaseActivity() { setContentView(R.layout.activity_none) - if (V2RayServiceManager.isRunning()) { - V2RayServiceManager.stopVService(this) + if (CoreServiceManager.isRunning()) { + CoreServiceManager.stopVService(this) } finish() } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScSwitchActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScSwitchActivity.kt index b75ae566..43d88288 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScSwitchActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/ScSwitchActivity.kt @@ -2,7 +2,7 @@ package com.v2ray.ang.ui import android.os.Bundle import com.v2ray.ang.R -import com.v2ray.ang.handler.V2RayServiceManager +import com.v2ray.ang.core.CoreServiceManager class ScSwitchActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -11,10 +11,10 @@ class ScSwitchActivity : BaseActivity() { setContentView(R.layout.activity_none) - if (V2RayServiceManager.isRunning()) { - V2RayServiceManager.stopVService(this) + if (CoreServiceManager.isRunning()) { + CoreServiceManager.stopVService(this) } else { - V2RayServiceManager.startVServiceFromToggle(this) + CoreServiceManager.startVServiceFromToggle(this) } finish() } diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/util/MessageUtil.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/util/MessageUtil.kt index ecbdb9e3..2e131165 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/util/MessageUtil.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/util/MessageUtil.kt @@ -5,7 +5,7 @@ import android.content.Context import android.content.Intent import com.v2ray.ang.AppConfig import com.v2ray.ang.dto.TestServiceMessage -import com.v2ray.ang.service.V2RayTestService +import com.v2ray.ang.service.CoreTestService import java.io.Serializable object MessageUtil { @@ -42,7 +42,7 @@ object MessageUtil { fun sendMsg2TestService(ctx: Context, message: TestServiceMessage) { try { val intent = Intent() - intent.component = ComponentName(ctx, V2RayTestService::class.java) + intent.component = ComponentName(ctx, CoreTestService::class.java) intent.putExtra("content", message) ctx.startService(intent) } catch (e: Exception) {