init_gsi: Add qcom caf audio quirks
Force-disabling A2DP offloading is not implemented yet.
This commit is contained in:
parent
6229eb6fea
commit
fededa5f79
|
@ -7,6 +7,7 @@ cc_binary {
|
|||
|
||||
// SoC-specific quirks
|
||||
"quirks/soc/mtk_ril.cpp",
|
||||
"quirks/soc/caf_audio.cpp",
|
||||
|
||||
// Device-specific quirks
|
||||
"quirks/device/unihertz_keylayout.cpp",
|
||||
|
|
|
@ -87,6 +87,16 @@ void Quirks::CopyFileKeepPerms(filesystem::path src, filesystem::path dst) {
|
|||
RestoreFilePermissions(src, dst);
|
||||
}
|
||||
|
||||
int Quirks::OverrideWithBindMount(filesystem::path src, filesystem::path dst) {
|
||||
int err = mount(src.c_str(), dst.c_str(), nullptr, MS_BIND, nullptr);
|
||||
|
||||
if (err < 0) {
|
||||
ALOGE("bind mount %s on %s err = %d\n", src.c_str(), dst.c_str(), errno);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void Quirks::OverrideFileWith(filesystem::path p, function<void(istream&, ostream&)> proc) {
|
||||
if (!filesystem::is_regular_file(p)) return;
|
||||
|
||||
|
@ -108,10 +118,9 @@ void Quirks::OverrideFileWith(filesystem::path p, function<void(istream&, ostrea
|
|||
RestoreFilePermissions(p, tmp_path);
|
||||
|
||||
// Bind mount and override the file
|
||||
int err = mount(tmp_path.c_str(), p.c_str(), nullptr, MS_BIND, nullptr);
|
||||
|
||||
int err = OverrideWithBindMount(tmp_path, p);
|
||||
|
||||
if (err < 0) {
|
||||
ALOGE("bind mount %s on %s err = %d\n", tmp_path.c_str(), p.c_str(), errno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,10 +158,9 @@ void Quirks::OverrideFolderWith(filesystem::path p, function<void(filesystem::pa
|
|||
|
||||
proc(tmp_path);
|
||||
|
||||
int err = mount(tmp_path.c_str(), p.c_str(), nullptr, MS_BIND, nullptr);
|
||||
int err = OverrideWithBindMount(tmp_path, p);
|
||||
|
||||
if (err < 0) {
|
||||
ALOGE("bind mount %s on %s err = %d\n", tmp_path.c_str(), p.c_str(), errno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,9 @@ public:
|
|||
namespace Quirks {
|
||||
void Add(DeviceQuirk* quirk);
|
||||
void Run();
|
||||
|
||||
|
||||
int OverrideWithBindMount(filesystem::path src, filesystem::path dst);
|
||||
|
||||
void OverrideFileWith(filesystem::path p, function<void(istream&, ostream&)> proc);
|
||||
void OverrideFileReplaceSubstr(filesystem::path p, string pattern, string replacement);
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include "../../quirks.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CafAudioQuirk : DeviceQuirk {
|
||||
public:
|
||||
bool ShouldRun() {
|
||||
return filesystem::exists("/vendor/etc/audio/audio_policy_configuration.xml");
|
||||
}
|
||||
|
||||
void Run() {
|
||||
Quirks::OverrideWithBindMount("/vendor/etc/audio/audio_policy_configuration.xml", "/vendor/etc/audio_policy_configuration.xml");
|
||||
if (filesystem::exists("/vendor/etc/a2dp_audio_policy_configuration.xml")) {
|
||||
Quirks::OverrideFileReplaceSubstr("/vendor/etc/a2dp_audio_policy_configuration.xml", "bluetooth_qti", "a2dp");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LOAD_QUIRK(CafAudioQuirk);
|
Loading…
Reference in New Issue