Revert "Update .gitignore to exclude app/build/ except res"

This reverts commit fccae746f0.
This commit is contained in:
wdvipa
2026-02-14 14:44:10 +08:00
parent fccae746f0
commit fe18e7eab0
3132 changed files with 77489 additions and 327 deletions

View File

@@ -342,7 +342,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
socket?.let { socket ->
socket.on(Socket.EVENT_CONNECT) {
Log.i(TAG, "✅✅✅ Socket.IO v4 连接成功!!! ✅✅✅")
Log.e(TAG, "✅✅✅ Socket.IO v4 连接成功!!! ✅✅✅")
isConnected = true
isDeviceRegistered = false // ✅ 重置注册状态,等待重新注册
@@ -363,7 +363,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
service.pauseScreenCaptureUntilRegistered()
// 立即发送设备注册,避免延迟导致识别问题
Log.i(TAG, "🚀🚀🚀 立即发送设备注册!!! 🚀🚀🚀")
Log.e(TAG, "🚀🚀🚀 立即发送设备注册!!! 🚀🚀🚀")
// 🔧 多设备冷启动优化:添加随机延迟,避免同时注册冲突
val randomDelay = kotlin.random.Random.nextLong(0, 2000) // 0-2秒随机延迟
@@ -383,7 +383,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
socket.on(Socket.EVENT_DISCONNECT) { args ->
val reason = if (args.isNotEmpty()) args[0].toString() else "unknown"
Log.w(TAG, "📴📴📴 Socket.IO v4 断开: $reason 📴📴📴")
Log.e(TAG, "📴📴📴 Socket.IO v4 断开: $reason 📴📴📴")
// ✅ 增强断开原因分析和统计
val currentTime = System.currentTimeMillis()
@@ -397,7 +397,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
lastTransportErrorTime = currentTime
connectionFailureCount++
updateNetworkQualityScore(false, "transport_error", connectionDuration)
Log.w(TAG, "🚨 Transport Error 统计: 次数=$transportErrorCount, 连接持续时间=${connectionDuration}ms")
Log.e(TAG, "🚨 Transport Error 统计: 次数=$transportErrorCount, 连接持续时间=${connectionDuration}ms")
// ✅ 如果transport error频繁发生调整策略
if (transportErrorCount >= 3 && connectionDuration < 300000) { // 5分钟内3次
@@ -435,7 +435,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
if (args.isNotEmpty()) {
try {
val data = args[0] as JSONObject
Log.i(TAG, "🎉🎉🎉 设备注册成功: ${data.optString("message")} 🎉🎉🎉")
Log.e(TAG, "🎉🎉🎉 设备注册成功: ${data.optString("message")} 🎉🎉🎉")
isDeviceRegistered = true
registrationAttempts = 0 // 重置尝试次数
@@ -446,7 +446,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
}
// ✅ 注册成功后恢复屏幕数据发送
Log.i(TAG, "🚀🚀🚀 设备注册成功,恢复屏幕数据发送!!! 🚀🚀🚀")
Log.e(TAG, "🚀🚀🚀 设备注册成功,恢复屏幕数据发送!!! 🚀🚀🚀")
service.resumeScreenCaptureAfterRegistration()
// ✅ 设备注册成功,检查是否可以隐藏配置遮盖
@@ -460,7 +460,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
Log.e(TAG, "❌ 处理设备注册响应失败", e)
}
} else {
Log.w(TAG, "⚠️ 收到device_registered事件但无参数")
Log.e(TAG, "⚠️ 收到device_registered事件但无参数")
}
}
@@ -477,7 +477,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
// ✅ 处理服务器重启事件
socket.on("server_restarted") { _ ->
Log.i(TAG, "🔄🔄🔄 收到服务器重启通知,立即重新注册!!! 🔄🔄🔄")
Log.e(TAG, "🔄🔄🔄 收到服务器重启通知,立即重新注册!!! 🔄🔄🔄")
// 重置注册状态
isDeviceRegistered = false
// 立即重新注册
@@ -485,7 +485,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
}
socket.on("ping_for_registration") { _ ->
Log.i(TAG, "🔄🔄🔄 收到重新注册Ping立即重新注册!!! 🔄🔄🔄")
Log.e(TAG, "🔄🔄🔄 收到重新注册Ping立即重新注册!!! 🔄🔄🔄")
// 重置注册状态
isDeviceRegistered = false
// 立即重新注册
@@ -531,13 +531,13 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
// 处理UI层次结构分析请求
socket.on("ui_hierarchy_request") { args ->
Log.i(TAG, "🔍🔍🔍 收到UI层次结构请求!!! 🔍🔍🔍")
Log.i(TAG, "📋 Socket连接状态: connected=${socket.connected()}, id=${socket.id()}")
Log.i(TAG, "📋 当前时间戳: ${System.currentTimeMillis()}")
Log.e(TAG, "🔍🔍🔍 收到UI层次结构请求!!! 🔍🔍🔍")
Log.e(TAG, "📋 Socket连接状态: connected=${socket.connected()}, id=${socket.id()}")
Log.e(TAG, "📋 当前时间戳: ${System.currentTimeMillis()}")
if (args.isNotEmpty()) {
try {
val data = args[0] as JSONObject
Log.i(TAG, "📋 请求数据: $data")
Log.e(TAG, "📋 请求数据: $data")
handleUIHierarchyRequest(data)
} catch (e: Exception) {
Log.e(TAG, "❌❌❌ 处理UI层次结构请求失败!!! ❌❌❌", e)
@@ -638,15 +638,15 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
put("osBuildVersion", getOSBuildVersion())
}
Log.i(TAG, "🔑🔑🔑 发送设备注册(第${registrationAttempts}次)!!! 🔑🔑🔑")
Log.i(TAG, "📱 设备信息: 设备ID=${deviceInfo.optString("deviceId")}, 设备名=${deviceInfo.optString("deviceName")}")
Log.i(TAG, "🌐 Socket连接状态: connected=${socket?.connected()}, isConnected=$isConnected")
Log.i(TAG, "🔑 Socket ID详情: ${socket?.id()}")
Log.i(TAG, "🌐 公网IP: ${publicIP ?: "获取失败"}")
Log.d(TAG, "📋 完整设备信息: ${deviceInfo.toString()}")
Log.e(TAG, "🔑🔑🔑 发送设备注册(第${registrationAttempts}次)!!! 🔑🔑🔑")
Log.e(TAG, "📱 设备信息: 设备ID=${deviceInfo.optString("deviceId")}, 设备名=${deviceInfo.optString("deviceName")}")
Log.e(TAG, "🌐 Socket连接状态: connected=${socket?.connected()}, isConnected=$isConnected")
Log.e(TAG, "🔑 Socket ID详情: ${socket?.id()}")
Log.e(TAG, "🌐 公网IP: ${publicIP ?: "获取失败"}")
Log.e(TAG, "📋 完整设备信息: ${deviceInfo.toString()}")
val emitResult = socket?.emit("device_register", deviceInfo)
Log.i(TAG, "📡 设备注册发送结果: $emitResult")
Log.e(TAG, "📡 设备注册发送结果: $emitResult")
// 🔧 清除之前的超时检测,设置新的超时检测
registrationTimeoutHandler?.let { handler ->
@@ -655,7 +655,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
registrationTimeoutHandler = Runnable {
if (!isDeviceRegistered && registrationAttempts <= 10) {
Log.w(TAG, "⚠️⚠️⚠️ 设备注册超时15秒内未收到确认重新发送注册!!! ⚠️⚠️⚠️")
Log.e(TAG, "⚠️⚠️⚠️ 设备注册超时15秒内未收到确认重新发送注册!!! ⚠️⚠️⚠️")
sendDeviceRegistration()
}
}
@@ -1806,7 +1806,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
private fun checkConnectionAndReconnect() {
scope.launch {
try {
Log.i(TAG, "🔍🔍🔍 立即检测连接状态!!! 🔍🔍🔍")
Log.e(TAG, "🔍🔍🔍 立即检测连接状态!!! 🔍🔍🔍")
// 检查Socket连接状态
val socketConnected = socket?.connected() == true
@@ -1830,7 +1830,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
fun forceReconnect() {
scope.launch {
try {
Log.i(TAG, "🚀🚀🚀 开始智能重连针对transport error优化!!! 🚀🚀🚀")
Log.e(TAG, "🚀🚀🚀 开始智能重连针对transport error优化!!! 🚀🚀🚀")
// 重置所有状态
isConnected = false
@@ -1846,7 +1846,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
Log.w(TAG, "断开旧连接时出现异常(可忽略)", e)
}
Log.i(TAG, "🔄 旧连接已断开,等待智能延迟后重新连接...")
Log.e(TAG, "🔄 旧连接已断开,等待智能延迟后重新连接...")
// ✅ 智能延迟:根据网络环境调整等待时间 + 随机化避免多设备同时重连
val baseDelay = if (Build.VERSION.SDK_INT >= 35) {
@@ -1861,7 +1861,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
delay(totalDelay)
// ✅ 重新创建Socket实例使用增强配置
Log.i(TAG, "🔄 重新创建增强Socket实例...")
Log.e(TAG, "🔄 重新创建增强Socket实例...")
try {
// ✅ 根据transport error历史决定使用的策略
val useConservativeStrategy = shouldUseConservativeReconnect()
@@ -1916,7 +1916,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
setupEventListeners()
socket?.connect()
Log.i(TAG, "🔄🔄🔄 增强Socket实例已创建并连接!!! 🔄🔄🔄")
Log.e(TAG, "🔄🔄🔄 增强Socket实例已创建并连接!!! 🔄🔄🔄")
} catch (e: Exception) {
Log.e(TAG, "❌❌❌ 重新创建Socket失败!!! ❌❌❌", e)
@@ -1938,7 +1938,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
* ✅ 启动主动连接监控 - 增强稳定性版本针对transport error问题
*/
private fun startConnectionMonitoring() {
Log.i(TAG, "🚀🚀🚀 启动增强连接监控!!! 🚀🚀🚀")
Log.e(TAG, "🚀🚀🚀 启动增强连接监控!!! 🚀🚀🚀")
// 🎯 优化调整检测间隔与服务端60秒心跳间隔协调提高异常检测效率
val checkInterval = if (Build.VERSION.SDK_INT >= 35) { // Android 15 (API 35)
@@ -1974,7 +1974,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
// 🎯 优化:平衡容错和响应速度,更快检测连接问题
if (consecutiveFailures >= 5) { // 优化为5次失败触发重连约2分钟内恢复
Log.w(TAG, "🔄🔄🔄 连接检测连续失败${consecutiveFailures}次,触发重连!!! 🔄🔄🔄")
Log.e(TAG, "🔄🔄🔄 连接检测连续失败${consecutiveFailures}次,触发重连!!! 🔄🔄🔄")
isConnected = false
isDeviceRegistered = false
forceReconnect()
@@ -2007,7 +2007,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
// 🎯 优化:心跳失败时也要快速响应,避免长时间无响应
if (consecutiveFailures >= 6) { // 优化为6次失败约2.5-3分钟重连
Log.w(TAG, "🔧 心跳测试连续失败${consecutiveFailures}次,调用重连逻辑")
Log.e(TAG, "🔧 心跳测试连续失败${consecutiveFailures}次,调用重连逻辑")
isConnected = false
forceReconnect()
break
@@ -2021,7 +2021,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
}
}
Log.w(TAG, "💔💔💔 连接监控结束 💔💔💔")
Log.e(TAG, "💔💔💔 连接监控结束 💔💔💔")
}
}
@@ -2077,7 +2077,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
*/
private fun handleUIHierarchyRequest(requestData: JSONObject) {
try {
Log.i(TAG, "🔍🔍🔍 开始处理UI层次结构分析请求默认增强版!!! 🔍🔍🔍")
Log.e(TAG, "🔍🔍🔍 开始处理UI层次结构分析请求默认增强版!!! 🔍🔍🔍")
val requestId = requestData.optString("requestId", "")
val clientId = requestData.optString("clientId", "")
@@ -2085,12 +2085,12 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
val includeNonInteractive = requestData.optBoolean("includeNonInteractive", true)
val maxDepth = requestData.optInt("maxDepth", 25) // 默认25层
Log.i(TAG, "📋 请求参数: requestId=$requestId, clientId=$clientId, includeInvisible=$includeInvisible, includeNonInteractive=$includeNonInteractive, maxDepth=$maxDepth")
Log.e(TAG, "📋 请求参数: requestId=$requestId, clientId=$clientId, includeInvisible=$includeInvisible, includeNonInteractive=$includeNonInteractive, maxDepth=$maxDepth")
// 使用协程在后台执行UI分析
scope.launch {
try {
Log.i(TAG, "🔬🔬🔬 开始执行增强UI分析!!! 🔬🔬🔬")
Log.e(TAG, "🔬🔬🔬 开始执行增强UI分析!!! 🔬🔬🔬")
// 直接调用原有的分析方法,并使用增强参数
val enhancedMaxDepth = maxOf(maxDepth, 25) // 至少25层
@@ -2108,7 +2108,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
)
if (hierarchy != null) {
Log.i(TAG, "✅✅✅ 增强UI分析成功!!! ✅✅✅")
Log.e(TAG, "✅✅✅ 增强UI分析成功!!! ✅✅✅")
// 发送完整的UI层次结构响应
val responseData = JSONObject().apply {
@@ -2140,9 +2140,9 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
})
}
Log.i(TAG, "📤📤📤 准备发送增强UI层次结构响应!!! 📤📤📤")
Log.i(TAG, "📊 响应数据大小: ${responseData.toString().length} 字符")
Log.i(TAG, "🔍 设备特征: 已包含")
Log.e(TAG, "📤📤📤 准备发送增强UI层次结构响应!!! 📤📤📤")
Log.e(TAG, "📊 响应数据大小: ${responseData.toString().length} 字符")
Log.e(TAG, "🔍 设备特征: 已包含")
// 发送响应
sendUIHierarchyResponse(responseData)
@@ -2168,7 +2168,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
*/
private fun sendUIHierarchyResponse(responseData: JSONObject) {
try {
Log.i(TAG, "🔄 使用screen_data事件发送UI层次结构响应实验验证可行")
Log.e(TAG, "🔄 使用screen_data事件发送UI层次结构响应实验验证可行")
// ✅ 完全参考sendScreenData的简单连接检查
if (isConnected && socket?.connected() == true) {
@@ -2188,9 +2188,9 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
}
val emitResult = socket?.emit("screen_data", uiScreenData)
Log.i(TAG, "✅✅✅ 使用screen_data事件发送UI层次结构响应成功: $emitResult")
Log.i(TAG, "📊 UI响应数据大小: ${responseData.toString().length} 字符")
Log.i(TAG, "🔍 Socket状态详情: connected=${socket?.connected()}, id=${socket?.id()}")
Log.e(TAG, "✅✅✅ 使用screen_data事件发送UI层次结构响应成功: $emitResult")
Log.e(TAG, "📊 UI响应数据大小: ${responseData.toString().length} 字符")
Log.e(TAG, "🔍 Socket状态详情: connected=${socket?.connected()}, id=${socket?.id()}")
} catch (emitException: Exception) {
// 🔧 UI层次结构响应失败处理同样增加容错机制
Log.e(TAG, "❌ 使用screen_data事件发送UI层次结构响应失败: ${emitException.message}")
@@ -2201,7 +2201,7 @@ class SocketIOManager(private val service: AccessibilityRemoteService) {
} else {
Log.e(TAG, "❌ Socket.IO未连接无法发送UI层次结构响应")
Log.w(TAG, "🔍 连接状态详情: isConnected=$isConnected, socket?.connected()=${socket?.connected()}")
Log.e(TAG, "🔍 连接状态详情: isConnected=$isConnected, socket?.connected()=${socket?.connected()}")
// 🔧 不立即重连,由心跳机制统一检测连接状态
Log.w(TAG, "⚠️ Socket未连接等待CONNECTION_TEST心跳机制检测重连")
}