This commit is contained in:
armv9 2025-02-23 23:04:24 +09:00
parent e1b8488f94
commit 3b3c6757b9
7 changed files with 36 additions and 51 deletions

View File

@ -344,7 +344,7 @@ class BaseService {
filter, filter,
"$packageName.SERVICE", "$packageName.SERVICE",
null, null,
Context.RECEIVER_NOT_EXPORTED Context.RECEIVER_EXPORTED
) )
} else { } else {
registerReceiver( registerReceiver(

View File

@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
import android.os.Build import android.os.Build
import android.text.format.Formatter import android.text.format.Formatter
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
@ -183,7 +184,17 @@ class ServiceNotification(
private suspend fun show() = private suspend fun show() =
useBuilder { (service as Service).startForeground(notificationId, it.build()) } useBuilder {
if (Build.VERSION.SDK_INT >= 34) {
(service as Service).startForeground(
notificationId,
it.build(),
FOREGROUND_SERVICE_TYPE_SPECIAL_USE
)
} else {
(service as Service).startForeground(notificationId, it.build())
}
}
private suspend fun update() = useBuilder { private suspend fun update() = useBuilder {
NotificationManagerCompat.from(service as Service).notify(notificationId, it.build()) NotificationManagerCompat.from(service as Service).notify(notificationId, it.build())

View File

@ -95,9 +95,9 @@ fun parseHysteria2(url: String): HysteriaBean {
link.queryParameter("obfs-password")?.also { link.queryParameter("obfs-password")?.also {
obfuscation = it obfuscation = it
} }
link.queryParameter("pinSHA256")?.also { // link.queryParameter("pinSHA256")?.also {
// TODO your box do not support it // // TODO your box do not support it
} // }
} }
} }
@ -284,9 +284,9 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
if (port != null) { if (port != null) {
server_port = port server_port = port
} else { } else {
hop_ports = bean.serverPorts server_ports = bean.serverPorts
} }
hop_interval = bean.hopInterval hop_interval = "${bean.hopInterval}s"
up_mbps = bean.uploadMbps up_mbps = bean.uploadMbps
down_mbps = bean.downloadMbps down_mbps = bean.downloadMbps
obfs = bean.obfuscation obfs = bean.obfuscation
@ -323,9 +323,9 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
if (port != null) { if (port != null) {
server_port = port server_port = port
} else { } else {
hop_ports = bean.serverPorts server_ports = bean.serverPorts
} }
hop_interval = bean.hopInterval hop_interval = "${bean.hopInterval}s"
up_mbps = bean.uploadMbps up_mbps = bean.uploadMbps
down_mbps = bean.downloadMbps down_mbps = bean.downloadMbps
if (bean.obfuscation.isNotBlank()) { if (bean.obfuscation.isNotBlank()) {

View File

@ -250,6 +250,7 @@ object RawUpdater : GroupUpdater() {
setTLS(proxy["tls"]?.toString() == "true") setTLS(proxy["tls"]?.toString() == "true")
sni = proxy["sni"]?.toString() sni = proxy["sni"]?.toString()
name = proxy["name"]?.toString() name = proxy["name"]?.toString()
allowInsecure = proxy["name"]?.toString() == "true"
}) })
} }

View File

@ -31,7 +31,7 @@ class VpnRequestActivity : AppCompatActivity() {
registerReceiver( registerReceiver(
receiver, receiver,
IntentFilter(Intent.ACTION_USER_PRESENT), IntentFilter(Intent.ACTION_USER_PRESENT),
Context.RECEIVER_NOT_EXPORTED Context.RECEIVER_EXPORTED
) )
} else { } else {
registerReceiver(receiver, IntentFilter(Intent.ACTION_USER_PRESENT)) registerReceiver(receiver, IntentFilter(Intent.ACTION_USER_PRESENT))

View File

@ -449,9 +449,9 @@ public class SingBoxOptions {
public OutboundTLSOptions tls; public OutboundTLSOptions tls;
public String hop_ports; public String server_ports;
public Integer hop_interval; public String hop_interval;
} }
@ -575,9 +575,9 @@ public class SingBoxOptions {
public OutboundTLSOptions tls; public OutboundTLSOptions tls;
public String hop_ports; public String server_ports;
public Integer hop_interval; public String hop_interval;
} }
@ -3902,9 +3902,9 @@ public class SingBoxOptions {
public OutboundTLSOptions tls; public OutboundTLSOptions tls;
public String hop_ports; public String server_ports;
public Integer hop_interval; public String hop_interval;
} }
@ -4276,9 +4276,9 @@ public class SingBoxOptions {
public OutboundTLSOptions tls; public OutboundTLSOptions tls;
public String hop_ports; public String server_ports;
public Integer hop_interval; public String hop_interval;
} }

View File

@ -6,18 +6,10 @@ import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.getByName import org.gradle.kotlin.dsl.getByName
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import java.security.MessageDigest
import java.util.Base64 import java.util.Base64
import java.util.Locale
import java.util.Properties import java.util.Properties
import kotlin.system.exitProcess import kotlin.system.exitProcess
fun sha256Hex(bytes: ByteArray): String {
val md = MessageDigest.getInstance("SHA-256")
val digest = md.digest(bytes)
return digest.fold("") { str, it -> str + "%02x".format(it) }
}
private val Project.android get() = extensions.getByName<ApplicationExtension>("android") private val Project.android get() = extensions.getByName<ApplicationExtension>("android")
private lateinit var metadata: Properties private lateinit var metadata: Properties
@ -74,22 +66,6 @@ fun Project.requireLocalProperties(): Properties {
return localProperties return localProperties
} }
fun Project.requireTargetAbi(): String {
var targetAbi = ""
if (gradle.startParameter.taskNames.isNotEmpty()) {
if (gradle.startParameter.taskNames.size == 1) {
val targetTask = gradle.startParameter.taskNames[0].lowercase(Locale.ROOT).trim()
when {
targetTask.contains("arm64") -> targetAbi = "arm64-v8a"
targetTask.contains("arm") -> targetAbi = "armeabi-v7a"
targetTask.contains("x64") -> targetAbi = "x86_64"
targetTask.contains("x86") -> targetAbi = "x86"
}
}
}
return targetAbi
}
fun Project.setupCommon() { fun Project.setupCommon() {
android.apply { android.apply {
buildToolsVersion = "35.0.1" buildToolsVersion = "35.0.1"
@ -186,9 +162,7 @@ fun Project.setupAppCommon() {
buildTypes { buildTypes {
val key = signingConfigs.findByName("release") val key = signingConfigs.findByName("release")
if (key != null) { if (key != null) {
if (requireTargetAbi().isBlank()) {
getByName("release").signingConfig = key getByName("release").signingConfig = key
}
getByName("debug").signingConfig = key getByName("debug").signingConfig = key
} }
} }
@ -208,8 +182,6 @@ fun Project.setupApp() {
} }
setupAppCommon() setupAppCommon()
val targetAbi = requireTargetAbi()
android.apply { android.apply {
this as AbstractAppExtension this as AbstractAppExtension
@ -223,12 +195,13 @@ fun Project.setupApp() {
} }
splits.abi { splits.abi {
reset()
isEnable = true isEnable = true
isUniversalApk = false isUniversalApk = false
if (targetAbi.isNotBlank()) { include("armeabi-v7a")
reset() include("arm64-v8a")
include(targetAbi) include("x86")
} include("x86_64")
} }
flavorDimensions += "vendor" flavorDimensions += "vendor"