FORUMS
Remove All Ads from XDA
Honor 7x
Win an Honor 7X!

[12/13/17] Unity Installer & Audio Modification Library [v2.5][TEMPLATE]

3,075 posts
Thanks Meter: 4,438
 
By ahrion, Forum Moderator / Recognized Developer on 26th March 2017, 11:31 PM
Post Reply Email Thread
This is a developement thread for Unity (Un)Installer and Audio Modification Library

Unity Installer allows the install/uninstall of a mod on any device regardless of root solution (or lack thereof) in use

Audio Modification Library (Audmodlib) is a framework that allows that installation of multiple audio mods without having compatibility issues with one another's audio config/policy/mixer file changes. The reason for this framework is primarily for magisk. Magisk mounts whatever is in it's directory and so if multiple copies of the same file are present across multiple mods (like with audio effect conf files in audio mods), then only one of them will be actually mounted to the system and as a result, only that mod will have full functionality. Audmodlib circumvents this issue by having all mods share those files.

Currently shared files include all config, audio policy, and mixer paths files

[UPDATED] Audio Modification Library
Current Version Changelog (v2.5):

- Fix conditional logic
- Fix boot scripts
- Fix prop install
- Concatentate and reorganize update-binary -> NOTE THAT TIMEOFEXEC FOR unity_mod_copy AND aml_mod_patch HAVE BEEN SWTICHED
- Removed xmlstarlet - not compatible with all devices and there's no real need for it
- Add some new variables and functionality so apps and libs will be installed to vendor if rom is oreo or newer
- Added audio_effects xml files to CFGS array - along with previous point, should add pixel 2 compatibility
- Added new sepolicy patch needed for oreo
- Replace sepolicy patches with "setenforce 0" if oos oreo is detected - temporary workaround for now

Changed files since last version:

- META-INF/com/google/android/update-binary
- common/unity-audmodlib/audmodlibmodule.prop
- common/unity-audmodlib/audmodlib-post-fs-data.sh
- common/unity-audmodlib/modid.sh
- common/aml-patches-wipe.sh
- common/aml-patches-remove.sh
- common/aml-patches-.sh
- common/aml-xml-patches-wipe.sh -> REMOVED
- common/aml-xml-patches-remove.sh -> REMOVED
- common/aml-xml-patches-.sh -> REMOVED

Previous Changelogs:

v2.4:

- Fix mounting issues with Magisk v14.0
- Streamlined some of the code

v2.3:

- Bug fixes and fine tuning for prop logic
- Fix unmounting for system installs
- Get rid of errors causeing recovery log spam
- Add pixel 2 support (need magisk 14.5 or newer)
- Remove all variables for conf/pol/mix files - autodetect them instead
- Comment out volume_listener library instead of the entire output_session_processing
- Remove proxy library addition from aml (mod specific)
- Redo util_functions - use magisk one if present
- Add magisk 14.5 support
- General script improvements

v2.2:

- Got rid of common aml prop file - now uses individual prop file for each mod
- Sepolicy function fixes
- Remove EXT variable - no need for it
- Use /su/bin/sush shebang for scripts with systemless supersu install
- Fix bootmode aml automount
- Fix magisk clean flash support
- Add AML upgrade feature

v2.1:

