[MODULE] SELinux Mode Inverter (Advanced SELinux Mode Changer) - Magisk

It Is Now A Part Of The Main Module Of MultiFunctions & Its Thread https://forum.xda-developers.com/apps/magisk/module-multifunctions-bootloop-t3933386.
Click to expand...
Click to collapse
Introduction:
Simple Module To Invert The Default Android SELinux Mode During Startup ([From Permissive To Enforcing] Or [From Enforcing To Permissive]).
- One Module To Switch Between Enforcing Mode & Permissive Mode
- This Module Changes The SELinux Mode For The Entirety Of The Device's Uptime Until Next Reboot
- The Default Android SELinux Mode Can Be Either Enforcing Mode Or Permissive Mode Which Depends On The Installed/Flashed Rom/Kernel
- After The Installation & 1st Reboot, The SELinux Mode = The Default Android SELinux Mode
- Disabling The Module = The Default Android SELinux Mode (Next Reboot)
- Enabling The Module = Inverting The Default Android SELinux Mode (Next Reboot)
Current Version: 1.0.3.3
- SELinux Enabled Kernel/SELinux Development Mode Is A Main Point To Use The Module So Check The General Steps
- Disabling Itself Before Getting Stuck On Bootloop For Some Roms/Kernels
- Just Install It & You Don't Need To Do Anything More
- Enforcing Mode Is Preferable For Security (Specially Banking Apps) & Permissive Mode Is Preferable For Mods (Specially Audio Mods)
- For Magisk Users, Disable Magisk Core Only Mode From The Section Of Settings In Magisk Manager Which Is Required As An Essential Step To Activate The Functionality Of SELinuxModeInverter
- For Activating The Functionality Of SELinuxModeInverter, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Copy The File Of Disable To The Folder Of Inactive --> Reboot
- Some Issues Which Are Related To Magisk/Rom/Kernel Itself Can Be Solved By Using A Different Modes [Where The Wait Mode (The Default One) Can Be Used For Resolving The Issue Of Bootloop/Bootscreen/Blackscreen Which Changes The SELinux Mode Within 5 Min. After Rebooting & The Fast Mode Can Be Used For Changing The SELinux Mode At Booting But You Need Firstly To Do What Are Mentioned In The General Steps]
- For Activating The Fast Mode, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Copy The File Of Disable To The Folder Of Wait --> Reboot
- For Activating The Wait Mode, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Delete The File Of Disable From The Folder Of Wait --> Reboot
Created: Apr.09.2018
Updated: May.09.2019
Download Link: Click Here (To Ensure That The Module Will Work Properly, Kindly Do What Are Mentioned In The General Steps)
- For The Module Which Is Ended Its Name With v1300, It Supports Magisk v13.1(1310) To v13.6(1360)
- For The Module Which Is Ended Its Name With v1400, It Supports Magisk v14.0(1400) To v15.3(1531)
- For The Module Which Is Ended Its Name With v1500, It Supports Magisk v15.0(1500) To v17.3(17300)
- For The Module Which Is Ended Its Name With v17000, It Supports Magisk v17.0(17000) To v17.3(17300)
- For The Module Which Is Ended Its Name With v18000, It Supports Magisk v18.0(18000) To v18.1(18100)
- For The Module Which Is Ended Its Name With v19000, It Supports Magisk v19.0(19000) To The Latest Version
- For The Module Which Is Ended Its Name With Unity, It Supports Any-Rooting-Tool Such As SuperSU, Lineage-AddOnSU & Magisk
Installation:
- Magisk Manager --> Modules --> Add (+) --> Choose The Downloaded File --> Reboot
- Or Flash It Thru TWRP Recovery
- Or Flash It Thru ADB Sideload --> adb sideload Module.zip --> Reboot
- Or Using A Flash-Tool (Flasher) Such FlashFire, Flashify Or Rashr --> Flash ZIP File (Flash A Flashable ZIP File) --> Choose The Downloaded File --> Reboot
Recommendation/In-Case Of Failure:
- Check The General Steps From This Post https://forum.xda-developers.com/apps/magisk/selinux-mode-inverter-t3775271/post76381334
General Info:
- To Disable The Module For Magisk Users, Open Magisk Manager --> Modules --> The Module --> Tap On The Check Box/The True Icon --> Reboot
- To Enable The Module For Magisk Users, Open Magisk Manager --> Modules --> The Module --> Tap On The Uncheck Box --> Reboot
- To Uninstall The Module For Magisk Users, Open Magisk Manager --> Modules --> The Module --> Tap On The Bin Icon --> Reboot
- To Disable The Module For All Users [Non-Magisk Users & Magisk Users], Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> The Module --> Copy The File Of Disable To The Folder Of Active (Or Delete The File Of Disable From The Folder Of Inactive) --> Reboot
- To Enable The Module For All Users [Non-Magisk Users & Magisk Users], Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> The Module --> Delete The File Of Disable From The Folder Of Active (Or Copy The File Of Disable To The Folder Of Inactive) --> Reboot
- To Uninstall The Module For All Users [Non-Magisk Users & Magisk Users] (Unity), Reflash The Module
- In-Case Of Facing A Bootloop/Bootscreen/Blackscreen Issue Due To Installing/Configuring An App, Download SafeMode4Magisk From This Thread https://forum.xda-developers.com/apps/magisk/module-safe-mode-bootloop-bootscreen-t3847422 Then Flash It
- In-Case Of Facing A Bootloop/Bootscreen/Blackscreen Issue Due To Adding App/Activity/Process To Magisk Hide, Download ClearHideList4Magisk From This Thread https://forum.xda-developers.com/apps/magisk/module-hide-list-bootloop-bootscreen-t3849208 Then Flash It
- In-Case Of Facing A Bootloop/Bootscreen/Blackscreen Issue Due To Flashing A Module, Download CoreOnlyMode4Magisk From This Thread https://forum.xda-developers.com/apps/magisk/module-core-mode-bootloop-solver-modules-t3817366 Then Flash It
Click On Thanks Button If The Module/Post Is Useful (Dreamer(3MF))
>>> Sharing A Good Thought Is Gold <<<
----------------------------------------------------------------------------------------------------------------
Core Only Mode - Microsoft Intune Company Portal Hider - Other Modules
----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------
permissive mode, selinux permissive, selinux permissive mode, enforcing mode, selinux enforcing, selinux enforcing mode, selinux mode changer, selinux changer, selinux switch, selinux selector, selinux toggler, setenforce, getenforce, magisk selinux, sestatus, enforce, permissive, selinux enabled kernel, selinux development mode, selinux manager, magisk module, selinux converter, selinux mode converter
---------------------------------------------------------------------------------------------------------------------------------------------------------------

Hi,
Saw your module, just wanted to tell you that not all devices have `getenforce`, some have `sestatus` instead. You might need to update accordingly.
MCMotherEffin'

SELinuxModeInverter4Magisk-v1.0.1
MCMotherEffin' said:
Hi,
Saw your module, just wanted to tell you that not all devices have `getenforce`, some have `sestatus` instead. You might need to update accordingly.
MCMotherEffin'
Click to expand...
Click to collapse
MCMotherEffin
Thanks For Your Advice & Your Modules. Kindly see the Attached Modified Module (SELinuxModeInverter4Magisk-v1.0.1(v1500)(3MF).zip) .
I would be Happy If There Is Any Recommendation/Advice.
Thanks Again.

