a71-common: Pass call state to audio hal and patch RIL

* Fixes 2nd sim audio when in call.

Change-Id: I64fefe8408464345df703fc1fc39801ef7d61b8c
This commit is contained in:
LuK1337
2024-06-15 15:08:16 +02:00
committed by Haky86
parent 444a97ee16
commit f3c6574484
7 changed files with 59 additions and 3 deletions

View File

@@ -75,6 +75,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",
@@ -92,6 +93,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",
@@ -108,6 +110,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",
@@ -124,6 +127,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",
@@ -142,6 +146,7 @@ cc_library_shared {
"android.hardware.audio.common@7.0-enums",
"android.hardware.audio.common@7.0-util",
"libbase",
"libcutils",
],
cflags: [
"-DMAJOR_VERSION=7",

View File

@@ -9,6 +9,11 @@
#include "core/default/PrimaryDevice.h"
#include "core/default/Util.h"
#include <cutils/properties.h>
#include <string.h>
#include <chrono>
#include <thread>
#if MAJOR_VERSION >= 4
#include <cmath>
#endif
@@ -194,6 +199,35 @@ Return<Result> PrimaryDevice::setVoiceVolume(float volume) {
}
Return<Result> 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 simSlot[92];
// This prop returns either -1 (no SIM is calling),
// 0 (SIM1 is calling) or 1 (SIM2 is calling)
property_get("vendor.calls.slotid", simSlot, "");
// Wait until RIL reports which SIM is being used
while (strcmp(simSlot, "-1") == 0 && mode == AudioMode::IN_CALL) {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
property_get("vendor.calls.slotid", simSlot, "");
}
if (strcmp(simSlot, "0") == 0) {
// SIM1
mDevice->halSetParameters("call_state=2;g_call_state=2;g_call_sim_slot=0x01");
} else if (strcmp(simSlot, "1") == 0) {
// SIM2
mDevice->halSetParameters("call_state=2;g_call_state=2;g_call_sim_slot=0x02");
} else if (strcmp(simSlot, "-1") == 0) {
// No call
mDevice->halSetParameters("call_state=1;g_call_state=1");
}
// INVALID, CURRENT, CNT, MAX are reserved for internal use.
// TODO: remove the values from the HIDL interface
switch (mode) {

View File

@@ -132,6 +132,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;
@@ -150,7 +152,6 @@ struct Device : public IDevice, public ParametersUtil {
// Methods from ParametersUtil.
char* halGetParameters(const char* keys) override;
int halSetParameters(const char* keysAndValues) override;
};
} // namespace implementation

View File

@@ -20,6 +20,17 @@ if [ ! -f "${HELPER}" ]; then
fi
source "${HELPER}"
function blob_fixup() {
case "${1}" in
vendor/lib64/libsec-ril.so)
sed -i 's/ril.dds.call.slotid/vendor.calls.slotid/g' "${2}"
;;
vendor/lib64/libsec-ril-dsds.so)
sed -i 's/ril.dds.call.slotid/vendor.calls.slotid/g' "${2}"
;;
esac
}
# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true

View File

@@ -1133,8 +1133,8 @@ vendor/lib64/libqrtr.so
vendor/lib64/libqsocket.so
-vendor/lib64/libril.so
vendor/lib64/librilqmiservices-ext.so
vendor/lib64/libsec-ril-dsds.so
vendor/lib64/libsec-ril.so
vendor/lib64/libsec-ril-dsds.so|7aeeccbca3730b4d9cb9fba6b06c49dfe7a2052f
vendor/lib64/libsec-ril.so|94bb3426a636263c4daf45e633e8061232c30954
vendor/lib64/libsec_semRil.so
vendor/lib64/libsecril-client.so
vendor/lib64/libvkmanager_vendor.so

View File

@@ -11,3 +11,5 @@ allow hal_audio_default vendor_audiopcm_data_file:dir create_dir_perms;
allow hal_audio_default vendor_audiopcm_data_file:file create_file_perms;
allow hal_audio_default vendor_log_file:dir r_dir_perms;
get_prop(hal_audio_default, vendor_radio_prop)

View File

@@ -1,2 +1,5 @@
# Fastbootd
ro.fastbootd.available u:object_r:exported_default_prop:s0
# Radio
vendor.calls.slotid u:object_r:vendor_radio_prop:s0