Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0265265f3 | |||
| 2d6dd33a7b |
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId = "com.v2ray.ang"
|
applicationId = "com.v2ray.ang"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 712
|
versionCode = 713
|
||||||
versionName = "2.0.12"
|
versionName = "2.0.13"
|
||||||
multiDexEnabled = true
|
multiDexEnabled = true
|
||||||
|
|
||||||
val abiFilterList = (properties["ABI_FILTERS"] as? String)?.split(';')
|
val abiFilterList = (properties["ABI_FILTERS"] as? String)?.split(';')
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.v2ray.ang.dto
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
data class TestServiceMessage(
|
||||||
|
val key: Int,
|
||||||
|
val subscriptionId: String = "",
|
||||||
|
val serverGuids: List<String> = emptyList()
|
||||||
|
) : Serializable
|
||||||
|
|
||||||
@@ -6,6 +6,8 @@ import android.os.IBinder
|
|||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG
|
import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG
|
||||||
import com.v2ray.ang.AppConfig.MSG_MEASURE_CONFIG_CANCEL
|
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.MmkvManager
|
||||||
import com.v2ray.ang.handler.V2RayNativeManager
|
import com.v2ray.ang.handler.V2RayNativeManager
|
||||||
import com.v2ray.ang.util.MessageUtil
|
import com.v2ray.ang.util.MessageUtil
|
||||||
@@ -52,13 +54,15 @@ class V2RayTestService : Service() {
|
|||||||
* @return The start mode.
|
* @return The start mode.
|
||||||
*/
|
*/
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
when (intent?.getIntExtra("key", 0)) {
|
val message = intent?.serializable<TestServiceMessage>("content") ?: return super.onStartCommand(intent, flags, startId)
|
||||||
|
when (message.key) {
|
||||||
MSG_MEASURE_CONFIG -> {
|
MSG_MEASURE_CONFIG -> {
|
||||||
val subscriptionId = intent.getStringExtra("content").orEmpty()
|
val guidsList = if (message.serverGuids.isNotEmpty()) {
|
||||||
val guidsList = if (subscriptionId.isEmpty()) {
|
message.serverGuids
|
||||||
MmkvManager.decodeAllServerList()
|
} else if (message.subscriptionId.isNotEmpty()) {
|
||||||
|
MmkvManager.decodeServerList(message.subscriptionId)
|
||||||
} else {
|
} else {
|
||||||
MmkvManager.decodeServerList(subscriptionId)
|
MmkvManager.decodeAllServerList()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guidsList.isNotEmpty()) {
|
if (guidsList.isNotEmpty()) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
|
import com.v2ray.ang.dto.TestServiceMessage
|
||||||
import com.v2ray.ang.service.V2RayTestService
|
import com.v2ray.ang.service.V2RayTestService
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
@@ -37,15 +38,13 @@ object MessageUtil {
|
|||||||
* Sends a message to the test service.
|
* Sends a message to the test service.
|
||||||
*
|
*
|
||||||
* @param ctx The context.
|
* @param ctx The context.
|
||||||
* @param what The message identifier.
|
* @param message The test service message containing key, subscriptionId, and serverGuids.
|
||||||
* @param content The message content.
|
|
||||||
*/
|
*/
|
||||||
fun sendMsg2TestService(ctx: Context, what: Int, content: Serializable) {
|
fun sendMsg2TestService(ctx: Context, message: TestServiceMessage) {
|
||||||
try {
|
try {
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
intent.component = ComponentName(ctx, V2RayTestService::class.java)
|
intent.component = ComponentName(ctx, V2RayTestService::class.java)
|
||||||
intent.putExtra("key", what)
|
intent.putExtra("content", message)
|
||||||
intent.putExtra("content", content)
|
|
||||||
ctx.startService(intent)
|
ctx.startService(intent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(AppConfig.TAG, "Failed to send message to test service", e)
|
Log.e(AppConfig.TAG, "Failed to send message to test service", e)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.v2ray.ang.dto.GroupMapItem
|
|||||||
import com.v2ray.ang.dto.ServersCache
|
import com.v2ray.ang.dto.ServersCache
|
||||||
import com.v2ray.ang.dto.SubscriptionCache
|
import com.v2ray.ang.dto.SubscriptionCache
|
||||||
import com.v2ray.ang.dto.SubscriptionUpdateResult
|
import com.v2ray.ang.dto.SubscriptionUpdateResult
|
||||||
|
import com.v2ray.ang.dto.TestServiceMessage
|
||||||
import com.v2ray.ang.extension.serializable
|
import com.v2ray.ang.extension.serializable
|
||||||
import com.v2ray.ang.extension.toastError
|
import com.v2ray.ang.extension.toastError
|
||||||
import com.v2ray.ang.extension.toastSuccess
|
import com.v2ray.ang.extension.toastSuccess
|
||||||
@@ -196,7 +197,10 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
* Tests the real ping for all servers.
|
* Tests the real ping for all servers.
|
||||||
*/
|
*/
|
||||||
fun testAllRealPing() {
|
fun testAllRealPing() {
|
||||||
MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG_CANCEL, "")
|
MessageUtil.sendMsg2TestService(
|
||||||
|
getApplication(),
|
||||||
|
TestServiceMessage(key = AppConfig.MSG_MEASURE_CONFIG_CANCEL)
|
||||||
|
)
|
||||||
MmkvManager.clearAllTestDelayResults(serversCache.map { it.guid }.toList())
|
MmkvManager.clearAllTestDelayResults(serversCache.map { it.guid }.toList())
|
||||||
updateListAction.value = -1
|
updateListAction.value = -1
|
||||||
|
|
||||||
@@ -204,7 +208,14 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
if (serversCache.isEmpty()) {
|
if (serversCache.isEmpty()) {
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG, subscriptionId)
|
MessageUtil.sendMsg2TestService(
|
||||||
|
getApplication(),
|
||||||
|
TestServiceMessage(
|
||||||
|
key = AppConfig.MSG_MEASURE_CONFIG,
|
||||||
|
subscriptionId = subscriptionId,
|
||||||
|
serverGuids = if (keywordFilter.isNotEmpty()) serversCache.map { it.guid } else emptyList()
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user