gta4xl-common: Build dummy soundtrigger HAL
* OK Google causes issues with microphone frequencies getting cut off, even with
the prebuilt audio HAL, since we have no way over ROMs globally setting
ro.opa.eligible_device, include a no-op soundtrigger impl so that OK Google
is marked as unavailable (due to lack of hotword apks)
Change-Id: I507b4aadd4a8c6188f6e914ae0de503b3d9397b6
diff --git a/audio/sthal/Android.bp b/audio/sthal/Android.bp
new file mode 100644
index 0000000..c15c47f
--- /dev/null
+++ b/audio/sthal/Android.bp
@@ -0,0 +1,13 @@
+//
+// Copyright (C) 2024 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+cc_library_shared {
+ name: "sound_trigger.primary.dummy",
+ relative_install_path: "hw",
+ vendor: true,
+ srcs: ["sound_trigger_dummy.c"],
+ header_libs: ["libhardware_headers"],
+}
diff --git a/audio/sthal/sound_trigger_dummy.c b/audio/sthal/sound_trigger_dummy.c
new file mode 100644
index 0000000..1deb0c4
--- /dev/null
+++ b/audio/sthal/sound_trigger_dummy.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include <hardware/sound_trigger.h>
+
+static const struct sound_trigger_properties hw_properties = {
+ "The LineageOS Project", // implementor
+ "Dummy SoundTrigger HAL", // description
+ 1, // version
+ { 0x1817de20, 0xfa3b, 0x11e5, 0xbef2, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }, // uuid
+ 2, // max_sound_models
+ 1, // max_key_phrases
+ 1, // max_users
+ RECOGNITION_MODE_VOICE_TRIGGER, // recognition_modes
+ true, // capture_transition
+ 0, // max_buffer_ms
+ false, // concurrent_capture
+ false, // trigger_in_event
+ 0 // power_consumption_mw
+};
+
+static struct sound_trigger_properties_extended_1_3 hw_properties_1_3 = {
+ {
+ SOUND_TRIGGER_DEVICE_API_VERSION_1_3, // API version
+ 320, // rough total size
+ },
+ {
+ "The LineageOS Project", // implementor
+ "Dummy SoundTrigger HAL", // description
+ 1, // version
+ { 0x1817de20, 0xfa3b, 0x11e5, 0xbef2, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }, // uuid
+ 2, // max_sound_models
+ 1, // max_key_phrases
+ 1, // max_users
+ RECOGNITION_MODE_VOICE_TRIGGER, // recognition_modes
+ true, // capture_transition
+ 0, // max_buffer_ms
+ false, // concurrent_capture
+ false, // trigger_in_event
+ 0, // power_consumption_mw
+ },
+ "374236809, 4ac4bfe8-a4c9-3f5c-8f02-6db7c7123cb6", // supportedModelArch
+ 0 // audioCapabilities
+};
+
+static int stdev_get_properties(const struct sound_trigger_hw_device* dev,
+ struct sound_trigger_properties *properties) {
+ if (properties == NULL)
+ return -EINVAL;
+ memcpy(properties, &hw_properties, sizeof(struct sound_trigger_properties));
+
+ (void)dev;
+ return 0;
+}
+
+static const struct sound_trigger_properties_header* stdev_get_properties_extended(
+ const struct sound_trigger_hw_device *dev) {
+ (void)dev;
+ return (struct sound_trigger_properties_header*)&hw_properties_1_3;
+}
+
+static int stdev_unimplemented() {
+ return -EINVAL;
+}
+
+static int stdev_close(hw_device_t *device) {
+ free(device);
+ return 0;
+}
+
+static int stdev_open(const hw_module_t* module, const char* name,
+ hw_device_t** device) {
+ struct sound_trigger_hw_device *stdev;
+
+ if (strcmp(name, SOUND_TRIGGER_HARDWARE_INTERFACE) != 0)
+ return -EINVAL;
+
+ stdev = calloc(1, sizeof(struct sound_trigger_hw_device));
+
+ stdev->common.tag = HARDWARE_DEVICE_TAG;
+ stdev->common.version = SOUND_TRIGGER_DEVICE_API_VERSION_1_3;
+ stdev->common.module = (struct hw_module_t*)module;
+ stdev->common.close = stdev_close;
+ stdev->get_properties = stdev_get_properties;
+ stdev->load_sound_model = stdev_unimplemented;
+ stdev->unload_sound_model = stdev_unimplemented;
+ stdev->start_recognition = stdev_unimplemented;
+ stdev->stop_recognition = stdev_unimplemented;
+ stdev->stop_all_recognitions = stdev_unimplemented;
+ stdev->get_model_state = stdev_unimplemented;
+ stdev->set_parameter = stdev_unimplemented;
+ stdev->get_parameter = stdev_unimplemented;
+ stdev->query_parameter = stdev_unimplemented;
+ stdev->get_properties_extended = stdev_get_properties_extended;
+ stdev->start_recognition_extended = stdev_unimplemented;
+
+ *device = &stdev->common;
+
+ return 0;
+};
+
+static struct hw_module_methods_t hal_module_methods = {
+ .open = stdev_open,
+};
+
+struct sound_trigger_module HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = SOUND_TRIGGER_MODULE_API_VERSION_1_0,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = SOUND_TRIGGER_HARDWARE_MODULE_ID,
+ .name = "Dummy SoundTrigger HAL",
+ .author = "The LineageOS Project",
+ .methods = &hal_module_methods,
+ },
+};
diff --git a/common.mk b/common.mk
index 23d8d64..8244401 100644
--- a/common.mk
+++ b/common.mk
@@ -30,13 +30,15 @@
android.hardware.audio@7.1-impl:32 \
android.hardware.audio.service \
android.hardware.bluetooth.audio-impl \
+ android.hardware.soundtrigger@2.3-impl \
audio.bluetooth.default \
audio.primary.exynos9611 \
audio.r_submix.default \
audio.usb.default \
libaudioroute \
libtinyalsa \
- libtinycompress
+ libtinycompress \
+ sound_trigger.primary.dummy
PRODUCT_PACKAGES += \
SamsungDAP
diff --git a/manifest.xml b/manifest.xml
index 06f7735..d64d4fc 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -95,6 +95,15 @@
</interface>
</hal>
<hal format="hidl">
+ <name>android.hardware.soundtrigger</name>
+ <transport>hwbinder</transport>
+ <version>2.3</version>
+ <interface>
+ <name>ISoundTriggerHw</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
<name>vendor.samsung.hardware.gnss</name>
<transport>hwbinder</transport>
<version>2.0</version>
diff --git a/vendor.prop b/vendor.prop
index 13d1ef3..16cd80b 100644
--- a/vendor.prop
+++ b/vendor.prop
@@ -12,6 +12,7 @@
aaudio.mmap_exclusive_policy=2
aaudio.hw_burst_min_usec=2000
af.fast_track_multiplier=1
+ro.hardware.sound_trigger.primary=dummy
## Bluetooth
bluetooth.device.class_of_device=90,1,16