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

This reverts commit 64b507b1cf.

Additionally, stop using delays as that can cause audioserver to crash

Change-Id: If77eef84d04039b79ea1390dc81f89e5f01f354f
fourteen-wip
Simon1511 8 months ago committed by Jenna
parent 581624a799
commit 14861f7f2e
  1. 4
      BoardConfigCommon.mk
  2. 6
      audio/impl/Android.bp
  3. 29
      audio/impl/PrimaryDevice.cpp
  4. 3
      audio/impl/include/core/default/Device.h
  5. 30
      audio/service/Android.bp
  6. 55
      audio/service/audio_parameter_service.cpp
  7. 16
      audio/service/audio_parameter_service.rc
  8. 3
      common.mk
  9. 8
      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. 2
      sepolicy/vendor/rild.te

@ -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)

@ -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",

@ -19,6 +19,9 @@
#include "core/default/PrimaryDevice.h"
#include "core/default/Util.h"
#include <cutils/properties.h>
#include <string.h>
#if MAJOR_VERSION >= 4
#include <cmath>
#endif
@ -208,6 +211,32 @@ 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 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) {

@ -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

@ -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",
],
}

@ -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 <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(), "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;
}

@ -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

@ -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 \

@ -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)

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

@ -1 +0,0 @@
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;
get_prop(hal_audio_default, vendor_call_prop)
get_prop(hal_audio_default, vendor_radio_prop)

@ -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

@ -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 };

Loading…
Cancel
Save