feat(android): Add voice interaction service for app launch

This commit is contained in:
cogwheel0
2025-11-21 19:16:51 +05:30
parent 4166862d08
commit 20e57e9f88
5 changed files with 64 additions and 8 deletions

View File

@@ -32,6 +32,18 @@
android:allowBackup="false"
android:fullBackupContent="false"
android:usesCleartextTraffic="true">
<service
android:name=".ConduitVoiceInteractionSessionService"
android:permission="android.permission.BIND_VOICE_INTERACTION"
android:exported="true">
<meta-data
android:name="android.voice_interaction"
android:resource="@xml/voice_interaction_service" />
<intent-filter>
<action android:name="android.service.voice.VoiceInteractionService" />
</intent-filter>
</service>
<activity
android:name=".MainActivity"
android:exported="true"

View File

@@ -0,0 +1,26 @@
package app.cogwheel.conduit
import android.content.Context
import android.content.Intent
import android.service.voice.VoiceInteractionSession
import android.os.Bundle
import android.app.assist.AssistStructure
import android.app.assist.AssistContent
class ConduitVoiceInteractionSession(context: Context) : VoiceInteractionSession(context) {
override fun onHandleAssist(
data: Bundle?,
structure: AssistStructure?,
content: AssistContent?
) {
super.onHandleAssist(data, structure, content)
android.util.Log.d("ConduitVoiceSession", "onHandleAssist called")
// Launch the main activity when the assistant is triggered
val intent = Intent(context, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}

View File

@@ -0,0 +1,11 @@
package app.cogwheel.conduit
import android.service.voice.VoiceInteractionSession
import android.service.voice.VoiceInteractionSessionService
import android.os.Bundle
class ConduitVoiceInteractionSessionService : VoiceInteractionSessionService() {
override fun onNewSession(args: Bundle?): VoiceInteractionSession {
return ConduitVoiceInteractionSession(this)
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<voice-interaction-service xmlns:android="http://schemas.android.com/apk/res/android"
android:sessionService="app.cogwheel.conduit.ConduitVoiceInteractionSessionService"
android:recognitionService="android.speech.RecognitionService"
android:settingsActivity="app.cogwheel.conduit.MainActivity"
android:supportsAssist="true"
android:supportsLocalInteraction="true" />

View File

@@ -961,10 +961,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.17.0"
mime:
dependency: transitive
description:
@@ -1606,26 +1606,26 @@ packages:
dependency: transitive
description:
name: test
sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb"
sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7"
url: "https://pub.dev"
source: hosted
version: "1.26.2"
version: "1.26.3"
test_api:
dependency: transitive
description:
name: test_api
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev"
source: hosted
version: "0.7.6"
version: "0.7.7"
test_core:
dependency: transitive
description:
name: test_core
sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a"
sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0"
url: "https://pub.dev"
source: hosted
version: "0.6.11"
version: "0.6.12"
timezone:
dependency: transitive
description: