From 157bb5a2c4d0dfaecf88318c46fcde85d9924571 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Tue, 28 Jul 2026 20:07:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(build):=20=E7=AE=80=E5=8C=96=20APK?= =?UTF-8?q?=20=E8=BE=93=E5=87=BA=E6=96=87=E4=BB=B6=E5=90=8D=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 640cfc2..f530f37 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -183,15 +183,12 @@ android { applicationVariants.all { variant -> variant.outputs.each { output -> def buildType = variant.buildType.name - def fileName = "" if (buildType.contains("debug")) { - fileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk" + output.outputFileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk" } else { - fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk" + output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk" } - - output.outputFileName = fileName } } } From 764816c65519a50f65ff74783855ba12a8dc0daa Mon Sep 17 00:00:00 2001 From: TongTongStudio Date: Tue, 28 Jul 2026 22:33:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(service):=20=E5=A2=9E=E5=BC=BA=20Voice?= =?UTF-8?q?Interaction=20=E6=9C=8D=E5=8A=A1=E4=B8=8E=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MyVoiceInteractionService.java | 27 +++++++++++++++++++ .../service/MyVoiceInteractionSession.java | 17 +++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionService.java b/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionService.java index b467813..f80fcb1 100644 --- a/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionService.java +++ b/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionService.java @@ -1,6 +1,9 @@ package com.ttstd.dialer.service; +import android.content.Intent; +import android.os.Bundle; import android.service.voice.VoiceInteractionService; +import android.service.voice.VoiceInteractionSession; import com.ttstd.dialer.utils.Logger; @@ -12,4 +15,28 @@ public class MyVoiceInteractionService extends VoiceInteractionService { super.onCreate(); Logger.d(TAG, "onCreate"); } + + @Override + public void onReady() { + super.onReady(); + Logger.d(TAG, "onReady"); + // 服务准备就绪,通常在此之后可以开启 Session 获取界面信息 + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + Logger.d(TAG, "onStartCommand: action=" + (intent != null ? intent.getAction() : "null")); + // 如果需要主动触发获取界面信息,可以调用 showSession + // 这会触发 MyVoiceInteractionSessionService 创建 Session,并回调 onHandleAssist + if (intent != null && "ACTION_SHOW_SESSION".equals(intent.getAction())) { + showSession(new Bundle(), VoiceInteractionSession.SHOW_WITH_ASSIST | VoiceInteractionSession.SHOW_WITH_SCREENSHOT); + } + return super.onStartCommand(intent, flags, startId); + } + + @Override + public void onShutdown() { + super.onShutdown(); + Logger.d(TAG, "onShutdown"); + } } diff --git a/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionSession.java b/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionSession.java index 841f85b..bbac15a 100644 --- a/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionSession.java +++ b/app/src/main/java/com/ttstd/dialer/service/MyVoiceInteractionSession.java @@ -22,17 +22,28 @@ public class MyVoiceInteractionSession extends VoiceInteractionSession { // 这是核心方法,structure 包含了整个屏幕的 View 树 Logger.d(TAG, "onHandleAssist"); if (structure != null) { - AssistStructure.WindowNode windowNode = structure.getWindowNodeAt(0); - if (windowNode != null) { + int windowCount = structure.getWindowNodeCount(); + Logger.d(TAG, "Window count: " + windowCount); + for (int i = 0; i < windowCount; i++) { + AssistStructure.WindowNode windowNode = structure.getWindowNodeAt(i); + Logger.d(TAG, "Window[" + i + "]: title=" + windowNode.getTitle()); traverseNode(windowNode.getRootViewNode(), ""); } + } else { + Logger.w(TAG, "AssistStructure is null"); } } private void traverseNode(AssistStructure.ViewNode node, String prefix) { if (node == null) return; - Logger.d(TAG, prefix + "View: text=" + node.getText() + ", id=" + node.getIdEntry()); + CharSequence text = node.getText(); + CharSequence contentDescription = node.getContentDescription(); + String id = node.getIdEntry(); + + if (text != null || contentDescription != null || id != null) { + Logger.d(TAG, prefix + "View: text=" + text + ", desc=" + contentDescription + ", id=" + id + ", class=" + node.getClassName()); + } for (int i = 0; i < node.getChildCount(); i++) { traverseNode(node.getChildAt(i), prefix + " ");