Fix Viper4Android Not Working With SELinux Enforcing

In this guide, we’ll show you how to fix the problem where the Viper4Android module doesn’t work when SELinux Enforcing is turned on. It wouldn’t be too much of an exaggeration to say that some users root their devices just to get this audio mod. We also can’t blame them.

Even though there are a lot of audio mods for devices that have been rooted, it’s hard to say that anyone could come up and take Viper’s place as the best. You name it, it has it: Master Limiter, Playback gain controller, FET Compressor, FIR Equalizer, Convolver, Reverberation, and Speaker Optimization. But, like other rooted mods, this one has its own share of problems.

The most recent problem started after Magisk was updated to version 21.1/21.2. Many users can’t use this mod because of changes to how Magisk handles SELinux policies. If you are also on the same page, this guide will help you out. Here are detailed steps on how to fix the problem where Viper4Android doesn’t work with SELinux Enforcing.

Why is Viper4Android Not Working with SELinux Enforcing?

Let’s back up and figure out what exactly is causing this problem before we jump into fixing it. Selinux is an Android security feature that prevents untrusted programs from accessing critical system data.

Viper4Android cannot function properly without access to these files, but Selinux’s enforcement prevents that access. Since SELinux enforcement causes Viper4Android to malfunction, it should not be enabled.

How to Fix Viper4Android not working with SELinux Enforcing

While some users may find that making SELinux more lenient is a solution, I do not support this approach, and neither should you. Follow the steps below to resolve this issue while still maintaining SELinux Enforcing.

To be on the safe side, it’s a good idea to make a full backup of your device before proceeding. In the event of a nuclear war, if your alarm doesn’t wake you up, or if anything happens to your device or data as a result of trying to fix the Viper4Android not working issue with SELinux Enforcing, neither AMS nor its members will be held liable.

Solution 1: Instructions Steps

  • To begin, get a File Explorer that allows root access and install it.
  • I’m working with Solid Explorer for this tutorial. Now, open File Explorer and navigate to this address:
/data/adb/modules/ViPER4AndroidFX/post-fs-data.sh
  • Open the post-fs-data.sh file and add the following set of lines at the end of this file:
magiskpolicy --live 'allow audioserver audioserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow audioserver system_file file { execmod }'
magiskpolicy --live 'allow mediaserver mediaserver_tmpfs file { read write execute }'
magiskpolicy --live 'allow mediaserver system_file file { execmod }'
magiskpolicy --live 'allow audioserver unlabeled file { read write execute open getattr }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default process { execmem }'
magiskpolicy --live 'allow hal_audio_default hal_audio_default_tmpfs file { execute }'
magiskpolicy --live 'allow hal_audio_default audio_data_file dir { search }'
magiskpolicy --live 'allow app app_data_file file { execute_no_trans }'
magiskpolicy --live 'allow mtk_hal_audio mtk_hal_audio_tmpfs file { execute }'
  • Viper4Android can have Legacy Mode turned on or off in its settings menu after the device has booted.
  • Save the file after finishing. Restart your device now. Launch Viper4Android after it has started, then go to Settings to turn Legacy Mode on or off.

Legacy Mode on or off.

Disable SELinux

Turning off SELinux completely is the simplest way to solve this problem. This is not advised, though, as it could make your device less secure. The steps below can be used to disable SELinux:

    1. Go to Settings on your device.
    2. Scroll down and tap on “System.”
    3. Tap on “Developer options.”
    4. Scroll down and find the “SELinux” option.
    5. Tap on it and select “Permissive.”

Solution 2: Grant Viper4Android Permissions

Giving Viper4Android access to the resources it requires is another option. You’ll need a root file explorer app, like ES File Explorer, to accomplish this. the following steps:

  1. Download and install ES File Explorer from the Google Play Store
  2. Open ES File Explorer and grant it root permissions
  3. Navigate to the “/system/etc/selinux/plat_sepolicy.cil” file
  4. Long press on the file and select “Open in Text Editor”
  5. Find the following line of code: “allow audioserver audioserver_tmpfs file { read write execute };”
  6. Below this line, add the following line of code: “allow viperd audioserver_tmpfs file { read write execute };”
  7. Save the file and reboot your device

Solution 3: Use a Custom ROM

You can try using a custom ROM that has SELinux turned off or set to the permissive mode by default if the aforementioned fixes do not work. This poses a risk because it might void the warranty on your device and result in other problems.

Conclusion

To sum up, Viper4Android is a fantastic audio enhancement tool for Android devices that can greatly enhance your listening experience. It might not function properly when SELinux is enforced, though. We’ve talked about a few fixes for this problem, like turning off SELinux and giving Viper4Android permissions.

Leave a Comment