Merge "hal: Add APIs for HIDL 5.0"
diff --git a/configs/msm8937/msm8937.mk b/configs/msm8937/msm8937.mk
index e6d9e14..3f3e7f4 100644
--- a/configs/msm8937/msm8937.mk
+++ b/configs/msm8937/msm8937.mk
@@ -259,3 +259,14 @@
     android.hardware.audio@4.0-impl \
     android.hardware.audio.effect@4.0 \
     android.hardware.audio.effect@4.0-impl
+
+# enable audio hidl hal 5.0 for sdk rev 29 and above
+ifeq ($(shell expr $(PLATFORM_SDK_VERSION) \>= 29), 1)
+PRODUCT_PACKAGES += \
+            android.hardware.audio@5.0 \
+            android.hardware.audio.common@5.0 \
+            android.hardware.audio.common@5.0-util \
+            android.hardware.audio@5.0-impl \
+            android.hardware.audio.effect@5.0 \
+            android.hardware.audio.effect@5.0-impl
+endif
diff --git a/hal/Android.mk b/hal/Android.mk
index 245679b..82eb510 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -486,6 +486,7 @@
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_VENDOR_MODULE := true
+LOCAL_CFLAGS += -DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 8eff647..8da1c08 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -460,6 +460,12 @@
 }
 #endif
 
+#if ANDROID_PLATFORM_SDK_VERSION >= 29
+static int in_set_microphone_direction(const struct audio_stream_in *stream,
+                                           audio_microphone_direction_t dir);
+static int in_set_microphone_field_dimension(const struct audio_stream_in *stream, float zoom);
+#endif
+
 static bool may_use_noirq_mode(struct audio_device *adev, audio_usecase_t uc_id,
                                int flags __unused)
 {
@@ -4150,6 +4156,25 @@
     return ret;
 }
 
+#if ANDROID_PLATFORM_SDK_VERSION >= 29
+static int in_set_microphone_direction(const struct audio_stream_in *stream,
+                                           audio_microphone_direction_t dir) {
+    int ret_val = -ENOSYS;
+    (void)stream;
+    (void)dir;
+    ALOGV("---- in_set_microphone_direction()");
+    return ret_val;
+}
+
+static int in_set_microphone_field_dimension(const struct audio_stream_in *stream, float zoom) {
+    int ret_val = -ENOSYS;
+    (void)zoom;
+    (void)stream;
+    ALOGV("---- in_set_microphone_field_dimension()");
+    return ret_val;
+}
+#endif
+
 static bool stream_get_parameter_channels(struct str_parms *query,
                                           struct str_parms *reply,
                                           audio_channel_mask_t *supported_channel_masks) {
@@ -7341,6 +7366,10 @@
     in->stream.read = in_read;
     in->stream.get_input_frames_lost = in_get_input_frames_lost;
     in->stream.get_active_microphones = in_get_active_microphones;
+#if ANDROID_PLATFORM_SDK_VERSION >= 29
+    in->stream.set_microphone_direction = in_set_microphone_direction;
+    in->stream.set_microphone_field_dimension = in_set_microphone_field_dimension;
+#endif
 
     in->device = devices;
     in->source = source;