diff --git a/lib/modules/agent/controllers/agent_controller.dart b/lib/modules/agent/controllers/agent_controller.dart index 4003b3f23..631f1c78d 100644 --- a/lib/modules/agent/controllers/agent_controller.dart +++ b/lib/modules/agent/controllers/agent_controller.dart @@ -318,8 +318,8 @@ class AgentController extends GetxController { // 更新分页状态 currentPage.value = 1; hasMoreMessages.value = result.totalPages > 1; - print( - 'liwei-------------读取历史记录 ${AppDir.value}${historyMessages[0].imagePath}'); + // print( + // 'liwei-------------读取历史记录 ${AppDir.value}${historyMessages[0].imagePath}'); Logger.i(TAG, '成功加载 ${historyMessages.length} 条聊天记录,总页数: ${result.totalPages}'); _logMessageDetails(historyMessages); @@ -800,12 +800,14 @@ class AgentController extends GetxController { ["card_navigation"]["start"] as String; final end = metaResult["maps_route_navigation"] ["card_navigation"]["end"] as String; - // Logger.i(TAG, 'liwei-------- 打开导航页面: $start $end '); - Future.delayed(Duration(seconds: 2), () { - // Logger.i(TAG, 'liwei-------- 打开导航页面: $start $end '); - // 2秒后执行的代码 - openNavigation(start, end, ""); - }); + final items = metaResult['items']; + if (items != null) { + Future.delayed(Duration(seconds: 2), () { + // Logger.i(TAG, 'liwei-------- 打开导航页面: $start $end '); + // 2秒后执行的代码 + openNavigation(start, end, ""); + }); + } } } } diff --git a/lib/modules/agent/views/message_bubble.dart b/lib/modules/agent/views/message_bubble.dart index c26503de6..d4120a931 100644 --- a/lib/modules/agent/views/message_bubble.dart +++ b/lib/modules/agent/views/message_bubble.dart @@ -296,20 +296,22 @@ class MessageBubble extends GetView { final start = card_navigation['start'] as String? ?? ''; final end = card_navigation['end'] as String? ?? ''; final destination = card_navigation['destination'] as String? ?? ''; - final rawList = card_navigation['items'] as List? ?? []; - final list = - rawList.map((e) => Map.from(e)).toList(); - final rawNavigation = card_navigation['navigation']; - final Map? navigation = - rawNavigation is Map ? rawNavigation : null; - print("导航实时数据 ${rawNavigation}"); - // 导航 - return navigationCard(context, - start: start, - end: end, - destination: destination, - modes: list, - navigation: navigation); + final rawList = card_navigation['items'] as List? ?? null; + if (rawList != null) { + final list = + rawList.map((e) => Map.from(e)).toList(); + final rawNavigation = card_navigation['navigation']; + final Map? navigation = + rawNavigation is Map ? rawNavigation : null; + // print("导航实时数据 ${rawNavigation}"); + // 导航 + return navigationCard(context, + start: start, + end: end, + destination: destination, + modes: list, + navigation: navigation); + } } } diff --git a/lib/modules/home/controllers/home_controller.dart b/lib/modules/home/controllers/home_controller.dart index c3fa87398..d3a95129e 100644 --- a/lib/modules/home/controllers/home_controller.dart +++ b/lib/modules/home/controllers/home_controller.dart @@ -1,4 +1,3 @@ - import 'package:get/get.dart'; import 'dart:async'; import '../../../data/services/novice_guide_service.dart'; @@ -69,7 +68,7 @@ class HomeController extends GetxController { super.onInit(); _otaCheckService = Get.find(); _initWithCachedInfo(); - _startBatteryRefreshTimer(); // 启动电池信息定时刷新 + // _startBatteryRefreshTimer(); // 启动电池信息定时刷新 } @override @@ -158,12 +157,12 @@ class HomeController extends GetxController { }); } // 根据连接状态控制定时器 - if (isNowConnected) { - _startBatteryRefreshTimer(); // 连接时启动定时器 - } else { - _stopBatteryRefreshTimer(); // 断开时停止定时器 - // 注意:不再重置OTA检查状态,因为现在由全局服务管理 - } + // if (isNowConnected) { + // _startBatteryRefreshTimer(); // 连接时启动定时器 + // } else { + // _stopBatteryRefreshTimer(); // 断开时停止定时器 + // // 注意:不再重置OTA检查状态,因为现在由全局服务管理 + // } } update(); @@ -351,7 +350,8 @@ class HomeController extends GetxController { Logger.d(_tag, 'OTA检查状态: $status'); // 使用全局OTA检查服务执行检查 - final success = await _otaCheckService.performOtaCheck(_isFullyConnected.value); + final success = + await _otaCheckService.performOtaCheck(_isFullyConnected.value); if (success) { Logger.d(_tag, 'OTA检查已成功执行'); @@ -365,6 +365,4 @@ class HomeController extends GetxController { Map getOtaCheckStatus() { return _otaCheckService.getCheckStatus(); } - - } diff --git a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureSpeechPlugin.swift b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureSpeechPlugin.swift index ea563aa1b..f946ef108 100644 --- a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureSpeechPlugin.swift +++ b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureSpeechPlugin.swift @@ -337,6 +337,7 @@ private func sendAstEvent(_ event: [String: Any]) { os_log("音频流未初始化", type: .error) return } + print("liwei----------外部音频推送:\(audioBytes.data.count)") audioStream.saveAudioDataTo(data: audioBytes.data) @@ -901,6 +902,7 @@ extension AzureSpeechPlugin: BleService.Callback { os_log("音频流未初始化", type: .error) return } + print("liwei--------------接收到音频数据回调") audioStream.saveAudioDataTo(data: data) } @@ -912,6 +914,7 @@ extension AzureSpeechPlugin: BleService.Callback { os_log("音频流未初始化", type: .error) return } + print("liwei--------------接收到音频数据回调1") audioStream.saveAudioDataTo(data: data) } diff --git a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/IntegratedSpeechTranslationService.swift b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/IntegratedSpeechTranslationService.swift index a922f92f0..db83bd553 100644 --- a/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/IntegratedSpeechTranslationService.swift +++ b/local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/IntegratedSpeechTranslationService.swift @@ -882,6 +882,7 @@ import os.log * 推送外部音频数据 */ public func pushAudioData(audioData: Data) { + audioProcessor?.saveAudioDataTo(data:audioData) } @@ -968,4 +969,4 @@ func withTimeout(_ timeout: TimeInterval, operation: @escaping () async throw group.cancelAll() return result } -} \ No newline at end of file +} diff --git a/local_plugins/azure_speech/ios/azure_speech/Sources/tools/SimpleAudioReceiver.swift b/local_plugins/azure_speech/ios/azure_speech/Sources/tools/SimpleAudioReceiver.swift index a1085878a..d2cba5f9f 100644 --- a/local_plugins/azure_speech/ios/azure_speech/Sources/tools/SimpleAudioReceiver.swift +++ b/local_plugins/azure_speech/ios/azure_speech/Sources/tools/SimpleAudioReceiver.swift @@ -223,21 +223,29 @@ public class SimpleAudioReceiver: NSObject { */ private func runMicrophoneCapture() { do { + + print("liwei------------启动麦克风权限") + // 【新增】首先配置音频会话 try audioSession.setCategory( .playAndRecord, mode: .videoChat, - options: [.defaultToSpeaker,.allowBluetooth,.mixWithOthers] + options: [ + .defaultToSpeaker, + .allowBluetooth, + .mixWithOthers, + .duckOthers + ] ) // 【新增】请求麦克风权限(如果尚未授权) - if audioSession.recordPermission != .granted { - audioSession.requestRecordPermission { granted in - if !granted { - print("麦克风权限被拒绝") - } - } - } +// if audioSession.recordPermission != .granted { +// audioSession.requestRecordPermission { granted in +// if !granted { +// print("麦克风权限被拒绝") +// } +// } +// } // 【新增】激活音频会话(在配置音频引擎之前) try audioSession.setActive(true) @@ -421,7 +429,7 @@ public class SimpleAudioReceiver: NSObject { print("当前正在识别") try audioEngine?.pause() // 先停用以避免冲突 -// try audioSession.setActive(false) + try audioSession.setActive(false) } print("setAudioOutputRoutecurrent,route=\(route)")