diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 6bc0b719b..542cf24d8 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -3,8 +3,6 @@ import java.io.FileInputStream repositories { google() mavenCentral() - maven { url = uri("https://artifact.bytedance.com/repository/Volcengine/") } - maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } } plugins { @@ -42,7 +40,7 @@ android { // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = 24 // Updated to meet azure_speech_recognition_null_safety requirements - targetSdk = 33 // 设置为 Android 13 (API 33),以匹配 FOREGROUND_SERVICE_MEDIA_PLAYBACK 权限的要求 + targetSdk = 34 // 设置为 Android 13 (API 33),以匹配 FOREGROUND_SERVICE_MEDIA_PLAYBACK 权限的要求 versionCode = flutter.versionCode versionName = flutter.versionName } @@ -83,9 +81,7 @@ android { } dependencies { - // WebRTC依赖已移除 - // implementation("io.antmedia:webrtc-android-framework:2.8.0-SNAPSHOT") - + // 添加OkHttp依赖 implementation("com.squareup.okhttp3:okhttp:4.9.3") diff --git a/android/app/src/main/kotlin/com/example/deep_voice/MainActivity.kt b/android/app/src/main/kotlin/com/example/deep_voice/MainActivity.kt index d60a43c22..49fd8fdf6 100644 --- a/android/app/src/main/kotlin/com/example/deep_voice/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/deep_voice/MainActivity.kt @@ -267,7 +267,11 @@ class MainActivity: FlutterActivity() { addAction(VoiceInteractionService.ACTION_RECOGNITION_STARTED) addAction(VoiceInteractionService.ACTION_CHAT_HISTORY_UPDATED) } - registerReceiver(voiceInteractionReceiver, voiceInteractionFilter) + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + registerReceiver(voiceInteractionReceiver, voiceInteractionFilter, Context.RECEIVER_NOT_EXPORTED) + } else { + registerReceiver(voiceInteractionReceiver, voiceInteractionFilter) + } // 注册蓝牙状态变化广播接收器 val bluetoothFilter = IntentFilter().apply { @@ -275,7 +279,11 @@ class MainActivity: FlutterActivity() { addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED) addAction(BluetoothAdapter.ACTION_STATE_CHANGED) } - registerReceiver(bluetoothStateReceiver, bluetoothFilter) + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + registerReceiver(bluetoothStateReceiver, bluetoothFilter, Context.RECEIVER_NOT_EXPORTED) + } else { + registerReceiver(bluetoothStateReceiver, bluetoothFilter) + } } override fun configureFlutterEngine(flutterEngine: FlutterEngine) { diff --git a/ios/Runner/AudioSessionManager.swift b/ios/Runner/AudioSessionManager.swift index feaeee830..d41d2fbf5 100644 --- a/ios/Runner/AudioSessionManager.swift +++ b/ios/Runner/AudioSessionManager.swift @@ -206,7 +206,7 @@ import UIKit // 重新激活会话 try audioSession.setActive(true, options: .notifyOthersOnDeactivation) isActive = true - + // 切换到扬声器 // 记录当前配置 currentCategory = category currentMode = mode @@ -319,6 +319,8 @@ import UIKit ], force: false // 是否强制重新配置 ) + try audioSession.overrideOutputAudioPort(.speaker) + } @@ -516,6 +518,8 @@ import UIKit force: force // 是否强制重新配置 ) + try audioSession.overrideOutputAudioPort(.speaker) + // 额外的优化配置 if configureAdditionalSettings { // 获取当前是否使用耳机