Merge "AGM: Add null pointer checks"
diff --git a/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp b/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp
index 8570662..f7b7df1 100644
--- a/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp
+++ b/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -156,8 +157,7 @@
     ALOGV("%s called audio_intf = %d \n", __func__, audio_intf);
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
-        hidl_vec<AgmMediaConfig> media_config_hidl;
-        media_config_hidl.resize(sizeof(struct agm_media_config));
+        hidl_vec<AgmMediaConfig> media_config_hidl(1);
         media_config_hidl.data()->rate = media_config->rate;
         media_config_hidl.data()->channels = media_config->channels;
         media_config_hidl.data()->format = (::vendor::qti::hardware::AGMIPC::V1_0::AgmMediaFormat) media_config->format;
@@ -175,21 +175,18 @@
     ALOGV("%s called with handle = %llx \n", __func__, (unsigned long long)handle);
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
-        hidl_vec<AgmSessionConfig> session_config_hidl;
-        session_config_hidl.resize(sizeof(struct agm_session_config));
+        hidl_vec<AgmSessionConfig> session_config_hidl(1);
         memcpy(session_config_hidl.data(),
                session_config,
                sizeof(struct agm_session_config));
 
-        hidl_vec<AgmMediaConfig> media_config_hidl;
-        media_config_hidl.resize(sizeof(struct agm_media_config));
+        hidl_vec<AgmMediaConfig> media_config_hidl(1);
         media_config_hidl.data()->rate = media_config->rate;
         media_config_hidl.data()->channels = media_config->channels;
         media_config_hidl.data()->format = (::vendor::qti::hardware::AGMIPC::V1_0::AgmMediaFormat) media_config->format;
         media_config_hidl.data()->data_format = media_config->data_format;
 
-        hidl_vec<AgmBufferConfig> buffer_config_hidl;
-        buffer_config_hidl.resize(sizeof(struct agm_buffer_config));
+        hidl_vec<AgmBufferConfig> buffer_config_hidl(1);
         buffer_config_hidl.data()->count = buffer_config->count;
         buffer_config_hidl.data()->size = buffer_config->size;
         ALOGV("%s : Exit", __func__);
@@ -598,19 +595,14 @@
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
 
-        hidl_vec<AgmTagConfig> tag_cfg_hidl;
-        tag_cfg_hidl.resize(sizeof(struct agm_tag_config) +
-                             (tag_config->num_tkvs)*sizeof(agm_key_value));
+        hidl_vec<AgmTagConfig> tag_cfg_hidl(1);
         tag_cfg_hidl.data()->tag = tag_config->tag;
         tag_cfg_hidl.data()->num_tkvs = tag_config->num_tkvs;
-        AgmKeyValue * ptr = NULL;
-        for (int i=0 ; i < tag_cfg_hidl.data()->num_tkvs ; i++ ) {
-             ptr = (AgmKeyValue *)(tag_cfg_hidl.data()
-                                  + sizeof(struct agm_tag_config)
-                                  + (sizeof(AgmKeyValue) * i));
-             ptr->key = tag_config->kv[i].key;
-             ptr->value = tag_config->kv[i].value;
-    }
+        tag_cfg_hidl.data()->kv.resize(tag_config->num_tkvs);
+        for (int i = 0 ; i < tag_cfg_hidl.data()->num_tkvs ; i++ ) {
+             tag_cfg_hidl.data()->kv[i].key = tag_config->kv[i].key;
+             tag_cfg_hidl.data()->kv[i].value = tag_config->kv[i].value;
+        }
         return agm_client->ipc_agm_set_params_with_tag(session_id,
                                                          aif_id, tag_cfg_hidl);
     }
@@ -641,10 +633,7 @@
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
 
