Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0737d5665 |
@@ -0,0 +1,33 @@
|
||||
name: Android client acceptance
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, "codex/**"]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test-and-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "21"
|
||||
- uses: android-actions/setup-android@v3
|
||||
- name: Install Android SDK
|
||||
run: sdkmanager "platforms;android-37" "build-tools;37.0.0" "platform-tools"
|
||||
- name: Restore verified native dependencies
|
||||
run: python3 Restore-Dependencies.py
|
||||
- name: Unit tests and unsigned candidate
|
||||
working-directory: V2rayNG
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew :app:testPlaystoreReleaseUnitTest :app:assemblePlaystoreRelease --no-daemon
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-unsigned-candidate
|
||||
path: V2rayNG/app/build/outputs/apk/playstore/release/*.apk
|
||||
|
||||
+3
-9
@@ -1,12 +1,6 @@
|
||||
# 纵横家 Android 客户端
|
||||
|
||||
版本 `1.0.7`;包名 `cn.toplc.zonghengjia`。这是公司 Android 客户端的 GPL-3.0 衍生源码,不包含服务器端、账号、节点凭据或公司签名私钥。发布状态以公司安装包仓库的同版正式 Release 为准。
|
||||
|
||||
1.0.7 修复共享安装包仓库分页后漏检 Android 版本,以及无关版本记录格式异常导致整个更新检查失败的问题。自动检查有统一20秒网络截止时间、分页及响应大小上限;发现新版本后提示从公司仓库覆盖安装,保留账号和配置,安装仍需 Android 系统确认。代理速度最低使用 KB/s;极小正样本显示 `<0.1 KB/s`。保留1.0.6的启动租约、授权隔离和电脑同款山水/半透明界面。本版验证包括离线 JVM 回归、五种 APK 的编译与同证书签名核验及 GPL 编译输入绑定;没有切换生产手机上的夜猫,也未把旧版手机验收记到本包。
|
||||
|
||||
1.0.6 保留1.0.5的山水背景和半透明界面,并修复VPN内核启动与停止交错时的启动租约竞态。构建按本轮JUnit XML实际用例计数,必须通过现有10项授权回归及至少8项 `UcvlVpnStartupLeaseTest` 新回归;不固定继承旧版本41项测试结论。新包仍须独立核验签名、GPL编译输入匹配和实体设备VPN行为;编译或单测通过不代表已正式发布,也不替代真实Service/广播、网络切换、休眠恢复及持续会话验收。
|
||||
|
||||
1.0.5 登录和主界面同步电脑同款原创山水图片,采用原生滚动控件、约50%白色透明卡片及深色文字,并适配系统栏和软键盘。仅同步有明确来源的山水PNG,不导入许可不明的人物插图;未修改API、授权、VPN路由或服务逻辑。签名、构建及实际设备验收记录按新包分别保存,不沿用1.0.4的包hash或旧模拟器结果冒称本包已验收。
|
||||
版本 `1.0.4` 本地候选,尚未作为正式版发布;包名 `cn.toplc.zonghengjia`。这是公司 Android 客户端的 GPL-3.0 衍生源码,不包含服务器端、账号、节点凭据或公司签名私钥。
|
||||
|
||||
1.0.4 纳入2026-09-17的后台授权隔离修复:区分“旧会话停止”和“当前账号撤销”,防止重新登录后的延迟响应误报新账号失效。旧1.0.3候选APK不含此修复。修复历史见`acceptance/AUTH-SESSION-ISOLATION-20260917.md`;1.0.4的构建、签名和本地验证见`acceptance/ACCEPTANCE-1.0.4.md`。本地检查不替代真实服务/设备VPN验收,候选未发布。
|
||||
|
||||
@@ -21,7 +15,7 @@
|
||||
- 公司账号登录、浏览器注册、设备授权、个人信息、套餐/额度/有效期。
|
||||
- 由平台自动分配节点,客户端只显示实际工作节点,不提供节点选择。
|
||||
- 完整保留平台下发的路由规则,支持智能/全局代理;使用 Android VpnService + HEV 隧道接管其他应用。
|
||||
- 仅统计 proxy 出站的速度/流量;速度使用 KB/s 或更大单位,直连不计入代理统计。
|
||||
- 仅统计 proxy 出站的速度/流量,两条低高度曲线;直连不计入代理统计。
|
||||
- Android Keystore 加密会话、同一证书覆盖升级保留配置。
|
||||
- VPN 后台每 60 秒检查授权,401/403 时断开并清除会话;临时网络错误不误当账号撤销。
|
||||
- 退出等待服务停止,TLS 清理在后台线程执行;系统 VPN 关闭后由 Android 恢复原网络。
|
||||
@@ -31,7 +25,7 @@
|
||||
|
||||
`acceptance/` 保存实际测试记录,不把编译成功当作手机实测。原生内核三节点 × 两模式 HTTPS、系统 VPN 独立 UID、退出/后台回收、同证书覆盖升级测试已通过。独立源码副本重新下载依赖并从头构建,通过 26 项单测;生成的 APK 解包内容与候选构建逐项相同。没有 Android 实体手机测试,尚未宣称与 Windows 全功能等价。
|
||||
|
||||
当前没有实现 Android 未知目标失败的全量学习闭环、持续故障自动换节点和应用内静默下载安装。公司已确认的规则会随连接配置下发。1.0.7没有手机实测:真实 Service/广播、网络切换、休眠恢复和持续会话仍需独立验收,离线回归不替代这些检查。旧1.0.0版本没有本版启动更新提示时,可从公司正式发布页下载同证书 APK 直接覆盖安装。
|
||||
当前没有实现 Android 未知目标失败的全量学习闭环、持续故障自动换节点和应用内下载安装升级流程。公司已确认的规则会随连接配置下发。暂不作为全公司稳定版通知。
|
||||
|
||||
## 从源码构建
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
# 纵横家 Android 客户端
|
||||
|
||||
版本 `1.0.7`;包名 `cn.toplc.zonghengjia`。这是公司 Android 客户端的 GPL-3.0 衍生源码,不包含服务器端、账号、节点凭据或公司签名私钥。发布状态以公司安装包仓库的同版正式 Release 为准。
|
||||
|
||||
1.0.7 修复共享安装包仓库分页后漏检 Android 版本,以及无关版本记录格式异常导致整个更新检查失败的问题。自动检查有统一20秒网络截止时间、分页及响应大小上限;发现新版本后提示从公司仓库覆盖安装,保留账号和配置,安装仍需 Android 系统确认。代理速度最低使用 KB/s;极小正样本显示 `<0.1 KB/s`。保留1.0.6的启动租约、授权隔离和电脑同款山水/半透明界面。本版验证包括离线 JVM 回归、五种 APK 的编译与同证书签名核验及 GPL 编译输入绑定;没有切换生产手机上的夜猫,也未把旧版手机验收记到本包。
|
||||
|
||||
1.0.6 保留1.0.5的山水背景和半透明界面,并修复VPN内核启动与停止交错时的启动租约竞态。构建按本轮JUnit XML实际用例计数,必须通过现有10项授权回归及至少8项 `UcvlVpnStartupLeaseTest` 新回归;不固定继承旧版本41项测试结论。新包仍须独立核验签名、GPL编译输入匹配和实体设备VPN行为;编译或单测通过不代表已正式发布,也不替代真实Service/广播、网络切换、休眠恢复及持续会话验收。
|
||||
|
||||
1.0.5 登录和主界面同步电脑同款原创山水图片,采用原生滚动控件、约50%白色透明卡片及深色文字,并适配系统栏和软键盘。仅同步有明确来源的山水PNG,不导入许可不明的人物插图;未修改API、授权、VPN路由或服务逻辑。签名、构建及实际设备验收记录按新包分别保存,不沿用1.0.4的包hash或旧模拟器结果冒称本包已验收。
|
||||
版本 `1.0.4` 本地候选,尚未作为正式版发布;包名 `cn.toplc.zonghengjia`。这是公司 Android 客户端的 GPL-3.0 衍生源码,不包含服务器端、账号、节点凭据或公司签名私钥。
|
||||
|
||||
1.0.4 纳入2026-09-17的后台授权隔离修复:区分“旧会话停止”和“当前账号撤销”,防止重新登录后的延迟响应误报新账号失效。旧1.0.3候选APK不含此修复。修复历史见`acceptance/AUTH-SESSION-ISOLATION-20260917.md`;1.0.4的构建、签名和本地验证见`acceptance/ACCEPTANCE-1.0.4.md`。本地检查不替代真实服务/设备VPN验收,候选未发布。
|
||||
|
||||
@@ -21,7 +15,7 @@
|
||||
- 公司账号登录、浏览器注册、设备授权、个人信息、套餐/额度/有效期。
|
||||
- 由平台自动分配节点,客户端只显示实际工作节点,不提供节点选择。
|
||||
- 完整保留平台下发的路由规则,支持智能/全局代理;使用 Android VpnService + HEV 隧道接管其他应用。
|
||||
- 仅统计 proxy 出站的速度/流量;速度使用 KB/s 或更大单位,直连不计入代理统计。
|
||||
- 仅统计 proxy 出站的速度/流量,两条低高度曲线;直连不计入代理统计。
|
||||
- Android Keystore 加密会话、同一证书覆盖升级保留配置。
|
||||
- VPN 后台每 60 秒检查授权,401/403 时断开并清除会话;临时网络错误不误当账号撤销。
|
||||
- 退出等待服务停止,TLS 清理在后台线程执行;系统 VPN 关闭后由 Android 恢复原网络。
|
||||
@@ -31,7 +25,7 @@
|
||||
|
||||
`acceptance/` 保存实际测试记录,不把编译成功当作手机实测。原生内核三节点 × 两模式 HTTPS、系统 VPN 独立 UID、退出/后台回收、同证书覆盖升级测试已通过。独立源码副本重新下载依赖并从头构建,通过 26 项单测;生成的 APK 解包内容与候选构建逐项相同。没有 Android 实体手机测试,尚未宣称与 Windows 全功能等价。
|
||||
|
||||
当前没有实现 Android 未知目标失败的全量学习闭环、持续故障自动换节点和应用内静默下载安装。公司已确认的规则会随连接配置下发。1.0.7没有手机实测:真实 Service/广播、网络切换、休眠恢复和持续会话仍需独立验收,离线回归不替代这些检查。旧1.0.0版本没有本版启动更新提示时,可从公司正式发布页下载同证书 APK 直接覆盖安装。
|
||||
当前没有实现 Android 未知目标失败的全量学习闭环、持续故障自动换节点和应用内下载安装升级流程。公司已确认的规则会随连接配置下发。暂不作为全公司稳定版通知。
|
||||
|
||||
## 从源码构建
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ android {
|
||||
applicationId = "cn.toplc.zonghengjia"
|
||||
minSdk = 24
|
||||
targetSdk = 37
|
||||
versionCode = 10007
|
||||
versionName = "1.0.7"
|
||||
versionCode = 10004
|
||||
versionName = "1.0.4"
|
||||
multiDexEnabled = true
|
||||
|
||||
val abiFilterList = (properties["ABI_FILTERS"] as? String)?.split(';')
|
||||
|
||||
@@ -19,18 +19,6 @@ interface ServiceControl {
|
||||
*/
|
||||
fun stopService()
|
||||
|
||||
/** Proxy-only services have no Android VPN lease and retain their old behavior. */
|
||||
fun sessionEpoch(): Long = 0L
|
||||
|
||||
fun isSessionValid(epoch: Long): Boolean = true
|
||||
|
||||
/** Report success only while the service still owns the session being started. */
|
||||
fun reportIfSessionValid(epoch: Long, report: () -> Unit): Boolean {
|
||||
if (!isSessionValid(epoch)) return false
|
||||
report()
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Protects the VPN socket.
|
||||
* @param socket The socket to protect.
|
||||
|
||||
@@ -38,7 +38,6 @@ import libv2ray.CoreController
|
||||
import libv2ray.ProcessFinder
|
||||
import java.lang.ref.SoftReference
|
||||
import java.net.InetSocketAddress
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
object CoreServiceManager {
|
||||
|
||||
@@ -47,8 +46,6 @@ object CoreServiceManager {
|
||||
private var currentConfig: ProfileItem? = null
|
||||
private var processFinder: XrayProcessFinder? = null
|
||||
private var browserDialer: IDialerService? = null
|
||||
private val coreLifecycleLock = Any()
|
||||
private val coreGeneration = AtomicLong(0)
|
||||
|
||||
var serviceControl: SoftReference<ServiceControl>? = null
|
||||
set(value) {
|
||||
@@ -114,10 +111,7 @@ object CoreServiceManager {
|
||||
* Checks if the V2Ray service is running.
|
||||
* @return True if the service is running, false otherwise.
|
||||
*/
|
||||
fun isRunning(): Boolean {
|
||||
val control = serviceControl?.get() ?: return false
|
||||
return coreController.isRunning && control.isSessionValid(control.sessionEpoch())
|
||||
}
|
||||
fun isRunning() = coreController.isRunning
|
||||
|
||||
/**
|
||||
* Gets the name of the currently running server.
|
||||
@@ -208,35 +202,26 @@ object CoreServiceManager {
|
||||
return false
|
||||
}
|
||||
|
||||
val control = serviceControl?.get()
|
||||
if (control == null) {
|
||||
val service = getService()
|
||||
if (service == null) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-Manager: Service is null")
|
||||
return false
|
||||
}
|
||||
val service = control.getService()
|
||||
val epoch = control.sessionEpoch()
|
||||
|
||||
try {
|
||||
requireSession(control, epoch)
|
||||
doStartCoreLoop(service, vpnInterface, control, epoch)
|
||||
doStartCoreLoop(service, vpnInterface)
|
||||
return true
|
||||
} catch (e: Exception) {
|
||||
val message = e.message?.takeUnless { it.isBlank() } ?: e.javaClass.simpleName
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-Manager: $message", e)
|
||||
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_FAILURE, message)
|
||||
if (serviceControl?.get() === control) stopCoreLoop()
|
||||
NotificationManager.cancelNotification()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private fun requireSession(control: ServiceControl, epoch: Long) {
|
||||
check(serviceControl?.get() === control && control.isSessionValid(epoch)) {
|
||||
"VPN permission or startup session was revoked"
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
private fun doStartCoreLoop(service: Service, vpnInterface: ParcelFileDescriptor?, control: ServiceControl, epoch: Long) {
|
||||
private fun doStartCoreLoop(service: Service, vpnInterface: ParcelFileDescriptor?) {
|
||||
val guid = MmkvManager.getSelectServer() ?: error("No server selected")
|
||||
val config = MmkvManager.decodeServerConfig(guid) ?: error("Failed to decode server config")
|
||||
|
||||
@@ -246,7 +231,6 @@ object CoreServiceManager {
|
||||
if (!result.status) {
|
||||
error(result.errorMessage.ifBlank { "Failed to get V2Ray config" })
|
||||
}
|
||||
requireSession(control, epoch)
|
||||
|
||||
val mFilter = IntentFilter(AppConfig.BROADCAST_ACTION_SERVICE)
|
||||
mFilter.addAction(Intent.ACTION_SCREEN_ON)
|
||||
@@ -267,14 +251,7 @@ object CoreServiceManager {
|
||||
|
||||
NotificationManager.showNotification(currentConfig)
|
||||
CoreNativeManager.reconcileBrowserDialer(dialerAddr)
|
||||
// Do not hold a VPN lease lock while entering native code: its callbacks
|
||||
// may arrive on another thread. A revoke invalidates that lease at once.
|
||||
synchronized(coreLifecycleLock) {
|
||||
requireSession(control, epoch)
|
||||
coreGeneration.incrementAndGet()
|
||||
coreController.startLoop(result.content, tunFd)
|
||||
}
|
||||
requireSession(control, epoch)
|
||||
coreController.startLoop(result.content, tunFd)
|
||||
|
||||
if (!coreController.isRunning) {
|
||||
error("Core failed to start")
|
||||
@@ -292,11 +269,8 @@ object CoreServiceManager {
|
||||
browserDialer!!.start(service, dialerAddr)
|
||||
}
|
||||
|
||||
requireSession(control, epoch)
|
||||
check(control.reportIfSessionValid(epoch) {
|
||||
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_SUCCESS, "")
|
||||
}) { "VPN session was revoked before startup could be reported" }
|
||||
if (isRunning()) NotificationManager.startSpeedNotification()
|
||||
MessageUtil.sendMsg2UI(service, AppConfig.MSG_STATE_START_SUCCESS, "")
|
||||
NotificationManager.startSpeedNotification()
|
||||
LogUtil.i(AppConfig.TAG, "StartCore-Manager: Core started successfully")
|
||||
}
|
||||
|
||||
@@ -308,17 +282,12 @@ object CoreServiceManager {
|
||||
fun stopCoreLoop(): Boolean {
|
||||
val service = getService() ?: return false
|
||||
|
||||
val generation = coreGeneration.get()
|
||||
// Always schedule stop, even when revoke preceded native startup. The
|
||||
// serialized generation check also prevents an old stop killing a new core.
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
synchronized(coreLifecycleLock) {
|
||||
if (coreGeneration.get() == generation) {
|
||||
try {
|
||||
coreController.stopLoop()
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-Manager: Failed to stop V2Ray loop", e)
|
||||
}
|
||||
if (coreController.isRunning) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
coreController.stopLoop()
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-Manager: Failed to stop V2Ray loop", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,10 +485,9 @@ object CoreServiceManager {
|
||||
val serviceControl = serviceControl?.get() ?: return
|
||||
when (intent?.getIntExtra("key", 0)) {
|
||||
AppConfig.MSG_REGISTER_CLIENT -> {
|
||||
val epoch = serviceControl.sessionEpoch()
|
||||
if (!coreController.isRunning || !serviceControl.reportIfSessionValid(epoch) {
|
||||
MessageUtil.sendMsg2UI(serviceControl.getService(), AppConfig.MSG_STATE_RUNNING, "")
|
||||
}) {
|
||||
if (coreController.isRunning) {
|
||||
MessageUtil.sendMsg2UI(serviceControl.getService(), AppConfig.MSG_STATE_RUNNING, "")
|
||||
} else {
|
||||
MessageUtil.sendMsg2UI(serviceControl.getService(), AppConfig.MSG_STATE_NOT_RUNNING, "")
|
||||
}
|
||||
}
|
||||
@@ -557,9 +525,9 @@ object CoreServiceManager {
|
||||
|
||||
Intent.ACTION_SCREEN_ON -> {
|
||||
LogUtil.i(AppConfig.TAG, "StartCore-Manager: Screen on")
|
||||
if (isRunning()) NotificationManager.startSpeedNotification()
|
||||
NotificationManager.startSpeedNotification()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,6 @@ import android.net.NetworkRequest
|
||||
import android.net.ProxyInfo
|
||||
import android.net.VpnService
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.ParcelFileDescriptor
|
||||
import android.os.StrictMode
|
||||
import androidx.annotation.RequiresApi
|
||||
@@ -27,14 +25,12 @@ import com.v2ray.ang.handler.MmkvManager
|
||||
import com.v2ray.ang.handler.NotificationManager
|
||||
import com.v2ray.ang.handler.SettingsManager
|
||||
import com.v2ray.ang.util.LogUtil
|
||||
import com.v2ray.ang.util.MessageUtil
|
||||
import com.v2ray.ang.util.MyContextWrapper
|
||||
import com.v2ray.ang.util.Utils
|
||||
import java.lang.ref.SoftReference
|
||||
import com.v2ray.ang.ucvl.UcvlApiClient
|
||||
import com.v2ray.ang.ucvl.UcvlAuthorizationGuard
|
||||
import com.v2ray.ang.ucvl.UcvlSecureStore
|
||||
import com.v2ray.ang.ucvl.UcvlVpnStartupLease
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
@@ -44,12 +40,8 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@SuppressLint("VpnServicePolicy")
|
||||
class CoreVpnService : VpnService(), ServiceControl {
|
||||
@Volatile private var mInterface: ParcelFileDescriptor? = null
|
||||
@Volatile private var isRunning = false
|
||||
@Volatile private var permissionRevoked = false
|
||||
@Volatile private var startupEpoch = 0L
|
||||
private val startupLease = UcvlVpnStartupLease()
|
||||
private val mainHandler = Handler(Looper.getMainLooper())
|
||||
private lateinit var mInterface: ParcelFileDescriptor
|
||||
private var isRunning = false
|
||||
private var tun2SocksService: Tun2SocksControl? = null
|
||||
private val authorizationScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
|
||||
private var authorizationJob: Job? = null
|
||||
@@ -102,9 +94,6 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
|
||||
override fun onRevoke() {
|
||||
LogUtil.w(AppConfig.TAG, "StartCore-VPN: Permission revoked")
|
||||
// onRevoke may arrive on Binder while establish/startLoop blocks main.
|
||||
// Invalidate first; cleanup must not race those main-thread operations.
|
||||
permissionRevoked = true
|
||||
stopAllService()
|
||||
}
|
||||
|
||||
@@ -114,43 +103,39 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
// }
|
||||
|
||||
override fun onDestroy() {
|
||||
startupLease.invalidate()
|
||||
stopAllServiceOnMain(false)
|
||||
authorizationScope.cancel()
|
||||
super.onDestroy()
|
||||
LogUtil.i(AppConfig.TAG, "StartCore-VPN: Service destroyed")
|
||||
|
||||
// Ensure VPN interface is properly closed when the service is destroyed without
|
||||
// going through stopAllService() (e.g. when killed unexpectedly). isRunning is
|
||||
// set to false at the start of stopAllService(), so this guard prevents a double-close.
|
||||
if (isRunning) {
|
||||
try {
|
||||
if (::mInterface.isInitialized) {
|
||||
mInterface.close()
|
||||
LogUtil.i(AppConfig.TAG, "StartCore-VPN: VPN interface closed in onDestroy")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Failed to close interface in onDestroy", e)
|
||||
}
|
||||
}
|
||||
|
||||
NotificationManager.cancelNotification()
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
if (isSessionValid(startupEpoch)) return START_NOT_STICKY
|
||||
if (permissionRevoked) {
|
||||
stopSelf()
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
if (isRunning) return START_NOT_STICKY
|
||||
val token = UcvlSecureStore.loadToken()
|
||||
if (token.isNullOrBlank()) {
|
||||
stopSelf()
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
LogUtil.i(AppConfig.TAG, "StartCore-VPN: Service command received")
|
||||
startupEpoch = startupLease.begin()
|
||||
NotificationManager.showNotification(null)
|
||||
val configured = try {
|
||||
setupVpnService(startupEpoch)
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: VPN setup failed", e)
|
||||
false
|
||||
}
|
||||
if (!configured) {
|
||||
MessageUtil.sendMsg2UI(this, AppConfig.MSG_STATE_START_FAILURE,
|
||||
"VPN permission or interface is no longer available")
|
||||
stopAllService()
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
setupVpnService()
|
||||
startService()
|
||||
if (isSessionValid(startupEpoch)) {
|
||||
if (isRunning) {
|
||||
authorizationJob?.cancel()
|
||||
authorizationJob = authorizationScope.launch {
|
||||
UcvlApiClient().use { api ->
|
||||
@@ -174,13 +159,11 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
}
|
||||
|
||||
override fun startService() {
|
||||
val vpnInterface = mInterface
|
||||
if (vpnInterface == null || !isSessionValid(startupEpoch)) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Interface or VPN session no longer valid")
|
||||
stopAllService()
|
||||
if (!::mInterface.isInitialized) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Interface not initialized")
|
||||
return
|
||||
}
|
||||
if (!CoreServiceManager.startCoreLoop(vpnInterface)) {
|
||||
if (!CoreServiceManager.startCoreLoop(mInterface)) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Failed to start core loop")
|
||||
stopAllService()
|
||||
return
|
||||
@@ -191,20 +174,6 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
stopAllService(true)
|
||||
}
|
||||
|
||||
override fun sessionEpoch(): Long = startupEpoch
|
||||
|
||||
override fun isSessionValid(epoch: Long): Boolean {
|
||||
if (!startupLease.isValid(epoch) || !isRunning ||
|
||||
mInterface?.fileDescriptor?.valid() != true) return false
|
||||
val prepared = try { prepare(this) == null } catch (_: Exception) { false }
|
||||
return prepared && startupLease.isValid(epoch) && !permissionRevoked
|
||||
}
|
||||
|
||||
override fun reportIfSessionValid(epoch: Long, report: () -> Unit): Boolean {
|
||||
if (!isSessionValid(epoch)) return false
|
||||
return startupLease.reportIfValid(epoch, report)
|
||||
}
|
||||
|
||||
override fun vpnProtect(socket: Int): Boolean {
|
||||
return protect(socket)
|
||||
}
|
||||
@@ -220,29 +189,28 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
* Sets up the VPN service.
|
||||
* Prepares the VPN and configures it if preparation is successful.
|
||||
*/
|
||||
private fun setupVpnService(epoch: Long): Boolean {
|
||||
if (!startupLease.isValid(epoch) || permissionRevoked) return false
|
||||
private fun setupVpnService() {
|
||||
val prepare = prepare(this)
|
||||
if (prepare != null) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Permission not granted")
|
||||
return false
|
||||
stopSelf()
|
||||
return
|
||||
}
|
||||
|
||||
if (!configureVpnService(epoch)) {
|
||||
if (configureVpnService() != true) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Configuration failed")
|
||||
return false
|
||||
stopSelf()
|
||||
return
|
||||
}
|
||||
|
||||
if (!isSessionValid(epoch)) return false
|
||||
runTun2socks()
|
||||
return isSessionValid(epoch)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the VPN service.
|
||||
* @return True if the VPN service was configured successfully, false otherwise.
|
||||
*/
|
||||
private fun configureVpnService(epoch: Long): Boolean {
|
||||
private fun configureVpnService(): Boolean {
|
||||
val builder = Builder()
|
||||
|
||||
// Configure network settings (addresses, routing and DNS)
|
||||
@@ -253,8 +221,9 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
|
||||
// Close the old interface since the parameters have been changed
|
||||
try {
|
||||
mInterface?.close()
|
||||
mInterface = null
|
||||
if (::mInterface.isInitialized) {
|
||||
mInterface.close()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtil.w(AppConfig.TAG, "Failed to close old interface", e)
|
||||
}
|
||||
@@ -264,18 +233,9 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
|
||||
// Create a new interface using the builder and save the parameters
|
||||
try {
|
||||
if (!startupLease.isValid(epoch) || prepare(this) != null) return false
|
||||
val established = builder.establish() ?: return false
|
||||
// Keep ownership even if a subsequent permission check throws, so
|
||||
// the common failure cleanup always closes the newly created fd.
|
||||
mInterface = established
|
||||
if (!startupLease.isValid(epoch) || permissionRevoked || prepare(this) != null) {
|
||||
established.close()
|
||||
mInterface = null
|
||||
return false
|
||||
}
|
||||
mInterface = builder.establish()!!
|
||||
isRunning = true
|
||||
return isSessionValid(epoch)
|
||||
return true
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "Failed to establish VPN interface", e)
|
||||
stopAllService()
|
||||
@@ -405,15 +365,12 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
* Starts the tun2socks process with the appropriate parameters.
|
||||
*/
|
||||
private fun runTun2socks() {
|
||||
val epoch = startupEpoch
|
||||
val vpnInterface = mInterface ?: return
|
||||
if (!isSessionValid(epoch)) return
|
||||
if (SettingsManager.isUsingHevTun()) {
|
||||
tun2SocksService = TProxyService(
|
||||
context = applicationContext,
|
||||
vpnInterface = vpnInterface,
|
||||
isRunningProvider = { isSessionValid(epoch) },
|
||||
restartCallback = { mainHandler.post { if (isSessionValid(epoch)) runTun2socks() } }
|
||||
vpnInterface = mInterface,
|
||||
isRunningProvider = { isRunning },
|
||||
restartCallback = { runTun2socks() }
|
||||
)
|
||||
} else {
|
||||
tun2SocksService = null
|
||||
@@ -423,19 +380,6 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
}
|
||||
|
||||
private fun stopAllService(isForced: Boolean = true) {
|
||||
val epoch = startupEpoch
|
||||
startupLease.invalidate()
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
stopAllServiceOnMain(isForced)
|
||||
} else {
|
||||
mainHandler.post {
|
||||
// A cleanup posted by an older session must not stop a later one.
|
||||
if (startupEpoch == epoch) stopAllServiceOnMain(isForced)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopAllServiceOnMain(isForced: Boolean) {
|
||||
authorizationJob?.cancel()
|
||||
authorizationJob = null
|
||||
// val configName = defaultDPreference.getPrefString(PREF_CURR_CONFIG_GUID, "")
|
||||
@@ -463,14 +407,24 @@ class CoreVpnService : VpnService(), ServiceControl {
|
||||
//in a row for several times. You will find that later created v2ray core report port in use
|
||||
//which means the first v2ray core somehow failed to stop and release the port.
|
||||
stopSelf()
|
||||
}
|
||||
// Close on every failure/destruction, including revoke before native start.
|
||||
val vpnInterface = mInterface
|
||||
mInterface = null
|
||||
try {
|
||||
vpnInterface?.close()
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Failed to close interface", e)
|
||||
|
||||
// Add a small delay to allow the async core stop operation to complete
|
||||
// before closing the VPN interface, preventing a race condition that can
|
||||
// leave the VPN icon in the status bar after stopping the service.
|
||||
try {
|
||||
Thread.sleep(100)
|
||||
} catch (e: InterruptedException) {
|
||||
LogUtil.w(AppConfig.TAG, "StartCore-VPN: Sleep interrupted", e)
|
||||
}
|
||||
|
||||
try {
|
||||
if (::mInterface.isInitialized) {
|
||||
mInterface.close()
|
||||
LogUtil.i(AppConfig.TAG, "StartCore-VPN: VPN interface closed")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtil.e(AppConfig.TAG, "StartCore-VPN: Failed to close interface", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Button
|
||||
@@ -28,7 +27,6 @@ import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.v2ray.ang.AppConfig
|
||||
import com.v2ray.ang.R
|
||||
import com.v2ray.ang.BuildConfig
|
||||
@@ -49,7 +47,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
private val releases = UcvlReleaseChecker()
|
||||
private var checkingUpdates = false
|
||||
private var availableUpdate: UcvlUpdateOffer? = null
|
||||
private var promptedUpdateVersion: String? = null
|
||||
private val mainViewModel: MainViewModel by viewModels()
|
||||
private var profile: UcvlProfile? = null
|
||||
private var busy = false
|
||||
@@ -87,7 +84,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
} else {
|
||||
pendingStart = false
|
||||
setConnectionState(false, "未连接", "需要允许系统 VPN 连接请求")
|
||||
availableUpdate?.let { showUpdateOffer(it, automatic = true) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +99,7 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
if (intent?.action != UcvlTraffic.ACTION) return
|
||||
val up = intent.getLongExtra("up_speed", 0)
|
||||
val down = intent.getLongExtra("down_speed", 0)
|
||||
proxySpeed.text = "↑ ${UcvlTrafficFormat.speed(up)} ↓ ${UcvlTrafficFormat.speed(down)}"
|
||||
proxySpeed.text = "↑ ${formatBytes(up)}/s ↓ ${formatBytes(down)}/s"
|
||||
proxyTotal.text = "本次代理 ${formatBytes(intent.getLongExtra("total", 0))} · 仅统计 proxy 出站"
|
||||
speedPoints.addLast(up to down)
|
||||
while (speedPoints.size > 40) speedPoints.removeFirst()
|
||||
@@ -111,22 +107,8 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun prepareScenicWindow() {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
if (Build.VERSION.SDK_INT < 35) {
|
||||
// Older releases keep the theme's opaque bars, including its night colors.
|
||||
val surface = ContextCompat.getColor(this, R.color.ucvl_surface)
|
||||
window.statusBarColor = surface
|
||||
window.navigationBarColor = surface
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
promptedUpdateVersion = savedInstanceState?.getString("ucvl.promptedUpdateVersion")
|
||||
prepareScenicWindow()
|
||||
setContentView(R.layout.activity_ucvl_main)
|
||||
val root = findViewById<View>(R.id.ucvlRoot)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(root) { view, insets ->
|
||||
@@ -136,7 +118,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
insets
|
||||
}
|
||||
WindowCompat.getInsetsController(window, root).isAppearanceLightStatusBars = true
|
||||
WindowCompat.getInsetsController(window, root).isAppearanceLightNavigationBars = true
|
||||
bindViews()
|
||||
setupActions()
|
||||
setupCoreState()
|
||||
@@ -156,16 +137,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
checkUpdates(manual = false)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
availableUpdate?.let { showUpdateOffer(it, automatic = true) }
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
outState.putString("ucvl.promptedUpdateVersion", promptedUpdateVersion)
|
||||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
private fun bindViews() {
|
||||
loginPanel = findViewById(R.id.loginPanel)
|
||||
dashboardPanel = findViewById(R.id.dashboardPanel)
|
||||
@@ -197,7 +168,10 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
findViewById<Button>(R.id.checkUpdatesButton).setOnClickListener {
|
||||
val offer = availableUpdate
|
||||
if (offer == null) checkUpdates(manual = true)
|
||||
else showUpdateOffer(offer, automatic = false)
|
||||
else MaterialAlertDialogBuilder(this).setTitle("发现新版本 ${offer.version}")
|
||||
.setMessage("从公司 Git 下载并使用系统安装器覆盖升级,保留账号和配置。不要先卸载旧版本。Android 要求的安装授权仍需本人确认。")
|
||||
.setPositiveButton("前往下载") { _, _ -> openWeb(offer.url) }
|
||||
.setNegativeButton("暂不更新", null).show()
|
||||
}
|
||||
findViewById<View>(R.id.registerButton).setOnClickListener {
|
||||
openWeb("https://vpn.toplc.cn/register/")
|
||||
@@ -439,7 +413,7 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
val identity = if (value.identityType == "employee") "内部员工" else "外部联系人"
|
||||
accountText.text = "${value.email} · $identity"
|
||||
|
||||
routeSpinner.adapter = ArrayAdapter(this, R.layout.ucvl_spinner_item, value.routeModes)
|
||||
routeSpinner.adapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, value.routeModes)
|
||||
val lastRoute = MmkvManager.decodeSettingsString(LAST_ROUTE_KEY, "smart").orEmpty()
|
||||
value.routeModes.indexOfFirst { it.id == lastRoute }.takeIf { it >= 0 }?.let(routeSpinner::setSelection)
|
||||
usageChart.setPoints(value.usageHistory.orEmpty().map { it.uploadBytes to it.downloadBytes })
|
||||
@@ -498,7 +472,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
statusDetail.text = message
|
||||
}
|
||||
loginButton.text = if (value && loginPanel.visibility == View.VISIBLE) "请稍候…" else "安全登录"
|
||||
if (!value) availableUpdate?.let { showUpdateOffer(it, automatic = true) }
|
||||
}
|
||||
|
||||
private fun friendlyError(exception: Exception): String = when (exception) {
|
||||
@@ -520,7 +493,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
val offer = availableUpdate
|
||||
button.text = offer?.let { "下载新版本 ${it.version}" } ?: "检查软件更新"
|
||||
status.text = if (offer != null) "新版本已发布,可覆盖升级保留配置" else if (manual) "暂无更新的 Android 正式版" else ""
|
||||
if (offer != null && !manual) showUpdateOffer(offer, automatic = true)
|
||||
} catch (cancelled: kotlinx.coroutines.CancellationException) {
|
||||
throw cancelled
|
||||
} catch (_: Exception) {
|
||||
@@ -532,16 +504,6 @@ class UcvlMainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showUpdateOffer(offer: UcvlUpdateOffer, automatic: Boolean) {
|
||||
if (isFinishing || isDestroyed || !lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) return
|
||||
if (automatic && (busy || pendingStart || promptedUpdateVersion == offer.version)) return
|
||||
promptedUpdateVersion = offer.version
|
||||
MaterialAlertDialogBuilder(this).setTitle("发现新版本 ${offer.version}")
|
||||
.setMessage("从公司 Git 下载并使用系统安装器覆盖升级,保留账号和配置。不要先卸载旧版本。Android 要求的安装授权仍需本人确认。")
|
||||
.setPositiveButton("前往下载") { _, _ -> openWeb(offer.url) }
|
||||
.setNegativeButton("暂不更新", null).show()
|
||||
}
|
||||
|
||||
private fun openWeb(url: String) {
|
||||
try { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) }
|
||||
catch (_: android.content.ActivityNotFoundException) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.v2ray.ang.ucvl
|
||||
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -22,14 +20,8 @@ class UcvlReleaseChecker : Closeable {
|
||||
.connectTimeout(10, TimeUnit.SECONDS).callTimeout(20, TimeUnit.SECONDS).build()
|
||||
|
||||
suspend fun latest(current: String): UcvlUpdateOffer? = withContext(Dispatchers.IO) {
|
||||
// One deadline covers every page; a shared cross-platform repository can
|
||||
// place Android releases beyond the first page after many Windows releases.
|
||||
val deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(20)
|
||||
lookup(current) { page ->
|
||||
val call = client.newCall(Request.Builder().url("$RELEASE_API&page=$page")
|
||||
.header("Accept", "application/json").get().build())
|
||||
call.timeout().deadlineNanoTime(deadline)
|
||||
call.execute().use { response ->
|
||||
client.newCall(Request.Builder().url(RELEASE_API).header("Accept", "application/json").get().build())
|
||||
.execute().use { response ->
|
||||
if (!response.isSuccessful) throw IOException("暂时无法读取公司 Git 版本列表。")
|
||||
val body = response.body
|
||||
if (body.contentLength() > MAX_METADATA) throw IOException("版本列表过大。")
|
||||
@@ -37,9 +29,8 @@ class UcvlReleaseChecker : Closeable {
|
||||
val source = body.source()
|
||||
source.request(MAX_METADATA + 1)
|
||||
if (source.buffer.size > MAX_METADATA) throw IOException("版本列表过大。")
|
||||
source.readUtf8()
|
||||
select(source.readUtf8(), current)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
@@ -54,9 +45,6 @@ class UcvlReleaseChecker : Closeable {
|
||||
const val RELEASE_API = "https://pro.ucvl.cn/api/v1/repos/admin/ucvl-software-downloads/releases?limit=50"
|
||||
private const val DOWNLOAD_ROOT = "https://pro.ucvl.cn/admin/ucvl-software-downloads/releases/download/"
|
||||
private const val MAX_METADATA = 1024L * 1024
|
||||
private const val MAX_TOTAL_METADATA = 4L * MAX_METADATA
|
||||
private const val PAGE_SIZE = 50
|
||||
private const val MAX_PAGES = 10
|
||||
private val tagPattern = Regex("^android-v(\\d+\\.\\d+\\.\\d+)$")
|
||||
private val versionPattern = Regex("^(\\d+)\\.(\\d+)\\.(\\d+)$")
|
||||
private val cleanup = Executors.newSingleThreadExecutor { work ->
|
||||
@@ -73,43 +61,13 @@ class UcvlReleaseChecker : Closeable {
|
||||
}
|
||||
|
||||
internal fun select(json: String, current: String): UcvlUpdateOffer? {
|
||||
return select(array(json), current)
|
||||
}
|
||||
|
||||
internal suspend fun lookup(current: String, loadPage: suspend (Int) -> String): UcvlUpdateOffer? {
|
||||
val releases = JsonArray()
|
||||
var bytes = 0L
|
||||
for (page in 1..MAX_PAGES) {
|
||||
val text = loadPage(page)
|
||||
val size = text.toByteArray(Charsets.UTF_8).size.toLong()
|
||||
bytes += size
|
||||
if (size > MAX_METADATA || bytes > MAX_TOTAL_METADATA) throw IOException("版本列表过大。")
|
||||
val rows = array(text)
|
||||
releases.addAll(rows)
|
||||
if (rows.size() < PAGE_SIZE) return select(releases, current)
|
||||
}
|
||||
throw IOException("版本列表分页过多,请稍后重试或从公司发布页下载。")
|
||||
}
|
||||
|
||||
private fun array(text: String): JsonArray = try {
|
||||
JsonParser.parseString(text).asJsonArray
|
||||
} catch (error: RuntimeException) {
|
||||
throw IOException("版本列表格式异常。", error)
|
||||
}
|
||||
|
||||
private fun select(rows: JsonArray, current: String): UcvlUpdateOffer? {
|
||||
val installed = parts(current.substringBefore('-').substringBefore('+'))
|
||||
val releases = rows.filter { it.isJsonObject }.map { it.asJsonObject }
|
||||
val releases = JsonParser.parseString(json).asJsonArray.map { it.asJsonObject }
|
||||
.filter { it.get("draft")?.asBoolean == false && it.get("prerelease")?.asBoolean == false }
|
||||
.mapNotNull { release ->
|
||||
// Malformed records for other products must not hide valid
|
||||
// Android updates. Missing flags remain ineligible.
|
||||
val tag = release.get("tag_name")?.takeIf { it.isJsonPrimitive && it.asJsonPrimitive.isString }
|
||||
?.asString.orEmpty()
|
||||
val match = tagPattern.matchEntire(tag) ?: return@mapNotNull null
|
||||
if (!release.isFalse("draft") || !release.isFalse("prerelease")) return@mapNotNull null
|
||||
val version = match.groupValues[1]
|
||||
val parsed = try { parts(version) } catch (_: IOException) { return@mapNotNull null }
|
||||
Triple(release, version, parsed)
|
||||
tagPattern.matchEntire(release.get("tag_name")?.asString.orEmpty())?.let { match ->
|
||||
Triple(release, match.groupValues[1], parts(match.groupValues[1]))
|
||||
}
|
||||
}
|
||||
val selected = releases.maxWithOrNull { left, right -> compare(left.third, right.third) } ?: return null
|
||||
if (compare(selected.third, installed) <= 0) return null
|
||||
@@ -117,18 +75,12 @@ class UcvlReleaseChecker : Closeable {
|
||||
val filename = "UCVL-Zonghengjia-$version-android-universal.apk"
|
||||
// Universal is an explicit cross-ABI package; never offer an arbitrary
|
||||
// first attachment, a Windows EXE, or a different publisher's APK.
|
||||
val assets = selected.first.get("assets")?.takeIf { it.isJsonArray }?.asJsonArray
|
||||
?.filter { it.isJsonObject }?.map { it.asJsonObject }
|
||||
?.filter { it.get("name")?.takeIf { value -> value.isJsonPrimitive }?.asString == filename }
|
||||
?: throw IOException("正式版本缺少 Android 安装包列表。")
|
||||
val assets = selected.first.getAsJsonArray("assets").map { it.asJsonObject }
|
||||
.filter { it.get("name")?.asString == filename }
|
||||
if (assets.size != 1) throw IOException("正式版本缺少唯一的 Android 通用安装包。")
|
||||
val size = assets.single().get("size")?.asLong ?: 0
|
||||
if (size <= 0 || size > 250L * 1024 * 1024) throw IOException("安装包大小异常。")
|
||||
return UcvlUpdateOffer(version, "$DOWNLOAD_ROOT${selected.first.get("tag_name").asString}/$filename", size)
|
||||
}
|
||||
|
||||
private fun JsonObject.isFalse(name: String): Boolean = get(name)?.let {
|
||||
it.isJsonPrimitive && it.asJsonPrimitive.isBoolean && !it.asBoolean
|
||||
} == true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.v2ray.ang.ucvl
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
/** Proxy speed uses KB/s or larger units, including idle and very small samples. */
|
||||
object UcvlTrafficFormat {
|
||||
fun speed(bytesPerSecond: Long): String {
|
||||
if (bytesPerSecond <= 0) return "0.0 KB/s"
|
||||
var amount = bytesPerSecond.toDouble() / 1024
|
||||
if (amount < 0.1) return "<0.1 KB/s"
|
||||
val units = arrayOf("KB/s", "MB/s", "GB/s", "TB/s")
|
||||
var unit = 0
|
||||
while (amount >= 1024 && unit < units.lastIndex) { amount /= 1024; unit++ }
|
||||
return String.format(Locale.US, "%.1f %s", amount, units[unit])
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.v2ray.ang.ucvl
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
/**
|
||||
* A startup owns one epoch. Android can revoke it on a Binder thread while the
|
||||
* main thread is still establishing the TUN or starting native code.
|
||||
*
|
||||
* Never hold [reportLock] around Android permission calls, native start/stop, or
|
||||
* cleanup. It only orders invalidation with short, final state reports.
|
||||
*/
|
||||
class UcvlVpnStartupLease {
|
||||
private val state = AtomicLong(0)
|
||||
private val reportLock = Any()
|
||||
|
||||
fun begin(): Long = synchronized(reportLock) {
|
||||
val next = (state.get() and -2L) + 3L
|
||||
state.set(next)
|
||||
next
|
||||
}
|
||||
|
||||
fun invalidate() = synchronized(reportLock) {
|
||||
state.set(state.get() and -2L)
|
||||
}
|
||||
|
||||
fun isValid(epoch: Long): Boolean = epoch and 1L == 1L && state.get() == epoch
|
||||
|
||||
fun reportIfValid(epoch: Long, report: () -> Unit): Boolean = synchronized(reportLock) {
|
||||
if (!isValid(epoch)) return@synchronized false
|
||||
report()
|
||||
true
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 MiB |
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/ucvl_glass_white" />
|
||||
<corners android:radius="18dp" />
|
||||
<stroke android:width="1dp" android:color="@color/ucvl_glass_border" />
|
||||
</shape>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:startColor="#D9F3F7FC"
|
||||
android:centerColor="#26F3F7FC"
|
||||
android:endColor="#D9F3F7FC" />
|
||||
</shape>
|
||||
@@ -1,482 +1,400 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/ucvlRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/ucvl_surface">
|
||||
android:background="@color/ucvl_surface"
|
||||
android:fillViewport="true">
|
||||
|
||||
<!-- The original desktop artwork stays separate from every native control. -->
|
||||
<ImageView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:alpha="0.86"
|
||||
android:contentDescription="@null"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ucvl_landscape_header_v1" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/ucvl_scenic_mist"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/ucvlRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="true"
|
||||
android:fillViewport="true"
|
||||
android:overScrollMode="never">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="18dp"
|
||||
android:paddingEnd="18dp"
|
||||
android:background="@color/ucvl_navy"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="22dp"
|
||||
android:paddingTop="22dp"
|
||||
android:paddingEnd="22dp"
|
||||
android:paddingBottom="22dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="26dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:src="@drawable/zonghengjia_logo" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="纵横家"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="28sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="智能安全网络 · Android"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:src="@drawable/zonghengjia_logo" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loginPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ucvl_glass_card"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="登录纵横家"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="25sp"
|
||||
android:text="优创⁺纵横家"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="使用公司分配的用户名或邮箱登录"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/loginInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="28dp"
|
||||
android:minHeight="56dp"
|
||||
android:autofillHints="username"
|
||||
android:background="@drawable/ucvl_input"
|
||||
android:hint="用户名 / 邮箱"
|
||||
android:inputType="textEmailAddress"
|
||||
android:imeOptions="actionNext"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textColorHint="@color/ucvl_muted" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passwordInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:minHeight="56dp"
|
||||
android:autofillHints="password"
|
||||
android:background="@drawable/ucvl_input"
|
||||
android:hint="密码"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textColorHint="@color/ucvl_muted" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginError"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/ucvl_danger"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="Powered by 优创未来 · Android"
|
||||
android:textColor="#B8DAF4"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/loginButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:minHeight="54dp"
|
||||
android:text="安全登录"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
app:backgroundTint="@color/ucvl_royal"
|
||||
app:cornerRadius="12dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/registerButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:text="注册新用户 · 审核后使用"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/ucvl_royal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:gravity="center"
|
||||
android:text="账号停用后,设备授权与线路会自动失效"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dashboardPanel"
|
||||
<LinearLayout
|
||||
android:id="@+id/loginPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="登录优创⁺纵横家"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="25sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="使用公司分配的用户名或邮箱登录"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/loginInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:autofillHints="username"
|
||||
android:background="@drawable/ucvl_input"
|
||||
android:hint="用户名 / 邮箱"
|
||||
android:inputType="textEmailAddress"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textColorHint="@color/ucvl_muted" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passwordInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:autofillHints="password"
|
||||
android:background="@drawable/ucvl_input"
|
||||
android:hint="密码"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textColorHint="@color/ucvl_muted" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginError"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/ucvl_danger"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/loginButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:text="安全登录"
|
||||
android:textSize="16sp"
|
||||
app:backgroundTint="@color/ucvl_royal"
|
||||
app:cornerRadius="12dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/registerButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent" android:layout_height="48dp"
|
||||
android:text="注册新用户 · 审核后使用" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:gravity="center"
|
||||
android:text="账号停用后,设备授权与线路会自动失效"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dashboardPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="18dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/welcomeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="23sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accountText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="18dp"
|
||||
app:strokeColor="@color/ucvl_border"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusDot"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="●"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="未连接"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusDetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="点击连接,由平台自动选择节点"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="18dp"
|
||||
app:strokeColor="@color/ucvl_border"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ucvl_glass_card"
|
||||
android:orientation="vertical"
|
||||
android:padding="18dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/welcomeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前工作节点"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="23sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/accountText"
|
||||
android:id="@+id/currentNode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="连接后显示实际工作节点"
|
||||
android:textColor="@color/ucvl_royal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="代理模式"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/routeSpinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@drawable/ucvl_input" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/connectButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="连接"
|
||||
android:textSize="17sp"
|
||||
app:backgroundTint="@color/ucvl_royal"
|
||||
app:cornerRadius="14dp" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
app:cardBackgroundColor="@color/ucvl_glass_white"
|
||||
app:cardCornerRadius="18dp"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@color/ucvl_glass_border"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusDot"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="●"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="未连接"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusDetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="点击连接,由平台自动选择节点"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
app:cardBackgroundColor="@color/ucvl_glass_white"
|
||||
app:cardCornerRadius="18dp"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@color/ucvl_glass_border"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="18dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前工作节点"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currentNode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="连接后显示实际工作节点"
|
||||
android:textColor="@color/ucvl_royal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="代理模式"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/routeSpinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="52dp"
|
||||
android:popupBackground="@android:color/white"
|
||||
android:background="@drawable/ucvl_input" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/connectButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:minHeight="56dp"
|
||||
android:text="连接"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="17sp"
|
||||
app:backgroundTint="@color/ucvl_royal"
|
||||
app:cornerRadius="14dp" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
app:cardBackgroundColor="@color/ucvl_glass_white"
|
||||
app:cardCornerRadius="18dp"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@color/ucvl_glass_border"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="18dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="本期流量"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/usageText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="@color/ucvl_royal"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/usageProgress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:max="100"
|
||||
android:progressTint="@color/ucvl_blue" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/planText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView android:id="@+id/proxySpeed" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:layout_marginTop="14dp"
|
||||
android:text="↑ 0.0 KB/s ↓ 0.0 KB/s" android:textColor="@color/ucvl_royal" />
|
||||
<com.v2ray.ang.ucvl.UcvlTrafficChart android:id="@+id/speedChart"
|
||||
android:layout_width="match_parent" android:layout_height="56dp"
|
||||
android:contentDescription="近期代理上传蓝线、下载青线速率,每三秒采样" />
|
||||
<TextView android:id="@+id/proxyTotal" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:text="本次代理 0 B · 仅统计 proxy 出站"
|
||||
android:textColor="@color/ucvl_muted" android:textSize="12sp" />
|
||||
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" android:text="近 7 天代理用量 · 蓝色上传 / 青色下载"
|
||||
android:textColor="@color/ucvl_muted" android:textSize="12sp" />
|
||||
<com.v2ray.ang.ucvl.UcvlTrafficChart android:id="@+id/usageChart"
|
||||
android:layout_width="match_parent" android:layout_height="56dp"
|
||||
android:contentDescription="近七天代理上传和下载用量" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="18dp"
|
||||
app:strokeColor="@color/ucvl_border"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical"
|
||||
android:padding="18dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/refreshButton"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:text="刷新"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/ucvl_royal"
|
||||
app:backgroundTint="@color/ucvl_glass_white"
|
||||
app:strokeColor="@color/ucvl_border" />
|
||||
android:text="本期流量"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/logoutButton"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:id="@+id/usageText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:text="退出账号"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="@color/ucvl_royal"
|
||||
app:backgroundTint="@color/ucvl_glass_white"
|
||||
app:strokeColor="@color/ucvl_border" />
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/usageProgress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:max="100"
|
||||
android:progressTint="@color/ucvl_blue" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/planText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView android:id="@+id/proxySpeed" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:layout_marginTop="14dp"
|
||||
android:text="↑ 0 B/s ↓ 0 B/s" android:textColor="@color/ucvl_royal" />
|
||||
<com.v2ray.ang.ucvl.UcvlTrafficChart android:id="@+id/speedChart"
|
||||
android:layout_width="match_parent" android:layout_height="56dp"
|
||||
android:contentDescription="近期代理上传蓝线、下载青线速率,每三秒采样" />
|
||||
<TextView android:id="@+id/proxyTotal" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:text="本次代理 0 B · 仅统计 proxy 出站"
|
||||
android:textColor="@color/ucvl_muted" android:textSize="12sp" />
|
||||
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" android:text="近 7 天代理用量 · 蓝色上传 / 青色下载"
|
||||
android:textColor="@color/ucvl_muted" android:textSize="12sp" />
|
||||
<com.v2ray.ang.ucvl.UcvlTrafficChart android:id="@+id/usageChart"
|
||||
android:layout_width="match_parent" android:layout_height="56dp"
|
||||
android:contentDescription="近七天代理上传和下载用量" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/exitButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:minHeight="48dp"
|
||||
android:text="断开并退出应用"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/ucvl_danger" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center"
|
||||
android:text="公司策略 · 代理流量统计\nvpn.toplc.cn · © 2026 UCVL"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:background="@drawable/ucvl_glass_card"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/updateStatus"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:gravity="center" android:textSize="12sp" android:paddingHorizontal="20dp"
|
||||
android:textColor="@color/ucvl_muted" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/checkUpdatesButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:text="检查软件更新"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/ucvl_royal" />
|
||||
android:id="@+id/refreshButton"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_weight="1"
|
||||
android:text="刷新" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/openSourceButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:text="版本与开源许可"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:textColor="@color/ucvl_royal" />
|
||||
android:id="@+id/logoutButton"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:text="退出账号" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/exitButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="断开并退出应用"
|
||||
android:textColor="@color/ucvl_danger" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center"
|
||||
android:text="公司策略 · 代理流量统计\nvpn.toplc.cn · © 2026 UCVL"
|
||||
android:textColor="@color/ucvl_muted"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/updateStatus"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:gravity="center" android:textSize="12sp" android:paddingHorizontal="20dp"
|
||||
android:textColor="@color/ucvl_muted" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/checkUpdatesButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent" android:layout_height="48dp"
|
||||
android:text="检查软件更新" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/openSourceButton"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="match_parent" android:layout_height="48dp"
|
||||
android:text="版本与开源许可" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="48dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:textColor="@color/ucvl_text"
|
||||
android:textSize="15sp" />
|
||||
@@ -5,10 +5,8 @@
|
||||
<color name="ucvl_royal">#1167D8</color>
|
||||
<color name="ucvl_surface">#F3F7FC</color>
|
||||
<color name="ucvl_text">#0B284D</color>
|
||||
<color name="ucvl_muted">#435F7B</color>
|
||||
<color name="ucvl_muted">#7186A1</color>
|
||||
<color name="ucvl_success">#15966A</color>
|
||||
<color name="ucvl_danger">#C63F45</color>
|
||||
<color name="ucvl_border">#D8E4F0</color>
|
||||
<color name="ucvl_glass_white">#80FFFFFF</color>
|
||||
<color name="ucvl_glass_border">#B3FFFFFF</color>
|
||||
</resources>
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.v2ray.ang.ucvl
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
|
||||
class UcvlUpgradeReliabilityTest {
|
||||
private fun android(version: String) = """{"tag_name":"android-v$version","draft":false,"prerelease":false,"assets":[{"name":"UCVL-Zonghengjia-$version-android-universal.apk","size":66000000}]}"""
|
||||
private fun fullPage() = "[" + (1..50).joinToString(",") {
|
||||
"""{"tag_name":"windows-v0.3.$it","draft":false,"prerelease":false,"assets":[]}"""
|
||||
} + "]"
|
||||
|
||||
@Test fun findsAndroidAfterFullPageOfWindowsReleases() = runBlocking {
|
||||
val pages = mutableListOf<Int>()
|
||||
val offer = UcvlReleaseChecker.lookup("1.0.6") { page ->
|
||||
pages.add(page)
|
||||
if (page == 1) fullPage() else "[${android("1.0.7")}]"
|
||||
}
|
||||
assertEquals(listOf(1, 2), pages)
|
||||
assertEquals("1.0.7", offer?.version)
|
||||
}
|
||||
|
||||
@Test fun checksAllPagesBeforeChoosingNumericallyNewest() = runBlocking {
|
||||
val first = fullPage().dropLast(1) + ",${android("1.0.7")}]"
|
||||
val offer = UcvlReleaseChecker.lookup("1.0.6") { page ->
|
||||
if (page == 1) first else "[${android("1.0.10")}]"
|
||||
}
|
||||
assertEquals("1.0.10", offer?.version)
|
||||
}
|
||||
|
||||
@Test fun ignoresMalformedUnrelatedAndOverflowingVersionRecords() {
|
||||
val json = """[null,17,{}, {"tag_name":"windows-v9","draft":"broken"},
|
||||
{"tag_name":"android-v99999999999999.0.0","draft":false,"prerelease":false}, ${android("1.0.7")}]"""
|
||||
assertEquals("1.0.7", UcvlReleaseChecker.select(json, "1.0.6")?.version)
|
||||
}
|
||||
|
||||
@Test fun duplicateUniversalApksFailClosed() {
|
||||
val release = android("1.0.7").replace("\"size\":66000000}]", "\"size\":66000000},{\"name\":\"UCVL-Zonghengjia-1.0.7-android-universal.apk\",\"size\":66000000}]")
|
||||
assertThrows(IOException::class.java) { UcvlReleaseChecker.select("[$release]", "1.0.6") }
|
||||
}
|
||||
|
||||
@Test fun refusesUnboundedPagination() = runBlocking {
|
||||
var calls = 0
|
||||
try {
|
||||
UcvlReleaseChecker.lookup("1.0.6") { calls++; fullPage() }
|
||||
fail("Unbounded release list must fail with a retryable error")
|
||||
} catch (_: IOException) {
|
||||
assertEquals(10, calls)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun rejectsOversizedDecodedPageBeforeParsing() = runBlocking {
|
||||
try {
|
||||
UcvlReleaseChecker.lookup("1.0.6") { " ".repeat(1024 * 1024 + 1) }
|
||||
fail("Decoded page must remain bounded")
|
||||
} catch (_: IOException) { }
|
||||
}
|
||||
|
||||
@Test fun emptyPageEndsLookupWithoutDowngrade() = runBlocking {
|
||||
var calls = 0
|
||||
assertNull(UcvlReleaseChecker.lookup("1.0.7") { calls++; "[]" })
|
||||
assertEquals(1, calls)
|
||||
}
|
||||
|
||||
@Test fun speedUsesKilobytesMinimumWithoutOverstatingTinyTransfers() {
|
||||
assertEquals("0.0 KB/s", UcvlTrafficFormat.speed(0))
|
||||
assertEquals("0.0 KB/s", UcvlTrafficFormat.speed(-10))
|
||||
assertEquals("<0.1 KB/s", UcvlTrafficFormat.speed(1))
|
||||
assertEquals("0.1 KB/s", UcvlTrafficFormat.speed(103))
|
||||
assertEquals("1.0 KB/s", UcvlTrafficFormat.speed(1024))
|
||||
assertEquals("1.5 MB/s", UcvlTrafficFormat.speed(1572864))
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.v2ray.ang.ucvl
|
||||
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class UcvlVpnStartupLeaseTest {
|
||||
@Test fun initialSessionCannotReportRunning() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
assertFalse(lease.isValid(0))
|
||||
assertFalse(lease.reportIfValid(0) { fail("No startup owns the service") })
|
||||
}
|
||||
|
||||
@Test fun beginCreatesValidSession() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
assertTrue(lease.isValid(lease.begin()))
|
||||
}
|
||||
|
||||
@Test fun replacementInvalidatesOlderStartup() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val old = lease.begin()
|
||||
val replacement = lease.begin()
|
||||
assertNotEquals(old, replacement)
|
||||
assertFalse(lease.isValid(old))
|
||||
assertTrue(lease.isValid(replacement))
|
||||
}
|
||||
|
||||
@Test fun revokeBeforeEstablishPreventsStartup() = revokeAt(Phase.BEFORE_ESTABLISH)
|
||||
@Test fun revokeDuringEstablishClosesInterfaceAndSkipsNative() = revokeAt(Phase.ESTABLISHED)
|
||||
@Test fun revokeDuringNativeStartStopsNativeWithoutSuccess() = revokeAt(Phase.NATIVE_STARTED)
|
||||
@Test fun revokeBeforeSuccessBroadcastPreventsGreenState() = revokeAt(Phase.BEFORE_REPORT)
|
||||
|
||||
@Test fun lateSuccessAfterStopCannotReportRunning() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val epoch = lease.begin()
|
||||
lease.invalidate()
|
||||
assertFalse(lease.reportIfValid(epoch) { fail("Stopped startup cannot revive") })
|
||||
}
|
||||
|
||||
@Test fun oldStartupCannotReportSuccessForReplacementSession() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val old = lease.begin()
|
||||
val replacement = lease.begin()
|
||||
assertFalse(lease.reportIfValid(old) { fail("Stale startup") })
|
||||
assertTrue(lease.reportIfValid(replacement) {})
|
||||
}
|
||||
|
||||
@Test fun registrationAfterRevokeCannotReportRunning() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val epoch = lease.begin()
|
||||
lease.invalidate()
|
||||
assertFalse(lease.reportIfValid(epoch) { fail("Native-running alone is insufficient") })
|
||||
}
|
||||
|
||||
@Test fun repeatedInvalidationCannotResurrectSession() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val epoch = lease.begin()
|
||||
repeat(3) { lease.invalidate() }
|
||||
assertFalse(lease.isValid(epoch))
|
||||
val next = lease.begin()
|
||||
assertNotEquals(epoch, next)
|
||||
assertTrue(lease.isValid(next))
|
||||
}
|
||||
|
||||
@Test fun binderCanInvalidateWhileNativeStartBlocksMain() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val epoch = lease.begin()
|
||||
val starting = CountDownLatch(1)
|
||||
val allowReturn = CountDownLatch(1)
|
||||
val finished = CountDownLatch(1)
|
||||
val success = AtomicBoolean(false)
|
||||
val main = Thread {
|
||||
starting.countDown()
|
||||
try {
|
||||
check(allowReturn.await(2, TimeUnit.SECONDS))
|
||||
success.set(lease.reportIfValid(epoch) {})
|
||||
} finally { finished.countDown() }
|
||||
}
|
||||
main.start()
|
||||
assertTrue(starting.await(2, TimeUnit.SECONDS))
|
||||
// No lock spans simulated establish/native code: Binder never waits for main.
|
||||
lease.invalidate()
|
||||
assertFalse(lease.isValid(epoch))
|
||||
allowReturn.countDown()
|
||||
assertTrue(finished.await(2, TimeUnit.SECONDS))
|
||||
assertFalse(success.get())
|
||||
main.join(2_000)
|
||||
}
|
||||
|
||||
@Test fun healthySessionReportsSuccessExactlyOnceWhenRequested() {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val epoch = lease.begin()
|
||||
var reports = 0
|
||||
assertTrue(lease.reportIfValid(epoch) { reports++ })
|
||||
assertEquals(1, reports)
|
||||
}
|
||||
|
||||
private enum class Phase { BEFORE_ESTABLISH, ESTABLISHED, NATIVE_STARTED, BEFORE_REPORT }
|
||||
|
||||
/** Fake Android/native boundaries exercise the same lease checks as the service. */
|
||||
private fun revokeAt(phase: Phase) {
|
||||
val lease = UcvlVpnStartupLease()
|
||||
val epoch = lease.begin()
|
||||
var interfaceOpen = false
|
||||
var nativeRunning = false
|
||||
var success = false
|
||||
fun boundary(at: Phase): Boolean {
|
||||
if (phase == at) lease.invalidate()
|
||||
return lease.isValid(epoch)
|
||||
}
|
||||
try {
|
||||
if (!boundary(Phase.BEFORE_ESTABLISH)) return
|
||||
interfaceOpen = true
|
||||
if (!boundary(Phase.ESTABLISHED)) return
|
||||
nativeRunning = true
|
||||
if (!boundary(Phase.NATIVE_STARTED)) return
|
||||
if (!boundary(Phase.BEFORE_REPORT)) return
|
||||
success = lease.reportIfValid(epoch) {}
|
||||
} finally {
|
||||
if (!lease.isValid(epoch)) {
|
||||
interfaceOpen = false
|
||||
nativeRunning = false
|
||||
}
|
||||
assertFalse("Revoked TUN must close", interfaceOpen)
|
||||
assertFalse("Late native start must stop", nativeRunning)
|
||||
assertFalse("Revoked startup cannot show connected", success)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
# Android 1.0.7 verification scope — 2026-11-07
|
||||
|
||||
This release uses package `cn.toplc.zonghengjia`, base version code `10007`, and APK version code `4010007` for all four ABIs and the universal APK.
|
||||
|
||||
Changes: bounded pagination when checking the shared company release repository; unrelated malformed records do not hide Android updates; a new-version prompt after the foreground activity becomes ready; and proxy speed displayed in KB/s or larger units. Download links remain canonical company universal APK links. Download confirmation opens a browser; Android's own installation confirmation remains required. No VPN shutdown is performed by the release checker.
|
||||
|
||||
The malformed-record regression was reproduced against the retained 1.0.6 checker: the existing `select` method threw `IllegalStateException: Not a JSON Object: null`. The new regression suite exercises this case, releases beyond a full first page, numeric newest-version selection across pages, duplicate package rejection, pagination and decoded-size bounds, empty lists, and minimum-unit speed formatting.
|
||||
|
||||
The release build runs the complete offline JVM suite, preserving the authorization and startup-lease regressions. Test totals are taken from the new build's JUnit XML and bound to its input manifest. Each signed APK is checked for package/version, v2/v3 signatures, the original company signing certificate, and unchanged compiled ZIP entries. The matching GPL source archive is bound to every compiled source input and the seven locked restorable binary dependencies.
|
||||
|
||||
The original company certificate fingerprint is `0f1a09870d6ee1e73b62138f99463e7066f4228ce28b7f16ff0aeccca59ea14f`. Retained 1.0.0, 1.0.2, 1.0.3 and 1.0.6 universal packages use this same certificate, supporting an in-place signed upgrade without uninstalling or deleting app data.
|
||||
|
||||
No physical phone, TV, ADB session, emulator, mobile VPN, Nightowl service, router, or host network was modified for this release. Physical-device VPN behavior, the actual automatic dialog and cover-installation interaction, Service/broadcast races, network transitions, sleep/wake, and sustained authenticated traffic were not tested with this APK. Offline checks do not imply those checks passed.
|
||||
|
||||
Old 1.0.0 installations may need the first upgrade downloaded from the release page because they predate the later release checker. Newer installations can use the company update button. The package does not perform silent installation and does not claim Windows/Tailscale feature parity.
|
||||
@@ -1,70 +0,0 @@
|
||||
{
|
||||
"BuildInputManifestSha256": "b018aec0675debe39dca37f105a325039d018f6b0b84ecb56c962529f6e5ce0d",
|
||||
"FullProductionAcceptance": false,
|
||||
"OriginalSourceFiles": 1010,
|
||||
"PhysicalDeviceTested": false,
|
||||
"PrivateHelperExcluded": true,
|
||||
"ReleaseMetadata": {
|
||||
"FrozenCandidateFlagsPreserved": true,
|
||||
"FullProductionAcceptance": false,
|
||||
"LimitedUiAndBasicVpnAcceptance": false,
|
||||
"OfflineValidationOnly": true,
|
||||
"PhysicalDeviceTested": false,
|
||||
"SourceLicense": "GPL-3.0",
|
||||
"UpdateBehavior": "New-version prompt opens browser APK download; Android controls installation. No silent installation.",
|
||||
"download_url": "https://pro.ucvl.cn/admin/ucvl-software-downloads/releases/download/android-v1.0.7/UCVL-Zonghengjia-1.0.7-android-universal.apk",
|
||||
"mandatory": false,
|
||||
"packages": {
|
||||
"UCVL-Zonghengjia-1.0.7-android-arm64-v8a.apk": {
|
||||
"sha256": "904f08376817de724a30dc453d9c8be7a8c44dd5210f532913ae06435bc71a21",
|
||||
"size": 29837957
|
||||
},
|
||||
"UCVL-Zonghengjia-1.0.7-android-armeabi-v7a.apk": {
|
||||
"sha256": "6e76f211c45efa4ca83bf8eb66b21ce73b5c6508e211583ff082b704ee907515",
|
||||
"size": 30190219
|
||||
},
|
||||
"UCVL-Zonghengjia-1.0.7-android-universal.apk": {
|
||||
"sha256": "0ca806fd5cab0bb517724be6584c78a1bb2259d6db425fd2c50f33bbc8ac5a8b",
|
||||
"size": 66563344
|
||||
},
|
||||
"UCVL-Zonghengjia-1.0.7-android-x86.apk": {
|
||||
"sha256": "495463f27190af4cbca71dffd92539d68f49bf647b897b6adef5b0c52bfe9299",
|
||||
"size": 31177331
|
||||
},
|
||||
"UCVL-Zonghengjia-1.0.7-android-x86_64.apk": {
|
||||
"sha256": "356416c6dc98e3e66091d97f310f05c7b5f305fe24d45746e98d5de252be54f5",
|
||||
"size": 30722684
|
||||
},
|
||||
"UCVL-Zonghengjia-1.0.7-source.zip": {
|
||||
"sha256": "d6bc9b5d5e6928c434485fea445cef3950e627e34d2cc12eb0c9cfc445b1c93d",
|
||||
"size": 12453339
|
||||
}
|
||||
},
|
||||
"platform": "android",
|
||||
"sha256": "0ca806fd5cab0bb517724be6584c78a1bb2259d6db425fd2c50f33bbc8ac5a8b",
|
||||
"size": 66563344,
|
||||
"validation": {
|
||||
"authorization_lifecycle_jvm_tests": 10,
|
||||
"compiled_public_inputs": 394,
|
||||
"locked_restorable_binary_inputs": 7,
|
||||
"offline_unit_tests": 62,
|
||||
"physical_device_tested": false,
|
||||
"physical_receipt_sha256": null,
|
||||
"source_files": 1010,
|
||||
"unverified": [
|
||||
"Phone installation and APK upgrade",
|
||||
"System VPN permission and data path",
|
||||
"Service/broadcast lifecycle",
|
||||
"Wi-Fi/mobile and sleep/wake recovery",
|
||||
"Sustained business session"
|
||||
]
|
||||
},
|
||||
"version": "1.0.7",
|
||||
"version_code": 4010007
|
||||
},
|
||||
"SourceArchiveSha256": "d6bc9b5d5e6928c434485fea445cef3950e627e34d2cc12eb0c9cfc445b1c93d",
|
||||
"SourceInventorySha256": "9e2235fa58e75a6e51cadcfce33f8130b4f875851a883a638fbcad09bc07dddb",
|
||||
"Status": "released-with-offline-validation-only",
|
||||
"Tag": "android-v1.0.7",
|
||||
"Version": "1.0.7"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,92 +0,0 @@
|
||||
# Local candidate only. Uses cached dependencies; never starts adb or an emulator.
|
||||
param([string]$JobDirectory = '',[switch]$ResumeAfterBuild)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
$repo = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
$tempRoot = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetTempPath())
|
||||
if ($ResumeAfterBuild -and -not $JobDirectory) { throw 'Resume requires the exact completed build directory' }
|
||||
if (-not $JobDirectory) { $JobDirectory = Join-Path $tempRoot ('ucvl-android-105-' + [guid]::NewGuid().ToString('N')) }
|
||||
$job = [IO.Path]::GetFullPath($JobDirectory)
|
||||
if ([IO.Path]::GetDirectoryName($job) -ine $tempRoot -or [IO.Path]::GetFileName($job) -cnotmatch '^ucvl-android-105-[a-f0-9]{32}$' -or $job -match '[^\x00-\x7F]') {
|
||||
throw 'A fresh scoped ASCII temporary directory is required'
|
||||
}
|
||||
if ((Test-Path -LiteralPath $job) -and -not $ResumeAfterBuild) { throw 'Candidate directory already exists' }
|
||||
foreach ($name in @('universal','arm64-v8a','armeabi-v7a','x86','x86_64')) {
|
||||
if (Test-Path -LiteralPath (Join-Path $repo "releases/UCVL-Zonghengjia-1.0.5-android-$name.apk")) { throw 'Signed 1.0.5 candidate already exists; do not replace it' }
|
||||
}
|
||||
$buildText = Get-Content -LiteralPath (Join-Path $repo 'V2rayNG/app/build.gradle.kts') -Raw
|
||||
if ($buildText -notmatch 'versionCode = 10005' -or $buildText -notmatch 'versionName = "1.0.5"') { throw 'Source version mismatch' }
|
||||
$project = Join-Path $job 'project'
|
||||
$source = Join-Path $repo 'V2rayNG'
|
||||
function Save-Json([string]$Name,$Value) {
|
||||
[IO.File]::WriteAllText((Join-Path $job "evidence/$Name"),($Value | ConvertTo-Json -Depth 12),[Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
$env:JAVA_HOME = Join-Path $repo '.tools/jdk-staging/jdk-21.0.12.1+1'
|
||||
$env:ANDROID_HOME = Join-Path $repo '.tools/android-sdk'
|
||||
if (-not $ResumeAfterBuild) {
|
||||
$null = New-Item -ItemType Directory -Path $job,$project,(Join-Path $job 'evidence'),(Join-Path $job 'artifacts')
|
||||
foreach ($name in @('gradlew','gradlew.bat','gradle.properties','settings.gradle.kts','build.gradle.kts','gradle')) {
|
||||
Copy-Item -LiteralPath (Join-Path $source $name) -Destination $project -Recurse
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path (Join-Path $project 'app')
|
||||
foreach ($name in @('src','libs','build.gradle.kts','proguard-rules.pro')) {
|
||||
Copy-Item -LiteralPath (Join-Path $source "app/$name") -Destination (Join-Path $project 'app') -Recurse
|
||||
}
|
||||
$inputs = @(Get-ChildItem -LiteralPath $project -File -Recurse | Sort-Object FullName | ForEach-Object {
|
||||
[ordered]@{Path=[IO.Path]::GetRelativePath($project,$_.FullName).Replace('\','/');Bytes=$_.Length;Sha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash}
|
||||
})
|
||||
Save-Json 'build-inputs.json' $inputs
|
||||
$inputsHash = (Get-FileHash -LiteralPath (Join-Path $job 'evidence/build-inputs.json')).Hash
|
||||
$started = [DateTimeOffset]::Now
|
||||
Push-Location $project
|
||||
try {
|
||||
& ./gradlew.bat --offline --no-daemon --max-workers=2 :app:testPlaystoreReleaseUnitTest :app:assemblePlaystoreRelease *> (Join-Path $job 'evidence/gradle.log')
|
||||
$buildExit = $LASTEXITCODE
|
||||
} finally { Pop-Location }
|
||||
$suites = @(Get-ChildItem -LiteralPath (Join-Path $project 'app/build/test-results/testPlaystoreReleaseUnitTest') -Filter 'TEST-*.xml' -File -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
[xml]$xml = Get-Content -LiteralPath $_.FullName -Raw
|
||||
[pscustomobject]@{Name=$xml.testsuite.name;Tests=[int]$xml.testsuite.tests;Failures=[int]$xml.testsuite.failures;Errors=[int]$xml.testsuite.errors;Skipped=[int]$xml.testsuite.skipped}
|
||||
})
|
||||
$tests = [ordered]@{StartedAt=$started.ToString('O');ExitCode=$buildExit;Offline=$true;Suites=$suites;BuildInputsSha256=$inputsHash;PhysicalDeviceTested=$false;EmulatorStarted=$false;Published=$false}
|
||||
Save-Json 'tests.json' $tests
|
||||
} else {
|
||||
$tests = Get-Content -LiteralPath (Join-Path $job 'evidence/tests.json') -Raw | ConvertFrom-Json
|
||||
$suites = $tests.Suites
|
||||
$buildExit = $tests.ExitCode
|
||||
$inputs = Get-Content -LiteralPath (Join-Path $job 'evidence/build-inputs.json') -Raw | ConvertFrom-Json
|
||||
$inputsHash = (Get-FileHash -LiteralPath (Join-Path $job 'evidence/build-inputs.json')).Hash
|
||||
if ($inputsHash -ne $tests.BuildInputsSha256) { throw 'Completed build input manifest changed' }
|
||||
}
|
||||
if ($buildExit -ne 0) { throw "Gradle failed ($buildExit); evidence retained at $job" }
|
||||
if (($suites | Measure-Object Tests -Sum).Sum -ne 41 -or ($suites | Measure-Object Failures -Sum).Sum -ne 0 -or ($suites | Measure-Object Errors -Sum).Sum -ne 0 -or ($suites | Measure-Object Skipped -Sum).Sum -ne 0) {
|
||||
throw 'Unexpected unit test coverage or failures'
|
||||
}
|
||||
foreach ($row in $inputs) {
|
||||
if ((Get-FileHash -LiteralPath (Join-Path $project $row.Path)).Hash -ne $row.Sha256 -or (Get-FileHash -LiteralPath (Join-Path $source $row.Path)).Hash -ne $row.Sha256) {
|
||||
throw "Input changed during build: $($row.Path)"
|
||||
}
|
||||
}
|
||||
& (Join-Path $repo 'Sign-Candidate.ps1') -Version '1.0.5' -InputDirectory (Join-Path $project 'app/build/outputs/apk/playstore/release') *> (Join-Path $job 'evidence/signing.log')
|
||||
$java = Join-Path $env:JAVA_HOME 'bin/java.exe'
|
||||
$signer = Join-Path $env:ANDROID_HOME 'build-tools/37.0.0/lib/apksigner.jar'
|
||||
$aapt = Join-Path $env:ANDROID_HOME 'build-tools/37.0.0/aapt.exe'
|
||||
$expectedCertificate = '0f1a09870d6ee1e73b62138f99463e7066f4228ce28b7f16ff0aeccca59ea14f'
|
||||
foreach ($version in @('1.0.2','1.0.3')) {
|
||||
$verification = (& $java -jar $signer verify --verbose --print-certs (Join-Path $repo "releases/UCVL-Zonghengjia-$version-android-universal.apk") 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $verification -notmatch $expectedCertificate) { throw "Old $version signing identity differs" }
|
||||
}
|
||||
$packages = @(foreach ($file in Get-ChildItem -LiteralPath (Join-Path $repo 'releases') -Filter 'UCVL-Zonghengjia-1.0.5-android-*.apk' -File | Sort-Object Name) {
|
||||
$verification = (& $java -jar $signer verify --verbose --print-certs $file.FullName 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $verification -notmatch $expectedCertificate -or $verification -notmatch 'v2\): true' -or $verification -notmatch 'v3\): true') { throw "Candidate signature mismatch: $($file.Name)" }
|
||||
$copy = Join-Path $job "artifacts/$($file.Name)"
|
||||
Copy-Item -LiteralPath $file.FullName -Destination $copy
|
||||
$badging = (& $aapt dump badging $copy 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $badging -notmatch "package: name='cn.toplc.zonghengjia' versionCode='4010005' versionName='1.0.5'") { throw "Candidate manifest mismatch: $($file.Name)" }
|
||||
[ordered]@{Name=$file.Name;Bytes=$file.Length;Sha256=(Get-FileHash -LiteralPath $copy).Hash;Version='1.0.5';VersionCode=4010005;SignerSha256=$expectedCertificate;V2=$true;V3=$true}
|
||||
})
|
||||
if ($packages.Count -ne 5) { throw 'Expected all five ABI/universal packages' }
|
||||
Save-Json 'candidate.json' ([ordered]@{Version='1.0.5';VersionCode=4010005;BaseVersionCode=10005;JobDirectory=$job;BuiltAt=[DateTimeOffset]::Now.ToString('O');Packages=$packages;BuildInputsSha256=$inputsHash;UnitTests=41;AuthorizationLifecycleJvmTests=10;SameSignerAs=@('1.0.2','1.0.3');PhysicalDeviceTested=$false;AndroidServiceBroadcastTested=$false;StableReleaseAccepted=$false;Published=$false})
|
||||
Write-Output "CANDIDATE_JOB=$job"
|
||||
Write-Output 'CANDIDATE_BUILD_SIGN_VERIFY_PASSED'
|
||||
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
# Local candidate only. Uses cached dependencies; never starts adb or an emulator.
|
||||
param([string]$JobDirectory = '',[switch]$ResumeAfterBuild)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
$repo = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
$tempRoot = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetTempPath())
|
||||
if ($ResumeAfterBuild -and -not $JobDirectory) { throw 'Resume requires the exact completed build directory' }
|
||||
if (-not $JobDirectory) { $JobDirectory = Join-Path $tempRoot ('ucvl-android-106-' + [guid]::NewGuid().ToString('N')) }
|
||||
$job = [IO.Path]::GetFullPath($JobDirectory)
|
||||
if ([IO.Path]::GetDirectoryName($job) -ine $tempRoot -or [IO.Path]::GetFileName($job) -cnotmatch '^ucvl-android-106-[a-f0-9]{32}$' -or $job -match '[^\x00-\x7F]') {
|
||||
throw 'A fresh scoped ASCII temporary directory is required'
|
||||
}
|
||||
if ((Test-Path -LiteralPath $job) -and -not $ResumeAfterBuild) { throw 'Candidate directory already exists' }
|
||||
foreach ($name in @('universal','arm64-v8a','armeabi-v7a','x86','x86_64')) {
|
||||
if (Test-Path -LiteralPath (Join-Path $repo "releases/UCVL-Zonghengjia-1.0.6-android-$name.apk")) { throw 'Signed 1.0.6 candidate already exists; do not replace it' }
|
||||
}
|
||||
$buildText = Get-Content -LiteralPath (Join-Path $repo 'V2rayNG/app/build.gradle.kts') -Raw
|
||||
if ($buildText -notmatch 'versionCode = 10006' -or $buildText -notmatch 'versionName = "1.0.6"') { throw 'Source version mismatch' }
|
||||
$project = Join-Path $job 'project'
|
||||
$source = Join-Path $repo 'V2rayNG'
|
||||
function Save-Json([string]$Name,$Value) {
|
||||
[IO.File]::WriteAllText((Join-Path $job "evidence/$Name"),($Value | ConvertTo-Json -Depth 12),[Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
function Read-UnitTestSuites {
|
||||
@(Get-ChildItem -LiteralPath (Join-Path $project 'app/build/test-results/testPlaystoreReleaseUnitTest') -Filter 'TEST-*.xml' -File -ErrorAction SilentlyContinue | Sort-Object Name | ForEach-Object {
|
||||
[xml]$xml = Get-Content -LiteralPath $_.FullName -Raw
|
||||
[pscustomobject]@{
|
||||
Name=[string]$xml.testsuite.name
|
||||
Tests=[int]$xml.testsuite.tests
|
||||
Failures=[int]$xml.testsuite.failures
|
||||
Errors=[int]$xml.testsuite.errors
|
||||
Skipped=[int]$xml.testsuite.skipped
|
||||
TestCases=@($xml.testsuite.testcase).Count
|
||||
ReportName=$_.Name
|
||||
ReportSha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash
|
||||
}
|
||||
})
|
||||
}
|
||||
$env:JAVA_HOME = Join-Path $repo '.tools/jdk-staging/jdk-21.0.12.1+1'
|
||||
$env:ANDROID_HOME = Join-Path $repo '.tools/android-sdk'
|
||||
if (-not $ResumeAfterBuild) {
|
||||
$null = New-Item -ItemType Directory -Path $job,$project,(Join-Path $job 'evidence'),(Join-Path $job 'artifacts')
|
||||
foreach ($name in @('gradlew','gradlew.bat','gradle.properties','settings.gradle.kts','build.gradle.kts','gradle')) {
|
||||
Copy-Item -LiteralPath (Join-Path $source $name) -Destination $project -Recurse
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path (Join-Path $project 'app')
|
||||
foreach ($name in @('src','libs','build.gradle.kts','proguard-rules.pro')) {
|
||||
Copy-Item -LiteralPath (Join-Path $source "app/$name") -Destination (Join-Path $project 'app') -Recurse
|
||||
}
|
||||
$inputs = @(Get-ChildItem -LiteralPath $project -File -Recurse | Sort-Object FullName | ForEach-Object {
|
||||
[ordered]@{Path=[IO.Path]::GetRelativePath($project,$_.FullName).Replace('\','/');Bytes=$_.Length;Sha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash}
|
||||
})
|
||||
Save-Json 'build-inputs.json' $inputs
|
||||
$inputsHash = (Get-FileHash -LiteralPath (Join-Path $job 'evidence/build-inputs.json')).Hash
|
||||
$started = [DateTimeOffset]::Now
|
||||
Push-Location $project
|
||||
try {
|
||||
& ./gradlew.bat --offline --no-daemon --max-workers=2 :app:testPlaystoreReleaseUnitTest :app:assemblePlaystoreRelease *> (Join-Path $job 'evidence/gradle.log')
|
||||
$buildExit = $LASTEXITCODE
|
||||
} finally { Pop-Location }
|
||||
$suites = @(Read-UnitTestSuites)
|
||||
$tests = [ordered]@{StartedAt=$started.ToString('O');ExitCode=$buildExit;Offline=$true;Suites=$suites;BuildInputsSha256=$inputsHash;PhysicalDeviceTested=$false;EmulatorStarted=$false;Published=$false}
|
||||
Save-Json 'tests.json' $tests
|
||||
} else {
|
||||
$tests = Get-Content -LiteralPath (Join-Path $job 'evidence/tests.json') -Raw | ConvertFrom-Json
|
||||
$suites = @(Read-UnitTestSuites)
|
||||
if (($tests.Suites | ConvertTo-Json -Depth 5 -Compress) -cne ($suites | ConvertTo-Json -Depth 5 -Compress)) { throw 'Completed JUnit XML evidence changed' }
|
||||
$buildExit = $tests.ExitCode
|
||||
$inputs = Get-Content -LiteralPath (Join-Path $job 'evidence/build-inputs.json') -Raw | ConvertFrom-Json
|
||||
$inputsHash = (Get-FileHash -LiteralPath (Join-Path $job 'evidence/build-inputs.json')).Hash
|
||||
if ($inputsHash -ne $tests.BuildInputsSha256) { throw 'Completed build input manifest changed' }
|
||||
}
|
||||
if ($buildExit -ne 0) { throw "Gradle failed ($buildExit); evidence retained at $job" }
|
||||
$totalUnitTests = [int]($suites | Measure-Object Tests -Sum).Sum
|
||||
$authorizationSuites = @($suites | Where-Object { $_.Name -ceq 'com.v2ray.ang.ucvl.UcvlAuthorizationGuardTest' })
|
||||
$startupLeaseSuites = @($suites | Where-Object { $_.Name -ceq 'com.v2ray.ang.ucvl.UcvlVpnStartupLeaseTest' })
|
||||
if ($totalUnitTests -lt 41 -or ($suites | Measure-Object Failures -Sum).Sum -ne 0 -or ($suites | Measure-Object Errors -Sum).Sum -ne 0 -or ($suites | Measure-Object Skipped -Sum).Sum -ne 0) {
|
||||
throw 'Unexpected unit test coverage or failures'
|
||||
}
|
||||
if ($authorizationSuites.Count -ne 1 -or $authorizationSuites[0].Tests -ne 10 -or $startupLeaseSuites.Count -ne 1 -or $startupLeaseSuites[0].Tests -lt 8) {
|
||||
throw 'Required authorization or VPN startup lease regressions missing'
|
||||
}
|
||||
foreach ($suite in $suites) {
|
||||
if (-not $suite.Name -or $suite.Tests -lt 1 -or $suite.Tests -ne $suite.TestCases) { throw 'JUnit suite count differs from actual test cases' }
|
||||
}
|
||||
$authorizationUnitTests = [int]$authorizationSuites[0].Tests
|
||||
$startupLeaseUnitTests = [int]$startupLeaseSuites[0].Tests
|
||||
foreach ($row in $inputs) {
|
||||
if ((Get-FileHash -LiteralPath (Join-Path $project $row.Path)).Hash -ne $row.Sha256 -or (Get-FileHash -LiteralPath (Join-Path $source $row.Path)).Hash -ne $row.Sha256) {
|
||||
throw "Input changed during build: $($row.Path)"
|
||||
}
|
||||
}
|
||||
& (Join-Path $repo 'Sign-Candidate.ps1') -Version '1.0.6' -InputDirectory (Join-Path $project 'app/build/outputs/apk/playstore/release') *> (Join-Path $job 'evidence/signing.log')
|
||||
$java = Join-Path $env:JAVA_HOME 'bin/java.exe'
|
||||
$signer = Join-Path $env:ANDROID_HOME 'build-tools/37.0.0/lib/apksigner.jar'
|
||||
$aapt = Join-Path $env:ANDROID_HOME 'build-tools/37.0.0/aapt.exe'
|
||||
$expectedCertificate = '0f1a09870d6ee1e73b62138f99463e7066f4228ce28b7f16ff0aeccca59ea14f'
|
||||
foreach ($version in @('1.0.2','1.0.3')) {
|
||||
$verification = (& $java -jar $signer verify --verbose --print-certs (Join-Path $repo "releases/UCVL-Zonghengjia-$version-android-universal.apk") 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $verification -notmatch $expectedCertificate) { throw "Old $version signing identity differs" }
|
||||
}
|
||||
$packages = @(foreach ($file in Get-ChildItem -LiteralPath (Join-Path $repo 'releases') -Filter 'UCVL-Zonghengjia-1.0.6-android-*.apk' -File | Sort-Object Name) {
|
||||
$verification = (& $java -jar $signer verify --verbose --print-certs $file.FullName 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $verification -notmatch $expectedCertificate -or $verification -notmatch 'v2\): true' -or $verification -notmatch 'v3\): true') { throw "Candidate signature mismatch: $($file.Name)" }
|
||||
$copy = Join-Path $job "artifacts/$($file.Name)"
|
||||
Copy-Item -LiteralPath $file.FullName -Destination $copy
|
||||
$badging = (& $aapt dump badging $copy 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $badging -notmatch "package: name='cn.toplc.zonghengjia' versionCode='4010006' versionName='1.0.6'") { throw "Candidate manifest mismatch: $($file.Name)" }
|
||||
[ordered]@{Name=$file.Name;Bytes=$file.Length;Sha256=(Get-FileHash -LiteralPath $copy).Hash;Version='1.0.6';VersionCode=4010006;SignerSha256=$expectedCertificate;V2=$true;V3=$true}
|
||||
})
|
||||
if ($packages.Count -ne 5) { throw 'Expected all five ABI/universal packages' }
|
||||
Save-Json 'candidate.json' ([ordered]@{Version='1.0.6';VersionCode=4010006;BaseVersionCode=10006;JobDirectory=$job;BuiltAt=[DateTimeOffset]::Now.ToString('O');Packages=$packages;BuildInputsSha256=$inputsHash;UnitTests=$totalUnitTests;AuthorizationLifecycleJvmTests=$authorizationUnitTests;StartupLeaseJvmTests=$startupLeaseUnitTests;SameSignerAs=@('1.0.2','1.0.3');PhysicalDeviceTested=$false;AndroidServiceBroadcastTested=$false;StableReleaseAccepted=$false;Published=$false})
|
||||
Write-Output "CANDIDATE_JOB=$job"
|
||||
Write-Output 'CANDIDATE_BUILD_SIGN_VERIFY_PASSED'
|
||||
@@ -1,116 +0,0 @@
|
||||
# Local candidate only. Uses cached dependencies; never starts adb or an emulator.
|
||||
param([string]$JobDirectory = '',[switch]$ResumeAfterBuild)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
$repo = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
$tempRoot = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetTempPath())
|
||||
if ($ResumeAfterBuild -and -not $JobDirectory) { throw 'Resume requires the exact completed build directory' }
|
||||
if (-not $JobDirectory) { $JobDirectory = Join-Path $tempRoot ('ucvl-android-107-' + [guid]::NewGuid().ToString('N')) }
|
||||
$job = [IO.Path]::GetFullPath($JobDirectory)
|
||||
if ([IO.Path]::GetDirectoryName($job) -ine $tempRoot -or [IO.Path]::GetFileName($job) -cnotmatch '^ucvl-android-107-[a-f0-9]{32}$' -or $job -match '[^\x00-\x7F]') {
|
||||
throw 'A fresh scoped ASCII temporary directory is required'
|
||||
}
|
||||
if ((Test-Path -LiteralPath $job) -and -not $ResumeAfterBuild) { throw 'Candidate directory already exists' }
|
||||
foreach ($name in @('universal','arm64-v8a','armeabi-v7a','x86','x86_64')) {
|
||||
if (Test-Path -LiteralPath (Join-Path $repo "releases/UCVL-Zonghengjia-1.0.7-android-$name.apk")) { throw 'Signed 1.0.7 candidate already exists; do not replace it' }
|
||||
}
|
||||
$buildText = Get-Content -LiteralPath (Join-Path $repo 'V2rayNG/app/build.gradle.kts') -Raw
|
||||
if ($buildText -notmatch 'versionCode = 10007' -or $buildText -notmatch 'versionName = "1.0.7"') { throw 'Source version mismatch' }
|
||||
$project = Join-Path $job 'project'
|
||||
$source = Join-Path $repo 'V2rayNG'
|
||||
function Save-Json([string]$Name,$Value) {
|
||||
[IO.File]::WriteAllText((Join-Path $job "evidence/$Name"),($Value | ConvertTo-Json -Depth 12),[Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
function Read-UnitTestSuites {
|
||||
@(Get-ChildItem -LiteralPath (Join-Path $project 'app/build/test-results/testPlaystoreReleaseUnitTest') -Filter 'TEST-*.xml' -File -ErrorAction SilentlyContinue | Sort-Object Name | ForEach-Object {
|
||||
[xml]$xml = Get-Content -LiteralPath $_.FullName -Raw
|
||||
[pscustomobject]@{
|
||||
Name=[string]$xml.testsuite.name
|
||||
Tests=[int]$xml.testsuite.tests
|
||||
Failures=[int]$xml.testsuite.failures
|
||||
Errors=[int]$xml.testsuite.errors
|
||||
Skipped=[int]$xml.testsuite.skipped
|
||||
TestCases=@($xml.testsuite.testcase).Count
|
||||
ReportName=$_.Name
|
||||
ReportSha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash
|
||||
}
|
||||
})
|
||||
}
|
||||
$env:JAVA_HOME = Join-Path $repo '.tools/jdk-staging/jdk-21.0.12.1+1'
|
||||
$env:ANDROID_HOME = Join-Path $repo '.tools/android-sdk'
|
||||
if (-not $ResumeAfterBuild) {
|
||||
$null = New-Item -ItemType Directory -Path $job,$project,(Join-Path $job 'evidence'),(Join-Path $job 'artifacts')
|
||||
foreach ($name in @('gradlew','gradlew.bat','gradle.properties','settings.gradle.kts','build.gradle.kts','gradle')) {
|
||||
Copy-Item -LiteralPath (Join-Path $source $name) -Destination $project -Recurse
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path (Join-Path $project 'app')
|
||||
foreach ($name in @('src','libs','build.gradle.kts','proguard-rules.pro')) {
|
||||
Copy-Item -LiteralPath (Join-Path $source "app/$name") -Destination (Join-Path $project 'app') -Recurse
|
||||
}
|
||||
$inputs = @(Get-ChildItem -LiteralPath $project -File -Recurse | Sort-Object FullName | ForEach-Object {
|
||||
[ordered]@{Path=[IO.Path]::GetRelativePath($project,$_.FullName).Replace('\','/');Bytes=$_.Length;Sha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash}
|
||||
})
|
||||
Save-Json 'build-inputs.json' $inputs
|
||||
$inputsHash = (Get-FileHash -LiteralPath (Join-Path $job 'evidence/build-inputs.json')).Hash
|
||||
$started = [DateTimeOffset]::Now
|
||||
Push-Location $project
|
||||
try {
|
||||
& ./gradlew.bat --offline --no-daemon --max-workers=2 :app:testPlaystoreReleaseUnitTest :app:assemblePlaystoreRelease *> (Join-Path $job 'evidence/gradle.log')
|
||||
$buildExit = $LASTEXITCODE
|
||||
} finally { Pop-Location }
|
||||
$suites = @(Read-UnitTestSuites)
|
||||
$tests = [ordered]@{StartedAt=$started.ToString('O');ExitCode=$buildExit;Offline=$true;Suites=$suites;BuildInputsSha256=$inputsHash;PhysicalDeviceTested=$false;EmulatorStarted=$false;Published=$false}
|
||||
Save-Json 'tests.json' $tests
|
||||
} else {
|
||||
$tests = Get-Content -LiteralPath (Join-Path $job 'evidence/tests.json') -Raw | ConvertFrom-Json
|
||||
$suites = @(Read-UnitTestSuites)
|
||||
if (($tests.Suites | ConvertTo-Json -Depth 5 -Compress) -cne ($suites | ConvertTo-Json -Depth 5 -Compress)) { throw 'Completed JUnit XML evidence changed' }
|
||||
$buildExit = $tests.ExitCode
|
||||
$inputs = Get-Content -LiteralPath (Join-Path $job 'evidence/build-inputs.json') -Raw | ConvertFrom-Json
|
||||
$inputsHash = (Get-FileHash -LiteralPath (Join-Path $job 'evidence/build-inputs.json')).Hash
|
||||
if ($inputsHash -ne $tests.BuildInputsSha256) { throw 'Completed build input manifest changed' }
|
||||
}
|
||||
if ($buildExit -ne 0) { throw "Gradle failed ($buildExit); evidence retained at $job" }
|
||||
$totalUnitTests = [int]($suites | Measure-Object Tests -Sum).Sum
|
||||
$authorizationSuites = @($suites | Where-Object { $_.Name -ceq 'com.v2ray.ang.ucvl.UcvlAuthorizationGuardTest' })
|
||||
$startupLeaseSuites = @($suites | Where-Object { $_.Name -ceq 'com.v2ray.ang.ucvl.UcvlVpnStartupLeaseTest' })
|
||||
$upgradeSuites = @($suites | Where-Object { $_.Name -ceq 'com.v2ray.ang.ucvl.UcvlUpgradeReliabilityTest' })
|
||||
if ($totalUnitTests -lt 41 -or ($suites | Measure-Object Failures -Sum).Sum -ne 0 -or ($suites | Measure-Object Errors -Sum).Sum -ne 0 -or ($suites | Measure-Object Skipped -Sum).Sum -ne 0) {
|
||||
throw 'Unexpected unit test coverage or failures'
|
||||
}
|
||||
if ($authorizationSuites.Count -ne 1 -or $authorizationSuites[0].Tests -ne 10 -or $startupLeaseSuites.Count -ne 1 -or $startupLeaseSuites[0].Tests -lt 8) {
|
||||
throw 'Required authorization or VPN startup lease regressions missing'
|
||||
}
|
||||
if ($upgradeSuites.Count -ne 1 -or $upgradeSuites[0].Tests -ne 8) { throw 'Required Android 1.0.7 upgrade regressions missing' }
|
||||
foreach ($suite in $suites) {
|
||||
if (-not $suite.Name -or $suite.Tests -lt 1 -or $suite.Tests -ne $suite.TestCases) { throw 'JUnit suite count differs from actual test cases' }
|
||||
}
|
||||
$authorizationUnitTests = [int]$authorizationSuites[0].Tests
|
||||
$startupLeaseUnitTests = [int]$startupLeaseSuites[0].Tests
|
||||
foreach ($row in $inputs) {
|
||||
if ((Get-FileHash -LiteralPath (Join-Path $project $row.Path)).Hash -ne $row.Sha256 -or (Get-FileHash -LiteralPath (Join-Path $source $row.Path)).Hash -ne $row.Sha256) {
|
||||
throw "Input changed during build: $($row.Path)"
|
||||
}
|
||||
}
|
||||
& (Join-Path $repo 'Sign-Candidate.ps1') -Version '1.0.7' -InputDirectory (Join-Path $project 'app/build/outputs/apk/playstore/release') *> (Join-Path $job 'evidence/signing.log')
|
||||
$java = Join-Path $env:JAVA_HOME 'bin/java.exe'
|
||||
$signer = Join-Path $env:ANDROID_HOME 'build-tools/37.0.0/lib/apksigner.jar'
|
||||
$aapt = Join-Path $env:ANDROID_HOME 'build-tools/37.0.0/aapt.exe'
|
||||
$expectedCertificate = '0f1a09870d6ee1e73b62138f99463e7066f4228ce28b7f16ff0aeccca59ea14f'
|
||||
foreach ($version in @('1.0.2','1.0.3')) {
|
||||
$verification = (& $java -jar $signer verify --verbose --print-certs (Join-Path $repo "releases/UCVL-Zonghengjia-$version-android-universal.apk") 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $verification -notmatch $expectedCertificate) { throw "Old $version signing identity differs" }
|
||||
}
|
||||
$packages = @(foreach ($file in Get-ChildItem -LiteralPath (Join-Path $repo 'releases') -Filter 'UCVL-Zonghengjia-1.0.7-android-*.apk' -File | Sort-Object Name) {
|
||||
$verification = (& $java -jar $signer verify --verbose --print-certs $file.FullName 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $verification -notmatch $expectedCertificate -or $verification -notmatch 'v2\): true' -or $verification -notmatch 'v3\): true') { throw "Candidate signature mismatch: $($file.Name)" }
|
||||
$copy = Join-Path $job "artifacts/$($file.Name)"
|
||||
Copy-Item -LiteralPath $file.FullName -Destination $copy
|
||||
$badging = (& $aapt dump badging $copy 2>&1 | Out-String)
|
||||
if ($LASTEXITCODE -ne 0 -or $badging -notmatch "package: name='cn.toplc.zonghengjia' versionCode='4010007' versionName='1.0.7'") { throw "Candidate manifest mismatch: $($file.Name)" }
|
||||
[ordered]@{Name=$file.Name;Bytes=$file.Length;Sha256=(Get-FileHash -LiteralPath $copy).Hash;Version='1.0.7';VersionCode=4010007;SignerSha256=$expectedCertificate;V2=$true;V3=$true}
|
||||
})
|
||||
if ($packages.Count -ne 5) { throw 'Expected all five ABI/universal packages' }
|
||||
Save-Json 'candidate.json' ([ordered]@{Version='1.0.7';VersionCode=4010007;BaseVersionCode=10007;JobDirectory=$job;BuiltAt=[DateTimeOffset]::Now.ToString('O');Packages=$packages;BuildInputsSha256=$inputsHash;UnitTests=$totalUnitTests;AuthorizationLifecycleJvmTests=$authorizationUnitTests;StartupLeaseJvmTests=$startupLeaseUnitTests;SameSignerAs=@('1.0.2','1.0.3');PhysicalDeviceTested=$false;AndroidServiceBroadcastTested=$false;StableReleaseAccepted=$false;Published=$false})
|
||||
Write-Output "CANDIDATE_JOB=$job"
|
||||
Write-Output 'CANDIDATE_BUILD_SIGN_VERIFY_PASSED'
|
||||
@@ -1,138 +0,0 @@
|
||||
"""Bind isolated APKs to their exact build inputs and reviewed GPL source. No network or devices."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
REPO = Path(__file__).resolve().parents[1]
|
||||
VERSION = '1.0.5'
|
||||
LOCKED_BINARY_INPUTS = {
|
||||
'app/libs/libv2ray.aar': '3d43b9344723e9c0625527de4f2bea0ee02c21180224e5ecab3384af143ca6d0',
|
||||
'app/libs/quickie-foss-1.14.0.aar': '4d90e9cb37e07b57eaa3a839be2abdc422c0ce9ac8e969720a2a71c968cd771f',
|
||||
'app/libs/Toasty-1.5.2.aar': '57866e731ebe3ef82328942cd4d96cf940b2406c9440f33857f69777027f36b5',
|
||||
'app/libs/arm64-v8a/libhev-socks5-tunnel.so': '4eb0b2353f4fb6d45f43cca39fe72197ce9df8c8f5ba5a82feac87abceb9ea7a',
|
||||
'app/libs/armeabi-v7a/libhev-socks5-tunnel.so': '816c48bab1785fcdaaf7fc2f49dc6b0733cf11e68b9379640d22d6a539f306ff',
|
||||
'app/libs/x86/libhev-socks5-tunnel.so': '6e42da45387d76630a8ffd52ea45cd5738395da39df31dba1a48806fa79d3572',
|
||||
'app/libs/x86_64/libhev-socks5-tunnel.so': 'c61a54f38f61feb73b465d2245fe6e4746c2efba7e9024de8de025ce3fc9206e',
|
||||
}
|
||||
|
||||
|
||||
def digest(path):
|
||||
with Path(path).open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def save(path, value):
|
||||
with Path(path).open('x', encoding='utf-8', newline='\n') as stream:
|
||||
json.dump(value, stream, indent=2, ensure_ascii=False)
|
||||
stream.write('\n')
|
||||
|
||||
|
||||
def main(job):
|
||||
job = Path(job).resolve()
|
||||
if not re.fullmatch(r'ucvl-android-105-[a-f0-9]{32}', job.name):
|
||||
raise RuntimeError('Unexpected candidate job')
|
||||
candidate = json.loads((job / 'evidence/candidate.json').read_text(encoding='utf-8'))
|
||||
if candidate['Version'] != VERSION or candidate['VersionCode'] != 4010005 or candidate['Published']:
|
||||
raise RuntimeError('Unexpected candidate contract')
|
||||
inputs_path = job / 'evidence/build-inputs.json'
|
||||
if digest(inputs_path) != candidate['BuildInputsSha256'].lower():
|
||||
raise RuntimeError('Build input manifest changed')
|
||||
inputs = json.loads(inputs_path.read_text(encoding='utf-8'))
|
||||
public = job / 'public-source-final'
|
||||
matched = 0
|
||||
binary_inputs = []
|
||||
for row in inputs:
|
||||
name, expected = row['Path'], row['Sha256'].lower()
|
||||
if digest(job / 'project' / name) != expected or digest(REPO / 'V2rayNG' / name) != expected:
|
||||
raise RuntimeError('Build/source drift: ' + name)
|
||||
if name in LOCKED_BINARY_INPUTS:
|
||||
if expected != LOCKED_BINARY_INPUTS[name]:
|
||||
raise RuntimeError('Dependency differs from public restoration lock: ' + name)
|
||||
binary_inputs.append({'path': name, 'sha256': expected})
|
||||
else:
|
||||
if digest(public / 'V2rayNG' / name) != expected:
|
||||
raise RuntimeError('GPL snapshot does not match compiled input: ' + name)
|
||||
matched += 1
|
||||
if len(binary_inputs) != len(LOCKED_BINARY_INPUTS):
|
||||
raise RuntimeError('Missing locked binary dependencies')
|
||||
|
||||
inventory = []
|
||||
forbidden = {'.jks', '.keystore', '.p12', '.pfx', '.pem', '.apk', '.aar', '.so', '.idsig', '.log'}
|
||||
for path in sorted(public.rglob('*')):
|
||||
if not path.is_file():
|
||||
continue
|
||||
name = path.relative_to(public).as_posix()
|
||||
if path.is_symlink() or name.casefold().startswith('zero3-helper/') or any(part.casefold() in {'.git', '.tools', 'build', 'releases', '.gradle'} for part in path.relative_to(public).parts):
|
||||
raise RuntimeError('Private/generated directory exported: ' + name)
|
||||
if path.suffix.casefold() in forbidden or path.name in {'signing.properties', 'local.properties'}:
|
||||
raise RuntimeError('Private/binary build input exported: ' + name)
|
||||
if re.search(rb'-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----', path.read_bytes()):
|
||||
raise RuntimeError('Private key marker exported: ' + name)
|
||||
inventory.append({'path': name, 'bytes': path.stat().st_size, 'sha256': digest(path)})
|
||||
required = ['LICENSE', 'README.md', 'README-UPSTREAM.md', 'SOURCE-PROVENANCE.json', 'Restore-Dependencies.py',
|
||||
'V2rayNG/app/src/main/java/com/v2ray/ang/ucvl/UcvlAuthorizationGuard.kt',
|
||||
'V2rayNG/app/src/test/java/com/v2ray/ang/ucvl/UcvlAuthorizationGuardTest.kt']
|
||||
if any(not (public / name).is_file() for name in required):
|
||||
raise RuntimeError('GPL source snapshot incomplete')
|
||||
output = REPO / '.tools/candidates' / ('android-1.0.5-20261016-' + job.name.rsplit('-', 1)[1][:8] + '-final')
|
||||
output.mkdir(parents=True, exist_ok=False)
|
||||
packages = []
|
||||
for package in candidate['Packages']:
|
||||
signed = job / 'artifacts' / package['Name']
|
||||
if digest(signed) != package['Sha256'].lower():
|
||||
raise RuntimeError('Signed APK changed')
|
||||
unsigned = job / 'project/app/build/outputs/apk/playstore/release' / package['Name']
|
||||
with zipfile.ZipFile(unsigned) as before, zipfile.ZipFile(signed) as after:
|
||||
added = set(after.namelist()) - set(before.namelist())
|
||||
if before.testzip() is not None or after.testzip() is not None or set(before.namelist()) - set(after.namelist()):
|
||||
raise RuntimeError('Signed APK removed or corrupted compiled entries')
|
||||
if added != {'META-INF/MANIFEST.MF', 'META-INF/UCVL-ZON.RSA', 'META-INF/UCVL-ZON.SF'}:
|
||||
raise RuntimeError('Unexpected entries added during signing')
|
||||
for name in before.namelist():
|
||||
if before.read(name) != after.read(name):
|
||||
raise RuntimeError('APK entry modified after build: ' + name)
|
||||
dex = {name: hashlib.sha256(after.read(name)).hexdigest() for name in after.namelist() if re.fullmatch(r'classes\d*\.dex', name)}
|
||||
shutil.copy2(signed, output / signed.name)
|
||||
packages.append({**package, 'DexSha256': dex, 'AllUnsignedZipEntriesPreserved': True, 'AddedSigningMetadata': sorted(added)})
|
||||
|
||||
save(output / 'android-1.0.5-source-inventory.json', inventory)
|
||||
source_archive = output / 'UCVL-Zonghengjia-1.0.5-source.zip'
|
||||
with zipfile.ZipFile(source_archive, 'x', compression=zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for row in inventory:
|
||||
archive.write(public / row['path'], 'UCVL-Zonghengjia-1.0.5-source/' + row['path'])
|
||||
with zipfile.ZipFile(source_archive) as archive:
|
||||
if archive.testzip() is not None or len(archive.namelist()) != len(inventory):
|
||||
raise RuntimeError('Source archive verification failed')
|
||||
report = {
|
||||
'Version': VERSION, 'BaseVersionCode': 10005, 'ApkVersionCode': 4010005,
|
||||
'Packages': packages, 'SourceArchive': source_archive.name, 'SourceArchiveSha256': digest(source_archive),
|
||||
'SourceInventorySha256': digest(output / 'android-1.0.5-source-inventory.json'), 'SourceFiles': len(inventory),
|
||||
'CompiledPublicSourceInputsMatched': matched, 'LockedRestorableBinaryInputs': binary_inputs,
|
||||
'BuildInputManifestSha256': digest(inputs_path), 'UnitTests': 41, 'AuthorizationLifecycleJvmTests': 10,
|
||||
'OriginalCompanySignerMatches102And103': True, 'PrivateZero3Excluded': True,
|
||||
'PhysicalDeviceTested': False, 'AndroidServiceBroadcastTested': False, 'EmulatorStarted': False,
|
||||
'StableReleaseAccepted': False, 'Published': False,
|
||||
'RemainingGates': ['Physical Android VPN permission and data path', 'Real Service/broadcast lifecycle for replaced login',
|
||||
'Wi-Fi/mobile transitions, sleep/wake and recovery', 'Authenticated sustained business session'],
|
||||
}
|
||||
save(output / 'android-1.0.5-candidate.json', report)
|
||||
shutil.copytree(job / 'evidence', output / 'local-evidence')
|
||||
shutil.copytree(job / 'source-evidence-final', output / 'source-export-evidence')
|
||||
with (output / 'SHA256SUMS.txt').open('x', encoding='ascii', newline='\n') as stream:
|
||||
for path in sorted(output.iterdir()):
|
||||
if path.is_file() and path.name != 'SHA256SUMS.txt':
|
||||
stream.write(digest(path) + ' ' + path.name + '\n')
|
||||
print(json.dumps({'output': str(output), 'source_files': len(inventory), 'source_sha256': digest(source_archive),
|
||||
'public_compiled_inputs_matched': matched, 'packages': packages}, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('job')
|
||||
main(parser.parse_args().job)
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
"""Bind isolated APKs to their exact build inputs and reviewed GPL source. No network or devices."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import zipfile
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
REPO = Path(__file__).resolve().parents[1]
|
||||
VERSION = '1.0.6'
|
||||
LOCKED_BINARY_INPUTS = {
|
||||
'app/libs/libv2ray.aar': '3d43b9344723e9c0625527de4f2bea0ee02c21180224e5ecab3384af143ca6d0',
|
||||
'app/libs/quickie-foss-1.14.0.aar': '4d90e9cb37e07b57eaa3a839be2abdc422c0ce9ac8e969720a2a71c968cd771f',
|
||||
'app/libs/Toasty-1.5.2.aar': '57866e731ebe3ef82328942cd4d96cf940b2406c9440f33857f69777027f36b5',
|
||||
'app/libs/arm64-v8a/libhev-socks5-tunnel.so': '4eb0b2353f4fb6d45f43cca39fe72197ce9df8c8f5ba5a82feac87abceb9ea7a',
|
||||
'app/libs/armeabi-v7a/libhev-socks5-tunnel.so': '816c48bab1785fcdaaf7fc2f49dc6b0733cf11e68b9379640d22d6a539f306ff',
|
||||
'app/libs/x86/libhev-socks5-tunnel.so': '6e42da45387d76630a8ffd52ea45cd5738395da39df31dba1a48806fa79d3572',
|
||||
'app/libs/x86_64/libhev-socks5-tunnel.so': 'c61a54f38f61feb73b465d2245fe6e4746c2efba7e9024de8de025ce3fc9206e',
|
||||
}
|
||||
|
||||
|
||||
def digest(path):
|
||||
with Path(path).open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def save(path, value):
|
||||
with Path(path).open('x', encoding='utf-8', newline='\n') as stream:
|
||||
json.dump(value, stream, indent=2, ensure_ascii=False)
|
||||
stream.write('\n')
|
||||
|
||||
|
||||
|
||||
def verify_junit_evidence(job, candidate):
|
||||
"""Bind reported counts to this build's XML, not a previous candidate's totals."""
|
||||
tests = json.loads((job / 'evidence/tests.json').read_text(encoding='utf-8'))
|
||||
if tests['ExitCode'] != 0 or tests['Offline'] is not True or tests['Published'] is not False:
|
||||
raise RuntimeError('Unsuccessful or unexpected unit-test build contract')
|
||||
if tests['BuildInputsSha256'].lower() != candidate['BuildInputsSha256'].lower():
|
||||
raise RuntimeError('JUnit build input manifest differs')
|
||||
reports = job / 'project/app/build/test-results/testPlaystoreReleaseUnitTest'
|
||||
suites = []
|
||||
for path in sorted(reports.glob('TEST-*.xml')):
|
||||
suite = ET.parse(path).getroot()
|
||||
if suite.tag != 'testsuite':
|
||||
raise RuntimeError('Unexpected JUnit report root: ' + path.name)
|
||||
row = {
|
||||
'Name': suite.attrib['name'],
|
||||
'Tests': int(suite.attrib['tests']),
|
||||
'Failures': int(suite.attrib['failures']),
|
||||
'Errors': int(suite.attrib['errors']),
|
||||
'Skipped': int(suite.attrib['skipped']),
|
||||
'TestCases': len(suite.findall('testcase')),
|
||||
'ReportName': path.name,
|
||||
'ReportSha256': digest(path).upper(),
|
||||
}
|
||||
if not row['Name'] or row['Tests'] < 1 or row['Tests'] != row['TestCases']:
|
||||
raise RuntimeError('JUnit suite count differs from actual test cases: ' + path.name)
|
||||
if any(row[name] != 0 for name in ('Failures', 'Errors', 'Skipped')):
|
||||
raise RuntimeError('JUnit suite has failures, errors or skipped cases: ' + path.name)
|
||||
suites.append(row)
|
||||
if tests['Suites'] != suites:
|
||||
raise RuntimeError('JUnit evidence changed since candidate signing')
|
||||
by_name = {row['Name']: row for row in suites}
|
||||
if len(by_name) != len(suites):
|
||||
raise RuntimeError('Duplicate JUnit suite names')
|
||||
authorization = by_name.get('com.v2ray.ang.ucvl.UcvlAuthorizationGuardTest', {}).get('Tests', 0)
|
||||
startup = by_name.get('com.v2ray.ang.ucvl.UcvlVpnStartupLeaseTest', {}).get('Tests', 0)
|
||||
total = sum(row['Tests'] for row in suites)
|
||||
if total < 41 or authorization != 10 or startup < 8:
|
||||
raise RuntimeError('Required authorization or VPN startup regressions missing')
|
||||
counts = {'UnitTests': total, 'AuthorizationLifecycleJvmTests': authorization, 'StartupLeaseJvmTests': startup}
|
||||
if any(candidate[name] != value for name, value in counts.items()):
|
||||
raise RuntimeError('Candidate test counts differ from this build JUnit XML')
|
||||
return counts
|
||||
|
||||
|
||||
def main(job):
|
||||
job = Path(job).resolve()
|
||||
if not re.fullmatch(r'ucvl-android-106-[a-f0-9]{32}', job.name):
|
||||
raise RuntimeError('Unexpected candidate job')
|
||||
candidate = json.loads((job / 'evidence/candidate.json').read_text(encoding='utf-8'))
|
||||
if candidate['Version'] != VERSION or candidate['VersionCode'] != 4010006 or candidate['Published']:
|
||||
raise RuntimeError('Unexpected candidate contract')
|
||||
test_counts = verify_junit_evidence(job, candidate)
|
||||
inputs_path = job / 'evidence/build-inputs.json'
|
||||
if digest(inputs_path) != candidate['BuildInputsSha256'].lower():
|
||||
raise RuntimeError('Build input manifest changed')
|
||||
inputs = json.loads(inputs_path.read_text(encoding='utf-8'))
|
||||
public = job / 'public-source-final'
|
||||
matched = 0
|
||||
binary_inputs = []
|
||||
for row in inputs:
|
||||
name, expected = row['Path'], row['Sha256'].lower()
|
||||
if digest(job / 'project' / name) != expected or digest(REPO / 'V2rayNG' / name) != expected:
|
||||
raise RuntimeError('Build/source drift: ' + name)
|
||||
if name in LOCKED_BINARY_INPUTS:
|
||||
if expected != LOCKED_BINARY_INPUTS[name]:
|
||||
raise RuntimeError('Dependency differs from public restoration lock: ' + name)
|
||||
binary_inputs.append({'path': name, 'sha256': expected})
|
||||
else:
|
||||
if digest(public / 'V2rayNG' / name) != expected:
|
||||
raise RuntimeError('GPL snapshot does not match compiled input: ' + name)
|
||||
matched += 1
|
||||
if len(binary_inputs) != len(LOCKED_BINARY_INPUTS):
|
||||
raise RuntimeError('Missing locked binary dependencies')
|
||||
|
||||
inventory = []
|
||||
forbidden = {'.jks', '.keystore', '.p12', '.pfx', '.pem', '.apk', '.aar', '.so', '.idsig', '.log'}
|
||||
for path in sorted(public.rglob('*')):
|
||||
if not path.is_file():
|
||||
continue
|
||||
name = path.relative_to(public).as_posix()
|
||||
if path.is_symlink() or name.casefold().startswith('zero3-helper/') or any(part.casefold() in {'.git', '.tools', 'build', 'releases', '.gradle'} for part in path.relative_to(public).parts):
|
||||
raise RuntimeError('Private/generated directory exported: ' + name)
|
||||
if path.suffix.casefold() in forbidden or path.name in {'signing.properties', 'local.properties'}:
|
||||
raise RuntimeError('Private/binary build input exported: ' + name)
|
||||
if re.search(rb'-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----', path.read_bytes()):
|
||||
raise RuntimeError('Private key marker exported: ' + name)
|
||||
inventory.append({'path': name, 'bytes': path.stat().st_size, 'sha256': digest(path)})
|
||||
required = ['LICENSE', 'README.md', 'README-UPSTREAM.md', 'SOURCE-PROVENANCE.json', 'Restore-Dependencies.py',
|
||||
'V2rayNG/app/src/main/java/com/v2ray/ang/ucvl/UcvlAuthorizationGuard.kt',
|
||||
'V2rayNG/app/src/test/java/com/v2ray/ang/ucvl/UcvlAuthorizationGuardTest.kt',
|
||||
'V2rayNG/app/src/main/java/com/v2ray/ang/ucvl/UcvlVpnStartupLease.kt',
|
||||
'V2rayNG/app/src/test/java/com/v2ray/ang/ucvl/UcvlVpnStartupLeaseTest.kt']
|
||||
if any(not (public / name).is_file() for name in required):
|
||||
raise RuntimeError('GPL source snapshot incomplete')
|
||||
output = REPO / '.tools/candidates' / ('android-1.0.6-20261016-' + job.name.rsplit('-', 1)[1][:8] + '-final')
|
||||
output.mkdir(parents=True, exist_ok=False)
|
||||
packages = []
|
||||
for package in candidate['Packages']:
|
||||
signed = job / 'artifacts' / package['Name']
|
||||
if digest(signed) != package['Sha256'].lower():
|
||||
raise RuntimeError('Signed APK changed')
|
||||
unsigned = job / 'project/app/build/outputs/apk/playstore/release' / package['Name']
|
||||
with zipfile.ZipFile(unsigned) as before, zipfile.ZipFile(signed) as after:
|
||||
added = set(after.namelist()) - set(before.namelist())
|
||||
if before.testzip() is not None or after.testzip() is not None or set(before.namelist()) - set(after.namelist()):
|
||||
raise RuntimeError('Signed APK removed or corrupted compiled entries')
|
||||
if added != {'META-INF/MANIFEST.MF', 'META-INF/UCVL-ZON.RSA', 'META-INF/UCVL-ZON.SF'}:
|
||||
raise RuntimeError('Unexpected entries added during signing')
|
||||
for name in before.namelist():
|
||||
if before.read(name) != after.read(name):
|
||||
raise RuntimeError('APK entry modified after build: ' + name)
|
||||
dex = {name: hashlib.sha256(after.read(name)).hexdigest() for name in after.namelist() if re.fullmatch(r'classes\d*\.dex', name)}
|
||||
shutil.copy2(signed, output / signed.name)
|
||||
packages.append({**package, 'DexSha256': dex, 'AllUnsignedZipEntriesPreserved': True, 'AddedSigningMetadata': sorted(added)})
|
||||
|
||||
save(output / 'android-1.0.6-source-inventory.json', inventory)
|
||||
source_archive = output / 'UCVL-Zonghengjia-1.0.6-source.zip'
|
||||
with zipfile.ZipFile(source_archive, 'x', compression=zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for row in inventory:
|
||||
archive.write(public / row['path'], 'UCVL-Zonghengjia-1.0.6-source/' + row['path'])
|
||||
with zipfile.ZipFile(source_archive) as archive:
|
||||
if archive.testzip() is not None or len(archive.namelist()) != len(inventory):
|
||||
raise RuntimeError('Source archive verification failed')
|
||||
report = {
|
||||
'Version': VERSION, 'BaseVersionCode': 10006, 'ApkVersionCode': 4010006,
|
||||
'Packages': packages, 'SourceArchive': source_archive.name, 'SourceArchiveSha256': digest(source_archive),
|
||||
'SourceInventorySha256': digest(output / 'android-1.0.6-source-inventory.json'), 'SourceFiles': len(inventory),
|
||||
'CompiledPublicSourceInputsMatched': matched, 'LockedRestorableBinaryInputs': binary_inputs,
|
||||
'BuildInputManifestSha256': digest(inputs_path), **test_counts,
|
||||
'OriginalCompanySignerMatches102And103': True, 'PrivateZero3Excluded': True,
|
||||
'PhysicalDeviceTested': False, 'AndroidServiceBroadcastTested': False, 'EmulatorStarted': False,
|
||||
'StableReleaseAccepted': False, 'Published': False,
|
||||
'RemainingGates': ['Physical Android VPN permission and data path', 'Real Service/broadcast lifecycle for replaced login',
|
||||
'Wi-Fi/mobile transitions, sleep/wake and recovery', 'Authenticated sustained business session'],
|
||||
}
|
||||
save(output / 'android-1.0.6-candidate.json', report)
|
||||
shutil.copytree(job / 'evidence', output / 'local-evidence')
|
||||
shutil.copytree(job / 'source-evidence-final', output / 'source-export-evidence')
|
||||
with (output / 'SHA256SUMS.txt').open('x', encoding='ascii', newline='\n') as stream:
|
||||
for path in sorted(output.iterdir()):
|
||||
if path.is_file() and path.name != 'SHA256SUMS.txt':
|
||||
stream.write(digest(path) + ' ' + path.name + '\n')
|
||||
print(json.dumps({'output': str(output), 'source_files': len(inventory), 'source_sha256': digest(source_archive),
|
||||
'public_compiled_inputs_matched': matched, 'packages': packages}, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('job')
|
||||
main(parser.parse_args().job)
|
||||
@@ -1,186 +0,0 @@
|
||||
"""Bind isolated APKs to their exact build inputs and reviewed GPL source. No network or devices."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import zipfile
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
REPO = Path(__file__).resolve().parents[1]
|
||||
VERSION = '1.0.7'
|
||||
LOCKED_BINARY_INPUTS = {
|
||||
'app/libs/libv2ray.aar': '3d43b9344723e9c0625527de4f2bea0ee02c21180224e5ecab3384af143ca6d0',
|
||||
'app/libs/quickie-foss-1.14.0.aar': '4d90e9cb37e07b57eaa3a839be2abdc422c0ce9ac8e969720a2a71c968cd771f',
|
||||
'app/libs/Toasty-1.5.2.aar': '57866e731ebe3ef82328942cd4d96cf940b2406c9440f33857f69777027f36b5',
|
||||
'app/libs/arm64-v8a/libhev-socks5-tunnel.so': '4eb0b2353f4fb6d45f43cca39fe72197ce9df8c8f5ba5a82feac87abceb9ea7a',
|
||||
'app/libs/armeabi-v7a/libhev-socks5-tunnel.so': '816c48bab1785fcdaaf7fc2f49dc6b0733cf11e68b9379640d22d6a539f306ff',
|
||||
'app/libs/x86/libhev-socks5-tunnel.so': '6e42da45387d76630a8ffd52ea45cd5738395da39df31dba1a48806fa79d3572',
|
||||
'app/libs/x86_64/libhev-socks5-tunnel.so': 'c61a54f38f61feb73b465d2245fe6e4746c2efba7e9024de8de025ce3fc9206e',
|
||||
}
|
||||
|
||||
|
||||
def digest(path):
|
||||
with Path(path).open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def save(path, value):
|
||||
with Path(path).open('x', encoding='utf-8', newline='\n') as stream:
|
||||
json.dump(value, stream, indent=2, ensure_ascii=False)
|
||||
stream.write('\n')
|
||||
|
||||
|
||||
|
||||
def verify_junit_evidence(job, candidate):
|
||||
"""Bind reported counts to this build's XML, not a previous candidate's totals."""
|
||||
tests = json.loads((job / 'evidence/tests.json').read_text(encoding='utf-8'))
|
||||
if tests['ExitCode'] != 0 or tests['Offline'] is not True or tests['Published'] is not False:
|
||||
raise RuntimeError('Unsuccessful or unexpected unit-test build contract')
|
||||
if tests['BuildInputsSha256'].lower() != candidate['BuildInputsSha256'].lower():
|
||||
raise RuntimeError('JUnit build input manifest differs')
|
||||
reports = job / 'project/app/build/test-results/testPlaystoreReleaseUnitTest'
|
||||
suites = []
|
||||
for path in sorted(reports.glob('TEST-*.xml')):
|
||||
suite = ET.parse(path).getroot()
|
||||
if suite.tag != 'testsuite':
|
||||
raise RuntimeError('Unexpected JUnit report root: ' + path.name)
|
||||
row = {
|
||||
'Name': suite.attrib['name'],
|
||||
'Tests': int(suite.attrib['tests']),
|
||||
'Failures': int(suite.attrib['failures']),
|
||||
'Errors': int(suite.attrib['errors']),
|
||||
'Skipped': int(suite.attrib['skipped']),
|
||||
'TestCases': len(suite.findall('testcase')),
|
||||
'ReportName': path.name,
|
||||
'ReportSha256': digest(path).upper(),
|
||||
}
|
||||
if not row['Name'] or row['Tests'] < 1 or row['Tests'] != row['TestCases']:
|
||||
raise RuntimeError('JUnit suite count differs from actual test cases: ' + path.name)
|
||||
if any(row[name] != 0 for name in ('Failures', 'Errors', 'Skipped')):
|
||||
raise RuntimeError('JUnit suite has failures, errors or skipped cases: ' + path.name)
|
||||
suites.append(row)
|
||||
if tests['Suites'] != suites:
|
||||
raise RuntimeError('JUnit evidence changed since candidate signing')
|
||||
by_name = {row['Name']: row for row in suites}
|
||||
if len(by_name) != len(suites):
|
||||
raise RuntimeError('Duplicate JUnit suite names')
|
||||
authorization = by_name.get('com.v2ray.ang.ucvl.UcvlAuthorizationGuardTest', {}).get('Tests', 0)
|
||||
startup = by_name.get('com.v2ray.ang.ucvl.UcvlVpnStartupLeaseTest', {}).get('Tests', 0)
|
||||
upgrade = by_name.get('com.v2ray.ang.ucvl.UcvlUpgradeReliabilityTest', {}).get('Tests', 0)
|
||||
total = sum(row['Tests'] for row in suites)
|
||||
if total < 41 or authorization != 10 or startup < 8 or upgrade != 8:
|
||||
raise RuntimeError('Required authorization or VPN startup regressions missing')
|
||||
counts = {'UnitTests': total, 'AuthorizationLifecycleJvmTests': authorization, 'StartupLeaseJvmTests': startup}
|
||||
if any(candidate[name] != value for name, value in counts.items()):
|
||||
raise RuntimeError('Candidate test counts differ from this build JUnit XML')
|
||||
return counts
|
||||
|
||||
|
||||
def main(job):
|
||||
job = Path(job).resolve()
|
||||
if not re.fullmatch(r'ucvl-android-107-[a-f0-9]{32}', job.name):
|
||||
raise RuntimeError('Unexpected candidate job')
|
||||
candidate = json.loads((job / 'evidence/candidate.json').read_text(encoding='utf-8'))
|
||||
if candidate['Version'] != VERSION or candidate['VersionCode'] != 4010007 or candidate['Published']:
|
||||
raise RuntimeError('Unexpected candidate contract')
|
||||
test_counts = verify_junit_evidence(job, candidate)
|
||||
inputs_path = job / 'evidence/build-inputs.json'
|
||||
if digest(inputs_path) != candidate['BuildInputsSha256'].lower():
|
||||
raise RuntimeError('Build input manifest changed')
|
||||
inputs = json.loads(inputs_path.read_text(encoding='utf-8'))
|
||||
public = job / 'public-source-final'
|
||||
matched = 0
|
||||
binary_inputs = []
|
||||
for row in inputs:
|
||||
name, expected = row['Path'], row['Sha256'].lower()
|
||||
if digest(job / 'project' / name) != expected or digest(REPO / 'V2rayNG' / name) != expected:
|
||||
raise RuntimeError('Build/source drift: ' + name)
|
||||
if name in LOCKED_BINARY_INPUTS:
|
||||
if expected != LOCKED_BINARY_INPUTS[name]:
|
||||
raise RuntimeError('Dependency differs from public restoration lock: ' + name)
|
||||
binary_inputs.append({'path': name, 'sha256': expected})
|
||||
else:
|
||||
if digest(public / 'V2rayNG' / name) != expected:
|
||||
raise RuntimeError('GPL snapshot does not match compiled input: ' + name)
|
||||
matched += 1
|
||||
if len(binary_inputs) != len(LOCKED_BINARY_INPUTS):
|
||||
raise RuntimeError('Missing locked binary dependencies')
|
||||
|
||||
inventory = []
|
||||
forbidden = {'.jks', '.keystore', '.p12', '.pfx', '.pem', '.apk', '.aar', '.so', '.idsig', '.log'}
|
||||
for path in sorted(public.rglob('*')):
|
||||
if not path.is_file():
|
||||
continue
|
||||
name = path.relative_to(public).as_posix()
|
||||
if path.is_symlink() or name.casefold().startswith('zero3-helper/') or any(part.casefold() in {'.git', '.tools', 'build', 'releases', '.gradle'} for part in path.relative_to(public).parts):
|
||||
raise RuntimeError('Private/generated directory exported: ' + name)
|
||||
if path.suffix.casefold() in forbidden or path.name in {'signing.properties', 'local.properties'}:
|
||||
raise RuntimeError('Private/binary build input exported: ' + name)
|
||||
if re.search(rb'-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----', path.read_bytes()):
|
||||
raise RuntimeError('Private key marker exported: ' + name)
|
||||
inventory.append({'path': name, 'bytes': path.stat().st_size, 'sha256': digest(path)})
|
||||
required = ['LICENSE', 'README.md', 'README-UPSTREAM.md', 'SOURCE-PROVENANCE.json', 'Restore-Dependencies.py',
|
||||
'V2rayNG/app/src/main/java/com/v2ray/ang/ucvl/UcvlAuthorizationGuard.kt',
|
||||
'V2rayNG/app/src/test/java/com/v2ray/ang/ucvl/UcvlAuthorizationGuardTest.kt',
|
||||
'V2rayNG/app/src/main/java/com/v2ray/ang/ucvl/UcvlVpnStartupLease.kt',
|
||||
'V2rayNG/app/src/test/java/com/v2ray/ang/ucvl/UcvlVpnStartupLeaseTest.kt']
|
||||
if any(not (public / name).is_file() for name in required):
|
||||
raise RuntimeError('GPL source snapshot incomplete')
|
||||
output = REPO / '.tools/candidates' / ('android-1.0.7-20261107-' + job.name.rsplit('-', 1)[1][:8] + '-final')
|
||||
output.mkdir(parents=True, exist_ok=False)
|
||||
packages = []
|
||||
for package in candidate['Packages']:
|
||||
signed = job / 'artifacts' / package['Name']
|
||||
if digest(signed) != package['Sha256'].lower():
|
||||
raise RuntimeError('Signed APK changed')
|
||||
unsigned = job / 'project/app/build/outputs/apk/playstore/release' / package['Name']
|
||||
with zipfile.ZipFile(unsigned) as before, zipfile.ZipFile(signed) as after:
|
||||
added = set(after.namelist()) - set(before.namelist())
|
||||
if before.testzip() is not None or after.testzip() is not None or set(before.namelist()) - set(after.namelist()):
|
||||
raise RuntimeError('Signed APK removed or corrupted compiled entries')
|
||||
if added != {'META-INF/MANIFEST.MF', 'META-INF/UCVL-ZON.RSA', 'META-INF/UCVL-ZON.SF'}:
|
||||
raise RuntimeError('Unexpected entries added during signing')
|
||||
for name in before.namelist():
|
||||
if before.read(name) != after.read(name):
|
||||
raise RuntimeError('APK entry modified after build: ' + name)
|
||||
dex = {name: hashlib.sha256(after.read(name)).hexdigest() for name in after.namelist() if re.fullmatch(r'classes\d*\.dex', name)}
|
||||
shutil.copy2(signed, output / signed.name)
|
||||
packages.append({**package, 'DexSha256': dex, 'AllUnsignedZipEntriesPreserved': True, 'AddedSigningMetadata': sorted(added)})
|
||||
|
||||
save(output / 'android-1.0.7-source-inventory.json', inventory)
|
||||
source_archive = output / 'UCVL-Zonghengjia-1.0.7-source.zip'
|
||||
with zipfile.ZipFile(source_archive, 'x', compression=zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for row in inventory:
|
||||
archive.write(public / row['path'], 'UCVL-Zonghengjia-1.0.7-source/' + row['path'])
|
||||
with zipfile.ZipFile(source_archive) as archive:
|
||||
if archive.testzip() is not None or len(archive.namelist()) != len(inventory):
|
||||
raise RuntimeError('Source archive verification failed')
|
||||
report = {
|
||||
'Version': VERSION, 'BaseVersionCode': 10007, 'ApkVersionCode': 4010007,
|
||||
'Packages': packages, 'SourceArchive': source_archive.name, 'SourceArchiveSha256': digest(source_archive),
|
||||
'SourceInventorySha256': digest(output / 'android-1.0.7-source-inventory.json'), 'SourceFiles': len(inventory),
|
||||
'CompiledPublicSourceInputsMatched': matched, 'LockedRestorableBinaryInputs': binary_inputs,
|
||||
'BuildInputManifestSha256': digest(inputs_path), **test_counts,
|
||||
'OriginalCompanySignerMatches102And103': True, 'PrivateZero3Excluded': True,
|
||||
'PhysicalDeviceTested': False, 'AndroidServiceBroadcastTested': False, 'EmulatorStarted': False,
|
||||
'StableReleaseAccepted': False, 'Published': False,
|
||||
'RemainingGates': ['Physical Android VPN permission and data path', 'Real Service/broadcast lifecycle for replaced login',
|
||||
'Wi-Fi/mobile transitions, sleep/wake and recovery', 'Authenticated sustained business session'],
|
||||
}
|
||||
save(output / 'android-1.0.7-candidate.json', report)
|
||||
shutil.copytree(job / 'evidence', output / 'local-evidence')
|
||||
shutil.copytree(job / 'source-evidence-final', output / 'source-export-evidence')
|
||||
with (output / 'SHA256SUMS.txt').open('x', encoding='ascii', newline='\n') as stream:
|
||||
for path in sorted(output.iterdir()):
|
||||
if path.is_file() and path.name != 'SHA256SUMS.txt':
|
||||
stream.write(digest(path) + ' ' + path.name + '\n')
|
||||
print(json.dumps({'output': str(output), 'source_files': len(inventory), 'source_sha256': digest(source_archive),
|
||||
'public_compiled_inputs_matched': matched, 'packages': packages}, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('job')
|
||||
main(parser.parse_args().job)
|
||||
Reference in New Issue
Block a user