init_gsi: Add support for optional alternate CAF audio policy
This commit is contained in:
parent
276d4b620b
commit
15ca354dfe
|
@ -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",
|
||||
|
|
|
@ -59,6 +59,8 @@ int main(int argc, char **argv) {
|
|||
// Reset SPL / device model related props during late init
|
||||
// so that they are set before keystore / vold is started.
|
||||
handle_device_model_props();
|
||||
} else if (argc >= 2 && strcmp(argv[1], "--post-fs-data") == 0) {
|
||||
Quirks::RunPostData();
|
||||
} else {
|
||||
Quirks::Run();
|
||||
}
|
||||
|
|
|
@ -4,5 +4,9 @@ on late-init
|
|||
on post-fs
|
||||
exec u:r:init_gsi:s0 root -- /system_ext/bin/init_gsi
|
||||
|
||||
# When we call our post-fs-data actions, we would like persist properties to be available
|
||||
on load_persist_props_action
|
||||
exec u:r:init_gsi:s0 root -- /system_ext/bin/init_gsi --post-fs-data
|
||||
|
||||
on property:persist.sys.gsi.hw.mainkeys=*
|
||||
setprop qemu.hw.mainkeys ${persist.sys.gsi.hw.mainkeys}
|
||||
|
|
|
@ -40,6 +40,16 @@ void Quirks::Run() {
|
|||
}
|
||||
}
|
||||
|
||||
void Quirks::RunPostData() {
|
||||
if (quirks == nullptr) return;
|
||||
|
||||
for (DeviceQuirk* quirk : *quirks) {
|
||||
if (quirk->ShouldRun()) {
|
||||
quirk->RunPostData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility functions for use with quirks
|
||||
#define QUIRKS_TMP_BASE_PATH "/mnt/quirks"
|
||||
#define QUIRKS_TMP_FILES_PATH QUIRKS_TMP_BASE_PATH "/files"
|
||||
|
|
|
@ -29,7 +29,8 @@ class DeviceQuirk {
|
|||
public:
|
||||
DeviceQuirk();
|
||||
virtual bool ShouldRun() = 0;
|
||||
virtual void Run() = 0;
|
||||
virtual void Run() {}
|
||||
virtual void RunPostData() {}
|
||||
virtual ~DeviceQuirk();
|
||||
};
|
||||
|
||||
|
@ -39,6 +40,7 @@ public:
|
|||
namespace Quirks {
|
||||
void Add(DeviceQuirk* quirk);
|
||||
void Run();
|
||||
void RunPostData();
|
||||
|
||||
int OverrideWithBindMount(filesystem::path src, filesystem::path dst);
|
||||
|
||||
|
|
21
init/quirks/soc/caf_audio.cpp
Normal file
21
init/quirks/soc/caf_audio.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "../../quirks.h"
|
||||
#include <android-base/properties.h>
|
||||
#include <filesystem>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CafAudioQuirk : DeviceQuirk {
|
||||
public:
|
||||
bool ShouldRun() {
|
||||
return filesystem::exists("/vendor/etc/audio/audio_policy_configuration.xml");
|
||||
}
|
||||
|
||||
void RunPostData() {
|
||||
if (android::base::GetBoolProperty("persist.sys.gsi.alternate_audio_policy", false)) {
|
||||
Quirks::OverrideWithBindMount("/vendor/etc/audio/audio_policy_configuration.xml", "/vendor/etc/audio_policy_configuration.xml");
|
||||
android::base::SetProperty("ctl.restart", "audioserver"); // Ensure our new policy is loaded into audioserver
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LOAD_QUIRK(CafAudioQuirk);
|
Loading…
Reference in a new issue