-        hidl_vec<AgmEventRegCfg> evt_reg_cfg_hidl;
-        size_t size_local = sizeof(struct agm_event_reg_cfg) +
-                      (evt_reg_cfg->event_config_payload_size);
-        evt_reg_cfg_hidl.resize(size_local);
+        hidl_vec<AgmEventRegCfg> evt_reg_cfg_hidl(1);
 
         evt_reg_cfg_hidl.data()->module_instance_id = evt_reg_cfg->module_instance_id;
         evt_reg_cfg_hidl.data()->event_id = evt_reg_cfg->event_id;
@@ -667,17 +656,12 @@
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
 
-        hidl_vec<AgmCalConfig> cal_cfg_hidl;
-        cal_cfg_hidl.resize(sizeof(AgmCalConfig) +
-                            (cal_config->num_ckvs)*sizeof(AgmKeyValue));
+        hidl_vec<AgmCalConfig> cal_cfg_hidl(1);
         cal_cfg_hidl.data()->num_ckvs = cal_config->num_ckvs;
-        AgmKeyValue * ptr = NULL;
-        for (int i=0 ; i < cal_cfg_hidl.data()->num_ckvs ; i++ ) {
-            ptr = (AgmKeyValue *) (cal_cfg_hidl.data() +
-                                   sizeof(struct agm_cal_config) +
-                                   (sizeof(AgmKeyValue)*i));
-            ptr->key = cal_config->kv[i].key;
-            ptr->value = cal_config->kv[i].value;
+        cal_cfg_hidl.data()->kv.resize(cal_config->num_ckvs);
+        for (int i = 0; i < cal_cfg_hidl.data()->num_ckvs; i++) {
+            cal_cfg_hidl.data()->kv[i].key = cal_config->kv[i].key;
+            cal_cfg_hidl.data()->kv[i].value = cal_config->kv[i].value;
         }
         return agm_client->ipc_agm_session_aif_set_cal(session_id, aif_id,
                                                                   cal_cfg_hidl);
@@ -862,34 +846,29 @@
 
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
-        hidl_vec<AgmSessionConfig> session_config_hidl;
-        session_config_hidl.resize(sizeof(struct agm_session_config));
+        hidl_vec<AgmSessionConfig> session_config_hidl(1);
         memcpy(session_config_hidl.data(),
                session_config,
                sizeof(struct agm_session_config));
 
-        hidl_vec<AgmMediaConfig> in_media_config_hidl, out_media_config_hidl;
-        in_media_config_hidl.resize(sizeof(struct agm_media_config));
+        hidl_vec<AgmMediaConfig> in_media_config_hidl(1), out_media_config_hidl(1);
         in_media_config_hidl.data()->rate = in_media_config->rate;
         in_media_config_hidl.data()->channels = in_media_config->channels;
         in_media_config_hidl.data()->format =
                        (::vendor::qti::hardware::AGMIPC::V1_0::AgmMediaFormat) in_media_config->format;
         in_media_config_hidl.data()->data_format = in_media_config->data_format;
 
-        out_media_config_hidl.resize(sizeof(struct agm_media_config));
         out_media_config_hidl.data()->rate = out_media_config->rate;
         out_media_config_hidl.data()->channels = out_media_config->channels;
         out_media_config_hidl.data()->format =
                        (::vendor::qti::hardware::AGMIPC::V1_0::AgmMediaFormat) out_media_config->format;
         out_media_config_hidl.data()->data_format = out_media_config->data_format;
 
-        hidl_vec<AgmBufferConfig> in_buffer_config_hidl, out_buffer_config_hidl;
-        in_buffer_config_hidl.resize(sizeof(struct agm_buffer_config));
+        hidl_vec<AgmBufferConfig> in_buffer_config_hidl(1), out_buffer_config_hidl(1);
         in_buffer_config_hidl.data()->count = in_buffer_config->count;
         in_buffer_config_hidl.data()->size = in_buffer_config->size;
         in_buffer_config_hidl.data()->max_metadata_size = in_buffer_config->max_metadata_size;
 
-        out_buffer_config_hidl.resize(sizeof(struct agm_buffer_config));
         out_buffer_config_hidl.data()->count = out_buffer_config->count;
         out_buffer_config_hidl.data()->size = out_buffer_config->size;
         out_buffer_config_hidl.data()->max_metadata_size = out_buffer_config->max_metadata_size;
@@ -913,7 +892,7 @@
     if (!agm_server_died) {
         ALOGV("%s:%d hndl %p",__func__, __LINE__, handle);
         android::sp<IAGM> agm_client = get_agm_server();
-        hidl_vec<AgmBuff> buf_hidl;
+        hidl_vec<AgmBuff> buf_hidl(1);
         native_handle_t *allocHidlHandle = nullptr;
         allocHidlHandle = native_handle_create(1, 1);
         if (!allocHidlHandle) {
@@ -923,7 +902,6 @@
         }
         allocHidlHandle->data[0] = buf->alloc_info.alloc_handle;
         allocHidlHandle->data[1] = buf->alloc_info.alloc_handle;
-        buf_hidl.resize(sizeof(struct agm_buff));
         AgmBuff *agmBuff = buf_hidl.data();
         agmBuff->size = buf->size;
         agmBuff->buffer.resize(buf->size);
@@ -982,8 +960,7 @@
         allocHidlHandle->data[0] = buf->alloc_info.alloc_handle;
         allocHidlHandle->data[1] = buf->alloc_info.alloc_handle;
 
-        hidl_vec<AgmBuff> buf_hidl;
-        buf_hidl.resize(sizeof(struct agm_buff));
+        hidl_vec<AgmBuff> buf_hidl(1);
         AgmBuff *agmBuff = buf_hidl.data();
         agmBuff->size = buf->size;
         agmBuff->metadata_size = buf->metadata_size;
@@ -1034,8 +1011,7 @@
     ALOGV("%s called, group_id = %d \n", __func__, group_id);
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
-        hidl_vec<AgmGroupMediaConfig> media_config_hidl;
-        media_config_hidl.resize(sizeof(struct agm_group_media_config));
+        hidl_vec<AgmGroupMediaConfig> media_config_hidl(1);
         media_config_hidl.data()->rate = media_config->config.rate;
         media_config_hidl.data()->channels = media_config->config.channels;
         media_config_hidl.data()->format = (::vendor::qti::hardware::AGMIPC::V1_0::AgmMediaFormat) media_config->config.format;
@@ -1087,8 +1063,7 @@
 
     if (!agm_server_died) {
         android::sp<IAGM> agm_client = get_agm_server();
-        hidl_vec<AgmBuff> buf_hidl;
-        buf_hidl.resize(sizeof(struct agm_buff));
+        hidl_vec<AgmBuff> buf_hidl(1);
         AgmBuff *agmBuff = buf_hidl.data();
         agmBuff->size = buf->size;
         agmBuff->buffer.resize(buf->size);
diff --git a/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp b/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
index fa2c6a1..7de89aa 100644
--- a/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
+++ b/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -361,8 +362,8 @@
     sp<IAGMCallback> clbk_bdr = NULL;
     struct listnode *node = NULL;
     struct listnode *tempnode = NULL;
-    hidl_vec<AgmEventCbParams> evt_param_l;
-    hidl_vec<AgmReadWriteEventCbParams> rw_evt_param_hidl;
+    hidl_vec<AgmEventCbParams> evt_param_l(1);
+    hidl_vec<AgmReadWriteEventCbParams> rw_evt_param_hidl(1);
     AgmReadWriteEventCbParams *rw_evt_param = NULL;
     AgmEventReadWriteDonePayload *rw_payload = NULL;
     struct gsl_event_read_write_done_payload *rw_done_payload;
@@ -438,7 +439,6 @@
             ALOGE("%s native_handle_create fails", __func__);
             return;
         }
-        rw_evt_param_hidl.resize(sizeof(struct AgmReadWriteEventCbParams));
         rw_evt_param = rw_evt_param_hidl.data();
         rw_evt_param->source_module_id = evt_param->source_module_id;
         rw_evt_param->event_payload_size = sizeof(struct agm_event_read_write_done_payload);
@@ -476,8 +476,6 @@
         if (allocHidlHandle)
             native_handle_delete(allocHidlHandle);
     } else {
-        evt_param_l.resize(sizeof(struct agm_event_cb_params) +
-                                evt_param->event_payload_size);
         evt_param_l.data()->source_module_id = evt_param->source_module_id;
         evt_param_l.data()->event_payload_size = evt_param->event_payload_size;
         evt_param_l.data()->event_id = evt_param->event_id;
@@ -716,13 +714,9 @@
             return -ENOMEM;
     }
     cal_config_local->num_ckvs = cal_config.data()->num_ckvs;
-    AgmKeyValue * ptr = NULL;
     for (int i=0 ; i < cal_config.data()->num_ckvs ; i++ ) {
-        ptr = (AgmKeyValue *) (cal_config.data() +
-                                             sizeof(struct agm_cal_config) +
-                                             (sizeof(AgmKeyValue)*i));
-        cal_config_local->kv[i].key = ptr->key;
-        cal_config_local->kv[i].value = ptr->value;
+        cal_config_local->kv[i].key = cal_config.data()->kv[i].key;
+        cal_config_local->kv[i].value = cal_config.data()->kv[i].value;
     }
     ret = agm_session_aif_set_cal(session_id, aif_id, cal_config_local);
     free(cal_config_local);
@@ -762,13 +756,9 @@
     }
     tag_config_local->num_tkvs = tag_config.data()->num_tkvs;
     tag_config_local->tag = tag_config.data()->tag;
