sm7125-common: audio: add dedicated service to pass g_call_sim_slot

This is a partial revert of c31482154b

Change-Id: Ibba1b588ee5836e8f51dfdb96231da66d7f3b09a
fourteen-wip
Simon1511 1 year ago
parent 93616b944c
commit 64b507b1cf
  1. 4
      BoardConfigCommon.mk
  2. 6
      audio/impl/Android.bp
  3. 34
      audio/impl/PrimaryDevice.cpp
  4. 3
      audio/impl/include/core/default/Device.h
  5. 30
      audio/service/Android.bp
  6. 58
      audio/service/audio_parameter_service.cpp
  7. 19
      audio/service/audio_parameter_service.rc
  8. 3
      common.mk
  9. 9
      sepolicy/private/audio_parameter_service.te
  10. 1
      sepolicy/private/file_contexts
  11. 1
      sepolicy/public/property.te
  12. 2
      sepolicy/vendor/hal_audio_default.te
  13. 3
      sepolicy/vendor/property_contexts
  14. 3
      sepolicy/vendor/rild.te

@ -212,8 +212,8 @@ TARGET_RELEASETOOLS_EXTENSIONS := $(COMMON_PATH)/releasetools
# SePolicy # SePolicy
include device/qcom/sepolicy_vndr-legacy-um/SEPolicy.mk include device/qcom/sepolicy_vndr-legacy-um/SEPolicy.mk
BOARD_VENDOR_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor BOARD_VENDOR_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/vendor
PRODUCT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/private
PRODUCT_PUBLIC_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/public SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += $(COMMON_PATH)/sepolicy/public
# Vibrator # Vibrator
$(call soong_config_set,samsungVibratorVars,duration_amplitude,true) $(call soong_config_set,samsungVibratorVars,duration_amplitude,true)

