From 5f9d460004c429f08f5727075cb9750be4c751f7 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 12 Nov 2025 21:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0ai=E7=A7=AF=E5=88=86=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/data/services/ble_manager.dart | 2 ++ lib/data/services/network/api.dart | 9 +++++++++ .../com/yunqiinnovation/agent_service/AgentService.kt | 4 +++- .../com/yunqiinnovation/agent_service/BleMediaService.kt | 8 +++++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/data/services/ble_manager.dart b/lib/data/services/ble_manager.dart index b53008c78..9b4a2cd56 100644 --- a/lib/data/services/ble_manager.dart +++ b/lib/data/services/ble_manager.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get_storage/get_storage.dart'; import 'package:get/get.dart'; @@ -775,6 +776,7 @@ class BleManager extends GetxService { 'musicServiceType': musicServiceType, "navigationMode": navigationMode, "isttsinterrupt": isTtsInterruptEnabled ? "true" : "false", + "aiintegral": 100, //ai积分 "callingTool": "callingTool".tr }; diff --git a/lib/data/services/network/api.dart b/lib/data/services/network/api.dart index 3c7ab245a..e405bd87f 100644 --- a/lib/data/services/network/api.dart +++ b/lib/data/services/network/api.dart @@ -243,4 +243,13 @@ class Api { params: params, ); } + + //资源使用请求 + static usagesResPoints([params]) { + return DioManager().request( + NWMethod.post, + '/api/home/user_usages', + params: params, + ); + } } diff --git a/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt b/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt index 8599c5962..140a73b01 100644 --- a/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt +++ b/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt @@ -135,6 +135,8 @@ object AgentService : CoroutineScope { private var currentAiJob: Job? = null private var currsessionId: String = "" + private var aiintegral:Int = 0 + // 空闲检测相关 private var idleCheckJob: Job? = null private val maxIdleSeconds = 10 // 最大空闲秒数(默认值) @@ -203,7 +205,7 @@ object AgentService : CoroutineScope { serverurl = config["serverurl"]?.toString() ?: ""; usertoken = config["usertoken"]?.toString() ?: ""; callingTool = config["callingTool"]?.toString() ?: ""; - + aiintegral = (config["aiintegral"] as? Number)?.toInt() ?: 0 // 初始化上下文和服务 this.context = appContext.applicationContext diff --git a/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleMediaService.kt b/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleMediaService.kt index d1b8a1827..f8cea9728 100644 --- a/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleMediaService.kt +++ b/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleMediaService.kt @@ -69,6 +69,7 @@ class BleMediaService : Service(), CoroutineScope { private const val KEY_MUSICSERVICE_TYPE = "musicServiceType" private const val APP_NAVIGATION_MODE = "navigationMode" private const val APP_CALLING_TOOL = "callingTool" + private const val KEY_AI_INTAGRAL = "aiintegral" // 用于跟踪服务是否正在运行 private val isRunning = AtomicBoolean(false) @@ -578,6 +579,7 @@ private var companionManager: BleCompanionManager? = null it.getStringExtra(KEY_MUSICSERVICE_TYPE)?.let { value -> config[KEY_MUSICSERVICE_TYPE] = value } it.getStringExtra(APP_NAVIGATION_MODE)?.let { value -> config[APP_NAVIGATION_MODE] = value } it.getStringExtra(APP_CALLING_TOOL)?.let { value -> config[APP_CALLING_TOOL] = value } + it.getStringExtra(KEY_AI_INTAGRAL)?.let { value -> config[KEY_AI_INTAGRAL] = value } it.getStringExtra("isttsinterrupt")?.let { value -> config["isttsinterrupt"] = value } // 提取 supportedLanguages 参数 @@ -641,6 +643,7 @@ private var companionManager: BleCompanionManager? = null config[KEY_MUSICSERVICE_TYPE] = getConfigString(prefs, KEY_MUSICSERVICE_TYPE, "") config[APP_NAVIGATION_MODE] = getConfigString(prefs, APP_NAVIGATION_MODE, "") config[APP_CALLING_TOOL] = getConfigString(prefs, APP_CALLING_TOOL, "") + config[KEY_AI_INTAGRAL] = getConfigInt(prefs, KEY_AI_INTAGRAL, 0) // 添加 supportedLanguages 参数处理 val supportedLanguagesStr = getConfigString(prefs, KEY_SUPPORTED_LANGUAGES, "") @@ -651,7 +654,6 @@ private var companionManager: BleCompanionManager? = null config[KEY_SUPPORTED_LANGUAGES] = languageList } } - return config } @@ -662,6 +664,10 @@ private var companionManager: BleCompanionManager? = null return prefs.getString(key, defaultValue) ?: defaultValue } + private fun getConfigInt(prefs: SharedPreferences, key: String, defaultValue: Int): Int { + return prefs.getInt(key, defaultValue) + } + override fun onBind(intent: Intent?): IBinder? = null override fun onDestroy() {