-    AgmKeyValue * ptr = NULL;
-    for (int i=0 ; i < tag_config.data()->num_tkvs ; i++ ) {
-        ptr = (AgmKeyValue *) (tag_config.data() +
-                                             sizeof(struct agm_tag_config) +
-                                             (sizeof(AgmKeyValue)*i));
-        tag_config_local->kv[i].key = ptr->key;
-        tag_config_local->kv[i].value = ptr->value;
+    for (int i = 0; i < tag_config.data()->num_tkvs; i++) {
+        tag_config_local->kv[i].key = tag_config.data()->kv[i].key;
+        tag_config_local->kv[i].value = tag_config.data()->kv[i].value;
     }
     ret = agm_set_params_with_tag(session_id, aif_id, tag_config_local);
     free(tag_config_local);
@@ -824,13 +814,12 @@
                                        ipc_agm_session_open_cb _hidl_cb) {
     uint64_t handle = 0;
     agm_client_session_handle *session_handle = NULL;
-    hidl_vec<uint64_t> handle_ret;
+    hidl_vec<uint64_t> handle_ret(1);
     int32_t ret = -EINVAL;
     enum agm_session_mode session_mode = (enum agm_session_mode) sess_mode;
 
     ALOGV("%s: session_id=%d session_mode=%d\n", __func__, session_id,
               session_mode);
-    handle_ret.resize(sizeof(uint64_t));
     pthread_mutex_lock(&client_list_lock);
     session_handle = get_session_handle_l(session_id);
     pthread_mutex_unlock(&client_list_lock);
@@ -1046,7 +1035,7 @@
     }
     size_t num_aif_info_ret = (size_t) num_aif_info;
     ret = agm_get_aif_info_list(aif_list, &num_aif_info_ret);
