From 14861f7f2e5db160e9d373c3a95d7a25368a797a Mon Sep 17 00:00:00 2001 From: Simon1511 Date: Sun, 24 Mar 2024 12:45:43 +0100 Subject: [PATCH] Revert "sm7125-common: audio: add dedicated service to pass g_call_sim_slot" This reverts commit 64b507b1cfb4fde4f60d3feb45523adeda7683f9. Additionally, stop using delays as that can cause audioserver to crash Change-Id: If77eef84d04039b79ea1390dc81f89e5f01f354f --- BoardConfigCommon.mk | 4 +- audio/impl/Android.bp | 6 +++ audio/impl/PrimaryDevice.cpp | 29 +++++++++++ audio/impl/include/core/default/Device.h | 3 +- audio/service/Android.bp | 30 ----------- audio/service/audio_parameter_service.cpp | 55 --------------------- audio/service/audio_parameter_service.rc | 16 ------ common.mk | 3 +- sepolicy/private/audio_parameter_service.te | 8 --- sepolicy/private/file_contexts | 1 - sepolicy/public/property.te | 1 - sepolicy/vendor/hal_audio_default.te | 2 +- sepolicy/vendor/property_contexts | 3 +- sepolicy/vendor/rild.te | 2 - 14 files changed, 42 insertions(+), 121 deletions(-) delete mode 100644 audio/service/Android.bp delete mode 100644 audio/service/audio_parameter_service.cpp delete mode 100644 audio/service/audio_parameter_service.rc delete mode 100644 sepolicy/private/audio_parameter_service.te delete mode 100644 sepolicy/private/file_contexts delete mode 100644 sepolicy/public/property.te diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 6b249fe..63dcdd1 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -210,8 +210,8 @@ TARGET_RELEASETOOLS_EXTENSIONS := $(COMMON_PATH)/releasetools # SePolicy include device/qcom/sepolicy_vndr/SEPolicy.mk BOARD_VENDOR_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor -SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private -SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/public +PRODUCT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private +PRODUCT_PUBLIC_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/public # Vibrator $(call soong_config_set,samsungVibratorVars,duration_amplitude,true) diff --git a/audio/impl/Android.bp b/audio/impl/Android.bp index daf358d..297c747 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", @@ -154,6 +159,7 @@ cc_library_shared { "android.hardware.audio.common@7.1-enums", "android.hardware.audio.common@7.1-util", "libbase", + "libcutils", ], cflags: [ "-DMAJOR_VERSION=7", diff --git a/audio/impl/PrimaryDevice.cpp b/audio/impl/PrimaryDevice.cpp index 13efbbc..24e75b5 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,32 @@ 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 g_call_sim_slot parameter 0x01 describes SIM1 and 0x02 SIM2. + */ + + char simSlot[92]; + + // These props return either -1 (not calling), + // 0 (SIM1 is calling) or 1 (SIM2 is calling) + property_get("vendor.calls.slotid", simSlot, ""); + + // Wait until one sim slot reports a call + if (mode == AudioMode::IN_CALL) { + while (strcmp(simSlot, "-1") == 0) { + property_get("vendor.calls.slotid", simSlot, ""); + } + } + + if (strcmp(simSlot, "0") == 0) { + // SIM1 + mDevice->halSetParameters("g_call_sim_slot=0x01"); + } else if (strcmp(simSlot, "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/audio/service/Android.bp b/audio/service/Android.bp deleted file mode 100644 index edc370e..0000000 --- a/audio/service/Android.bp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (C) 2023 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -cc_binary { - name: "audio_parameter_service.samsung_sm7125", - init_rc: ["audio_parameter_service.rc"], - system_ext_specific: true, - srcs: [ - "audio_parameter_service.cpp", - ], - shared_libs: [ - "libbase", - "libutils", - "libhidlbase", - "liblog", - "android.hardware.audio@7.0", - ], -} diff --git a/audio/service/audio_parameter_service.cpp b/audio/service/audio_parameter_service.cpp deleted file mode 100644 index 2e5069c..0000000 --- a/audio/service/audio_parameter_service.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2023 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -using android::base::GetProperty; -using android::base::SetProperty; -using android::sp; -using ::android::hardware::hidl_string; - -int main() { - sp<::android::hardware::audio::V7_0::IDevice> audioDevice; - - LOG(DEBUG) << "Passing g_call_sim_slot parameter"; - - if (!audioDevice) { - ::android::hardware::audio::V7_0::IDevicesFactory::getService()->openDevice( - "primary", [&](::android::hardware::audio::V7_0::Result, const sp<::android::hardware::audio::V7_0::IDevice>& result) { - audioDevice = result; - }); - } - - if (audioDevice != nullptr) { - std::string value = ""; - - if (strcmp(GetProperty("vendor.calls.slotid", "-1").c_str(), "1") == 0) { - // SIM 2 - value = "0x02"; - } - - audioDevice->setParameters({}, {{"g_call_sim_slot", value}}); - } - - if (audioDevice != nullptr) - audioDevice->close(); - - SetProperty("vendor.calls.parameter_state", "1"); - - return 0; -} diff --git a/audio/service/audio_parameter_service.rc b/audio/service/audio_parameter_service.rc deleted file mode 100644 index 156c630..0000000 --- a/audio/service/audio_parameter_service.rc +++ /dev/null @@ -1,16 +0,0 @@ -service audio_parameter_service /system_ext/bin/audio_parameter_service.samsung_sm7125 - oneshot - disabled - -on boot - setprop vendor.calls.parameter_state 0 - -on property:vendor.calls.slotid=1 && property:vendor.calls.parameter_state=0 - stop audioserver - start audioserver - start audio_parameter_service - -on property:vendor.calls.slotid=-1 && property:vendor.calls.parameter_state=1 - setprop vendor.calls.parameter_state 0 - stop audioserver - start audioserver diff --git a/common.mk b/common.mk index a87c539..cfe0795 100644 --- a/common.mk +++ b/common.mk @@ -72,8 +72,7 @@ PRODUCT_PACKAGES += \ libqcomvisualizer \ libqcomvoiceprocessing \ libqcompostprocbundle \ - libvolumelistener \ - audio_parameter_service.samsung_sm7125 + libvolumelistener PRODUCT_COPY_FILES += \ $(COMMON_PATH)/audio/configs/audio_configs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs.xml \ diff --git a/sepolicy/private/audio_parameter_service.te b/sepolicy/private/audio_parameter_service.te deleted file mode 100644 index 1f8e174..0000000 --- a/sepolicy/private/audio_parameter_service.te +++ /dev/null @@ -1,8 +0,0 @@ -type audio_parameter_service, domain, coredomain; -type audio_parameter_service_exec, system_file_type, exec_type, file_type; - -init_daemon_domain(audio_parameter_service) - -hal_client_domain(audio_parameter_service, hal_audio) - -set_prop(audio_parameter_service, vendor_call_prop) diff --git a/sepolicy/private/file_contexts b/sepolicy/private/file_contexts deleted file mode 100644 index 9dfd308..0000000 --- a/sepolicy/private/file_contexts +++ /dev/null @@ -1 +0,0 @@ -/(system_ext|system/system_ext)/bin/audio_parameter_service.samsung_sm7125 u:object_r:audio_parameter_service_exec:s0 diff --git a/sepolicy/public/property.te b/sepolicy/public/property.te deleted file mode 100644 index 1ca4b02..0000000 --- a/sepolicy/public/property.te +++ /dev/null @@ -1 +0,0 @@ -system_public_prop(vendor_call_prop) diff --git a/sepolicy/vendor/hal_audio_default.te b/sepolicy/vendor/hal_audio_default.te index 6592d9e..a819e93 100644 --- a/sepolicy/vendor/hal_audio_default.te +++ b/sepolicy/vendor/hal_audio_default.te @@ -6,4 +6,4 @@ 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_call_prop) +get_prop(hal_audio_default, vendor_radio_prop) diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index 3101192..ba633e7 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -22,8 +22,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 u:object_r:vendor_call_prop:s0 +vendor.calls u:object_r:vendor_radio_prop:s0 # Sensors vendor.sensor.file.permission u:object_r:vendor_sensors_prop:s0 diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te index 9b4a529..873bdec 100644 --- a/sepolicy/vendor/rild.te +++ b/sepolicy/vendor/rild.te @@ -3,8 +3,6 @@ get_prop(rild, vendor_radio_prop) get_prop(rild, radio_prop) -set_prop(rild, vendor_call_prop) - allow rild block_device:dir search; allow rild mnt_vendor_file:dir { getattr search };