Merge "hal: pass is_in_call flag to suspended setparam for A2DP device"
diff --git a/configs/anorak/audio-modules.mk b/configs/anorak/audio-modules.mk
index c8e2fdc..bfd294f 100644
--- a/configs/anorak/audio-modules.mk
+++ b/configs/anorak/audio-modules.mk
@@ -161,4 +161,8 @@
vendor.qti.hardware.ListenSoundModel@1.0 \
vendor.qti.hardware.ListenSoundModel@1.0-impl
+#usb recorder
+AUDIO_MODULES += \
+ vendor.qti.hardware.umd@1.0-service \
+ libumd-adaptor
endif
diff --git a/configs/kalama/audio-modules.mk b/configs/kalama/audio-modules.mk
index cb1a8cc..1c11240 100644
--- a/configs/kalama/audio-modules.mk
+++ b/configs/kalama/audio-modules.mk
@@ -86,6 +86,11 @@
AUDIO_MODULES += IDP_UPD_workspaceFileXml.qwsp
AUDIO_MODULES += GRD_acdb_cal.acdb
AUDIO_MODULES += GRD_workspaceFileXml.qwsp
+ AUDIO_MODULES += RB5_GEN2_DVT_acdb_cal.acdb
+ AUDIO_MODULES += RB5_GEN2_DVT_workspaceFileXml.qwsp
+ AUDIO_MODULES += ffv__5.0.2_0.1__eai_2.10_enpu.pmd
+ AUDIO_MODULES += AIM_acdb_cal.acdb
+ AUDIO_MODULES += AIM_workspaceFileXml.qwsp
endif
ifeq ($(call is-board-platform-in-list,crow),true)
AUDIO_MODULES += audio.primary.crow
diff --git a/configs/kalama/kalama.mk b/configs/kalama/kalama.mk
index 7196d11..1c3e9c7 100644
--- a/configs/kalama/kalama.mk
+++ b/configs/kalama/kalama.mk
@@ -129,17 +129,21 @@
$(CONFIG_HAL_SRC_DIR)/microphone_characteristics.xml:$(TARGET_COPY_OUT_VENDOR)/etc/microphone_characteristics.xml \
$(CONFIG_PAL_SRC_DIR)/card-defs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/card-defs.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_qrd.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_qrd.xml \
+ $(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_aim.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_aim.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_mtp.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_mtp.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_mtp_apq.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_mtp_apq.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_cdp.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_cdp.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_cdp_apq.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_cdp_apq.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_cdp_wsa883x.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_cdp_wsa883x.xml \
$(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_grd.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_grd.xml \
+ $(CONFIG_PAL_SRC_DIR)/mixer_paths_kalama_rb5_gen2_dvt.xml:$(CONFIG_SKU_OUT_DIR)/mixer_paths_kalama_rb5_gen2_dvt.xml \
$(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_qrd.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_qrd.xml \
+ $(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_aim.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_aim.xml \
$(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_mtp.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_mtp.xml \
$(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_mtp_apq.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_mtp_apq.xml \
$(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_cdp.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_cdp.xml \
$(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_cdp_apq.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_cdp_apq.xml \
+ $(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_rb5_gen2_dvt.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_rb5_gen2_dvt.xml \
$(CONFIG_PAL_SRC_DIR)/usecaseKvManager.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usecaseKvManager.xml \
$(CONFIG_PAL_SRC_DIR)/resourcemanager_kalama_grd.xml:$(CONFIG_SKU_OUT_DIR)/resourcemanager_kalama_grd.xml \
vendor/qcom/opensource/audio-hal/primary-hal/configs/common/media_codecs_vendor_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_vendor_audio.xml \
diff --git a/hal/AudioStream.cpp b/hal/AudioStream.cpp
index 0bec4fc..3c88c56 100644
--- a/hal/AudioStream.cpp
+++ b/hal/AudioStream.cpp
@@ -2456,6 +2456,7 @@
if (ret<0){
AHAL_ERR("Error usb device is not connected");
+ mAndroidOutDevices.clear();
ret = -ENOSYS;
goto done;
}
@@ -4503,6 +4504,7 @@
if (ret<0) {
AHAL_ERR("Error usb device is not connected");
+ mAndroidInDevices.clear();
ret = -ENOSYS;
goto done;
}
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
index bb4351e..20ddb5e 100644
--- a/hal/audio_extn/Android.mk
+++ b/hal/audio_extn/Android.mk
@@ -94,6 +94,12 @@
-Wno-unused-function \
-Wno-unused-variable
+# Define HEALTH_AIDL for targets other than anorak.
+ifneq ($(TARGET_BOARD_PLATFORM), anorak)
+ LOCAL_CFLAGS += -DHEALTH_AIDL
+ $(warning "Using AIDL HEALTH")
+endif
+
LOCAL_SHARED_LIBRARIES := \
android.hardware.health@1.0 \
android.hardware.health@2.0 \
@@ -109,6 +115,12 @@
liblog \
libutils \
+ifneq ($(TARGET_BOARD_PLATFORM), anorak)
+ LOCAL_SHARED_LIBRARIES += \
+ android.hardware.health-V1-ndk \
+ libbinder_ndk
+endif
+
LOCAL_STATIC_LIBRARIES := libhealthhalutils
include $(BUILD_SHARED_LIBRARY)
diff --git a/hal/audio_extn/battery_listener.cpp b/hal/audio_extn/battery_listener.cpp
index 9c6b338..1250e78 100644
--- a/hal/audio_extn/battery_listener.cpp
+++ b/hal/audio_extn/battery_listener.cpp
@@ -28,23 +28,45 @@
*
* Changes from Qualcomm Innovation Center are provided under the following license:
*
-* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#define LOG_TAG "audio_hw::BatteryListener"
#include <log/log.h>
+#ifdef HEALTH_AIDL
#include <android/binder_manager.h>
#include <aidl/android/hardware/health/IHealth.h>
#include <aidl/android/hardware/health/IHealthInfoCallback.h>
#include <aidl/android/hardware/health/BnHealthInfoCallback.h>
+#else
+#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <android/hardware/health/2.1/IHealth.h>
+#include <android/hardware/health/2.1/IHealthInfoCallback.h>
+#include <healthhalutils/HealthHalUtils.h>
+#include <hidl/HidlTransportSupport.h>
+#endif
+
#include <thread>
#include "battery_listener.h"
+#ifdef HEALTH_AIDL
using aidl::android::hardware::health::BatteryStatus;
using aidl::android::hardware::health::HealthInfo;
using aidl::android::hardware::health::IHealthInfoCallback;
using aidl::android::hardware::health::BnHealthInfoCallback;
using aidl::android::hardware::health::IHealth;
+#else
+using android::hardware::interfacesEqual;
+using android::hardware::Return;
+using android::hardware::Void;
+using android::hardware::health::V1_0::BatteryStatus;
+using android::hardware::health::V1_0::toString;
+using android::hardware::health::V2_1::HealthInfo;
+using android::hardware::health::V2_1::IHealthInfoCallback;
+using android::hardware::health::V2_1::IHealth;
+using android::hardware::health::V2_0::Result;
+using android::hidl::manager::V1_0::IServiceManager;
+#endif
using namespace std::literals::chrono_literals;
namespace android {
@@ -52,6 +74,7 @@
#define GET_HEALTH_SVC_RETRY_CNT 5
#define GET_HEALTH_SVC_WAIT_TIME_MS 500
+#ifdef HEALTH_AIDL
struct BatteryListenerImpl : public BnHealthInfoCallback {
typedef std::function<void(bool)> cb_fn_t;
BatteryListenerImpl(cb_fn_t cb);
@@ -81,17 +104,55 @@
static std::shared_ptr<BatteryListenerImpl> batteryListener;
+#else
+struct BatteryListenerImpl : public hardware::health::V2_1::IHealthInfoCallback,
+ public hardware::hidl_death_recipient {
+ typedef std::function<void(bool)> cb_fn_t;
+ BatteryListenerImpl(cb_fn_t cb);
+ virtual ~BatteryListenerImpl ();
+ virtual hardware::Return<void> healthInfoChanged(
+ const hardware::health::V2_0::HealthInfo& info);
+ virtual hardware::Return<void> healthInfoChanged_2_1(
+ const hardware::health::V2_1::HealthInfo& info);
+ virtual void serviceDied(uint64_t cookie,
+ const wp<hidl::base::V1_0::IBase>& who);
+ bool isCharging() {
+ std::lock_guard<std::mutex> _l(mLock);
+ return statusToBool(mStatus);
+ }
+ void reset();
+ private:
+ sp<hardware::health::V2_1::IHealth> mHealth;
+ status_t init();
+ BatteryStatus mStatus;
+ cb_fn_t mCb;
+ std::mutex mLock;
+ std::condition_variable mCond;
+ std::unique_ptr<std::thread> mThread;
+ bool mDone;
+ bool statusToBool(const BatteryStatus &s) const {
+ return (s == BatteryStatus::CHARGING) ||
+ (s == BatteryStatus::FULL);
+ }
+};
+#endif
status_t BatteryListenerImpl::init()
{
int tries = 0;
+#ifdef HEALTH_AIDL
auto service_name = std::string() + IHealth::descriptor + "/default";
+ #endif
if (mHealth != NULL)
return INVALID_OPERATION;
do {
+#ifdef HEALTH_AIDL
mHealth = IHealth::fromBinder(ndk::SpAIBinder(
AServiceManager_getService(service_name.c_str())));
+#else
+ mHealth = IHealth::getService();
+#endif
if (mHealth != NULL)
break;
usleep(GET_HEALTH_SVC_WAIT_TIME_MS * 1000);
@@ -105,7 +166,17 @@
ALOGI("Get health service in %d tries", tries);
}
mStatus = BatteryStatus::UNKNOWN;
+#ifdef HEALTH_AIDL
auto ret = mHealth->getChargeStatus(&mStatus);
+#else
+ auto ret = mHealth->getChargeStatus([&](Result r, BatteryStatus status) {
+ if (r != Result::SUCCESS) {
+ ALOGE("batterylistener: cannot get battery status");
+ return;
+ }
+ mStatus = status;
+ });
+#endif
if (!ret.isOk())
ALOGE("batterylistener: get charge status transaction error");
@@ -148,6 +219,7 @@
}
}
});
+#ifdef HEALTH_AIDL
mHealth->registerCallback(batteryListener);
binder_status_t binder_status = AIBinder_linkToDeath(
mHealth->asBinder().get(), mDeathRecipient.get(), this);
@@ -156,9 +228,14 @@
static_cast<int>(binder_status));
return NO_INIT;
}
+#else
+ mHealth->registerCallback(this);
+ mHealth->linkToDeath(this, 0 /* cookie */);
+#endif
return NO_ERROR;
}
+#ifdef HEALTH_AIDL
BatteryListenerImpl::BatteryListenerImpl(cb_fn_t cb) :
mCb(cb),
mDeathRecipient(AIBinder_DeathRecipient_new(BatteryListenerImpl::serviceDied))
@@ -166,29 +243,44 @@
}
+#else
+BatteryListenerImpl::BatteryListenerImpl(cb_fn_t cb) :
+ mCb(cb)
+{
+ init();
+}
+#endif
BatteryListenerImpl::~BatteryListenerImpl()
{
+#ifdef HEALTH_AIDL
{
std::lock_guard<std::mutex> _l(mLock);
mDone = true;
mCond.notify_one();
}
+#endif
mThread->join();
}
void BatteryListenerImpl::reset() {
std::lock_guard<std::mutex> _l(mLock);
if (mHealth != nullptr) {
+#ifdef HEALTH_AIDL
mHealth->unregisterCallback(batteryListener);
binder_status_t status = AIBinder_unlinkToDeath(
mHealth->asBinder().get(), mDeathRecipient.get(), this);
if (status != STATUS_OK && status != STATUS_DEAD_OBJECT)
ALOGE("Cannot unlink to death");
+#else
+ mHealth->unregisterCallback(this);
+ mHealth->unlinkToDeath(this);
+#endif
}
mStatus = BatteryStatus::UNKNOWN;
mDone = true;
mCond.notify_one();
}
+#ifdef HEALTH_AIDL
void BatteryListenerImpl::serviceDied(void *cookie)
{
BatteryListenerImpl *listener = reinterpret_cast<BatteryListenerImpl *>(cookie);
@@ -208,11 +300,30 @@
listener->init();
}
+#else
+void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
+ const wp<hidl::base::V1_0::IBase>& who)
+{
+ {
+ std::lock_guard<std::mutex> _l(mLock);
+ if (mHealth == NULL || !interfacesEqual(mHealth, who.promote())) {
+ ALOGE("health not initialized or unknown interface died");
+ return;
+ }
+ ALOGI("health service died, reinit");
+ mDone = true;
+ }
+ mThread->join();
+ std::lock_guard<std::mutex> _l(mLock);
+ init();
+}
+#endif
// this callback seems to be a SYNC callback and so
// waits for return before next event is issued.
// therefore we need not have a queue to process
// NOT_CHARGING and CHARGING concurrencies.
// Replace single var by a list if this assumption is broken
+#ifdef HEALTH_AIDL
ndk::ScopedAStatus BatteryListenerImpl::healthInfoChanged(const HealthInfo& info)
{
ALOGV("healthInfoChanged: %d", info.batteryStatus);
@@ -224,15 +335,45 @@
return ndk::ScopedAStatus::ok();
}
+#else
+Return<void> BatteryListenerImpl::healthInfoChanged(
+ const hardware::health::V2_0::HealthInfo& info)
+{
+ ALOGV("healthInfoChanged: %d", info.legacy.batteryStatus);
+ std::unique_lock<std::mutex> l(mLock);
+ if (info.legacy.batteryStatus != mStatus) {
+ mStatus = info.legacy.batteryStatus;
+ mCond.notify_one();
+ }
+ return Void();
+}
+
+Return<void> BatteryListenerImpl::healthInfoChanged_2_1(
+ const hardware::health::V2_1::HealthInfo& info) {
+ ALOGV("healthInfoChanged_2_1: %d", info.legacy.legacy.batteryStatus);
+ healthInfoChanged(info.legacy);
+ return Void();
+}
+
+static sp<BatteryListenerImpl> batteryListener;
+#endif
status_t batteryPropertiesListenerInit(BatteryListenerImpl::cb_fn_t cb)
{
+#ifdef HEALTH_AIDL
batteryListener = ndk::SharedRefBase::make<BatteryListenerImpl>(cb);
return batteryListener->init();
+#else
+ batteryListener = new BatteryListenerImpl(cb);
+ return NO_ERROR;
+#endif
}
status_t batteryPropertiesListenerDeinit()
{
batteryListener->reset();
+#ifndef HEALTH_AIDL
+ batteryListener.clear();
+#endif
return OK;
}