-
-
Notifications
You must be signed in to change notification settings - Fork 964
Android Auto-aware Assist Triggering #6710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
3924d80
61e60a4
7222192
ea41e1b
2fad74a
1b1d0f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,11 +48,14 @@ class AssistActivity : BaseActivity() { | |||||||
| private var contextIsLocked = true | ||||||||
|
|
||||||||
| companion object { | ||||||||
| private const val EXTRA_SERVER = "server" | ||||||||
| private const val EXTRA_PIPELINE = "pipeline" | ||||||||
| private const val EXTRA_START_LISTENING = "start_listening" | ||||||||
| private const val EXTRA_FROM_FRONTEND = "from_frontend" | ||||||||
| private const val EXTRA_FROM_WAKE_WORD_PHRASE = "from_wake_word_phrase" | ||||||||
| const val EXTRA_SERVER = "server" | ||||||||
| const val EXTRA_PIPELINE = "pipeline" | ||||||||
| const val EXTRA_START_LISTENING = "start_listening" | ||||||||
| const val EXTRA_FROM_FRONTEND = "from_frontend" | ||||||||
| const val EXTRA_FROM_WAKE_WORD_PHRASE = "from_wake_word_phrase" | ||||||||
| const val EXTRA_TRIGGER_SOURCE = "trigger_source" | ||||||||
| const val TRIGGER_SOURCE_ASSIST = "assist" | ||||||||
| const val ACTION_TRIGGER_AUTOMOTIVE_ASSIST = "ACTION_TRIGGER_AUTOMOTIVE_ASSIST" | ||||||||
|
|
||||||||
| fun newInstance( | ||||||||
| context: Context, | ||||||||
|
|
@@ -61,13 +64,15 @@ class AssistActivity : BaseActivity() { | |||||||
| startListening: Boolean = true, | ||||||||
| fromFrontend: Boolean = true, | ||||||||
| wakeWordPhrase: String? = null, | ||||||||
| triggerSource: String? = null, | ||||||||
| ): Intent { | ||||||||
| return Intent(context, AssistActivity::class.java).apply { | ||||||||
| putExtra(EXTRA_SERVER, serverId) | ||||||||
| putExtra(EXTRA_PIPELINE, pipelineId) | ||||||||
| putExtra(EXTRA_START_LISTENING, startListening) | ||||||||
| putExtra(EXTRA_FROM_FRONTEND, fromFrontend) | ||||||||
| putExtra(EXTRA_FROM_WAKE_WORD_PHRASE, wakeWordPhrase) | ||||||||
| putExtra(EXTRA_TRIGGER_SOURCE, triggerSource) | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
@@ -113,6 +118,27 @@ class AssistActivity : BaseActivity() { | |||||||
| } | ||||||||
|
|
||||||||
| val fromFrontend = intent.getBooleanExtra(EXTRA_FROM_FRONTEND, false) | ||||||||
| val triggerSource = intent.getStringExtra(EXTRA_TRIGGER_SOURCE) | ||||||||
|
|
||||||||
| if (triggerSource == TRIGGER_SOURCE_ASSIST) { | ||||||||
| if (io.homeassistant.companion.android.vehicle.HaCarAppService.carInfo != null) { | ||||||||
| val automotiveIntent = Intent( | ||||||||
| io.homeassistant.companion.android.vehicle.HaCarAppService.ACTION_NAVIGATE_TO_AUTOMOTIVE_ASSIST, | ||||||||
| ).apply { | ||||||||
| putExtra( | ||||||||
| io.homeassistant.companion.android.vehicle.HaCarAppService.EXTRA_SERVER, | ||||||||
| if (intent.hasExtra(EXTRA_SERVER)) { | ||||||||
| intent.getIntExtra(EXTRA_SERVER, ServerManager.SERVER_ID_ACTIVE) | ||||||||
| } else { | ||||||||
| ServerManager.SERVER_ID_ACTIVE | ||||||||
| }, | ||||||||
| ) | ||||||||
| } | ||||||||
| sendBroadcast(automotiveIntent) | ||||||||
| finish() | ||||||||
|
Comment on lines
+125
to
+138
|
||||||||
| return | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| setContent { | ||||||||
| if (viewModel.shouldFinish) { | ||||||||
|
|
@@ -166,6 +192,9 @@ class AssistActivity : BaseActivity() { | |||||||
|
|
||||||||
| override fun onPause() { | ||||||||
| super.onPause() | ||||||||
| // The error says onPause() is protected in AssistViewModel. | ||||||||
| // We need to call it, but it's protected. | ||||||||
| // Let's see if we can change the visibility in AssistViewModel. | ||||||||
|
Comment on lines
+195
to
+197
|
||||||||
| // The error says onPause() is protected in AssistViewModel. | |
| // We need to call it, but it's protected. | |
| // Let's see if we can change the visibility in AssistViewModel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACTION_TRIGGER_AUTOMOTIVE_ASSISTis a very generic intent action string. To avoid collisions (and accidental triggering by other apps), intent action constants should be fully qualified (e.g., include the application package).