@ -68,7 +68,6 @@ cc_library_shared {
"android.hardware.audio@2.0-util", "android.hardware.audio@2.0-util",
"android.hardware.audio.common@2.0", "android.hardware.audio.common@2.0",
"android.hardware.audio.common@2.0-util", "android.hardware.audio.common@2.0-util",
"libcutils",
], ],
cflags: [ cflags: [
"-DMAJOR_VERSION=2", "-DMAJOR_VERSION=2",
@ -86,7 +85,6 @@ cc_library_shared {
"android.hardware.audio@4.0-util", "android.hardware.audio@4.0-util",
"android.hardware.audio.common@4.0", "android.hardware.audio.common@4.0",
"android.hardware.audio.common@4.0-util", "android.hardware.audio.common@4.0-util",
"libcutils",
], ],
cflags: [ cflags: [
"-DMAJOR_VERSION=4", "-DMAJOR_VERSION=4",
@ -103,7 +101,6 @@ cc_library_shared {
"android.hardware.audio@5.0-util", "android.hardware.audio@5.0-util",
"android.hardware.audio.common@5.0", "android.hardware.audio.common@5.0",
"android.hardware.audio.common@5.0-util", "android.hardware.audio.common@5.0-util",
"libcutils",
], ],
cflags: [ cflags: [
"-DMAJOR_VERSION=5", "-DMAJOR_VERSION=5",
@ -120,7 +117,6 @@ cc_library_shared {
"android.hardware.audio@6.0-util", "android.hardware.audio@6.0-util",
"android.hardware.audio.common@6.0", "android.hardware.audio.common@6.0",
"android.hardware.audio.common@6.0-util", "android.hardware.audio.common@6.0-util",
"libcutils",
], ],
cflags: [ cflags: [
"-DMAJOR_VERSION=6", "-DMAJOR_VERSION=6",
@ -139,7 +135,6 @@ cc_library_shared {
"android.hardware.audio.common@7.0-enums", "android.hardware.audio.common@7.0-enums",
"android.hardware.audio.common@7.0-util", "android.hardware.audio.common@7.0-util",
"libbase", "libbase",
"libcutils",
], ],
cflags: [ cflags: [
"-DMAJOR_VERSION=7", "-DMAJOR_VERSION=7",
@ -159,7 +154,6 @@ cc_library_shared {
"android.hardware.audio.common@7.1-enums", "android.hardware.audio.common@7.1-enums",
"android.hardware.audio.common@7.1-util", "android.hardware.audio.common@7.1-util",
"libbase", "libbase",
"libcutils",
], ],
cflags: [ cflags: [
"-DMAJOR_VERSION=7", "-DMAJOR_VERSION=7",

@ -19,11 +19,6 @@
#include "core/default/PrimaryDevice.h" #include "core/default/PrimaryDevice.h"
#include "core/default/Util.h" #include "core/default/Util.h"
#include <cutils/properties.h>
#include <string.h>
#include <chrono>
#include <thread>
#if MAJOR_VERSION >= 4 #if MAJOR_VERSION >= 4
#include <cmath> #include <cmath>
#endif #endif
@ -213,35 +208,6 @@ Return<Result> PrimaryDevice::setVoiceVolume(float volume) {
} }
Return<Result> PrimaryDevice::setMode(AudioMode mode) { 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. // INVALID, CURRENT, CNT, MAX are reserved for internal use.
// TODO: remove the values from the HIDL interface // TODO: remove the values from the HIDL interface
switch (mode) { switch (mode) {

@ -173,8 +173,6 @@ struct Device : public IDevice, public ParametersUtil {
uint32_t version() const { return mDevice->common.version; } uint32_t version() const { return mDevice->common.version; }
int halSetParameters(const char* keysAndValues) override;
private: private:
bool mIsClosed; bool mIsClosed;
audio_hw_device_t* mDevice; audio_hw_device_t* mDevice;
@ -193,6 +191,7 @@ struct Device : public IDevice, public ParametersUtil {
// Methods from ParametersUtil. // Methods from ParametersUtil.
char* halGetParameters(const char* keys) override; char* halGetParameters(const char* keys) override;
int halSetParameters(const char* keysAndValues) override;
}; };
} // namespace implementation } // namespace implementation

@ -0,0 +1,30 @@
//
// 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",
],
}

@ -0,0 +1,58 @@
/*
* 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 <android-base/properties.h>
#include <android-base/logging.h>
#include <android/hardware/audio/7.0/IDevicesFactory.h>
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(), "0") == 0) {
// SIM 1
value = "0x01";
} else 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;
}

@ -0,0 +1,19 @@
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=0 && 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=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

@ -72,7 +72,8 @@ PRODUCT_PACKAGES += \
libqcomvisualizer \ libqcomvisualizer \
libqcomvoiceprocessing \ libqcomvoiceprocessing \
libqcompostprocbundle \ libqcompostprocbundle \
libvolumelistener libvolumelistener \
audio_parameter_service.samsung_sm7125
PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \
$(COMMON_PATH)/audio/configs/audio_configs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs.xml \ $(COMMON_PATH)/audio/configs/audio_configs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs.xml \

@ -0,0 +1,9 @@
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)
get_prop(audio_parameter_service, vendor_call_prop)
set_prop(audio_parameter_service, vendor_call_prop)

@ -0,0 +1 @@
/(system_ext|system/system_ext)/bin/audio_parameter_service.samsung_sm7125 u:object_r:audio_parameter_service_exec:s0

@ -0,0 +1 @@
system_public_prop(vendor_call_prop)

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

@ -22,7 +22,8 @@ vendor.sec.rild. u:object_r:vendor_radio_prop:s0
ro.vendor.sec.radio. 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.use_data_netmgrd u:object_r:vendor_radio_prop:s0
ro.vendor.epdg.support u:object_r:vendor_radio_prop:s0 ro.vendor.epdg.support u:object_r:vendor_radio_prop:s0
vendor.calls u:object_r:vendor_radio_prop:s0
vendor.calls u:object_r:vendor_call_prop:s0
# Sensors # Sensors
vendor.sensor.file.permission u:object_r:vendor_sensors_prop:s0 vendor.sensor.file.permission u:object_r:vendor_sensors_prop:s0

@ -3,6 +3,9 @@
get_prop(rild, vendor_radio_prop) get_prop(rild, vendor_radio_prop)
get_prop(rild, radio_prop) get_prop(rild, radio_prop)
set_prop(rild, vendor_call_prop)
get_prop(rild, vendor_call_prop)
allow rild block_device:dir search; allow rild block_device:dir search;
allow rild mnt_vendor_file:dir { getattr search }; allow rild mnt_vendor_file:dir { getattr search };

Loading…
Cancel
Save