-    aif_list_ret.resize(sizeof(struct aif_info) * num_aif_info);
+    aif_list_ret.resize(num_aif_info);
     if ( aif_list != NULL) {
         for (int i=0 ; i<num_aif_info ; i++) {
             aif_list_ret.data()[i].aif_name = aif_list[i].aif_name;
@@ -1402,7 +1391,7 @@
 {
     struct agm_buff buf;
     int32_t ret = 0;
-    hidl_vec<AgmBuff> outBuff_hidl;
+    hidl_vec<AgmBuff> outBuff_hidl(1);
     uint32_t bufSize;
     uint32_t captured_size = captured_sz;
     const native_handle *allochandle = nullptr;
@@ -1429,7 +1418,6 @@
     ALOGV("%s:%d sz %d", __func__,__LINE__,bufSize);
     ret = agm_session_read_with_metadata(hndl, &buf, &captured_size);
     if (ret > 0) {
-        outBuff_hidl.resize(sizeof(struct agm_buff));
         outBuff_hidl.data()->size = (uint32_t)buf.size;
         outBuff_hidl.data()->buffer.resize(buf.size);
         memcpy(outBuff_hidl.data()->buffer.data(), buf.addr,
@@ -1488,7 +1476,7 @@
     }
     size_t num_aif_groups_ret = (size_t) num_groups;
     ret = agm_get_group_aif_info_list(aif_list, &num_aif_groups_ret);
-    aif_list_ret.resize(sizeof(struct aif_info) * num_groups);
+    aif_list_ret.resize(num_groups);
     if (aif_list != NULL) {
         for (int i = 0; i < num_groups ; i++) {
             aif_list_ret.data()[i].aif_name = aif_list[i].aif_name;
diff --git a/ipc/SwBinders/agm_client/Makefile.am b/ipc/SwBinders/agm_client/Makefile.am
index e361e12..621cb7a 100644
--- a/ipc/SwBinders/agm_client/Makefile.am
+++ b/ipc/SwBinders/agm_client/Makefile.am
@@ -1,9 +1,9 @@
 
 AM_CPPFLAGS := -I $(top_srcdir) -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/agm/
 AM_CPPFLAGS += -DDYNAMIC_LOG_ENABLED
-lib_LTLIBRARIES      = libagmclient.la
-libagmclient_ladir = $(libdir)
-libagmclient_la_SOURCES   = src/agm_client_wrapper.cpp
-libagmclient_la_CPPFLAGS := $(AM_CPPFLAGS)
-libagmclient_la_LDFLAGS   = -lcutils -llog -ldl -lbinder -shared -avoid-version -lutils -lrt
-libagmclient_la_LIBADD     =  -lagmproxy -laudio_log_utils
+lib_LTLIBRARIES      = libagmclientwrapper.la
+libagmclientwrapper_ladir = $(libdir)
+libagmclientwrapper_la_SOURCES   = src/agm_client_wrapper.cpp
+libagmclientwrapper_la_CPPFLAGS := $(AM_CPPFLAGS)
+libagmclientwrapper_la_LDFLAGS   = -lcutils -llog -ldl -lbinder -shared -avoid-version -lutils -lrt
+libagmclientwrapper_la_LIBADD     =  -lagmproxy -laudio_log_utils
diff --git a/ipc/SwBinders/agm_client/src/agm_client_wrapper.cpp b/ipc/SwBinders/agm_client/src/agm_client_wrapper.cpp
index fd7a49e..9d43cc5 100644
--- a/ipc/SwBinders/agm_client/src/agm_client_wrapper.cpp
+++ b/ipc/SwBinders/agm_client/src/agm_client_wrapper.cpp
@@ -25,6 +25,39 @@
 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/
 
 #define LOG_TAG "agm_client_wrapper"
@@ -85,7 +118,7 @@
     proc->startThreadPool();
 }
 
-void server_death_notifier::binderDied(const wp<IBinder>& who __unused)
+void server_death_notifier::binderDied(const wp<IBinder>& who __attribute__((unused)))
 {
     agm_server_died = true;
     AGM_LOGE("Agm server died !! and I am notified\n");
diff --git a/ipc/SwBinders/agm_server/inc/agm_server_wrapper.h b/ipc/SwBinders/agm_server/inc/agm_server_wrapper.h
index fb31fbe..f0ed0fc 100644
--- a/ipc/SwBinders/agm_server/inc/agm_server_wrapper.h
+++ b/ipc/SwBinders/agm_server/inc/agm_server_wrapper.h
@@ -25,6 +25,39 @@
 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/
 
 
@@ -88,9 +121,6 @@
         virtual int ipc_agm_set_params_with_tag(uint32_t session_id,
                                      uint32_t aif_id,
                                      struct agm_tag_config *tag_config);
-        virtual int ipc_agm_set_params_with_tag_to_acdb(uint32_t session_id,
-                                     uint32_t aif_id, void *payload,
-                                     size_t size);
         virtual int ipc_agm_session_register_for_events(uint32_t session_id,
                                      struct agm_event_reg_cfg *evt_reg_cfg);
         virtual int ipc_agm_session_register_cb(uint32_t session_id,
diff --git a/ipc/SwBinders/agm_server/inc/ipc_interface.h b/ipc/SwBinders/agm_server/inc/ipc_interface.h
index c3bd023..cbbd0e1 100644
--- a/ipc/SwBinders/agm_server/inc/ipc_interface.h
+++ b/ipc/SwBinders/agm_server/inc/ipc_interface.h
@@ -25,6 +25,39 @@
 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/
 
 #ifndef __AGM_SERVER_INTERFACE_H__
@@ -100,9 +133,6 @@
         virtual int ipc_agm_set_params_with_tag(uint32_t session_id,
                                     uint32_t aif_id,
                                     struct agm_tag_config *tag_config) = 0;
-        virtual int ipc_agm_set_params_with_tag_to_acdb(uint32_t session_id,
-                                    uint32_t aif_id,
-                                    void* payload, size_t size) = 0;
         virtual int ipc_agm_session_set_ec_ref(uint32_t capture_session_id,
                                     uint32_t aif_id, bool state) = 0;
         virtual int ipc_agm_session_aif_set_cal(
diff --git a/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp b/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
index cf66eb7..bedb56e 100644
--- a/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
+++ b/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
@@ -25,6 +25,39 @@
 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 ** IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/
 
 #define LOG_TAG "ipc_proxy"
@@ -511,22 +544,14 @@
          int count = *size;
 
          data.writeInterfaceToken(IAgmService::getInterfaceDescriptor());
-         if (payload == NULL) {
-             data.writeInt64((long)payload);
-             data.writeUint32(count);
-             data.writeUint32(session_id);
-             data.writeUint32(aif_id);
-             remote()->transact(GET_TAG_MODULE_INFO, data, &reply);
-             *size = reply.readInt32();
-             return  reply.readInt32();
-         } else if (payload != NULL && count != 0) {
+         if (payload != NULL && count != 0) {
              android::Parcel::ReadableBlob tag_info_blob;
 
-             data.writeInt64((long)payload);
              data.writeUint32(count);
              data.writeUint32(session_id);
              data.writeUint32(aif_id);
              remote()->transact(GET_TAG_MODULE_INFO, data, &reply);
+             count = (size_t) reply.readUint32();
              reply.readBlob(count, &tag_info_blob);
              memcpy(payload, tag_info_blob.data(), count);
              tag_info_blob.release();
@@ -1177,16 +1202,10 @@
         size_t count = 0;
         void *bn_payload = NULL;
 
-        bn_payload = (void*)data.readInt64();
         count = (size_t) data.readUint32();
         pcm_idx = data.readUint32();
         be_idx = data.readUint32();
-        if (bn_payload == NULL) {
-            rc = ipc_agm_session_aif_get_tag_module_info(pcm_idx, be_idx, NULL,
-                                                                       &count);
-            reply->writeInt32(count);
-            reply->writeInt32(rc);
-        } else if (count != 0){
+        if (count != 0){
             bn_payload = calloc(count, sizeof(uint8_t));
             if (bn_payload == NULL) {
                 AGM_LOGE("calloc failed\n");
@@ -1195,6 +1214,7 @@
             rc = ipc_agm_session_aif_get_tag_module_info(pcm_idx, be_idx,
                                                      bn_payload, &count);
             android::Parcel::WritableBlob tag_info_blob;
+            reply->writeUint32(count);
             reply->writeBlob(count, false, &tag_info_blob);
             memcpy(tag_info_blob.data(), bn_payload, count);
             tag_info_blob.release();
@@ -1402,9 +1422,9 @@
 
     case SET_GAPLESS_SESSION_METADATA : {
         uint64_t handle = (uint64_t )data.readInt64();
-        uint32_t type = data.readUint32();
+        agm_gapless_silence_type type = (agm_gapless_silence_type) data.readUint32();
         uint32_t silence = data.readUint32();
-        rc = ipc_agm_set_gapless_session_metadata(handle, init_silence, trail_silence);
+        rc = ipc_agm_set_gapless_session_metadata(handle, type, silence);
         reply->writeInt32(rc);
         break; }
 
diff --git a/plugins/tinyalsa/Makefile.am b/plugins/tinyalsa/Makefile.am
index c82e5f2..7815088 100644
--- a/plugins/tinyalsa/Makefile.am
+++ b/plugins/tinyalsa/Makefile.am
@@ -7,7 +7,7 @@
 AM_CFLAGS := -Wno-unused-parameter
 if !BUILDSYSTEM_OPENWRT
 AM_CFLAGS += -I $(top_srcdir)/include @AGM_CFLAGS@
-AM_CFLAGS += @GLIB_CFLAGS@ -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat
+AM_CFLAGS += @GLIB_CFLAGS@ -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
 AM_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\) -DLINUX_ENABLED
 AM_CFLAGS += @SNDPARSER_CFLAGS@
 AM_CFLAGS += -Wno-unused-parameter
@@ -22,7 +22,7 @@
 if BUILDSYSTEM_OPENWRT
 libagm_pcm_plugin_la_LDFLAGS += -lagm
 else
-libagm_pcm_plugin_la_LDFLAGS += -lagm -laudio_log_utils
+libagm_pcm_plugin_la_LDFLAGS += -lagmclientwrapper -laudio_log_utils
 endif
 
 lib_LTLIBRARIES      += libagm_pcm_passthrough_plugin.la
@@ -40,7 +40,7 @@
 lib_LTLIBRARIES      += libagm_compress_plugin.la
 libagm_compress_plugin_la_SOURCES   = src/agm_compress_plugin.c
 libagm_compress_plugin_la_CFLAGS := $(AM_CFLAGS)
-libagm_compress_plugin_la_LDFLAGS   = -ltinyalsa -ltinycompress -lsndcardparser -lpthread  -avoid-version -laudio_log_utils -shared -lagm
+libagm_compress_plugin_la_LDFLAGS   = -ltinyalsa -ltinycompress -lsndcardparser -lpthread  -avoid-version -laudio_log_utils -shared -lagmclientwrapper
 
 lib_LTLIBRARIES      += libagm_compress_passthrough_plugin.la
 libagm_compress_passthrough_plugin_la_SOURCES   = src/agm_compress_plugin.c
@@ -55,7 +55,7 @@
 if BUILDSYSTEM_OPENWRT
 libagm_mixer_plugin_la_LDFLAGS += -lagm
 else
-libagm_mixer_plugin_la_LDFLAGS += -lagm -laudio_log_utils
+libagm_mixer_plugin_la_LDFLAGS += -lagmclientwrapper -laudio_log_utils
 endif
 
 lib_LTLIBRARIES      += libagm_mixer_passthrough_plugin.la