mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 22:50:05 +08:00
Fix bugs
This commit is contained in:
parent
e1b8488f94
commit
3b3c6757b9
@ -344,7 +344,7 @@ class BaseService {
|
||||
filter,
|
||||
"$packageName.SERVICE",
|
||||
null,
|
||||
Context.RECEIVER_NOT_EXPORTED
|
||||
Context.RECEIVER_EXPORTED
|
||||
)
|
||||
} else {
|
||||
registerReceiver(
|
||||
|
||||
@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||
import android.os.Build
|
||||
import android.text.format.Formatter
|
||||
import androidx.core.app.NotificationCompat
|
||||
@ -183,7 +184,17 @@ class ServiceNotification(
|
||||
|
||||
|
||||
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 {
|
||||
NotificationManagerCompat.from(service as Service).notify(notificationId, it.build())
|
||||
|
||||
@ -95,9 +95,9 @@ fun parseHysteria2(url: String): HysteriaBean {
|
||||
link.queryParameter("obfs-password")?.also {
|
||||
obfuscation = it
|
||||
}
|
||||
link.queryParameter("pinSHA256")?.also {
|
||||
// TODO your box do not support it
|
||||
}
|
||||
// link.queryParameter("pinSHA256")?.also {
|
||||
// // TODO your box do not support it
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,9 +284,9 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
|
||||
if (port != null) {
|
||||
server_port = port
|
||||
} else {
|
||||
hop_ports = bean.serverPorts
|
||||
server_ports = bean.serverPorts
|
||||
}
|
||||
hop_interval = bean.hopInterval
|
||||
hop_interval = "${bean.hopInterval}s"
|
||||
up_mbps = bean.uploadMbps
|
||||
down_mbps = bean.downloadMbps
|
||||
obfs = bean.obfuscation
|
||||
@ -323,9 +323,9 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
|
||||
if (port != null) {
|
||||
server_port = port
|
||||
} else {
|
||||
hop_ports = bean.serverPorts
|
||||
server_ports = bean.serverPorts
|
||||
}
|
||||
hop_interval = bean.hopInterval
|
||||
hop_interval = "${bean.hopInterval}s"
|
||||
up_mbps = bean.uploadMbps
|
||||
down_mbps = bean.downloadMbps
|
||||
if (bean.obfuscation.isNotBlank()) {
|
||||
|
||||
@ -250,6 +250,7 @@ object RawUpdater : GroupUpdater() {
|
||||
setTLS(proxy["tls"]?.toString() == "true")
|
||||
sni = proxy["sni"]?.toString()
|
||||
name = proxy["name"]?.toString()
|
||||
allowInsecure = proxy["name"]?.toString() == "true"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class VpnRequestActivity : AppCompatActivity() {
|
||||
registerReceiver(
|
||||
receiver,
|
||||
IntentFilter(Intent.ACTION_USER_PRESENT),
|
||||
Context.RECEIVER_NOT_EXPORTED
|
||||
Context.RECEIVER_EXPORTED
|
||||
)
|
||||
} else {
|
||||
registerReceiver(receiver, IntentFilter(Intent.ACTION_USER_PRESENT))
|
||||
|
||||
@ -449,9 +449,9 @@ public class SingBoxOptions {
|
||||
|
||||
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 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 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 String hop_ports;
|
||||
public String server_ports;
|
||||
|
||||
public Integer hop_interval;
|
||||
public String hop_interval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -6,18 +6,10 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.kotlin.dsl.getByName
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
|
||||
import java.security.MessageDigest
|
||||
import java.util.Base64
|
||||
import java.util.Locale
|
||||
import java.util.Properties
|
||||
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 lateinit var metadata: Properties
|
||||
@ -74,22 +66,6 @@ fun Project.requireLocalProperties(): Properties {
|
||||
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() {
|
||||
android.apply {
|
||||
buildToolsVersion = "35.0.1"
|
||||
@ -186,9 +162,7 @@ fun Project.setupAppCommon() {
|
||||
buildTypes {
|
||||
val key = signingConfigs.findByName("release")
|
||||
if (key != null) {
|
||||
if (requireTargetAbi().isBlank()) {
|
||||
getByName("release").signingConfig = key
|
||||
}
|
||||
getByName("debug").signingConfig = key
|
||||
}
|
||||
}
|
||||
@ -208,8 +182,6 @@ fun Project.setupApp() {
|
||||
}
|
||||
setupAppCommon()
|
||||
|
||||
val targetAbi = requireTargetAbi()
|
||||
|
||||
android.apply {
|
||||
this as AbstractAppExtension
|
||||
|
||||
@ -223,12 +195,13 @@ fun Project.setupApp() {
|
||||
}
|
||||
|
||||
splits.abi {
|
||||
reset()
|
||||
isEnable = true
|
||||
isUniversalApk = false
|
||||
if (targetAbi.isNotBlank()) {
|
||||
reset()
|
||||
include(targetAbi)
|
||||
}
|
||||
include("armeabi-v7a")
|
||||
include("arm64-v8a")
|
||||
include("x86")
|
||||
include("x86_64")
|
||||
}
|
||||
|
||||
flavorDimensions += "vendor"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user