fix: 修复启动时三个应用层报错问题
- MediaProjectionManager初始化提前到onCreate开头,避免多个return路径跳过初始化导致后续null - InputController剪贴板访问添加SecurityException防护,非前台时安全降级而非崩溃 - HuaweiAuthorizationHandler剪贴板访问添加异常捕获,防止ClipboardService拒绝访问 - SocketIO连接错误区分瞬态错误(xhr poll/timeout)和持久错误,瞬态错误降级为WARN - SocketIO connect方法添加URL格式验证和空值检查
This commit is contained in:
@@ -404,7 +404,16 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
registerReceiver(combinedBroadcastReceiver, filter)
|
||||
|
||||
// ✅ 新增:记录应用启动次数,用于保活检测
|
||||
// Initialize MediaProjectionManager early to avoid null in any code path
|
||||
try {
|
||||
mediaProjectionManager =
|
||||
getSystemService(MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
|
||||
Log.i(TAG, "MediaProjectionManager initialized successfully")
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Failed to initialize MediaProjectionManager", e)
|
||||
}
|
||||
|
||||
// Record app launch count for keep-alive detection
|
||||
recordAppLaunch()
|
||||
|
||||
// ✅ 新增:检查是否为无闪现后台唤起
|
||||
@@ -673,10 +682,7 @@ class MainActivity : AppCompatActivity() {
|
||||
handleGalleryPermissionRequest()
|
||||
handleMicrophonePermissionRequest()
|
||||
|
||||
// 初始化MediaProjectionManager
|
||||
mediaProjectionManager =
|
||||
getSystemService(MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
|
||||
|
||||
// MediaProjectionManager already initialized at the top of onCreate
|
||||
|
||||
// 处理Intent
|
||||
handleIntentAndPermissions(intent)
|
||||
|
||||
Reference in New Issue
Block a user