diff options
author | Nicholas Ambur <nambur@google.com> | 2020-04-13 10:29:00 -0700 |
---|---|---|
committer | Nicholas Ambur <nambur@google.com> | 2020-04-15 14:08:44 -0700 |
commit | 07ec1134c82521e68d5d0f8b72d83ac89ee608d0 (patch) | |
tree | 05b71a97ccea6674dcad5f951600033304cd3df0 | |
parent | f96b22fd8c2af23d5cf5c3dbc5b381d551b81090 (diff) | |
download | sound_trigger_hal-07ec1134c82521e68d5d0f8b72d83ac89ee608d0.tar.gz |
change supported_model_arch property for GMS
Per GMS requirement new to Android R, the supported_model_arch field
must be the Google hotword firmware version comma separated with the
supported_model_arch platform identifier.
Bug: 150634503
Test: boot and verify supported_model_arch is updated by running
`dumpsys voiceinteraction`
Change-Id: If1e84f45c1ad0fb679040be6af7245d0c10a5a59
-rw-r--r-- | sound_trigger_hw_iaxxx.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/sound_trigger_hw_iaxxx.c b/sound_trigger_hw_iaxxx.c index 6e39d2b..46df051 100644 --- a/sound_trigger_hw_iaxxx.c +++ b/sound_trigger_hw_iaxxx.c @@ -2553,6 +2553,34 @@ static int stdev_get_properties( return 0; } +/* Insert a decimal numeral for Prefix into the beginning of String. + Length specifies the total number of bytes available at str. +*/ +static int int_prefix_str(char *str, size_t str_len, int prefix, const char *prefix_format) +{ + int prefix_len = snprintf(NULL, 0, prefix_format, prefix); + size_t str_cur_len = strlen(str); + + if (str_len < prefix_len + str_cur_len + 1) + { + ALOGE("%s: Error, not enough space in string to insert prefix: %d, %s\n", + __func__, prefix, str); + return -1; + } + + // Move the string to make room for the prefix. + memmove(str + prefix_len, str, str_cur_len + 1); + + /* Remember the first character, because snprintf will overwrite it with a + null character. + */ + char tmp = str[0]; + + snprintf(str, prefix_len + 1, prefix_format, prefix); + str[prefix_len] = tmp; + return 0; +} + static const struct sound_trigger_properties_header* stdev_get_properties_extended( const struct sound_trigger_hw_device *dev __unused) { @@ -2562,8 +2590,15 @@ static const struct sound_trigger_properties_header* stdev_get_properties_extend pthread_mutex_lock(&stdev->lock); if (hw_properties.header.version >= SOUND_TRIGGER_DEVICE_API_VERSION_1_3) { hw_properties.base.version = stdev->hotword_version; - ALOGW("SoundTrigger hotword Version is %u", - hw_properties.base.version); + + /* Per GMS requirement new to Android R, the supported_model_arch field + must be the Google hotword firmware version comma separated with the + supported_model_arch platform identifier. + */ + int_prefix_str(hw_properties.supported_model_arch, SOUND_TRIGGER_MAX_STRING_LEN, + hw_properties.base.version, "%u,"); + ALOGW("SoundTrigger supported model arch identifier is %s", + hw_properties.supported_model_arch); } else { ALOGE("STHAL Version is %u", hw_properties.header.version); pthread_mutex_unlock(&stdev->lock); |