- Updated for Magisk v14.3
- Updated to Magisk module template 1410
- Massive script reduction & efficiency enhancements
- Added XMLStartlet for arm/arm64 & x86 by JamesDSP developer, james3460297 @ XDA Developers (this toolkit allows the editing & patching of XML files using a simple set of shell commands in a way similar to how it is done with grep, sed, awk, diff, patch, join, etc commands)
- Combined customrules.sh CP_PRFX command with MK_PRFX so by default, the command CP_PRFX both creates the directory and copies the file (thus removing the need to have two seperate customrules.sh for cp and mk)
- Combined customrules.sh CP_PRFX command with CP_SFFX, so the default file placement permission is 0644 and the default folder creation permission is 0755 (you can manually define file copy permission by adding " 0755" or whatever permission you want at the end of the line that contains CP_PRFX)
- Silently uninstall previous version before new version upgrades (this is to keep every upgrade install clean in cases where the new version doesn't include files the previous version may have included)
- Further A/B OTA (Pixel family) improvements
- System backup/restore fully automated (no need to manually write files to INFO file anymore)
- Added MAXAPI variable to unity-uservariables that compliments MINAPI (this allows the developer to quickly set the minimum and maximum SDK version of their modification)
- Added cabability for modifications to modify /data partition, with full backup/removal support
- Greatly improved uninstall function by concatenating script
- Added "minVer" (an internal check that should always be equal to the latest stable Magisk release in cases where the template is based off of a beta release)
- Added support for SuperSU BINDSBIN mode
- Fix cache system installs
- Moved scripts to post-fs-data for Magisk installs (fixes some issues such as AM3D white screen on compatible devices)
- Combined multiple wipe functions into one
- Fixed System override issues some were facing
- Fixed System install partition re-mounting
- Updated Instructions (for developers only)
- Addon.d script fixes/improvements
- Various miscellaneous script fixes and improvements

v2.0:

- Massive installer and script overhaul
- Added autouninstall (if mod is already installed and you flash same version zip again, it'll uninstall), thus removing the need for an uninstall zip
- Added file/folder backup/restore of modified files
- Added file/folder backup/restore of normally wiped files
- Added Osm0sis @ xda-developers uninstaller idea (just add "uninstall" to zip name and it'll function as uninstaller)
- Added phh's SuperUser and LOS su support (note, LOS doesn't support sepolicy patching)
- Added proxy library to AML to allow the proxy effects found in multiple audio modules
- Added support for Magisk imgs located in /cache/audmodlib
- Added system_root support for Pixel devices
- Added system override (if you're on magisk but would rather have it install to system, add word "system" to zip name and it'll install everything but scripts to system)
- Add Unity system props
- Added vendor fix for Nexus devices
- AML functionality and uses overhauled
- Bug fixes
- Modified Unity Installer to allow use for non AML modules
- Moved scripts from Magisk .core to the individual module folder due to .core limitations
- New modular approach - no need to modify update-binary anymore: check instructions for more details on how this works
- Reworked addon.d system install scripts
- Removed AML cache workaround by reworking AML changes via magisk_merge
- Reworked AML vendor audio_effects to not be overwritten by system audio_effects by commenting out conflicting lines
- Reworked script permissions
- Update sepolicy for Magisk 13+
- Updated to Magisk module template 1400

v1.4:

- Change SELinux live patching to allow better compatibility between different devices, kernels, and roms; while also keeping the amount of "allowances" to a minumum
- Changed post-fs-data(.d)/service(.d) shell script names for cosmetic recognition
- Merge SuperSU shell script with MagiskSU post-fs-data(.d)/service(.d) script for less fragmentation
- Added /cache/audmodlib.log to determine if script has run successfully
- More audio policy files and various mixer_paths files are now included in the framework
- Install script changes that include: major update to Pixel (A/B OTA) support, mounting changes, improved script efficiency, fixes & consolidation, and cosmetic fixes
- Add/fix proper addon.d support

v1.3:

- Script addition to allow various audio mods working with SELinux Enforcing
- Remove (audmodlib)service.sh and replace with pos-fs-data(.d) audmodlib.sh, which should fix when root may be lost upon installing certain mods

v1.2:

- Added audmodlib.sh post-fs-data.d script
- Fix selinux injection script to work for MagiskSU/SuperSU (system and systemless)
- Install script fixes

v1.1:

- Hotfix for bootloop issues on some devices

v1.0:

- Initial Magisk release


How to Make Your own Unity and/or Audmodlib Modules:
  1. Add your mod info to module.prop
  2. Place your files in their respective directories in the system folder (where they will be installed to)
    For apps, place in system/app/APPNAME/APPNAME.apk
    For vendor, just create the vendor folder in the system folder
  3. Place your files in their respective directories in the data folder (where they will be installed to)
    Note that these files will always be installed to /data regardless of root method
  4. Place any files that need conditionals (only installed in some circumstances) in the custom folder (can be placed however you want)
    The exeception here are apps. Place apps in custom/APPNAME/APPNAME.apk
  5. Add your min/max android version and other variables to common/unity-uservariables.sh (more instructions are in the file)
    Note the Audmodlib variable in this file. Uncomment it if you're making an audio module
  6. Modify the post-fs-data.sh in common as you would with any other magisk module
    If post-fs-data is going to be used, set it's value to true in config.sh (THESE WILL BE INSTALLED AS REGULAR BOOT SCRIPTS IF NOT A MAGISK INSTALL)
  7. Modify the service.sh in common as you would with any other magisk module (most everything should be a late start, not post-fs-data)
    If service is going to be used, set it's value to true in config.sh (THESE WILL BE INSTALLED AS REGULAR BOOT SCRIPTS IF NOT A MAGISK INSTALL)
  8. Add any build props you want added into the system.prop
  9. Add any possibly conflicting files you want removed/wiped before install into the unity-file-wipe.sh (use full paths - Ex: $SYS/etc/audmodlib/audmodlib.conf)
    If folder, add FOL prefix (Ex: FOL$SYS/etc/audmodlib)
    If app, just put the app name with the APP prefix (Ex: APPViPER4AndroidFX) - note the lack of slashes and the '.apk' extension
  10. Add any config/policy/mixer patches you want added into the aml-patches.sh (audio module only)
    Any patching of xmlstarlet patches should go into the if statement at the bottom of the aml-patches.sh file (uncomment it)
  11. Add the removal of your patches into the aml-patches-remove.sh (audio module only)
    Any removal patching of xmlstarlet patches should go into the if statement at the bottom of the aml-patches-remove.sh file (uncomment it)
  12. Add any other config/policy/mixer patches you want removed/wiped (may conflict with your patches) before install into the aml-patches-wipe.sh (audio module only)
    Any wipe patching of xmlstarlet patches should go into the if statement at the bottom of the aml-patches-wipe.sh file (uncomment it)
  13. Add any custom permissions needed into config.sh (this will apply to both magisk and system installs) (default permissions is 755 for folders and 644 for files)
    DON'T MODIFY ANY OTHER PARTS OF CONFIG.SH (this is different from normal magisk modules)
  14. Add any custom install/uninstall logic to unity-customrules1.sh (see section below)
    This is where you would put your stuff for any custom files and whatever else isn't taken care of already
Important Notes About Above Instructions:
  • NOTE: MAKE SURE YOU LEAVE A BLANK LINE AT THE END OF EACH FILE
  • DO NOT MODIFY ANY OTHER FILES THAN THOSE MENTIONED ABOVE
  • So all of the files you need to modify are located in the root and common folder of the zip
  • For props, they all must be listed in this format: setprop name.of.prop value
  • For all of the patch files, all destinations must be preceded by $AMLPATH. Ex: sed -i '/v4a_standard_fx {/,/}/d' $AMLPATH$CONFIG_FILE
  • Patches for audio_effects need to be put into both system/etc/audio_effects (CONFIG_FILE) and /vendor/etc/audio_effects (V_CONFIG_FILE) if present
  • For xmlstarlet commands, you may need to have the command write to a temporary files and then replace the original file with the temporary one for it to work:
    Code:
    if [ "$($XML_PRFX sel -t -m '/mixer/ctl[@name="DAC1 Switch"]' -c . $AMLPATH$MIX)" ]; then
      $XML_PRFX ed -u "/mixer/ctl[@name='DAC1 Switch']/@value" -v 1 $AMLPATH$MIX > $AMLPATH$MIX.temp
      mv -f $AMLPATH$MIX.temp $AMLPATH$MIX
    fi


Custom Rules Notes:

You can do just about anything in the customrules and can have any number of them. Just create copies of the file rename it so it has the next number after it (ex: unity-customrules2.sh).
The TIMEOFEXEC variable is what dictates when during the (un)install the script is run. They can equal the following values:
[0]File will not be run (default)
[1]unity_mod_wipe - this function removes any files/folders that may conflict with the mod. This is where the files specified in unity-file-wipe.sh are removed
[2]aml_mod_patch - only applicable for audio modules (ones that use aml). This function applies all of the patches for aml and from all of the patch files.
[3]unity_mod_copy - this function makes the proper directories and copies all of the files present in system and data folders of zip. This is also where the props in system.prop (and other prop files) are installed
[4]unity_uninstall - this function uninstalls the mod
The functions above are listed in the order that they're executed (on an uninstall, only the unity_uninstall function is run - it isn't run on an install).


Some other functions to note:
  • unity_prop_copy - adds props to a common prop file. If you have multiple prop files and require conditionals for some to be set, use this function in a customrules. Ex: unity_prop_copy $INSTALLER/common/customprops.prop. This would be best with a TIMEOFEXEC=2
  • custom_app_install - installs specified app to the proper directory. Use this function for any apps in custom folder that need installed . Ex: custom_app_install ViPER4AndroidFX. Note the lack of a file path, just use the app name
  • ui_print - Prints out message. Ex: ui_print "Audmodlib is awesome"
  • abort - Prints message, unmounts partitions, and exits installer with error code of 1. Ex: abort "!Error! Exiting installer!"
  • mktouch - Creates an empty file and the directories for that file. Ex: mktouch $SYS/etc/exlib.so
  • set_perm - Only applicable to config.sh - see file for examples. Sets the permissions of the file
  • set_perm_recursive - Only applicable to config.sh - see file for examples. Sets the permissions of the folder and all files in it recurssively
  • set_permissions - Only applicable to customrules uninstalls. Sets the permissions of everything specified in that section of config.sh
  • get_prop - gets a variable's value from specified file. Ex: get_prop id $UNITY$SYS/build.prop
  • set_sepolicy - sets the sepolicy based on the input. 2 different formats:
    Ex1 - will "allow" input: set_sepolicy mediaserver mediaserver_tmpfs file read,write,execute
    Ex2 - will set input to permissive: set_sepolicy priv_app audio_prop


Index of Usable Variables - You may need to call these variables for various stuff:
  • INSTALLER - Working directory of installer (origin of files to be installed
  • UNITY - Conatins proper location for mod regardless of install method - this should always precede any destination file/directory
  • ROOT - Location of root of file system
  • SYS - Location of system folder
  • VEN - Location of vendor folder
  • MODID - 'id' from module.prop unless overridden in uservariables
  • AMLPATH - Install path for audio modification library files
  • CFGS - An array containing all audio effects conf files
  • CFGSXML - An array containing all audio effects xml files
  • POLS - An array containing all audio policy conf files
  • POLSXML - An array containing all audio policy xml files
  • MIXS - An array containing all mixer paths xml files
  • LIBDIR - Equal to vendor if rom is oreo or newer, system otherwise
  • LIBPATCH - Same as libdir but formatted for sed with standard '/' delimiter
  • MAGISK - Set to 'true' if magisk is detected, 'false' otherwise - Useful for unity-scripts if you want parts to only run with/without magisk installs
  • MK_PRFX - Contains the proper mkdir command regardless of install method. Always use this instead of a manual mkdir command
  • MK_SFFX - Contains proper permissions for mkdir command regardless of install method. Always put this at end of any mkdir command
  • CP_PRFX - Contains the proper copy command regardless of install method. Always use this instead of a manual cp command
  • CP_SFFX - Contains proper permissions for cp command regardless of install method. Always put this at end of any cp command
  • WP_PRFX - Backs up and removes specified file/folder. Ex: wipe_ch /data/app/com.audlabs.viperfx-1
  • XML_PRFX - Location of xmlstarlet binary for patching xml files - use for patching xml files
  • API - Taken from build.prop. Equal to the API version of the rom installed
  • ABI - Taken from build.prop. Equal to the ABI number (first 3 characters of ABILONG) of the device
  • ABI2 - Taken from build.prop. Equal to the ABI2 number of the device (first 3 characters)
  • ABILONG - Taken from build.prop. Equal to the ABI version of the device)
  • MIUIVER - Taken from build.prop. Equal to MIUI version of the rom
  • ARCH - Equal to the cpu type of the device - equal to 'arm', 'arm64', or 'x86'
  • DRVARCH - Set to 'NEON' if non x86 device, set to 'x86' otherwise
  • IS64BIT - Set to 'true' if 64 bit capable device is detected, set to 'false' otherwise
  • SH - Only applicable to boot scripts. The directory in which the script is running
  • SEINJECT - Only applicable to boot scripts/ Command for sepolicy setting, dynamically set depending on root method
Note for Working with Arrays:

The easiest way to itterate through each file in an array is by using a for loop. Here's an example it echo each config file:
Code:
for FILE in ${CFGS}; do
  echo $FILE
done
Note the squiggly brackets around the variable, this is the syntax needed for arrays (well it's not a true array but works similarly)

In the download section is a list of all variables and functions used in the (un)installer. It's easiest to just search the file for any variable/function names you were thinking of using to make sure that they are not present in the file.

This is a running list of mods that utilize my Unity installer that can install on Magisk OR System if Magisk is not detected. I do not support any other audio mod, and if Magisk, I do not support any mod mod that does not utilize AudModLib:
Downloads
Unity/AML Template
Functions and Variables


XDA:DevDB Information
Unity Installer & Audio Modification Library, Tool/Utility for the XDA Community Apps

Contributors
ahrion, Zackptg5
Source Code: https://github.com/therealahrion/Aud...cation-Library


Version Information
Status: Stable
Current Stable Version: v2.5
Stable Release Date: 2017-12-13

Created 2017-03-26
Last Updated 2017-12-14
The Following 66 Users Say Thank You to ahrion For This Useful Post: [ View ]
 
 
28th March 2017, 03:40 AM |#2  
Junior Member
Thanks Meter: 3
 
More
I have BT's issue installing this module on Pure Nexus for Kenzo/Kate (SD650)
28th March 2017, 03:41 AM |#3  
ahrion's Avatar
OP Forum Moderator / Recognized Developer
Thanks Meter: 4,438
 
More
Quote:
Originally Posted by ExEdd

I have BT's issue installing this module on Pure Nexus for Kenzo/Kate (SD650)

You must have installed other modules, probably my deep_buffer Remover because this module does NOT touch your bluetooth settings. This module is simply a framework for other modules to utilize and edit audio policy and audio effect files on your system.
28th March 2017, 04:11 AM |#4  
Junior Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by ahrion

You must have installed other modules, probably my deep_buffer Remover because this module does NOT touch your bluetooth settings. This module is simply a framework for other modules to utilize and edit audio policy and audio effect files on your system.

I not have other modules or mods, only install Magisk and then AudModLib (downloaded through Magisk Downloads), when I reboot my device after install the module BT crash
28th March 2017, 04:19 AM |#5  
ahrion's Avatar
OP Forum Moderator / Recognized Developer
Thanks Meter: 4,438
 
More
Quote:
Originally Posted by ExEdd

I not have other modules or mods, only install Magisk and then AudModLib (downloaded through Magisk Downloads), when I reboot my device after install the module BT crash

Don't know what to tell you man. All this mod does is copy certain configs to a magisk directory and then magisk symlink them to your system.

The only thing I can think is that you have a boot.img compatibility issue with magisk.
28th March 2017, 12:42 PM |#6  
ahrion's Avatar
OP Forum Moderator / Recognized Developer
Thanks Meter: 4,438
 
More
Good news guys. I finally found a fix for AM3D and Dolby Atmos to work 100% in enforcing on both MagiskSU/SuperSU, Magisk OR System install.

This will be available in the AudModLib v1.3 update I will be pushing soon. I'll obviously fix any more bugs or make any other additions in the meantime.
The Following 7 Users Say Thank You to ahrion For This Useful Post: [ View ]
28th March 2017, 09:59 PM |#7  
JohnCorleone's Avatar
Senior Member
Flag Whittier,CA
Thanks Meter: 5,924
 
Donate to Me
More
Quote:
Originally Posted by ahrion

Good news guys. I finally found a fix for AM3D and Dolby Atmos to work 100% in enforcing on both MagiskSU/SuperSU, Magisk OR System install.

This will be available in the AudModLib v1.3 update I will be pushing soon. I'll obviously fix any more bugs or make any other additions in the meantime.

I can't wait! I really think that is going to make everything work . I prefer the SeLinux to be enabled with it my responsibility to flip if it didn't automatically. Looking forward to it!
28th March 2017, 10:02 PM |#8  
ahrion's Avatar
OP Forum Moderator / Recognized Developer
Thanks Meter: 4,438
 
More
Quote:
Originally Posted by JohnCorleone

I can't wait! I really think that is going to make everything work . I prefer the SeLinux to be enabled with it my responsibility to flip if it didn't automatically. Looking forward to it!

You wont need it anymore i only enabled permissive because of my mods i wont need it after this
The Following User Says Thank You to ahrion For This Useful Post: [ View ]
28th March 2017, 11:18 PM |#9  
JohnCorleone's Avatar
Senior Member
Flag Whittier,CA
Thanks Meter: 5,924
 
Donate to Me
More
Quote:
Originally Posted by ahrion

You wont need it anymore i only enabled permissive because of my mods i wont need it after this

But it does spoof being enabled correct?-Because I get a Google Services warning to uninstall SELinux changer
28th March 2017, 11:30 PM |#10  
ahrion's Avatar
OP Forum Moderator / Recognized Developer
Thanks Meter: 4,438
 
More
Quote:
Originally Posted by JohnCorleone

But it does spoof being enabled correct?-Because I get a Google Services warning to uninstall SELinux changer

So this won't be an app, this will be as part of the script. It essentially makes a few things permissive and allows the appropriate things to be activated, those that effect AM3D and Atmos.
The Following 2 Users Say Thank You to ahrion For This Useful Post: [ View ]
29th March 2017, 12:10 AM |#11  
Senior Member
Thanks Meter: 49
 
More
Hi. Thanks for the mod. If I download and install through magisk or even download through magisk I get installation error. Doesn't say why. I'm on Z5C Nougat and fully rooted. Thanks Kam
Post Reply Subscribe to Thread

Tags
audmodlib, magisk

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes