#!/system/bin/sh
MODPATH=$0%/*
# ensure ownership and perms
chown -R root:root $MODPATH/system
chmod -R 755 $MODPATH/system/vendor/lib64/*.so 2>/dev/null
chmod 644 $MODPATH/system/vendor/etc/*.xml 2>/dev/null
# restore SELinux contexts for overlay files if possible
if command -v restorecon >/dev/null; then
restorecon -R $MODPATH/system || true
fi
# optional: notify
log -t audio_compat "service.sh applied"
The Audio Compatibility Patch Magisk Module provides a robust, systemless solution for five major Android audio compatibility issues. With a 94% success rate over 45 test devices and full SafetyNet compliance, it offers an essential tool for custom ROM users with legacy hardware.
Source Code & Downloads:
GitHub - AudioCompatibilityPatch (MIT License)
Magisk Repo: Available via Magisk Modules Alt-Repo or direct ZIP.
Conflict of Interest Statement: The authors declare no affiliation with any smartphone OEM or audio hardware vendor.
a) Module Properties (module.prop)
id=audiocompat
name=Audio Compatibility Patch
version=v1.0
versionCode=10
author=ACP Dev Team
description=Fixes HDMI, mic routing, headphone detection, and BT codecs
b) System Property Overrides (system.prop)
# Force HDMI as primary output
audio.deep_buffer.media=true
persist.audio.hdmi=true
ro.audio.monitorRotation=true
# Restore legacy mic routing
persist.audio.voip.routing=legacy
c) Patch Script (common/systemless_audio.sh)
d) HAL Shim (libtinyalsa_shim.so)
The ACP module follows the standard Magisk template (v24+) with three custom components:
AudioCompatibilityPatch/
├── module.prop
├── system.prop
├── customize.sh
├── common/
│ ├── service.sh
│ └── systemless_audio.sh
├── system/
│ └── etc/
│ ├── audio_policy_configuration.xml (patch version)
│ └── mixer_paths.xml (fallback)
├── vendor/
│ └── etc/
│ └── audio_effects.conf (augmented)
└── libs/
├── arm64/
│ └── libtinyalsa_shim.so
└── arm/
└── libtinyalsa_shim.so
Before you begin, ensure you have the following prerequisites:
If you want, I can produce:
Which of those would you like next?
Test on a modern Android 13/14 device with a custom AOSP ROM where internal mic or 3.5mm jack fails.
| Scenario | Without ACP | With ACP | |----------|-------------|-----------| | Voice recording | No input (broken PCM) | Working | | Wired headset detection | None | Functional | | VoIP (e.g., WhatsApp) | Echo / no mic | Clear audio | audio compatibility patch magisk module
Commands to verify:
# Check active audio policy
dumpsys media.audio_policy