From ff14ded8868f684266a198523c184246ca6dd1f1 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 20 Jun 2022 12:27:27 +0200 Subject: [PATCH] sm8550-common: audio-impl: Pass call state to audio hal and patch RIL * Fixes 2nd sim audio when in call. Co-authored-by: Simon1511 Change-Id: I25ced80d833a36ac1141d5894aed99a0931d3946 --- audio/impl/Android.bp | 5 ++++ audio/impl/PrimaryDevice.cpp | 32 ++++++++++++++++++++++++ audio/impl/include/core/default/Device.h | 3 ++- extract-files.sh | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/audio/impl/Android.bp b/audio/impl/Android.bp index 7c8b4b7..ce086ca 100644 --- a/audio/impl/Android.bp +++ b/audio/impl/Android.bp @@ -68,6 +68,7 @@ cc_library_shared { "android.hardware.audio@2.0-util", "android.hardware.audio.common@2.0", "android.hardware.audio.common@2.0-util", + "libcutils", ], cflags: [ "-DMAJOR_VERSION=2", @@ -85,6 +86,7 @@ cc_library_shared { "android.hardware.audio@4.0-util", "android.hardware.audio.common@4.0", "android.hardware.audio.common@4.0-util", + "libcutils", ], cflags: [ "-DMAJOR_VERSION=4", @@ -101,6 +103,7 @@ cc_library_shared { "android.hardware.audio@5.0-util", "android.hardware.audio.common@5.0", "android.hardware.audio.common@5.0-util", + "libcutils", ], cflags: [ "-DMAJOR_VERSION=5", @@ -117,6 +120,7 @@ cc_library_shared { "android.hardware.audio@6.0-util", "android.hardware.audio.common@6.0", "android.hardware.audio.common@6.0-util", + "libcutils", ], cflags: [ "-DMAJOR_VERSION=6", @@ -135,6 +139,7 @@ cc_library_shared { "android.hardware.audio.common@7.0-enums", "android.hardware.audio.common@7.0-util", "libbase", + "libcutils", ], cflags: [ "-DMAJOR_VERSION=7", diff --git a/audio/impl/PrimaryDevice.cpp b/audio/impl/PrimaryDevice.cpp index 13efbbc..5f519fc 100644 --- a/audio/impl/PrimaryDevice.cpp +++ b/audio/impl/PrimaryDevice.cpp @@ -19,6 +19,9 @@ #include "core/default/PrimaryDevice.h" #include "core/default/Util.h" +#include +#include + #if MAJOR_VERSION >= 4 #include #endif @@ -208,6 +211,35 @@ Return PrimaryDevice::setVoiceVolume(float volume) { } Return PrimaryDevice::setMode(AudioMode mode) { + /* On stock ROM Samsung sets the g_call_state and g_call_sim_slot audio parameters + * in the framework, breaking it on AOSP ROMs. For the audio params call_state and + * g_call_state 2 corresponds to CALL_ACTIVE and 1 to CALL_INACTIVE respectively. + * For the g_call_sim_slot parameter 0x01 describes SIM1 and 0x02 SIM2. + */ + + char simSlot1[92], simSlot2[92]; + + // These props return either 0 (not calling), + // or 1 (SIM is calling) + property_get("vendor.calls.slot_id0", simSlot1, ""); + property_get("vendor.calls.slot_id1", simSlot2, ""); + + // Wait until one sim slot reports a call + if (mode == AudioMode::IN_CALL) { + while (strcmp(simSlot1, "0") == 0 && strcmp(simSlot2, "0") == 0) { + property_get("vendor.calls.slot_id0", simSlot1, ""); + property_get("vendor.calls.slot_id1", simSlot2, ""); + } + } + + if (strcmp(simSlot1, "1") == 0) { + // SIM1 + mDevice->halSetParameters("g_call_sim_slot=0x01"); + } else if (strcmp(simSlot2, "1") == 0) { + // SIM2 + mDevice->halSetParameters("g_call_sim_slot=0x02"); + } + // INVALID, CURRENT, CNT, MAX are reserved for internal use. // TODO: remove the values from the HIDL interface switch (mode) { diff --git a/audio/impl/include/core/default/Device.h b/audio/impl/include/core/default/Device.h index 0696f97..f0e7afd 100644 --- a/audio/impl/include/core/default/Device.h +++ b/audio/impl/include/core/default/Device.h @@ -173,6 +173,8 @@ struct Device : public IDevice, public ParametersUtil { uint32_t version() const { return mDevice->common.version; } + int halSetParameters(const char* keysAndValues) override; + private: bool mIsClosed; audio_hw_device_t* mDevice; @@ -191,7 +193,6 @@ struct Device : public IDevice, public ParametersUtil { // Methods from ParametersUtil. char* halGetParameters(const char* keys) override; - int halSetParameters(const char* keysAndValues) override; }; } // namespace implementation diff --git a/extract-files.sh b/extract-files.sh index 7647243..f5043d4 100755 --- a/extract-files.sh +++ b/extract-files.sh @@ -70,6 +70,7 @@ function blob_fixup() { vendor/lib64/libsec-ril.so) xxd -p -c0 "${2}" | sed "s/600e40f9e10315aa820c8052e30314aa/600e40f9e10315aa820c8052030080d2/g" | xxd -r -p > "${2}".patched mv "${2}".patched "${2}" + sed -i 's/ril.dds.call.ongoing/vendor.calls.slot_id/g' "${2}" ;; vendor/etc/vintf/manifest/sec_c2_manifest_default0_1_0.xml) sed -i 's/default0/software/g' "${2}"