sm7125: Pass call state to audio hal and patch RIL

Simon1511: libsec-ril sets a prop (ril.dds.call.slotid) when in call with Sim1 or Sim2. Patch libsec-ril to make that prop vendor lable-able (vendor.calls.slotid). Then use that prop to check which Sim is currently in a call (0 for Sim1 and 1 for Sim2) and pass the arguments to audio HAL depending on that.

Note for later: Check whether passing [g_]call_state is really needed

Change-Id: I5a0dfd3b100287a2cf1ec3c156292487dc4da3d5
fourteen-wip
LuK1337 3 years ago committed by Simon1511
parent 1c47751006
commit c31482154b
  1. 5
      audio/Android.bp
  2. 34
      audio/PrimaryDevice.cpp
  3. 3
      audio/include/core/default/Device.h
  4. 8
      extract-files.sh
  5. 2
      proprietary-files.txt
  6. 2
      sepolicy/vendor/hal_audio_default.te
  7. 1
      sepolicy/vendor/property_contexts

@ -69,6 +69,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",
@ -86,6 +87,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",
@ -102,6 +104,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",
@ -118,6 +121,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",
@ -136,6 +140,7 @@ cc_library_shared {
"android.hardware.audio.common@7.0-enums",
"android.hardware.audio.common@7.0-util",
"libbase",
"libcutils",
],
cflags: [
"-DMAJOR_VERSION=7",

@ -19,6 +19,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
@ -204,6 +209,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) {

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

@ -63,4 +63,12 @@ BLOB_ROOT="$ANDROID_ROOT"/vendor/"$VENDOR"/"$DEVICE_COMMON"/proprietary
# Replace libutils with vndk30 libutils
"${PATCHELF}" --replace-needed libutils.so libutils-v30.so $BLOB_ROOT/vendor/lib64/hw/android.hardware.health@2.0-impl-2.1-samsung.so
function blob_fixup() {
case "${1}" in
vendor/lib64/libsec-ril.so)
sed -i 's/ril.dds.call.slotid/vendor.calls.slotid/g' "${2}"
;;
esac
}
"${MY_DIR}/setup-makefiles.sh"

@ -978,7 +978,7 @@ vendor/lib64/libnetmgr.so
vendor/lib64/libnetmgr_common.so
vendor/lib/libqrtr.so
vendor/lib64/libqrtr.so
vendor/lib64/libsec-ril.so
vendor/lib64/libsec-ril.so|1d97ef6504c6380466d4ea82b3428f496e4d0ab8
vendor/lib64/libsecril-client.so
vendor/lib/libsystem_health_mon.so
vendor/lib64/libsystem_health_mon.so

@ -5,3 +5,5 @@ allow hal_audio_default imei_efs_file:dir search;
allow hal_audio_default imei_efs_file:file { read open getattr };
allow hal_audio_default efs_file:dir search;
get_prop(hal_audio_default, vendor_radio_prop)

@ -21,6 +21,7 @@ vendor.sec.rild. u:object_r:vendor_radio_prop:s0
ro.vendor.sec.radio. u:object_r:vendor_radio_prop:s0
ro.vendor.use_data_netmgrd u:object_r:vendor_radio_prop:s0
ro.vendor.epdg.support u:object_r:vendor_radio_prop:s0
vendor.calls.slotid u:object_r:vendor_radio_prop:s0
# Sensors
vendor.sensor.file.permission u:object_r:vendor_sensors_prop:s0

Loading…
Cancel
Save