Dreamer(3MF) said:
MCMotherEffin
Thanks For Your Advice & Your Modules. Kindly see the Attached Modified Module (SELinuxModeInverter4Magisk-v1.0.1(v1500)(3MF).zip) .
I would be Happy If There Is Any Recommendation/Advice.
Thanks Again.
Click to expand...
Click to collapse
Hi,
Instead of using `ls`, you could simply put `||` in there, also you could combine exit 1 into the same statement.
Code:
if ! selinux_mode=$(getenforce || sestatus); then exit 1; fi;
The above statement combines setenforce, sestatus and exit all in one. Also you don't need asterisks in the case statement and, setenforce takes only 1 and 0 as arguments, not enforcing or permissive, no matter what getenforce / sestatus shows.
Code:
case $selinux_mode in
enforcing|Enforcing|1 ) setenforce 0; ;;
permissive|Permissive|0) setenforce 1; ;;
esac;
will do the job while saving space.

What would one gain from inverting the status during Magisk's Startup?

MCMotherEffin' said:
Hi,
Instead of using `ls`, you could simply put `||` in there, also you could combine exit 1 into the same statement.
Code:
if ! selinux_mode=$(getenforce || sestatus); then exit 1; fi;
The above statement combines setenforce, sestatus and exit all in one. Also you don't need asterisks in the case statement and, setenforce takes only 1 and 0 as arguments, not enforcing or permissive, no matter what getenforce / sestatus shows.
Code:
case $selinux_mode in
enforcing|Enforcing|1 ) setenforce 0; ;;
permissive|Permissive|0) setenforce 1; ;;
esac;
will do the job while saving space.
Click to expand...
Click to collapse
Concerning
A- (if ! selinux_mode=$(getenforce || sestatus); then exit 1; fi , I tried Something like This But The Module doesnot change the SELinux Mode because 'sestatus' which is not Supported in My Android So The Module will get An Error which force to not Continue. So The Best Solution For Me is Using 'ls'.
B- The Other Points, Will be Reflected/Applied In The Next Version
Thanks For Sharing Your Thoughts & Efforts

SELinuxModeInverter4Magisk-v1.0.2
Dreamer(3MF) said:
Concerning
A- (if ! selinux_mode=$(getenforce || sestatus); then exit 1; fi , I tried Something like This But The Module doesnot change the SELinux Mode because 'sestatus' which is not Supported in My Android So The Module will get An Error which force to not Continue. So The Best Solution For Me is Using 'ls'.
B- The Other Points, Will be Reflected/Applied In The Next Version
Thanks For Sharing Your Thoughts & Efforts
Click to expand...
Click to collapse
I use Your Sytanx [ (if ! selinux_mode=$(getenforce || sestatus); then exit 1; fi] which works Good

oreo27 said:
What would one gain from inverting the status during Magisk's Startup?
Click to expand...
Click to collapse
For Example
- This is Useful for Certain Audio Mods.
- Some Android Versions come with Permissive As The Default SELinux Mode. Enforcing is The Preferred SELinux Mode for Security so You can choose It But It needs SELinux Enabled Kernel.
Kindly check This Link https://wiki.gentoo.org/wiki/SELinux/Tutorials/Permissive_versus_enforcing

Dreamer(3MF) said:
For Eaxample
- This is Useful for Certain Audio Mods.
- Some Android Versions come with Permissive As The Default SELinux Mode. Enforcing is The Preferred SELinux Mode for Security so You can choose It But It needs SELinux Enabled Kernel.
Kindly check This Link https://wiki.gentoo.org/wiki/SELinux/Tutorials/Permissive_versus_enforcing
Click to expand...
Click to collapse
Thank you!
Ah yes. I think I've read something similar to what you've mentioned. If mine is already Enforcing, will this change it to Permissive during the boot-up process only or for the entirety of the device's uptime until next reboot?
If the former, what benefits will I actually gain in having it use Permissive during boot-up?

oreo27 said:
Thank you!
Ah yes. I think I've read something similar to what you've mentioned. If mine is already Enforcing, will this change it to Permissive during the boot-up process only or for the entirety of the device's uptime until next reboot?
If the former, what benefits will I actually gain in having it use Permissive during boot-up?
Click to expand...
Click to collapse
This Module will change the SELinux Mode for the entirety of the device's uptime until next reboot

Notes:
- This Module Changes The SELinux Mode (Invert The Default Android SELinux Mode) For The Entirety Of The Device's Uptime Until Next Reboot
- Disabling This Module From Magisk Manager = The Default Android SELinux Mode
- Enabling This Module From Magisk Manager = Inverting The Default Android SELinux Mode
- Enforcing Mode For Security
- Permissive Mode For Mods (Specially Audio Mods)

For Magisk v1400, Download SELinuxModeInverter4Magisk-v1.0.2(v1400)(3MF).zip

Reserved for News/Updates #1

Deleted

Reserved for News/Updates #2

Changelog: More Details Have Been Added In The 1st Post.

Updated SELinuxModeInverter4Magisk To v1.0.3!
Changelog: Disabling Itself Before Getting Stuck On Bootloop For Some Roms/Kernels.
Just Install It & You Don't Need To Do Anything More.

For More Details About Enforcing Mode & Permissive Mode, Check This Link https://wiki.gentoo.org/wiki/SELinux/Tutorials/Permissive_versus_enforcing

The General Steps:
- SELinux Enabled Kernel/SELinux Development Mode Is Required Which Means The Installed/Flashed Rom/Kernel Has The Ability To Switch Between Enforcing Mode & Permissive Mode
- To Check The Above Mentioned Ability, Install Terminal Emulator From PlayStore --> Open It -->
-----> For Getting The Current Android SELinux Mode, Write su --> Click On Enter --> Write getenforce (Most Devices) Or sestatus (Some Devices) --> Click On Enter
-----> For Setting The Current Android SELinux Mode, Write su --> Click On Enter --> Write setenforce 0 (For Permissive Mode) Or setenforce 1 (For Enforcing Mode) --> Click On Enter
-----> Check Again The Current Android SELinux Mode
-----> If The Mentioned Steps Worked/Succeeded, Download SELinuxModeInverter4Magisk From This Link https://androidfilehost.com/?w=files&flid=293646 & Flash It Then Reboot
-----> Enforcing Mode Is Preferable For Security (Specially Banking Apps) & Permissive Mode Is Preferable For Mods (Specially Audio Mods)
-----> For Magisk Users, Disable Magisk Core Only Mode From The Section Of Settings In Magisk Manager
-----> For Activating The Functionality Of SELinuxModeInverter, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Copy The File Of Disable To The Folder Of Inactive --> Reboot
-----> Some Issues Which Are Related To Magisk/Rom/Kernel Itself Can Be Solved By Using A Different Modes [Where The Wait Mode (The Default One) Can Be Used For Resolving The Issue Of Bootloop/Bootscreen/Blackscreen Which Changes The SELinux Mode Within 5 Min. After Rebooting & The Fast Mode Can Be Used For Changing The SELinux Mode At Booting]
-----> For Activating The Fast Mode, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Copy The File Of Disable To The Folder Of Wait --> Reboot
-----> For Activating The Wait Mode, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Delete The File Of Disable From The Folder Of Wait --> Reboot
-----> If The Mentioned Steps Didn't Work/Succeed, It Means The Flashed Rom/Kernel Hasn't The Ability To Switch Between Enforcing Mode & Permissive Mode So Flash Another Rom/Kernel Which Supports The Ability Of Changing SELinux Mode
- P.S. Maybe The Flashed Rom/Kernel Hasn't The Ability To Switch Between Permissive Mode & Enforcing Mode During Startup So You Can Use Only The Wait Mode (Not The Fast Mode)
- For Magisk Users, If You Want To Get Accurate Feedback From getenforce/sestatus, Disable Magisk Hide (Magisk Manager --> Settings --> Disable Magisk Hide) And After Finishing, Enable Magisk Hide Again [P.S. Magisk Hide Will Hide That Your Device Is In Permissive Mode To Pass The SafetyNet]
In-Case Of Failure: After Doing Successfully The Above Mentioned Steps
- For Magisk Users, Disable All Modules From Magisk Manager (Modules) & Also Disable All Apps Except Terminal Emulator From Magisk Manager (SuperUser) Then Reboot
- For Non-Magisk Users, Disable All Apps Except Terminal Emulator From SuperUser Of The Used Rooting Tool Then Reboot
- For Activating The Functionality Of ClearDalvikCache, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> DalvikCache --> Delete The File Of Disable From The Folder Of Active --> Reboot
- For Activating The Functionality Of SELinuxModeInverter, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> SELinuxModeInverter --> Copy The File Of Disable To The Folder Of Inactive --> Reboot
- Terminal Emulator --> Write su --> Click On Enter --> Write getenforce (Most Devices) Or sestatus (Some Devices) --> Click On Enter --> Write setenforce 0 (For Permissive Mode) Or setenforce 1 (For Enforcing Mode) --> Click On Enter --> Write getenforce (Most Devices) Or sestatus (Some Devices) --> Click On Enter --> Send The Screenshot Of Terminal Emulator
- Download The Test Module Of SELinuxModeInverter4Magisk From This Link https://androidfilehost.com/?w=files&flid=274655 & Flash It Then Reboot
- Wait About 30 Min.
- Terminal Emulator --> Write su --> Click On Enter --> Write getenforce (Most Devices) Or sestatus (Some Devices) --> Click On Enter --> Send The Screenshot Of Terminal Emulator
- Reboot & Wait About 30 Min.
- Terminal Emulator --> Write su --> Click On Enter --> Write getenforce (Most Devices) Or sestatus (Some Devices) --> Click On Enter --> Send The Screenshot Of Terminal Emulator
- Send A Copy Of debug-SELinux.txt & debug-SELinux-BU.txt (Their Paths Are Root --> /data/debug-SELinux.txt, /data/debug-SELinux-BU.txt & For Copying These Files, Use Any Root File Explorer Such As MiXplorer)
- For Magisk Users, Magisk Manager --> Modules --> Send Its Screenshot & Magisk Manager --> SuperUser --> Send Its Screenshot
- For Non-Magisk Users, Send The Screenshot Of SuperUser Of The Used Rooting Tool
- Send Full Logcat (Download Logcat Extreme From PlayStore)
- For Magisk Users, Send Magisk Log (Magisk Manager --> Log --> Magisk & Also The Screenshot Of Magisk Manager --> Log --> SuperUser]
P.S. In-Case Of Facing A Bootloop/Bootscreen/Blackscreen Issue Due To Flashing A Module,
- For Magisk Users, Download CoreOnlyMode4Magisk From This Thread https://forum.xda-developers.com/apps/magisk/module-core-mode-bootloop-solver-modules-t3817366 Then Flash It
- For All Users [Non-Magisk Users & Magisk Users] (Unity), Reflash The Module To Uninstall The Module

Updated SELinuxModeInverter4Magisk To v1.0.5!
Changelog: Checking Its Path.
Just Install It & You Don't Need To Do Anything More.

Related

[CLOSED][OUTDATED][2017.2.7][GUIDES & DOCS] Magisk All-In-One Wiki

This thread is outdated and will never be updated
Please check the official Magisk documentation on Github!
Magisk All-In-One Wiki​
Table of Contents
Module Creation And Online Repos
Create your first Magisk Module; Submit to Magisk Module Repo
Notes Regarding Magisk Module Repos
Magisk Guides and Tricks
How Do Magic Mount Behave
Manipulate system props (build.prop)
Remove files / folders
Cache mounts
Magisk Details (DEV)
sepolicy-inject tool
Work flow
File structure
Boot stages
Module Creation And Online Repos
Create your first Magisk Module; Submit to Magisk Module Repo
Details are all listed in the module template on Github.​
Notes Regarding Magisk Module Repos
Magisk module can be different kinds, for example it can be used to debloat your system; it can be used to install your favorite application into system to give it the privilege of system apps.; it can be a full custom rom; it can also be cool mods like Xposed and root. However I view the "Magisk Module Repo" as a platform to share modules that can be used on lots of devices, preferably universal to all Android devices. Device specific modules are OK if stated clearly in the descriptions, and actually doing something that is non-trivial.
I will moderate the "Magisk Module Repo" in my personal preference and standard, here are some that will not be included:
Modules that are too large. A full custom rom, for example, is too large to be hosted on Github effectively. You can share them on XDA forums in your device specific forums
Modules that are too trivial. For example: mods that simply just add apps to system; debloating selective apps; doing things that can be done in simple boot scripts. I'll add more here if when I face requests that I consider "trivial"
Modules that contains copyright property (unless given permission)
Modules that violates XDA rules
This thread is outdated and will never be updated
Please check the official Magisk documentation on Github!
Magisk Guides and Tricks
How Do Magic Mount Behave
Magic Mount by default merges the files in $MODPATH/system into the real /system. You can think as it dirty flashes the contents into /system.
Existing files will be replaced; new files will be added; will not remove any files
Directories under $MODPATH/system that contains a file named ".replace" will NOT merge into the system. It will directly replace the correspond directory in /system.
In the module template, you can list them in "config.sh", the scripts will create the ".replace" file automatically for you.
You can think as it wipes the existing folder, and then adds contents to that folder in /system.
The directory that contains ".replace" will replace the one in /system, all contents originally in the folder will be discarded
Adding items to system is relatively expensive, Magisk would need to do many under-the-hood tasks to achieve it (thus, called "Magic Mount")
Furthermore, the higher level the file is added, the more it effects the overall system
Only add new items if necessary! Think twice before adding items to /system root!
Replacing a whole folder is recommended if viable, it reduces the complicated process and speed up the booting time
Manipulate system props (build.prop)
Since the early days of XDA, people love "build.prop" mods. It can bring cool effects to our devices.
build.prop files are loaded early in the boot process, and once read-in, the values cannot be modified... in theory.
Magisk included a tool called "resetprop", it can modify any system props you want easily.
In the module template, you can set PROPFILE=true, then add your props into the file common/system.prop
Magisk by default reads the system.prop of each module and set the props.
Further resetprop options:
Code:
usage: /data/magisk/resetprop [-v] [-n] [--file propfile] [--delete name] [ name value ]
-v :
verbose output (Default: Disabled)
-n :
no event triggers when changing props (Default: Will trigger events)
--file propfile :
Read props from prop files (e.g. build.prop)
--delete name :
Remove a prop entry
Remove files / folders
It is complicated to actually remove a file (possible, not worth the effort). Replacing it with a dummy file should be good enough
Add an empty file with the same name and path into your module (easy way), or add this code to the updater-script to create it at flash time
Code:
# Example: you want to remove /system/media/audio/alarms/Argon.ogg
# Note: mktouch is a function defined in my updater-script, it is not a standard command!
mktouch $MODDIR/system/media/audio/alarms/Argon.ogg
It is complicated to actually remove a folder (possible, not worth the effort). Replacing it with an empty folder should be good enough
Add the folder to the replace list in "config.sh" in the module template, it will replace the folder with an empty one
Cache mounts
Some files requires to be mounted much earlier in the boot process, currently known are bootanimation, and some libs (most users won't change them).
You can place your files into the corresponding location under /cache/magisk_mount, Magisk will automagiskally manage selinux contexts, permissions and the mounting for you. For example, you want to replace /system/media/bootanimation.zip, copy your new boot animation zip to /cache/magisk_mount/system/media/bootanimation.zip, Magisk will mount your files in the next reboot​
More to come ...
This thread is outdated and will never be updated
Please check the official Magisk documentation on Github!
Magisk Details (DEV)
sepolicy-inject
Before starting, check the complete document from Chainfire
SELinux Policy Section in How-To SU
The included sepolicy manipulation tool is called "sepolicy-inject", it supports live patching, and also supports policy statements following the same syntax as supolicy:
Code:
sepolicy-inject [--live] [--minimal] [--load <infile>] [--save <outfile>] [policystatement...]
--live: directly load patched policy to device
--minimal: minimal patches for boot image to let Magisk live patch on boot
Supported policy statements:
"allow #source-class #target-class permission-class #permission"
"deny #source-class #target-class permission-class #permission"
"auditallow #source-class #target-class permission-class #permission"
"auditdeny #source-class #target-class permission-class #permission"
"create #class"
"permissive #class"
"enforcing #class"
"attradd #class #attribute"
"typetrans source-class target-class permission-class default-class (optional: object-name)"
source-class and target-class can be attributes (patches the whole group)
All sections (except typetrans) can be replaced with '*' to patch every possible matches
Sections marked with '#' can be replaced with collections in curly brackets
e.g: allow { source1 source2 } { target1 target2 } permission-class { permission1 permission2 }
Will be expanded to:
allow source1 target1 permission-class permission1
allow source1 target1 permission-class permission2
allow source1 target2 permission-class permission1
allow source1 target2 permission-class permission2
allow source2 target1 permission-class permission1
allow source2 target1 permission-class permission2
allow source2 target2 permission-class permission1
allow source2 target2 permission-class permission2
Work flow
Code:
--------post-fs---------
(Device Boots) -> Mount Magisk cache files -> (build.prop and persist prop loads) ->
-----------------------------post-fs-data---------------------------------
-> Live patch sepolicy -> mount magisk.img -> Preparation -> 5 stage of tasks ->
--------------late_start--------------
-> (System Start Up) -> run all service.sh -> Start Magisk Hide
-> (Parallel with other processes....)
(Preparation) Magisk will travel through all enabled module directories to collect info
(1st stage) Mount system (vendor) mirrors. This is used to revert dummy files
(2nd stage) Clone the system structure, and mount the dummy directories to provide a dummy skeleton
(3rd stage) Mount module items into the system (and dummy skeletons)
(4th stage) Execute scripts
(5th stage) Mount the mirror items back to the remaining dummy files
File Structures
A "Magisk Module" is a subfolder under magisk root directory
The structure of a Magisk Module do not have a strict restriction. However, here are some key files / folders:
Code:
/magisk
|
|-.core <--- Magisk auto-generated files. Do not mess with them :)
| |
| |
| |-hosts <--- This file will be mounted to /system/etc/hosts to enable
| | systemless support for AdBlocker apps.
| |-magiskhide <--- This folder holds the hide list and add/rm/list/enable/disable scripts
| | | Include the magiskhide binary
| | |-magiskhide
| | |-hidelist
| | |-add
| | |-rm
| | |-list
| | |-enable
| | |-disable
| |
| |-su <--- This folder holds the MagiskSU binaries and scripts
| | | Include the magiskhide binary
| | |-su
| | |-magisksu.sh
| | |-sbin_bind <--- This folder will bind mount to /sbin
| | |-.....
| |
| |-post-fs-data.d <--- Place scripts that should be executed at post-fs-data here
| | |-.....
| |
| |-service.d <--- Place scripts that should be executed at late_start service here
| |-.....
|
|
|-other_module
| |-.....
|
|-your_module
| |
| |-auto_mount <--- If this file exists, auto mount is enabled
| |
| |-disable <--- If this file exists, the module is disabled
| |
| |-remove <--- If this file exists, the whole module folder
| | will be removed in the next reboot
| |-module.prop <--- This files stores the info of your module
| |
| |-system.prop <--- This file will be read by resetprop
| |
| |-post-fs-data.sh <--- This script will be executed in post-fs-data
| |
| |-service.sh <--- This script will be executed in late_start service
| |
| |-system <--- If auto mount is enabled, Magisk will "Magic Mount" this folder
| | |-....
| | |-....
| | |-....
| | |-....
| |
| |-vendor <--- Auto generated. A symlink to $MODID/system/vendor
| | Dealing with separate vendor partitions
| |-..... <--- Any other files/folders are allowed
|
|-another_module
| |-.....
|-...
Other important folders (under /dev), these will be created every boot
Code:
/dev/busybox <--- Busybox applet symlinks will be created here
|-.... Will be bind mounted to /system/xbin if enable busybox in Magisk Manager
|-....
|-....
/dev/magisk
|
|-dummy <--- Lies all cloned dummy structures
| | Folders in here will be mounted to /system
| |-.....
|
|-mirror <--- Lies all mirrors
| |
| |-system
| | |-....
| |
| |-vendor <--- Could be a symlink to /dev/mirror/system/vendor
| |-....
|
|-mnt <--- Lies all mounting info
|
|-dummy <--- Lists all dummy mounts
| |-....
|
|-mirror <--- Lists all mirror mounts
| |-....
|
|-system <--- Lists all /system mounts
| |-....
|
|-vendor <--- Lists all /vendor mounts
|-....
Boot Stages
If you are working on complicated projects, you shall need more control to the whole process.
Magisk can run scripts in different boot stages, you can fine tune exactly what you want to do.
post-fs mode:
This stage is BLOCKING. Boot process will NOT continue until everything is done, or 20 seconds has passed
Happens after most partitions are mounted, except /data
Magisk will bind mount items in: /cache/magisk_mount/system (*1)
post-fs-data mode:
This stage is BLOCKING. Boot process will NOT continue until everything is done, or 60 seconds has passed
Happens after /data is ready (including encrypted data)
Happens before Zygote is started (which means pretty much everything)
/data/magisk.img will be mounted to /magisk
Magisk will bind mount items in: /magisk/$MODID/system (*2)
Magisk will run script: /magisk/$MODID/post-fs-data.sh
Magisk will run scripts in: /magisk/.core/post-fs-data.d
late_start service mode:
This stage is NON-BLOCKING, it will run parallel with other processes
Put time consuming but non time critical tasks here. In other modes, the boot process will be stuck if it took too long to finish your tasks.
Happens when class late_start is started . Most things are are loaded/loading in this case.
Magisk will run script: /magisk/$MODID/service.sh
Magisk will run scripts in: /magisk/.core/service.d
(*1) Bind mounting in post-fs only support simple bind mounts, which mean you cannot add files or replace directories.
It will only mount files that exist in the current system.
(*2) Bind mounting in post-fs-data support complex bind mounts. Please refer to the "Magic Mount" section
Thanks for this @topjohnwu.
If github is the where all modules need to be hosted, how do we plan on supporting closed source modules?
Or is closed source modules not supported?
@topjohnwu is there any thought about aroma installers being supported? is this already possible? or are you planning to add something similar?
I've tried to build a v7-compatible zip file for an app and Magisk Manager kept crashing with the following in its module.prop:
Code:
versionCode=7.1.3231428
Is it supposed to be a single round number (like a versionCode for Android apps)?
anantharam said:
Thanks for this @topjohnwu.
If github is the where all modules need to be hosted, how do we plan on supporting closed source modules?
Or is closed source modules not supported?
Click to expand...
Click to collapse
You can host closed source binary on Github.
ibrokemypie said:
@topjohnwu is there any thought about aroma installers being supported? is this already possible? or are you planning to add something similar?
Click to expand...
Click to collapse
You can flash the Magisk Module template in aroma with the same method to flash SuperSU. However if the module itself is made with aroma, it will not be able to flash in Magisk Manager
stangri said:
I've tried to build a v7-compatible zip file for an app and Magisk Manager kept crashing with the following in its module.prop:
Is it supposed to be a single round number (like a versionCode for Android apps)?
Click to expand...
Click to collapse
Yes, the versionCode is the similar concept of Android application's version code. It has to be a single number. You can place your long version number into version, which supports any string.
i have a problem with MagiskManager 2.0 launch.... app stopped after open it.
Zenfone ZE520KL...
Also, plz help - where can i found new supersu 2.78 for magisk?
topjohnwu said:
Yes, the versionCode is the similar concept of Android application's version code. It has to be a single number. You can place your long version number into version, which supports any string.
Click to expand...
Click to collapse
Still, the magisk manager shouldn't crash on invalid versionCode.
I need to patch in lines to audio_effects.conf rather than replace the file. Is there any way to do a systemless merge of lines within a conf with Magisk?
Hello, I'm trying to bring the OnePlus Camera to Magisk, and I'm having issues. I feel that I understand how to create a Magisk module from following your tutorial on Github, but apparently I don't. I just spent about 25 minutes trying to figure this out on my own, and couldn't.
When I flash my zip, I get error 255 in TWRP. It claims "/tmp/updater" doesn't exist. Magisk Manager also claims it's not a Magisk module when trying to manually add it in the app.
Below is the recovery.log, and link to the Github repo for what I'm working on. Any help is appreciated!
Source: https://github.com/ryanguy426/OnePlus-Camera-Magisk
recovery.log (PasteBin): http://pastebin.com/z0B9jaSM
ryanguy426 said:
When I flash my zip, I get error 255 in TWRP. It claims "/tmp/updater" doesn't exist. Magisk Manager also claims it's not a Magisk module when trying to manually add it in the app.
Source: https://github.com/ryanguy426/OnePlus-Camera-Magisk
recovery.log (PasteBin): http://pastebin.com/z0B9jaSM
Click to expand...
Click to collapse
AFAIK If you use the Magisk v7 template (from github), you do not flash resulting ZIP in recovery. Also, I'm not sure if just downloading the ZIP file from github will do, AFAIK doing that creates a nesting folder which is probably why Magisk refuses to add the module.
I can create the correct ZIP and I would have tried it on my phone, but I followed your support link and it leads to the generic Magisk thread and doesn't list specific models it's compatible with, so I refrained.
PS. Fix REPLACE in your config.sh
stangri said:
AFAIK If you use the Magisk v7 template (from github), you do not flash resulting ZIP in recovery. Also, I'm not sure if just downloading the ZIP file from github will do, AFAIK doing that creates a nesting folder which is probably why Magisk refuses to add the module.
I can create the correct ZIP and I would have tried it on my phone, but I followed your support link and it leads to the generic Magisk thread and doesn't list specific models it's compatible with, so I refrained.
PS. Fix REPLACE in your config.sh
Click to expand...
Click to collapse
I haven't created a support thread yet, as XDA doesn't allow placeholder threads. I'll create the thread when the module works.
I'll start over with it, and see if I can get it working. They're for the tips!
I have created a module that will enable miracast by adding a line to the build.prop. When I try to manually add the module to magisk I get an error saying "This zip is not a magisk module!!" Can someone please tell me what I'm doing wrong.
Here is the module : github.com/blake1029384756/EnableMiracast
Blake1029384756 said:
I have created a module that will enable miracast by adding a line to the build.prop. When I try to manually add the module to magisk I get an error saying "This zip is not a magisk module!!" Can someone please tell me what I'm doing wrong.
Here is the module : github.com/blake1029384756/EnableMiracast
Click to expand...
Click to collapse
If you are downloading the zip from github it nests a folder within it which magisk doesnt like, you need to zip up the files in the root of the zip.
ibrokemypie said:
If you are downloading the zip from github it nests a folder within it which magisk doesnt like, you need to zip up the files in the root of the zip.
Click to expand...
Click to collapse
I am aware that it does that and have made sure all files are in the root of the zip. Idk why it doesnt add to magisk manager
ahrion said:
I need to patch in lines to audio_effects.conf rather than replace the file. Is there any way to do a systemless merge of lines within a conf with Magisk?
Click to expand...
Click to collapse
Just make a copy of the file as /magisk/your_mldule/system/etc/audio_effects.conf, and modify the fake aidio_effects.conf which will be mounted during boot.
But the weird thing is that some setprop commands don't work when it is written in post-fs-data or post-fs, at least under Magisk v6 OnePlus 3 Oxygen OS. I have to write the setprop modifications in a fake build.prop instead.
Here is the module that I transplant from guitardedhero's ViPER4Audio_5.4_Stock.zip. Maybe it would help.
BTW: The attachment doesn't work well on v7, it stuck at boot animation. While it works well on v6.
Iceyogurt said:
Just make a copy of the file as /magisk/your_mldule/system/etc/audio_effects.conf, and modify the fake aidio_effects.conf which will be mounted during boot.
But the weird thing is that some setprop commands don't work when it is written in post-fs-data or post-fs, at least under Magisk v6 OnePlus 3 Oxygen OS. I have to write the setprop modifications in a fake build.prop instead.
Here is the module that I transplant from guitardedhero's ViPER4Audio_5.4_Stock.zip. Maybe it would help.
BTW: The attachment doesn't work well on v7, it stuck at boot animation. While it works well on v6.
Click to expand...
Click to collapse
Perhaps you might be able to tell me why Magisk Manager isn't recognizing my zip as a Magisk module...https://github.com/therealahrion/Audio-Modification-Framework
ahrion said:
Perhaps you might be able to tell me why Magisk Manager isn't recognizing my zip as a Magisk module...https://github.com/therealahrion/Audio-Modification-Framework
Click to expand...
Click to collapse
It is not easy to find a bug in my mobile browser. I'll try to look through your script more carefully when I get a PC. Now there is a mistake in the config.sh.
Code:
# This is an example
REPLACE="
/system/app/Youtube
/system/priv-app/SystemUI
/system/priv-app/Settings
/system/framework
"
# Construct your own list
REPLACE="
/system/etc
/system/vendor/etc
"
The first variable REPLACE is an example, so just delete it.(oh sorry, I forget it will be revalued because of the second one) And leave the second REPLACE void.
Code:
# Construct your own list
REPLACE=""
Since the value of REPLACE are folders, it mean replace an existing folder with a same-name-folder. The modified fake audio_effects.conf file will be mounted to replace the existing file automatically. No need to replace a whole folder.
ahrion said:
Perhaps you might be able to tell me why Magisk Manager isn't recognizing my zip as a Magisk module...https://github.com/therealahrion/Audio-Modification-Framework
Click to expand...
Click to collapse
Sorry about it, i can't figure out the reason either. I don't recommend you do the modification of the audio config files in post-fs-data.sh, which will be executed during every boot. I love your dax, wish it be a magisk module soon.

Modules not appearing as installed nor working

I just tried installing Magisk v9 with the current Xposed module on a YotaPhone 2 running Android 5.0, but it seems that the module doesn't correctly initialize.
I downloaded and installed the Xposed SDK 21 module in Magisk Manager v2.5. After reboot, however, the module list in Magis Manager was empty (not even phh's Superuser was visible there, which I previously flashed in recovery). However, the Magisk log shows that the Xposed script is executed:
Code:
** Magisk post-fs mode running...
** Magisk post-fs-data mode running...
Preparing modules
Bind mount dummy system
Bind mount module items
post-fs-data: /magisk/xposed/post-fs-data.sh
Enabling systemless hosts file support
Mount: /magisk/.core/hosts
Bind mount system mirror
Mount: /system
Bind mount mirror items
** Magisk late_start service mode running...
service: /magisk/phh/service.sh
phh: Live patching sepolicy
phh: Mounting supath
phh: Starting su daemon
The Xposed Installer now shows on the status screen that Xposed is installed but not active. An Xposed log file in /data/data/de.robv.android.xposed.installer/log doesn't exist. Logcat has no entries for Magisk nor Xposed. Also, the "Enable systemless hosts" checkbox in Magisk Manager isn't active anymore after reboot, even if it clearly is configured that way according to the logs. Is this a bug in Magisk or am I doing something wrong?

[MODULE] Clear Hide List (Bootloop/Bootscreen/Blackscreen Solver For Magisk Hide)

It Is Now A Part Of The Main Module Of MultiFunctions & Its Thread https://forum.xda-developers.com/apps/magisk/module-multifunctions-bootloop-t3933386.
Click to expand...
Click to collapse
Introduction:
Simple Module To Clear Magisk Hide List.
- In-Case Of Facing A Bootloop Issue Due To Adding App/Activity/Process To Magisk Hide, Flash This Module
- This Module Clears All Added Apps/Activities/Processes In Magisk Hide List
- After The Installation & Booting, It Clears Magisk Hide List & Disables Itself
- Enabling This Module = Doing Its Functionality & Disabling Itself (Next Reboot)
Current Version: 1.0.3.3
- For Magisk Users, Disable Magisk Core Only Mode From The Section Of Settings In Magisk Manager Which Is Required As An Essential Step To Activate The Functionality Of ClearHideList
- For Activating The Functionality Of ClearHideList, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> MagiskHideList --> Delete The File Of Disable From The Folder Of Active --> Reboot
- For Using The Module Thru ADB Shell/TWRP Terminal [The Module Must Be Pre-Installed Via Magisk Manager/TWRP Recovery/ADB Sideload], Write The Following Commands --> rm -f /data/DreamerMods/MultiFunctions/MagiskHideList/Active/disable (Click On Enter) --> reboot (Click On Enter)
Created: Oct.01.2018
Updated: May.09.2019
Download Link: Click Here
- For The Module Which Is Ended Its Name With v1300, It Supports Magisk v13.1(1310) To v13.6(1360)
- For The Module Which Is Ended Its Name With v1400, It Supports Magisk v14.0(1400) To v15.3(1531)
- For The Module Which Is Ended Its Name With v1500, It Supports Magisk v15.0(1500) To v17.3(17300)
- For The Module Which Is Ended Its Name With v17000, It Supports Magisk v17.0(17000) To v17.3(17300)
- For The Module Which Is Ended Its Name With v18000, It Supports Magisk v18.0(18000) To v18.1(18100)
- For The Module Which Is Ended Its Name With v19000, It Supports Magisk v19.0(19000) To The Latest Version
- For The Module Which Is Ended Its Name With Unity, It Supports Any-Rooting-Tool Such As SuperSU, Lineage-AddOnSU & Magisk
Installation:
- Flash It Thru TWRP Recovery
- Or Magisk Manager --> Modules --> Add (+) --> Choose The Downloaded File --> Reboot
- Or Flash It Thru ADB Sideload --> adb sideload Module.zip --> Reboot
General Info:
- To Disable The Module For Magisk Users, Open Magisk Manager --> Modules --> The Module --> Tap On The Check Box/The True Icon --> Reboot
- To Enable The Module For Magisk Users, Open Magisk Manager --> Modules --> The Module --> Tap On The Uncheck Box --> Reboot
- To Uninstall The Module For Magisk Users, Open Magisk Manager --> Modules --> The Module --> Tap On The Bin Icon --> Reboot
- To Disable The Module For All Users [Non-Magisk Users & Magisk Users], Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> The Module --> Copy The File Of Disable To The Folder Of Active (Or Delete The File Of Disable From The Folder Of Inactive) --> Reboot
- To Enable The Module For All Users [Non-Magisk Users & Magisk Users], Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> The Module --> Delete The File Of Disable From The Folder Of Active (Or Copy The File Of Disable To The Folder Of Inactive) --> Reboot
- To Uninstall The Module For All Users [Non-Magisk Users & Magisk Users] (Unity), Reflash The Module
- In-Case Of Facing A Bootloop/Bootscreen/Blackscreen Issue Due To Installing/Configuring An App, Download SafeMode4Magisk From This Thread https://forum.xda-developers.com/apps/magisk/module-safe-mode-bootloop-bootscreen-t3847422 Then Flash It
- In-Case Of Facing A Bootloop/Bootscreen/Blackscreen Issue Due To Flashing A Module, Download CoreOnlyMode4Magisk From This Thread https://forum.xda-developers.com/apps/magisk/module-core-mode-bootloop-solver-modules-t3817366 Then Flash It
Click On Thanks Button If The Module/Post Is Useful (Dreamer(3MF))
>>> Sharing A Good Thought Is Gold <<<
----------------------------------------------------------------------------------------------------------------
SELinux Mode Inverter - Clear Dalvik Cache - Other Modules
----------------------------------------------------------------------------------------------------------------
Reserved for News/Updates #1
Reserved for News/Updates #2
This module is useful! THANKS!
Updated ClearHideList4Magisk To v1.0.0A!
Changelog: Checking The Paths
- For The Module Which Is Ended Its Name With v1300, It Supports Magisk v13.1(1310) To v13.6(1360)
- For The Module Which Is Ended Its Name With v1400, It Supports Magisk v14.0(1400) To v15.3(1531)
- For The Module Which Is Ended Its Name With v1500, It Supports Magisk v15.0(1500) To The Latest Version Which Is Currently v17.2(17200)
- For The Module Which Is Ended Its Name With v17000, It Supports Magisk v17.0(17000) To The Latest Version Which Is Currently v17.2(17200)
Updated ClearAll4Magisk To 1.0.3.0A!
Changelog: Rewriting The Script & Adding Extra Options
- For The Module Which Is Ended Its Name With v1300, It Supports Magisk v13.1(1310) To v13.6(1360)
- For The Module Which Is Ended Its Name With v1400, It Supports Magisk v14.0(1400) To v15.3(1531)
- For The Module Which Is Ended Its Name With v1500, It Supports Magisk v15.0(1500) To v17.3(17300)
- For The Module Which Is Ended Its Name With v17000, It Supports Magisk v17.0(17000) To v17.3(17300)
- For The Module Which Is Ended Its Name With v18000, It Supports Magisk v18.0(18000) To v18.1(18100)
- For The Module Which Is Ended Its Name With v19000, It Supports Magisk v19.0(19000) To The Latest Version
- For The Module Which Is Ended Its Name With Unity, It Supports Any-Rooting-Tool Such As SuperSU, Lineage-AddOnSU & Magisk
Kindly Be Informed That
- For Doing Its Functionality, Use Any File Explorer --> Internal Storage --> DreamerMods --> The Module --> Delete The File Of Disable From The Folder Of ClearMagiskHideList --> Reboot
Updated MultiFunctions4Magisk To 1.0.3.3!
Changelog: ClearHideList Is A Sub-Module Of The Main Module Of MultiFunctions Which Supports Currently The Following Functions [Clearing DalvikCache-PlayStoreWithServices-MagiskHideList, Changing The SELinux Mode, Booting The Android Into Safe Mode & Opening Magisk In Core Only Mode]
- For The Module Which Is Ended Its Name With v1300, It Supports Magisk v13.1(1310) To v13.6(1360)
- For The Module Which Is Ended Its Name With v1400, It Supports Magisk v14.0(1400) To v15.3(1531)
- For The Module Which Is Ended Its Name With v1500, It Supports Magisk v15.0(1500) To v17.3(17300)
- For The Module Which Is Ended Its Name With v17000, It Supports Magisk v17.0(17000) To v17.3(17300)
- For The Module Which Is Ended Its Name With v18000, It Supports Magisk v18.0(18000) To v18.1(18100)
- For The Module Which Is Ended Its Name With v19000, It Supports Magisk v19.0(19000) To The Latest Version
- For The Module Which Is Ended Its Name With Unity, It Supports Any-Rooting-Tool Such As SuperSU, Lineage-AddOnSU & Magisk
Kindly Be Informed That
- For Magisk Users, Disable Magisk Core Only Mode From The Section Of Settings In Magisk Manager Which Is Required As An Essential Step To Activate The Functionality Of ClearHideList
- For Activating The Functionality Of ClearHideList, Use Any Root File Explorer Such MiXplorer --> Root --> data --> DreamerMods --> MultiFunctions --> MagiskHideList --> Delete The File Of Disable From The Folder Of Active --> Reboot
Download link?
https://androidfilehost.com/?w=files&flid=293646 which you provided does not work. There is no file to download.
No files, dude....
amirasyraf said:
Download link?
https://androidfilehost.com/?w=files&flid=293646 which you provided does not work. There is no file to download.
Click to expand...
Click to collapse
The zip-file 'MultiFunctions4Magisk-v1.0.3.3(v19000)(3MF).zip' (being the version for Magisk V19) can be downloaded via this link:
https://androidfilehost.com/?fid=1395089523397962220
73sydney said:
No files, dude....
Click to expand...
Click to collapse
amirasyraf said:
Download link?
https://androidfilehost.com/?w=files&flid=293646 which you provided does not work. There is no file to download.
Click to expand...
Click to collapse
It Is Now A Part Of The Main Module Of MultiFunctions & Its Thread https://forum.xda-developers.com/apps/magisk/module-multifunctions-bootloop-t3933386.

S10 w BeyondRom, Magisk and TWRP - Systemize not finding apps

Installed BeyondROM a few days ago with the help of:
The Proper Way to root your S10 (10+,10e) Device and get it Right! Tipps & Tricks
Hi Guys :cowboy: Today I want to bring some simple and effektive Insights on proper Device & Software Management and also about Mistakes on the Way and Solutions! :good: ;) So make yourself comfortable and check this out! It will really help...
forum.xda-developers.com
Click to expand...
Click to collapse
no boot issues, Magisk safety check cleared, TWRP working perfectly with no issues. but when i try to systemize a file trough adb shell or Terminux i run into this issue
C:\Users\Name\AppData\Local\Android\Sdk\platform-tools>adb shell
beyond1:/ $ su
beyond1:/ # systemize
==============================================
App Systemizer (Terminal Emulator) v17.3.1(70)
by veez21
==============================================
BusyBox v1.33.1-osm0sis
/system/bin/busybox
==============================================
Enter logs to upload logs
==============================================
Set SELinux Enabled: false
SELinux Status: Enforcing
==============================================
1 - Systemize Installed Apps (Listed)
2 - Systemize Installed Apps (Enter label)
3 - Systemize given APK
s - Set SELinux
0 - Exit
[CHOICE]: 1
Loading Apps [-]
==============================================
Installed Apps ===============================
==============================================
To systemize multiple apps, enter multiple number. Example: "1 0 0"
x - Back to Menu
r - Refresh list
0 - Exit
[CHOICE]:
Click to expand...
Click to collapse
Trying to move a app from standard install into app-priv, but with no success so far. i have tried to copy or move manually with TWRP file management but that just removes the app(files are there, but phone removes the install)
Tried option 2 with label but systemize cant find the Folder or the APK in the folder.
any help appreciated.

[UNLOCKED][ROOTED]Android 11 system-as-root and privacy policy updates permission problem

Hi,
This is my first post here.
Yesterday I rooted a Samsung A51 SM-A515F/N with android 11 [A515FxxU4EUD7] stock rom with twrp recovery, unlocked bootloader, and magisk.
As far as I can tell zero functionality loss on OS. Got everything to work just right.
Pass SafetyNet Test.
systemized FGL Pro and GPS Joystick as priv-apps.
Both applications recognize system mode but they both crash when you start the location mocking.
I believe I found what is making them crash.
Need confirmation/Advise on how to proceed.
Assume full rooted SM-515F with fully working Magisk 23.0 and Terminal Systemizer module installed
Systemizer command:
a51:/ $ su
a51:/ # systemize
! Busybox not detected
Please install one (@osm0sis' busybox recommended)
df: Unknown option 'm' (see "df --help")
df: Unknown option 'm' (see "df --help")
==============================================
App Systemizer (Terminal Emulator) v17.3.1(70)
by veez21
==============================================
BusyBox not found!
==============================================
Enter logs to upload logs
==============================================
Set SELinux Enabled: false
SELinux Status: Enforcing
==============================================
1 - Systemize Installed Apps (Listed)
2 - Systemize Installed Apps (Enter label)
3 - Systemize given APK
s - Set SELinux
0 - Exit
[CHOICE]: 3
Enter APK Path
Example: /sdcard/launcher.apk
x - Back to Menu
> /sdcard/Download/com.ltp.pro.fakelocation.apk
Checking if file exists - OK
Checking if file is an APK - OK
Checking package name - com.ltp.pro.fakelocation
Where to install?
< 1 - /system/app | 2 - /system/priv-app | 0 - cancel > : 2
df: Unknown option 'm' (see "df --help")
df: Unknown option 'm' (see "df --help")
Checking APK size - 5M
Transfering com.ltp.pro.fakelocation.apk(com.ltp.pro.fakelocation) to '/system/priv-app'...
Granting Permissions
com.ltp.pro.fakelocation - Done
1|a51:/ # mount -o rw,remount /
a51:/ # rm /etc/permissions/privapp-permissions-platform.xml
a51:/ # cp /sdcard/Download/privapp-permissions-platform.xml /etc/permissions/
a51:/ # chown root:root /etc/permissions/privapp-permissions-platform.xml
a51:/ # chmod 644 /etc/permissions/privapp-permissions-platform.xml
a51:/ # mount -o ro,remount /
a51:/ # reboot
Snippet of /etc/permissions/privapp-permissions-platform.xml:
...
<!-- CUSTOM Permissions -->
<privapp-permissions package="com.ltp.pro.fakelocation">
<permission name="android.permission.READ_EXTERNAL_STORAGE" />
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" />
<permission name="android.permission.ACCESS_FOREGROUND_LOCATION" />
<permission name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<permission name="android.permission.ACCESS_FINE_LOCATION" />
<permission name="android.permission.ACCESS_COARSE_LOCATION" />
<permission name="android.permission.INSTALL_LOCATION_PROVIDER" />
<permission name="android.permission.ACCESS_MOCK_LOCATION" />
<permission name="android.permission.ACCESS_MEDIA_LOCATION" />
</privapp-permissions>
<!-- END -->>
...
snippet from cmd dumpsys package com.ltp.pro.fakelocation:
Packages:
Package [com.ltp.pro.fakelocation] (1e331cd):
userId=10264
pkg=Package{876da82 com.ltp.pro.fakelocation}
codePath=/system/app/com.ltp.pro.fakelocation
resourcePath=/system/app/com.ltp.pro.fakelocation
legacyNativeLibraryDir=/system/app/com.ltp.pro.fakelocation/lib
primaryCpuAbi=null
secondaryCpuAbi=null
versionCode=67 minSdk=15 targetSdk=28
versionName=3.4.9.3
splits=[base]
apkSigningVersion=2
applicationInfo=ApplicationInfo{876da82 com.ltp.pro.fakelocation}
flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA LARGE_HEAP ]
privateFlags=[ PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING ]
forceQueryable=false
queriesPackages=[]
dataDir=/data/user/0/com.ltp.pro.fakelocation
supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
usesLibraries:
android.test.base
android.hidl.manager-V1.0-java
android.hidl.base-V1.0-java
usesOptionalLibraries:
org.apache.http.legacy
usesLibraryFiles:
/system/framework/android.test.base.jar
/system/framework/android.hidl.manager-V1.0-java.jar
/system/framework/android.hidl.base-V1.0-java.jar
/system/framework/org.apache.http.legacy.jar
timeStamp=2021-05-30 19:29:31
firstInstallTime=2021-05-30 19:29:31
lastUpdateTime=2021-05-30 19:29:31
signatures=PackageSignatures{3bad593 version:2, signatures:[721026fa], past signatures:[]}
installPermissionsFixed=true
pkgFlags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA LARGE_HEAP ]
declared permissions:
com.ltp.pro.fakelocation.permission.MAPS_RECEIVE: prot=signature, INSTALLED
com.ltp.pro.fakelocation.permission.C2D_MESSAGE: prot=signature, INSTALLED
requested permissions:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_COARSE_LOCATION
android.permission.SYSTEM_ALERT_WINDOW
com.google.android.providers.gsf.permission.READ_GSERVICES
android.permission.READ_EXTERNAL_STORAGE: restricted=true
android.permission.WRITE_EXTERNAL_STORAGE: restricted=true
android.permission.FOREGROUND_SERVICE
com.android.vending.BILLING
com.android.vending.CHECK_LICENSE
android.permission.WRITE_SETTINGS
android.permission.INSTALL_LOCATION_PROVIDER
android.permission.WRITE_SECURE_SETTINGS
android.permission.ACCESS_MOCK_LOCATION
android.permission.WAKE_LOCK
com.google.android.c2dm.permission.RECEIVE
com.ltp.pro.fakelocation.permission.C2D_MESSAGE
android.permission.ACCESS_BACKGROUND_LOCATION: restricted=true
android.permission.ACCESS_MEDIA_LOCATION
install permissions:
com.ltp.pro.fakelocation.permission.C2D_MESSAGE: granted=true
android.permission.WRITE_SETTINGS: granted=true
com.google.android.c2dm.permission.RECEIVE: granted=true
com.google.android.providers.gsf.permission.READ_GSERVICES: granted=true
android.permission.SYSTEM_ALERT_WINDOW: granted=true
android.permission.FOREGROUND_SERVICE: granted=true
android.permission.INTERNET: granted=true
com.android.vending.CHECK_LICENSE: granted=true
com.android.vending.BILLING: granted=true
android.permission.ACCESS_NETWORK_STATE: granted=true
android.permission.WAKE_LOCK: granted=true
User 0: ceDataInode=46342 installed=true hidden=false suspended=false distractionFlags=0 stopped=false notLaunched=false enabled=0 instant=false virtual=false
overlay paths:
/product/overlay/NavigationBarMode3Button/NavigationBarMode3ButtonOverlay.apk
gids=[3003]
runtime permissions:
android.permission.ACCESS_FINE_LOCATION: granted=true, flags=[ USER_SET]
android.permission.READ_EXTERNAL_STORAGE: granted=false, flags=[ APPLY_RESTRICTION]
android.permission.ACCESS_COARSE_LOCATION: granted=true, flags=[ USER_SET]
android.permission.WRITE_EXTERNAL_STORAGE: granted=false, flags=[ APPLY_RESTRICTION]
android.permission.ACCESS_BACKGROUND_LOCATION: granted=false, flags=[ REVOKE_WHEN_REQUESTED|APPLY_RESTRICTION]
android.permission.ACCESS_MEDIA_LOCATION: granted=true, flags=[ USER_SET|REVOKE_WHEN_REQUESTED]
Please direct your attention to the second last line: "android.permission.ACCESS_BACKGROUND_LOCATION: granted=false, flags=[ REVOKE_WHEN_REQUESTED|APPLY_RESTRICTION]"
This permission is restricted even though permission has been explicitly set with the xml file.
I believe this is due to: https://developer.android.com/training/location/permissions this update of the privacy policy on Android 11.
Now this thread says that the permission for ACCESS_FOREGROUND_LOCATION needs to be requested in the application.manifest file before ACCESS_BACKGROUND_LOCATION is called. This allows the user to select the always allow option that allows background threads to handle location permissions. This is where I believe the app crashes - the thread gets aborted and then crashes the app because it can't get background location access.
I'm thinking the only solution is to get the devs of FGL/GPSJoystick to add these permissions to their minifest files. Am I correct or am I missing something big?
EDIT: interestingly - installing the app as userapp(not system app), gives the "Allow all the time" option under location (Settings->Apps->Permissions->Location). I think I'm missing something, aldo I might be a little sleep deprived, 36 hours straight with this A51
Please let me know if you need any more info from me
RESERVED
Were you able to solve this problem facing same with my custom system app
Hi,
I emailed the devs of the afore mentioned apps, asking for them to add the permission in their manifest files but never got any replies.
After that I just switched over to patching the framework so the OS can not detect when a location mock app is selected in developer settings (using Smali patcher).
I have run into this permission and location settings issue a couple times since then on other apps, some not written by me and others written by me. The only fix I have been able to find is to add the permissions in the app manifest file. Ever since Android 10 google made it much harder to enable the "Always Allow Location Access" in settings.
Hope this helps

Categories

Resources