Magisk Module - DiamondJohnHostManager - VERY Large Host File Builder or even small host file - Magisk

This module is capable of building VERY large hosts files from multiple sources.
In my testing (and is actually my current live environment) I build a host file blocking 2.8 million hosts, from sources listing >4M hosts. Obviously some duplication between sources.
Requirements
Root
BusyBox
CURL - see post 2 for instruction on how to enable
Feature List
Builds from multiple host list sources. I am running >90
Allows whitelist
Supports HTTP, HTTPS as well as local FILE
Runs using multiple parallel threads. i.e. Multi-threaded. Defaults to 16 parallel threads, so while one is awaiting downloading, another would be parsed
In my testing, an older device built large hosts files not too much slower than that on a newer device
Supports mirrors
Fallbacks to previous good run
Multiple file source formats. ie host file with IP and/or simple domain lists even two formats within the same file
Can be run without Magisk
It is script based, so is open source
Configurable via a text file
Tries to clean up / correct some poorly formatted hosts files
Automaically enables / allows the host sources./. ie no need to explicitly include an allow list for the host sources
Automaticallly handles the removal of local hosts in the header from source block lists
Numerous reports on the results can be attained using my other development app with a UI called TeMeFI
You can manually run the build from TeMeFI or from a shell / adb
It defaults to building to the systemless host location of MAgisk, but can build to a RW direct location of /sytsem/etc/hosts
It runs at the LOWEST priority, thus minimal to no degradation of phone performance.
Redirects - text file
triues to minimise downloading files that have not changed
Does not rebuild the host file if the source host lists have not changed
Will force a re-download and host file rebuild if the host sources list has changed
Comments can be aadded to host source list without forcing a rebuild
Its not an app to install and does not run in the background, but a script that only runs on boot
Not Supported
Wildcards in whitelist
No UI, its all script and text files, however reports can be generated using TeMeFI
Install Instructions
Install CURL (see post 2)
Install the Magisk module from within Magisk, using the zip attached to this post
Enable the Magisk systemless host
Reboot twice. Once to finish the install, and the second top actually run the build of host file
MD5: C3464A3A594ECFE95EF87E6E0D324A62
Download: DiamondJohnHostManager_v2.1.zip

Busybox has WGet, and the script will dall back to WGet, but Wget has less featires and also a very well known bug, Dont expect this bug to be fixed too soon as it is even present in the desktop build of Linux!
So the solution is to install CUrl. Following the steps below will get you up and running by installing a MAgisk Module. Its called "Cross Compiled Binaries"
So to clarify the steps.
1. Download & Install "Cross Compiled Binaries" from the Magisk Repo
2. Reboot
3. Open a shell and get an su
4. Run "ccbins"
Spoiler: SCREEN OUTPUT
Code:
sunfish:/ $ su
sunfish:/ # ccbins
===============================
Cross Compiled Binaries v7.2(9)
by Zackptg5
===============================
BusyBox v1.31.1-osm0sis
/dev/a7Y7BvR/.magisk/modules/ccbins/busybox
===============================
Testing internet connection [/] - OK
Fetching available binaries
[|] - Done
Checking for mod updates
[\] - Ccbins is up to date
Checking for binary updates
[/] - Installing NCursesw v6.2
[-] - NCursesw has been installed!
[|] - Binaries are up to date
Checking for conflicting modules
[\] - No conflicting mods were found
===============================
Binary Installer ==============
===============================
Current install location: /system/bin
Auto-update binaries at launch: Enabled (recommended)
DOH Server: None
===============================
Choose option =================
===============================
0: Refresh CCbins (remove everything - start fresh)
1: General Information
2: Options/Settings
3: List all installed binaries
4: List all downloadable binaries
5: Remove binary
6: Install binary
7: Install dynamic linked binary
Type 'q' at any time to quit
-->
5. Select "Install a Binary" ie "--> 6"
Spoiler: SCREEN OUTPUT
Code:
--> 6
===============================
Install which binary? =========
===============================
Current install location: =====
/system/bin ===================
===============================
0: None, go back to main menu
1: Install all binaries listed below
2: Aria2 (v1.35.0)
3: Bash (v5.1.8)
4: Bc (v1.07.1)
5: Brotli (v1.0.9)
6: Coreutils (v8.32)
7: Cpio (v2.12)
8: Curl (v7.78.0)
9: Diffutils (v3.7)
10: Ed (v1.17)
11: Findutils (v4.8.0)
12: Gawk (v5.1.0)
13: Grep (v3.6)
14: Gzip (v1.10)
15: Htop (v3.0.5)
16: Iw (v5.9)
17: Keycheck (v1.0)
18: Nano (v5.8.0)
19: Nethogs (v0.8.6)
20: Openssl (v1.1.1.11)
21: Patch (v2.7.6)
22: Patchelf (v0.12)
23: Sed (v4.8)
24: Strace (v5.13)
25: Tar (v1.34)
26: Tcpdump (v4.99.1)
27: Vim (v8.2.3095)
28: Wavemon (v0.9.3)
29: Xmlstarlet (v1.0)
30: Xxd (v1.10)
31: Zip (v3.0)
32: Zsh (v5.8.0)
33: Zstd (v1.5.0)
-->
6. Install the selected one. "curl" in my case. ie "--> 8"
Spoiler: SCREEN OUTPUT
Code:
--> 8
Downloading Curl
[|] - Curl has been installed!
Reboot for changes to take effect
7. Reboot
8. open a shell, get su and curl is now available
Spoiler: CURL NOW AVAILABLE
Code:
sunfish:/ $ su
sunfish:/ # curl--help
/system/bin/sh: curl--help: inaccessible or not found
127|sunfish:/ # curl --help
Usage: curl [options...] <url>
-d, --data <data> HTTP POST data
-f, --fail Fail silently (no output at all) on HTTP errors
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
-s, --silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".

Some file Locations:
Your listt of Host Sources: /storage/emulated/0/Android/data/DiamondJophnDroidHostManager/host_sources.trxt
Each line is a different "row" which is a host source.
Lines Preceded with a "-" will be treated as an allow list, otherwise it will be treated as a deny list
Within each line, a mirror for the host sources is define by sepereating with a piping character ie "|"
A source can be https:// or http:// or file:// Note for a file source, the protocol has 2 slashes and then a third slash will be there for the path. Hence a file will have a tipple slash
Anything after the hash (#) will be ignored and treated as a comment
Empty lines will be ignored
MAKE SURE YOU USE A LINE-FEED and NOT a CARRIAGE RETURN & LINE-FEED to end each line. ie Android/Unix/Linux style, not windows style.
An example of each of the above:
Code:
https://dbl.oisd.nl
https://winhelp2002.mvps.org/hosts.txt|http://winhelp2002.mvps.org/hosts.txt|https://raw.githubusercontent.com/hectorm/hmirror/master/data/winhelp2002.mvps.org/list.txt|https://ssl-proxy.my-addr.org/myaddrproxy.php/http/winhelp2002.mvps.org/hosts.txt
file:///data/media/0/User/hosts/Deny/deny_coinblocker.txt
# Dead Host source
#https://raw.githubusercontent.com/Zelo72/hosts/main/big.txt
-file:///data/media/0/User/hosts/Allow/google_play_whitelist.txt
-file:///data/media/0/User/hosts/Allow/google_video_whitelist.txt
The config is stored at: /data/adb/modules/DiamondJophnDroidHostManager/bin/includes/shared_constants.sh
The logs will go to: /storage/emulated/0/Android/data/DiamondJophnDroidHostManager/logs/*
The history / previous run will go to: /storage/emulated/0/Android/data/DiamondJophnDroidHostManager/previous/*

reserved...

reserved...

Just to give you some context on performance. I have a Pixel 4A and the following is from the end of the log:
Code:
...snip...
download_hosts.sh - Start build final output host file at 2021-10-18 10:40:14.018
21 seconds - download_hosts.sh 91 files combined,
blocking 2,888,313 hosts from 5,172,803 total blocking hosts and 622 allowed hosts
with a file size of 87,246,214 bytes,
built using 79 historic hosts lists, of 91 total sources. at 2021-10-18 10:40:34.596
Resultant Hosts file copied to /data/adb/modules/hosts/system/etc/hosts at 2021-10-18 10:40:34.857
SAVE_PARAM >>> ROW= MIRROR=0 NAME=UNIQUE_BLOCKED_HOSTS VALUE=2888313 at 2021-10-18 10:40:34.905
SAVE_PARAM >>> ROW= MIRROR=0 NAME=BLOCKED_HOSTS VALUE=5172803 at 2021-10-18 10:40:34.952
SAVE_PARAM >>> ROW= MIRROR=0 NAME=ALLOWED_HOSTS VALUE=622 at 2021-10-18 10:40:34.999
SAVE_PARAM >>> ROW= MIRROR=0 NAME=SOURCE_COUNT VALUE=91 at 2021-10-18 10:40:35.050
SAVE_PARAM >>> ROW= MIRROR=0 NAME=HISTORIC_SOURCES VALUE=79 at 2021-10-18 10:40:35.090
SAVE_PARAM >>> ROW= MIRROR=0 NAME=FILE_SIZE VALUE=87246214 at 2021-10-18 10:40:35.126
SAVE_PARAM >>> ROW= MIRROR=0 NAME=ELAPSED_TIME VALUE=232 at 2021-10-18 10:40:35.166
ALL processed in 232 seconds at 2021-10-18 10:40:35.181
I also did some tests on an old 2013 Samsung S4, and it was around 300-400 seconds to build a similar 2.8M host file from 4.8M hosts.

Updated module. v2.1 Removed some debug code that made its way into the release.
Also note, the default host source list does not download 2.8M hosts. Its gets about 200K hosts, which are about 90+% unique.

Buena tarde:
Para agregar más fuentes de las que vienen, ¿qué sería modificar el archivo host_sources.txt?
Lo que no entiendo es que el complemento se descargue de magisk o .zip.
Saludos cordiales FELIZ NAVIDAD Y PRÓSPERO AÑO NUEVO.

Related

Boot-Time Auto-SuperLog! [12 Apr 2013]

Boot-Time Auto-Superlog! [12 Apr 2013]
USERS --- TESTERS --- DEVS​Plumb the depths of Middle Droid with Auto-Superlog!​
So…
Your device doesn't finish booting
It reboots on its own (and you may not know it)
An application or feature crashes (and you may not know it)
Generally speaking, any manually-launched app or tool could miss key events leading to random reboot or application crash.
Problem addressed with Auto-Superlog!​
cm10-auto-superlog-v1.0.zip (3MB): http://www.mediafire.com/?cf5f9rq4z7p6gep
This flashable zip is tested working on my Atrix running CWM Recovery 5.0.2.0 and CM10 SuperLite. It should also work on epinter’s CM10 4.1.x builds and on close relatives. Not sure about 4.2.x yet.
In this exciting age of alpha-beta ROM testing, my lightweight Auto-Superlog, presently built on epinter’s versatile CM10 boot image (for demo purposes), can help just about anyone, whether end-user, tester or developer!
In fact it is already helping me track down abnormal battery drain and shutdown problems!
Alternatively instead of flashing the boot-time version, you can extract “auto-superlog.sh” from the flashable zip and manually execute it at run time.
Features
Automatically launches at boot-time under “class_start core” --- just after ROM filesystems are mounted, thus maximizing the likelihood of capturing key events, even if phone does not finish booting
Comprehensive log set includes: system build properties (getprop), kernel configuration file (from /proc/config.gz), kernel dmesg and system logcat --- all in sync, all in ASCII text format, and all stored in a single gzipped, time-stamped tar file on $EXTERNAL_STORAGE/auto-superlog for easy access and analysis.
Android events are quietly, nimbly and continuously streamed via kernel “dmesg” and system “logcat” commands. The dmesg log is pushed at 2-second intervals (default) with a 1MB ring buffer which is cleared on each pass. Logcat is configured to log “main” and “system” events with a generous 10MB buffer to help in discerning error trends.
Access real-time dmesg and logcat output right on your device by tapping the /data/auto-superlog directory using a (root) file explorer.
Log file contents are time stamped using absolute time ([YYYY-]MM-DD HH:MM:SS), enabling users to correlate Android events with the outside world
Filename timestamps show when your system was rebooted
Self-cleaning feature: On reboot, your most recent superlog is gzipped and archived to $EXTERNAL_STORAGE and then is removed from /data/auto-superlog so only your most recent superlog remains on the /data partition.
Shell script: auto-superlog.sh is stored under /system/bin, enabling users to extract and execute it at run-time and/or customize.
How to kill dmesg and logcat? Use the ps and grep commands: http://stackoverflow.com/questions/3117095/stopping-an-android-app-from-console (It’s a sheepish way of saying “mechanization of this feature is still in work” lol)
Instructions
Nandroid Backup current ROM (security blanket)
Flash zip if running epinter CM10 4.1.x or close relative (e.g. SuperLite)
Reboot and relax.
…OR, if you don’t want to flash the zip, but still want the run-time features of auto-superlog, simply extract /system/bin/auto-superlog.sh from zip and do this…
copy auto-superlog.sh to /system/bin (Tip: mount /system/bin as read-write (rw), then revert to ro when done)
chmod 0755 /system/bin/auto-superlog.sh
sh /system/bin/auto-superlog.sh (using Script Manager or other tool, as root)
Click to expand...
Click to collapse
After launching the script, just tap the Home button to resume other activity as the loggers are now running in background. Then you will have real-time streaming dmesg and logcat (as well as getprop and kernel config) at your fingertips --- literally.
The advantage of flashing the zip (if it’s compatible with your ROM) is that you are more likely to capture key events leading to a failed boot, random reboot or application crash.
Screenshots
​
Boot Image Source Code
This is the only change I made to CM10 boot.img...
Code:
ramdisk/init.olympus.rc ...
# sendust7 (12 Apr 2013)
service auto-superlog /system/bin/sh /system/bin/auto-superlog.sh
class core
# class main
# class late_start
user root
group system
# disabled
oneshot
# sendust7 (12 Apr 2013)
Documentation
dmesg: http://unixhelp.ed.ac.uk/CGI/man-cgi?dmesg+8
logcat: http://developer.android.com/tools/debugging/debugging-log.html#outputFormat
Android Encryption: http://source.android.com/tech/encryption/android_crypto_implementation.html
from Android Encryption…"This magic was accomplished by requiring all services to be in 1 of 3 groups: core, main and late_start. Core services are never shut down after starting. main services are shutdown and then restarted after the disk password is entered. late_start services are not started until after /data has been decrypted and mounted.”
Click to expand...
Click to collapse
Thoughts and Ideas: This has been a fun project so far. Time permitting, I may be able to service bug fixes and add more goodies like event filtering.
Disclaimer: Standard disclaimers apply.
Credits:Emerson Pinter (CM10 for Atrix 4g), Cyanogenmod Team
Very nice!
The OS considers the internal SD as EXTERNAL_STORAGE in assigning the env variable which is perhaps the reason you should too:
Booted without external sd mounted:
Code:
[email protected]:/ $ echo $EXTERNAL_STORAGE
/storage/sdcard0
Booted with external sd mounted:
Code:
[email protected]:/ $ echo $EXTERNAL_STORAGE
/storage/sdcard0
Possibly just tweak this part of your script:
Before
Code:
/system/bin/mount -t vfat /dev/block/mmcblk1p1 $EXTERNAL_STORAGE
After
Code:
/system/bin/mount -t vfat /dev/block/mmcblk0p18 $EXTERNAL_STORAGE
This then sends the archive to a location that will always exist (sdcard0).
I mention as I don't always have external SD mounted.
Sent from my MB860 using Tapatalk 2
Thanks sendust7
Good job !

[UTILITY] qcndiff: analyze differences between Qualcomm QPST files

[size=+1]QCNDIFF[/size]
This is a utility that parses and displays differences between two text format .qcn files produced by Qualcomm's QPST (Qualcomm Product Support Tools). It's intended use is to display the differences between two files from two different phones in order to help determine which of the nvitems are involved in enabling the different radio frequency bands. This application is meant to be run on Linux or on Windows. Examples for Linux usage and compilation are given for a RHEL / Centos / Fedora distribution. Adapt as necessary to your own distribution.
[size=+1]HOW TO USE[/size]
There are pre-built binaries for 64 and 32 bit Windows as well as pre-built binaries for 64 and 32 bit Linux. The Linux binaries were built on Fedora 20 and the Windows binaries were built with MinGW and statically linked. For Linux you will need to install the boost shared libraries.
Code:
yum install boost
Program usage is as follows
Code:
Usage: qcndiff64 [options] file file
-h [ --help ] show help message
-t [ --type ] arg (=p) show differences
p for items present in both files
m for items missing in either file
b for both present and missing items
-f [ --format ] arg (=i) output format
i for interleaved output
s for sequential output
c to suppress item data and print only
count
-l [ --lookup ] arg (=nv.txt) nv item descriptions
Interleaved output shows the nvitem that is different for both files before displaying the next one. Sequential output displays all the differing items in the first file before proceeding to display the second file.
If the file nv.txt exists (use -l to override the name) it will be used to look up text descriptions of the codes in order to render the output more friendly.
[size=+1]HOW TO COMPILE[/size]
Linux
Code:
yum install boost boost-devel
make
If you wish to compile for a different architecture, for example you run x86_64 and you wish to compile a 32 bit variant, then first make sure you have the 32 bit libraries and then override the target with the ARCH commandline option
Code:
yum install boost.i686 boost-devel.i686
make ARCH=32
Windows
You will need to install MinGW. You need separate toolchains for the 64 bit versions and the 32 bit versions. You will also need to compile the boost libraries.
Once Boost is compiled, edit the Makefile to change the paths to the libraries and include files to conform to where you have them installed. Take note that if the default --layout==versioning option is used to compile Boost then you may also need to change the suffix option in the Makefile
[size=+1]CHANGELOG[/size]
0.2 - add dictionary facility to allow the lookup of text descriptions
0.1 - initial release
[size=+1]DOWNLOAD LINKS[/size]
Binaries and source are available on github
[size=+1]CREDITS[/size]
autoprime for the complete list of nv items used in the dictionary implementation
XDA:DevDB Information
qcndiff, Tool/Utility for the Samsung Galaxy S 5
Contributors
dl12345, autoprime
Source Code: https://github.com/dl12345/qcn
Version Information
Status: Beta
Current Beta Version: 0.2
Beta Release Date: 2014-11-14
Created 2014-11-09
Last Updated 2014-11-13
Version 0.2
Version 0.2 released. This implements a dictionary lookup facility to print textual descriptions of the non-matching nv items so as to make the resulting analysis easier to complete. The included dictionary is not complete but has a substantial number of items defined.
Thanks to autoprime for the list used in the implementation.
Hello
I have tried qcndiff for windows and despite you saed that are statically linked I have an error:
C:\Users\Ovidiu\Desktop\New folder>qcndiff64 80CB5BDE_1.qcn 80CB5BDE_0.qcn
Assertion failed!
Program: C:\Users\Ovidiu\Desktop\New folder\qcndiff64.exe
File: D:\boost_1_57_0/boost/spirit/home/support/char_encoding/ascii.hpp, Line 25
6
Expression: isascii_(ch)
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
C:\Users\Ovidiu\Desktop\New folder>
Thank you

[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.

[ROM] - Universal ROM One UI for any Galaxy A

Universal ROM One UI for any Galaxy A:
Hello guys, this time I bring you something different... it is a zip to convert stock to rom, this project is based on Dynamic Installer.
I am not responsible for damaged phones, install at your own risk.
Dynamic Installer: https://forum.xda-developers.com/t/...1-android-10-or-earlier.4279541/post-85046055
Features:
Spoiler: Features
Working on Snapdragon and Exynos devices
Debloat
Mod flag secure
Mod Outdoor mode
Mod remove permission when installing apps
Mod Theme Store
Vaultkeeper disabled
Proca disabled
Cass disabled
SCS disabled
CSC Features
Floating Features
knox counter at 0 (Samsung Health)
optimizations
Higher audio quality (Disabled DRC, which deeply compresses audio)
Deknoxed full (Including KnoxGuard)
Fix bluetooth pairings loss
and more
Installation:
This zip is meant to install from stock, if you have any problems please send it to me Universal_ROM_v2.x.log and recovery.log too, If it's a problem with the debloat send me too:
/sdcard/blacklist.txt
/Sdcard/packages.txt
Have stock One UI installed
Make a backup of the partitions (optional)
Just flash via recovery (TWRP recommended)
Format data
Reboot system
Downloads:
Version 2.1.1:
MD5: aa4e1555a5911b38687acd87568ce0af
AndroidFileHost: Download
Version 2.1.2:
MD5: 70607d913bd219018bea53321be43c5c
AndroidFileHost: Download
Version 2.1.3:
MD5: 4c24c7c2a0c22eb3678af6664ae02108
AndroidFileHost: Download
Version 2.1.4:
MD5: 83c658902ef14b675da9c61223fcca88
AndroidFileHost: Download
Version 2.1.5:
MD5: 8a91a604a7a3079571e7d25d93f8c38a
AndroidFileHost: Download
Version 2.2:
MD5: c4b8a62e229733b47ab73206e773ca36
AndroidFileHost: Download
Version 2.2.1:
MD5: 98696b8a42b7c02880891ec60c783c34
AndroidFileHost: Download
Version 2.2.1-b:
MD5: dbe0fd10d866ca8e2839de72cb7c1629
AndroidFileHost: Download
Credits:
@Gollo99 - Help and tips
@Nico04 - Help and tips
@3arthur6 - Fixed bluetooth pairing
@ShaDisNX255 - Mods
@BlassGO - Dynamic installer.
Thanks to all the users who tested
Paypal: Paypal.me ...
if you want to support the project
Telegram:
Channel: t.me/Swx...
XDA: DevDB Information
Universal, ROM for any Samsung Galaxy A
ROM OS Version: Android 11
Based on: ONE UI
Version Information
Status: Stable
Current Stable Versionl: 2.2.1-b
Stable Release Date: 2021-11-30
Edit the zip
Something I like about using this zip is that you can edit it according to your tastes or needs. I will show you how (Dynamic Installer Based Script Codes)
- Debloat:
You just have to add or delete the name of the apks that you want to be deleted during the installation in:
Apk name: "Universal ROM One UI v2.x.zip/META-INF/addons/blacklist.txt"
Apk package name: "Universal ROM One UI v2.x.zip/META-INF/addons/blacklist_packages.txt"
Script code:
Bash:
#Debloat normal
setdefault debloat_paths "
/system/app
/system/priv-app
/product/app
/product/priv-app
"
#Check IF AAPT WORKS
if ! can_run aapt; then
savelog "AAPT: FAIL"
else
savelog "AAPT: WORKS"
fi
#Start
apps=0
bloat=0
delete "$TMP/userlist.txt"
delete "$TMP/packages.txt"
for search in $debloat_paths; do
for userlist in $(find $search -type f -name "*.apk"); do
package=$(apk_package "$userlist")
echo "$userlist" >> "$TMP/userlist.txt"
echo "$(basename "$userlist")=$package" >> "$TMP/packages.txt"
export apps=$(($apps + 1))
done
done
#CAt debloat list
cat "$TMP/userlist.txt" > /sdcard/userlist.txt
cat "$TMP/packages.txt" > /sdcard/packages.txt
#Debloat blacklist.txt
for blacklist in $(cat "$addons/blacklist.txt"); do
black=$(grep -m1 "$blacklist" "$TMP/userlist.txt")
if defined black && exist "$black"; then
delete_recursive "$black"
if ! exist "$black"; then
export bloat=$(($bloat + 1))
package=$(get_file_prop $TMP/packages.txt "$(basename "$black")")
savelog " removed:blacklist:$bloat: package=$package path=$black"
huh=$(string escape "$(basename "$black")")
sed -i "/$huh/d" "$TMP/userlist.txt"
sed -i "/$huh/d" "$TMP/packages.txt"
else
savelog " -- CANT DELETE: $(basename "$black") "
fi
fi
done
#Debloat blacklist_packages.txt
for blackpack in $(cat "$addons/blacklist_packages.txt"); do
black=$(grep -m1 "$blackpack" "$TMP/packages.txt" | cut -d '=' -f1)
[ -z "$black" ] && continue
black=$(grep -m1 "$black" $TMP/userlist.txt)
if defined black && exist "$black"; then
delete_recursive "$black"
if ! exist "$black"; then
export bloat=$(($bloat + 1))
package=$(get_file_prop $TMP/packages.txt "$(basename "$black")")
savelog " removed:blacklist:$bloat: package=$package path=$black"
huh=$(string escape "$(basename "$black")")
sed -i "/$huh/d" "$TMP/userlist.txt"
sed -i "/$huh/d" "$TMP/packages.txt"
else
savelog " -- CANT DELETE: $(basename "$black") "
fi
fi
done
#end of debloat
ui_print " -- Removed $bloat of $apps applications"
- Decode OMC and csc features
Edit the following .xml files which are the features that will be added
cscfeatures.xml: "Universal ROM One UI v2.x.zip/omc/cscfeatures.xml"
cscfeatures_network.xml: "Universal ROM One UI v2.x.zip/omc/cscfeatures_network.xml"
Script code:
Bash:
#OMC
try_mount -e -rw /odm
#Check if dalvikvm work
run_jar_addon omc-decoder.jar > /dev/null || abort " CANT USE: run_jar: dalvikvm not available"
#Getting OMC type
if exist /system_root/optics/configs /system_root/prism/etc; then ported=true
elif exist /optics /prism; then newdevice=true
elif exist "$(find /product -type d -name "omc")" || exist "$(find /odm -type d -name "omc")"; then partdevice=true
elif exist "$(find /system -type d -name "omc")" || exist /system/csc; then olddevice=true
fi
#Getting OMC path
if defined newdevice; then
try_mount -rw -e /optics || abort " CANT MOUNT: /optics "
omc_path=/optics
elif defined partdevice; then
for omc in /product /odm; do
tryomc=$(find "$omc" -type f -name "cscfeature.xml" | head -n1)
if defined tryomc; then
if is_substring "/conf/" "$tryomc"; then
conf=true
omc_path=$(dirname "$(dirname "$(dirname "$tryomc")")")
else
omc_path=$(dirname "$(dirname "$tryomc")")
fi
fi
done
elif defined olddevice; then
if exist /system/csc; then
omc_path=/system/csc
else
tryomc=$(find /system -type f -name "cscfeature.xml" | head -n1)
if defined tryomc; then
omc_path=$(dirname "$(dirname "$tryomc")")
fi
fi
fi
#Decode All cscfeature.xml cscfeature_network.xml
error=0
ui_print " -- Decoding: $omc_path"
while read csc; do
if undefined csc; then abort "CANT FIND VALID PATH"; fi
if ! run_jar_addon omc-decoder.jar -d -i "$csc" -o "$csc"; then echo2 "CANT DECODE: $csc" && error=$(calc $error + 1); fi
done <<< $(find "$omc_path" -type f -name cscfeature.xml -o -name cscfeature_network.xml)
#Check results
if [[ "$error" != "0" ]]; then
abort " -- The installation had: $error ERRORs "
fi
#CSC Features
ui_print " -- Adding csc features... "
package_extract_dir omc "$TMP/omc"
#Get custom cscfeature.xml cscfeature_network.xml
base_csc=$(cat "$TMP/omc/cscfeature.xml")
base_network=$(cat "$TMP/omc/cscfeature_network.xml")
#Editing cscfeature.xml
for csc in $(find $omc_path -type f -name cscfeature.xml); do
content=$(string -f "$csc" extract '<FeatureSet>' '</FeatureSet>')
if defined content; then
replace "$content" "$base_csc" "$csc"
else
echo2 "CANT GET CONTENT: $csc"
fi
done
#Editing cscfeature_network.xml
for csc in $(find $omc_path -type f -name cscfeature_network.xml); do
content=$(string -f "$csc" extract '<FeatureSet>' '</FeatureSet>')
if defined content; then
replace "$content" "$base_network" "$csc"
else
echo2 "CANT GET CONTENT: $csc"
fi
done
#Remove enforcedeletepackage.txt enforceskippingpackages.txt
find $omc_path -type f -name enforcedeletepackage.txt -delete
find $omc_path -type f -name enforceskippingpackages.txt -delete
- Floating Features
Edit the following file to add the features to floating features (It does not matter if the line already exists in the stock file, it will be omitted)
Floating_Features.xml: "Universal ROM One UI v2.x.zip/META-INF/addons/floating.txt"
Script code:
Bash:
#Floating features
ui_print " -- Adding Features... "
update_file_string '<SEC_FLOATING_FEATURE_FRAMEWORK_CONFIG_AOD_ITEM>aodversion=7,clearcoveroff,clocktransition</SEC_FLOATING_FEATURE_FRAMEWORK_CONFIG_AOD_ITEM>' /vendor/etc/floating_feature.xml
force_update_file_addon floating.txt /vendor/etc/floating_feature.xml
- Tweaks build.prop
You can add or remove tweaks in the following files (in the same way as floating, if the line already exists it will be omitted)
/system/build.prop: "Universal ROM One UI v2.x.zip/META-INF/addons/newprops.txt"
/vendor/build.prop: "Universal ROM One UI v2.x.zip/META-INF/addons/vendorprops.txt"
Script code:
Bash:
#Define common files
if exist /system/build.prop; then
system_build="/system/build.prop"
else
abort "FATAL ERROR: Failed to find system partition "
fi
if exist /vendor/build.prop; then
vendor_build="/vendor/build.prop"
else
abort "FATAL ERROR: Failed to find vendor partition "
fi
#build.prop
update_file_string 'ro.build.display.id=Universal ROM One UI v2.2.1-b' $system_build
replace "ro.config.tima=1" "ro.config.tima=0" $system_build
update_file_string 'ro.config.dmverity=false' $system_build
force_update_file_addon newprops.txt $system_build
force_update_file_addon vendorprops.txt $vendor_build
update_file_string 'restore.feature.use_samsung_smart_switch_flow=0' /system/etc/prop.default
- Extra script codes
Flag Secure
Bash:
ui_print " "
ui_print " You want the patch for Flag Secure? "
press
if $yes; then
ui_print " -- Flag secure will be disabled"
flag=true
else
ui_print " -- Flag secure will not be disabled"
fi
#Flag secure
disable='
.locals 1
const/4 v0, 0x0
return v0
'
if defined flag; then
stock_services="/system/framework/services.jar"
mod_services="/system/framework/services.jar"
if ! unzip -l "$stock_services" | grep classes.dex >/dev/null; then
abort " You need a deodexed services.jar"
fi
ui_print " -- Decompiling services.jar... "
apktool -f d "$stock_services" -o "$TMP/services"
ui_print " -- Disabling Flag Secure... "
smali_kit -c -m "isSecureLocked()Z" -re "$disable" -d "$TMP/services"
smali_kit -c -m "preventTakingScreenshotToTargetWindow" -re "$disable" -d "$TMP/services"
ui_print " -- Recompiling services.jar (Please wait)..."
apktool --copy-original -f b "$TMP/services" -o "$mod_services"
if [ ! -e "$mod_services" ]; then
abort " -- Some ERROR occurred during the recompilation of services.jar ! "
elif ! unzip -l "$mod_services" | grep classes.dex >/dev/null; then
abort " -- Invalid file: services.jar "
fi
fi
Outdoor mode
Bash:
ui_print " "
ui_print " -- You want mod of Outdoor mode? "
press
if $yes; then
outdoor=true
ui_print " -- Outdoor mode will be enabled"
else
ui_print " -- Outdoor mod will not apply"
fi
#Outdoor mode
enable='
.locals 1
const/4 v0, 0x1
return v0
'
if defined outdoor; then
ui_print " -- Finding SecSettings.apk"
SecSettings=$(find_apk com.android.settings /system)
if undefined SecSettings; then
abort " CANT FIND: SecSettings.apk"
fi
ui_print " -- Decompiling SecSettings.apk"
dynamic_apktool -decompile "$SecSettings" -output "$TMP/Settings"
ui_print " -- Enabling outdoor mode..."
smali_kit -c -m "isAvailable" -remake "$enable" -dir "$TMP/Settings" -name "SecOutDoorModePreferenceController"
ui_print " -- Recompiling SecSettings.apk (Please wait)..."
dynamic_apktool -preserve-signature -recompile "$TMP/Settings" -output "$SecSettings"
if ! is_valid "$SecSettings"; then
abort "Some error in the SecSettings.apk recompilation"
fi
fi
ThemeCenter Patch
Bash:
ui_print " "
ui_print " -- You want mod of ThemeCenter Patch? "
press
if $yes; then
themes=true
ui_print " -- The mod will be applied"
else
ui_print " -- Mod will not apply"
fi
#ThemesCenter mod
dummy='
.registers 5
return-void
'
if defined themes; then
ui_print " -- Finding ThemeCenter.apk"
ThemesCenter=$(find_apk com.samsung.android.themecenter /system)
if undefined ThemesCenter; then
abort " CANT FIND: ThemesCenter.apk"
fi
ui_print " -- Decompiling ThemeCenter.apk"
dynamic_apktool -decompile "$ThemesCenter" -output "$TMP/Center"
ui_print " -- Patching ThemeCenter.apk..."
smali_kit -c -m "setTrialExpiredPackage" -remake "$dummy" -d "$TMP/Center"
smali_kit -c -m "setAlarm" -remake "$dummy" -d "$TMP/Center"
ui_print " -- Recompiling ThemeCenter.apk (Please wait)..."
dynamic_apktool -preserve-signature -recompile "$TMP/Center" -output "$ThemesCenter"
if ! is_valid "$ThemesCenter"; then
abort "Some error in the ThemesCenter.apk recompilation"
fi
fi
permission when installing apps
Bash:
ui_print " "
ui_print " -- You want remove permission when installing apps? "
press
if $yes; then
permission=true
ui_print " -- The mod will be applied"
else
ui_print " -- Mod will not apply"
fi
#permission when installing apps
disabledd='
.registers 6
invoke-direct {p0}, Lcom/android/packageinstaller/PackageInstallerActivity;->initiateInstall()V
return-void
'
if defined permission; then
ui_print " -- Finding GooglePackageInstaller.apk "
googleinstaller=$(find_apk com.google.android.packageinstaller /system)
if undefined googleinstaller; then
abort " CANT FIND: GooglePackageInstaller.apk"
fi
ui_print " -- Decompiling GooglePackageInstaller.apk"
dynamic_apktool -decompile "$googleinstaller" -output "$TMP/googleinstaller"
ui_print " -- Removing permission when installing apps..."
smali_kit -c -m "checkIfAllowedAndInitiateInstall" -remake "$disabledd" -dir "$TMP/googleinstaller" -name "PackageInstallerActivity"
ui_print " -- Recompiling GooglePackageInstaller.apk (Please wait)..."
dynamic_apktool -preserve-signature -recompile "$TMP/googleinstaller" -output "$googleinstaller"
if ! is_valid "$googleinstaller"; then
abort "Some error in the GooglePackageInstaller.apk recompilation"
fi
fi
fstab file (encryption storage)
Bash:
#fstab
for fstab in $(find /vendor/etc -type f -name "fstab.*"); do
if $(cat "$fstab" | grep -q "encryptable=ice"); then
savelog "device no encrypt"
else
ui_print " -- Patching $fstab... "
replace "fileencryption" "encryptable" $fstab
fi
done
Version 1.1.0:
- Fixed side key option (Bixby removed)
- Added ViperFX and OnePlus Launcher to apps that should not be removed
- Themes mod was added (Apply themes without trial limit)
- DFE was added on installation
- Optimizations
Version 1.1.1:
- Random WIFI MAC address error fixed
- Samsung Max was added to the apps that need to be removed
Version 2.1.1:
- Now works on any Galaxy A device that is Snapdragon or Exynos
- Optimizations added
- Updated the base of Dynamic Installer to version 3.0
- Other changes
Version 2.1.2:
- Fixed some bugs in exynos
- Other small changes
Version 2.1.3:
- Added ripple animation on devices with FOD (optional)
- Fixed option to change clock on devices without always on display
- Corrections in the debloat
Version 2.1.4:
- The following services were disabled: Frp, cass, vaultkeeperd, proca, wsm and encryption [fstab file]
- AirCommand added [SPen feature] (optional)
- Disable DRC audio is now optional
- Removed multidisabler and DFE
- Dynamic Installer base was updated to version 3.2
- Some corrections
Version 2.1.5:
- Fixed creating custom omc on devices with unsupported csc (Csc Features)
- Knox removal improved
- Camera features returns for Galaxy A70 devices
- Debloat was improved for snapdragon devices with dynamic partitions
- Removing some apps like Chrome, Game Launcher, Samsung Free, etc, is now optional (This will only ask if the app exists)
Version 2.2:
- Fixed installation on newer devices like Galaxy A72, A52, etc
- The system should be more stable
- Debloat improvements
- Redesigned debloat code logic
- Now decode the existing cscfeatures.xml and cscfeatures_network.xml during the installation and add the new features in them (before it deleted the existing ones and created a new one)
- The precision of the extra debloat was improved
- Added flag secure mod
- Now the bootanimation will keep the stock
- Will now delete bixby residues
- DeKnox improvements (will now clear knox permissions)
- Now delete permissions of some deleted apps
- Now disable scs service (services disabler)
- Now recovery-from-boot.p is also deleted
- Fixes some file contexts on installation
- AirComand was deleted
- Camera features was deleted from galaxy a70 due to some bugs
- The visual error in the TIMA version was corrected
- Smart switch is disabled in the initial android setup
- Samsung cloud was deleted because if bixby does not work it does not work and is useless
- Now wipe cache and dalvik is automatic at the end of the installation
- Wallpaper was updated
- Dynamic Installer base was updated to version 4.x
- And more
Version 2.2.1:
- Dynamic Installer base was updated to version 4.1-b
- Outdoor mod added
- Added mod of disable permission when installing apps
- Fixed selection to remove Chrome and Google app on devices with dynamic partitions
- VPN networks should work now
- Debloat improvements
- Now a installation log is created in /sdcard/Universal_ROM_v2.1.1.log, if you have any problems please send it to me and recovery.log too, If it's a problem with the debloat send me too:
/sdcard/blacklist.txt
/Sdcard/packages.txt
Version 2.2.1-b:
- Project name change to "Universal ROM One UI"
- Theme Store mod added
Devices tested:
- Galaxy A20
- Galaxy A30
- Galaxy A70
- Galaxy A51
- Galaxy A71
- Galaxy A21s
Please let me know if it works on other devices.
This is modifed original ROM?
oli231 said:
This is modifed original ROM?
Click to expand...
Click to collapse
It is a zip to edit your stock rom or stock base with only flash that you already have installed
Followed your steps and am having a bloat-free experience till now. Samasung health also working. No bugs whatsoever. Excited for future updates. Would really appreciate more development for this device. (A705gm)
Thanks
kirbyNx said:
Universal ROM Galaxy A70:
Hi guys, this time I bring something different... it is a zip to convert stock to a rom, this project is based on Dynamic Installer and SuperR custom zip.
This time it works for all variants of the Galaxy A70 ( SM-: A705FN, A705MN, A705GM, etc...)
I am not responsible for damaged phones, install at your own risk.
FEATURES:
Spoiler: Features
Debloat
Vaultkeeper disabled
Proca disabled
Wsm disabled
Cass disabled
Custom CSC Features
Floating Features
knox counter at 0 (Samsung Health)
optimizations
Higher audio quality (Disabled DRC, which deeply compresses audio)
Deknoxed full (Including KnoxGuard)
Secure Folder working
Multidisabler
Fix bluetooth pairings loss
and more
Installation:
This zip is intended to be installed over stock but if you get bootloop you can use one of the bases where encryption is disabled to allow booting
Just flash via recovery (TWRP recommended)
Format data
Reboot system
Downloads:
Version 1.0.1:
AndroidFileHost: download
Version 1.1.1:
AndroidFileHost: download
Download direct: download
Bases stock:
Extract .7z with an unzip program
Reboot recovery
Full wipes (Cache, Dalvik cache, system, vendor y data)
Install "system.img" as "system" image in TWRP
Install "vendor.img" as "vendor" image in TWRP
Install "boot.img" as "boot" image in TWRP
SM-A705MN: download
SM-A705FN: download
SM-A705GM: download
Credits:
@Gollo99 - Help and suggestions
@SuperR. - kitchen SuperR to make the zip
@Nico04 - Help and suggestions
@3arthur6 - Fixed bluetooth pairing
@BlassGO - Mods, secure folder, Dynamic Installer.
@itz_rogue_77 - Help, suggestions, and more
@ Samsung - FIrmware
Samsung Open Source
opensource.samsung.com
BTC: bc1qqtg3pgxkhm7egmh35qnsq8xmnjjte6zeyz8s30
Paypal: Paypal.me...
if you want to support the project
XDA: DevDB Information
Universal, ROM for the Samsung Galaxy A70
ROM OS Version: Android 11
Based On: ONE UI
Version Information
Status: Stable
Current Stable Version: 1.1.0
Stable Release Date: 2021-07-18
Click to expand...
Click to collapse
Al flashear el archivo pierde la aleatorizacion de Mac address y muestra la del dispositivo, puede solucionar eso por favor? . Mac Rndomization es muy importante para la privacidad
When flashing the file loses the Mac address randomization and shows that of the device, can you fix that please? . Mac Rndomization is very important for privacy
javierami said:
Al flashear el archivo pierde la aleatorizacion de Mac address y muestra la del dispositivo, puede solucionar eso por favor? . Mac Rndomization es muy importante para la privacidad
When flashing the file loses the Mac address randomization and shows that of the device, can you fix that please? . Mac Rndomization is very important for privacy
Click to expand...
Click to collapse
Logs please...
logs mac randomization not work
javierami said:
logs mac randomization not work
Click to expand...
Click to collapse
Ok, I have fixed it, I will update Universal ROM later
javierami said:
logs mac randomization not work
Click to expand...
Click to collapse
Meanwhile, you can fix it with just flash this file
after installing rom it goes in downoald mode
what are the differences between this and swx rom?
Awesome software and all working like it should GZ!!
One question, does this method remove TWRP? I cant enter it somehow. What are the keys to press? I watched youtube and none work...
rolarocka said:
Awesome software and all working like it should GZ!!
One question, does this method remove TWRP? I cant enter it somehow. What are the keys to press? I watched youtube and none work...
Click to expand...
Click to collapse
I think you can Access twrp if your phone connected to cable and use combination (up+power) then release
Second if you have root access you can use magisk manager or any boot app to enter twrp
Kraitos said:
I think you can Access twrp if your phone connected to cable and use combination (up+power) then release
Second if you have root access you can use magisk manager or any boot app to enter twrp
Click to expand...
Click to collapse
True, didn't know they changed that and made it annoying
Flash this file, and you will be able to turn on TWRP mode without connecting the power cord
kissa67zwi said:
Flash this file, and you will be able to turn on TWRP mode without connecting the power cord
Click to expand...
Click to collapse
Tyvm
kissa67zwi said:
Flash this file, and you will be able to turn on TWRP mode without connecting the power cord
Click to expand...
Click to collapse
Flash it how. i tried with twrp and it tells me i need magisk to use that file.
WharfRat4 said:
Flash it how. i tried with twrp and it tells me i need magisk to use that file.
Click to expand...
Click to collapse
After flashing magisk this file works

How To Guide How to enable access via adb on a new installed OS

For automatic installation and configuration of a phone running the Android OS the access via adb is required. "Unfortunately" the access via adb is disabled in most Android distributions (in reality it is of course good that the access via adb is disabled in the default setting! See also the notes regarding the LineageOS at the end of this post))
There are (at least) two ways to enable access via adb:
Manually via the GUI of Android on the phone or via the Android command settings executed by the user root in a shell ,e.g.:
Bash:
settings put global development_settings_enabled 1
settings put global adb_enabled 1
The latter can also be done in a script in an adb shell -- but of course we need a working adb connection ....
One way around this problem is to use Magisk:
In principle this could be done using an init script for Magisk:
Magisk allows to run scripts while booting the phone (see How to run a script at every boot using Magisk); this feature could be used to enable adb via script.
Unfortunately, this method no longer works in the latest Android versions (Androd 12 and Android 13; Android 11 not tested):
Android now uses encryption for most of the files in the subdirectories in /data and to initiate the encryption keys for the files in these directories, the phone must boot once from the installed OS.
To use a Magisk init script to enable the access via adb, we need to create files in the directories /data/adb and /data/misc/adb. If you create these files while booting into TWRP recovery without a configured Android operating system, these files will be created unencrypted, making it impossible to boot the installed Android operating system:
If the Android operating system finds unencrpyted files in these directories at the first reboot, it boots into the installed recovery with the famous error message "Cannot load Android system. Your data may be corrupt" (see How to fix the error "Cannot load Android system. Your data may be corrupt" for details)
Fortunately, the Android operating system does not encrypt files in the directory /data/recovery (and therefore continues booting if there are already files in that directory) and the part of Magisk in the boot partition does not need the Magisk files /data/adb.
So to enable the access via adb using Magisk, we can create a script in the directory /data/recovery and a new Init .rc file for the Android operating system to execute that script while the Android OS is booting - for details about how to do that see How to trigger an action when a property is changed.
The working method to enable adb via Magisk is as follows:
- Boot the phone from a recovery (like TWRP)
- Install the new OS image but do not reboot the phone (see How to install an OS image using the TWRP binary twrp for how to install the OS via the cli commands from TWRP)
- Install Magisk into the boot partition of the phone and delete all files in /data/adb afterwards (see How to install Magisk into the boot partition using a script for how to install Magisk via script)
- copy a script to the directory /data/recovery on the phone that will enable access via adb using the Android command settings and copy the public ssl keys for the access via adb to the directory /data/misc/adb on the phone
- install a new init .rc file via Magisk which executes the script in the direcory /data/recovery to enable the access via adb - this script will be executed while doing the 1st reboot of the new installed Android OS.
(see How to trigger an action when a property is changed for how to add a new init .rc file using Magisk)
- reboot the phone
I wrote two scripts to enable adb using this method:
enable_adb_using_magisk.sh
The script enable_adb_using_magisk.sh must run in an adb session in TWRP after the new OS was installed and after Magisk has been installed into the boot partition but before the first reboot of the new installed operating system.
The script enable_adb_using_magisk.sh
- creates the script /data/recover/enable_adb_via_service.sh on the phone to enable adb and install the public ssl key for access via adb
- creates a new init *rc file using Magisk that will run the script /data/recover/enable_adb_via_service.sh on the phone while doing the 1st reboot (after the file encryption for the files /data is initalized by the Android OS)
To use the script enable_adb_using_magisk.sh manually after installing the new OS and Magisk do while the phone is booted into TWRP:
Bash:
#
# copy the script enable_adb_using_magisk.sh to the directory /tmp on the phone
#
adb push enable_adb_using_magisk.sh /tmp/enable_adb_using_magisk.sh
# copy the public ssl key for access via adb to the directory /tmp on the phone
#
adb push $HOME/.android/adbkey.pub /tmp/adbkey.pub
# execute the script /tmp/enable_adb_using_magisk.sh on the phone
#
adb shell sh /tmp/enable_adb_using_magisk.sh
# reboot the phone into the new installed OS
#
adb reboot
Notes:
The script enable_adb_using_magisk.sh installs the init *rc file into the boot partition from the slot for the next reboot: In this scenario this is the slot with the new installed OS.
To specify the boot partition to use add the boot partition as parameter, e.g.
Bash:
adb shell sh /tmp/enable_adb_using_magisk.sh _a
The init *rc service used is:
Spoiler: init *rc service to enable adb
Code:
#
# additional RC service to enable the access via adb after the 1st boot into the new installed Android OS
#
service bnsmb_enable_adb /system/bin/sh /data/recovery/enable_adb_via_service.sh
user root
group root
seclabel u:r:magisk:s0
disabled
oneshot
on zygote-start
setprop sys.bnsmb_enable_adb_done 0
start bnsmb_enable_adb
#
# Note: the following entries are for testing only!
#
on zygote-start
write /data/recovery/semfile Here_I_am
setprop sys.bnsmb.test.okay 0
The script enable_adb_using_magisk.sh creates the files adb_keys and adb_temp_keys.xml in the directory /data/misc/adb if the public ssl key /tmp/adbkey.pub exists on the phone.
Note that the file /data/misc/adb/db_temp_keys.xml is an Android Binary XML fIle (see How to change files in Android XML Binary format for details about Android Binary XML files)
To avoid the manual steps listed above I wrote another script:
enable_access_via_adb.sh
The script enable_access_via_adb.sh does all the steps listed above; the usage for enable_access_via_adb.sh is
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $ ./enable_access_via_adb.sh -h
enable_access_via_adb.sh version - v1.0.0.0 - shell script to enable adb access via an init .rc file configured via Magisk
enable_access_via_adb.sh [-h|help|-H] [--reboot|--noreboot] [--nopubkey|--pubkey]
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $
Spoiler: Detailed Usage
Code:
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $ ./enable_access_via_adb.sh -H
enable_access_via_adb.sh version - v1.0.0.0 - shell script to enable adb access via an init .rc file configured via Magisk
Usage
enable_access_via_adb.sh [-h|help|-H] [--reboot|--noreboot] [--nopubkey|--pubkey]
All parameter are optional. The parameter can be used in any order.
Use the parameter "help" or "-H" to print the detailed usage help; use the parameter "-h" to print only the short usage help
If the parameter "--reboot" is used the script will reboot the phone after installing Init .rc file; to disable the automatic reboot use the parameter "--noreboot".
Default is to ask the user for confirmation to reboot the phone.
Use the parameter "--nopubkey" to disable configuring the public key of the current user on the PC for the access via adb; use the parameter "--pubkey" to configure
the public key; default is to configure the public key.
The default public ssl key used is the key in the file "${HOME}/.android/adbkey.pub".
To change some of the values used by the script these environment variables can be set before starting the script:
Set the environment variable PUBLIC_KEY_ON_PC to the file with the public ssl key to use for the access via adb if another public key should be used
Set the environment variable REBOOT to "yes" before starting the script to automatically reboot the phone after enabling the root access
Set the environment variable REBOOT to "no" before starting the script to disable the automatic reboot after enabling the root access
See also the source code of the script
boot_phone_from_twrp.sh
for environment variables supported by this script
Prerequisites
- the phone must be connected via USB
- Magisk must be already installed in the boot partition of the phone
- the phone must be either booted into the fastbootd or bootloader with a working fastboot connection
or already booted into a recovery image with working adb connnection
The scripts boot_phone_from_twrp.sh and enable_adb_using_magisk.sh are required by this script -- see the source code of the script
[ OmniRom 13 Dev - [email protected] /data/develop/android/scripts_on_linux ] $
So installing a new OS and enabling access via adb in a script without user intervention can be done using these commands:
Bash:
#
# do a factory reset and install the OS image using the TRWP binary twrp
#
REBOOT=no ./install_os_via_twrp.sh factory_reset /data/backup/ASUS_ZENFONE8/omnirom_local/omni-13/omni-13-20221211-zenfone8-MICROG.zip
# install Magisk into the boot sector of the partition with the new OS and delete all files in /data/adb afterwards
#
# The parameter delete_adb_dir for the script "install_magisk_via_twrp.sh" is only available in version 2.2.0.0 or newer of the script.
#
REBOOT=no ./install_magisk_via_twrp.sh next copy_apk delete_adb_dir
# enable adb and copy the public keys for adb via new init *rc file using Magisk in the boot partition
#
REBOOT=no ./enable_access_via_adb.sh
# reboot the phone
#
adb reboot
# wait until the new OS is booted and adb is enabled
#
adb wait-for-device
# install the Magisk App
#
./install_apk.sh /data/backup/Android/EssentialApps/Magisk-v25.2.apk
# install the Magisk directories and binaries in /data/adb
#
REBOOT=no ./install_magisk_via_twrp.sh adb_only
# (optional) enable root access for the adb shell
#
REBOOT=yes ./init_magisk_db.sh
Notes:
The script enable_access_via_adb.sh needs the helper script boot_phone_from_twrp.sh.sh and the script enable_adb_using_magisk.sh .
The scripts can be downloaded from my homepage:
enable_access_via_adb.sh
enable_adb_using_magisk.sh
boot_phone_from_twrp.sh
The other scripts mentioned in ths post can also be downloaded from my home page:
install_os_via_twrp.sh (see How to install an OS image using the TWRP binary twrp for a descripton of this script)
install_magisk_via_twrp.sh (see How to install Magisk into the boot partition using a script for a description for this script)
install_apk.sh (see How to install packages (apk files) for Android via script for a description for this script)
init_magisk_db.sh (see How to enable root access using Magisk in a script for a description for this script)
Disabling the service to enable access via adb
To only run once, the script enable_adb_using_magisk.sh creates the file /data/recovery/adb_initialized exists on the phone. If that file already exists when enable_adb_using_magisk.sh starts, the script will do nothing and end immediately.
Therefor, it's not necessary to delete the new init *rc service.
It might even be useful to leave the service installed, since it can be used for other purposes later by modifying the script
However, if necessary, you can either delete the script used by the init *rc service enable_adb_using_magisk.sh or reinstall the original boot partition to get rid of the new service completely:
Bash:
#
# while the phone is booted into the Android OS with enabled root access or while the phone is booted into TWRP
#
# use the parameter "yes" for the script to run without requesting user input
#
adb shell su - -c /data/recovery/work/restore_boot_partition.sh
Directories and files used
Name
Type
Content
Comment
/tmp/adbkey.pubfilessl public key that should be configured/tmp is on a ramdisk so this file is lost after booting the phone/data/recovery/workDirectorytemporary files used for enabling adb/data/recovery/work/enable_adb_via_service.rcfileinit *rc file added to the boot partition via Magiks/data/recovery/work/boot_a.imgfileimage of the original boot partition/data/recovery/work/original_boot_partition.imgSymLinklink to the image with the original boot partition/data/recovery/work/restore_boot_partition.shfileScript to restore the boot partition using the image of the original boot partition/data/recovery/work/header
/data/recovery/work/kernel
/data/recovery/work/ramdisk.cpiofilescontents of the boot partition/data/recovery/adbkey.pubfilepublic ssl key to be configured for access via adb/data/recovery/adb_temp_keys.xml.humanfileXML file with the configuration for the access via adb
(will be converted to an XML file in Android binary XML format in /data/misc/adb)/data/recovery/enable_adb_via_service.shfilescript to enable the access via adb and installl the public ssl key for the access via adb
The script is configured in the init*rc file /data/recovery/work/enable_adb_via_service.rc/data/recovery/enable_adb_via_service.logfilelog file created by the script /data/recovery/enable_adb_via_service.sh/data/recovery/adb_initializedfilesemphor file for the script /data/recovery/enable_adb_via_service.sh - if this file exists the script will do nothing/data/recovery/semfilefiletest file created by the new init *rc service/data/recovery/log.gz
/data/recovery/last_log.gz
/data/recovery/recovery.fstab
/data/recovery/storage.fstabfileFiles created by TWRPonly for information
Enabling access via adb in the LineageOS (Update 11.01.2023)
In the LineageOS 19 for the ASUS Zenfone 8 access via adb is enabled in the default configuration.
Therefor these instructions are not necessary. The only configuration that must be done on a phone running the LineageOS is to copy the public ssl keys to /data/misc/adb to enable the access via adb.
Unfortunately the method used for this described in this post seems not to work in the LineageOS.
In addition, root access via adb can be enabled in the developer settings in the LineageOS. Until now I did not find out how to enable the plain root access from the LineageOS from within a script.
userdebug builds
In userdebug builds of Android the access via adb (without authentification) is enabled in the default.
Trouble Shooting
The script enable_adb_using_magisk.sh uses the log file /data/recovery/enable_adb_via_service.log if executed via init *rc service.
To check if the init *rc file was configured successfully check the properties
sys.bnsmb_enable_adb_done
sys.bnsmb.test.okay
in the running Android OS. Both properties should be defined with the value 0:
Code:
ASUS_I006D:/ # getprop sys.bnsmb_enable_adb_done
0
ASUS_I006D:/ #
ASUS_I006D:/ # getprop sys.bnsmb.test.okay
0
ASUS_I006D:/ #
In addition, if everything worked there should exist the file /data/recovery/semfile.
Code:
130|ASUS_I006D:/ # ls -l /data/recovery/semfile
-rw------- 1 root root 9 2022-12-29 11:44 /data/recovery/semfile
ASUS_I006D:/ #
Use the Android command start to check if the service exists and can be started, e.g.
Spoiler: start bnsmb_enable_adb
Code:
ASUS_I006D:/ # start bnsmb_enable_adb ; dmesg | tail -10
[ 3069.861365] [ 3069.861365] (CPU:2-pid:1:init) [12:35:31.711593934] init: Service 'exec 613 (/system/bin/flags_health_check UPDATABLE_CRASHING)' (pid 5734) exited with status 0 waiting took 0.024000 seconds
[ 3069.861402] [ 3069.861402] (CPU:2-pid:1:init) [12:35:31.711630236] init: Sending signal 9 to service 'exec 613 (/system/bin/flags_health_check UPDATABLE_CRASHING)' (pid 5734) process group...
[ 3069.861618] [ 3069.861618] (CPU:2-pid:1:init) [12:35:31.711846069] libprocessgroup: Successfully killed process cgroup uid 1000 pid 5734 in 0ms
[ 3071.202534] [ 3071.202486] (CPU:2-pid:5077:wk:0xffffffe40) [12:35:33.052716433] [BAT][CHG]asus_jeita_cc_worker set BATTMAN_OEM_WORK_EVENT : WORK_JEITA_CC
[ 3071.220807] [ 3071.220807] (CPU:0-pid:350:wk:0xffffffe40) [12:35:33.071038100] [BAT][CHG]handle_message set property:16 successfully
[ 3071.570753] [ 3071.570753] (CPU:2-pid:1:init) [12:35:33.420982631] init: starting service 'bnsmb_enable_adb'...
[ 3071.575971] [ 3071.575971] (CPU:3-pid:1:init) [12:35:33.426199819] init: Control message: Processed ctl.start for 'bnsmb_enable_adb' from pid: 5735 (start bnsmb_enable_adb)
[ 3071.614570] [ 3071.614570] (CPU:3-pid:1:init) [12:35:33.464799298] init: Service 'bnsmb_enable_adb' (pid 5736) exited with status 0 oneshot service took 0.040000 seconds in background
[ 3071.614609] [ 3071.614609] (CPU:3-pid:1:init) [12:35:33.464837267] init: Sending signal 9 to service 'bnsmb_enable_adb' (pid 5736) process group...
[ 3071.614788] [ 3071.614788] (CPU:3-pid:1:init) [12:35:33.465016277] libprocessgroup: Successfully killed process cgroup uid 0 pid 5736 in 0ms
ASUS_I006D:/ #
If something does not work execute the script manually in an adb session to check :
Spoiler: /data/recovery/enable_adb_via_service.sh
Code:
ASUS_I006D:/ # rm -f /data/recovery/adb_initialized
ASUS_I006D:/ #
ASUS_I006D:/ #
ASUS_I006D:/ # sh -x /data/recovery/enable_adb_via_service.sh
+ tty -s
+ '[' 0 -ne 0 ']'
+ PATH=/system/bin:/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin
+ export PATH
+ '[' ! -r /data/recovery/adb_initialized ']'
+ echo 'Sleeping 30 seconds now ...'
Sleeping 30 seconds now ...
+ sleep 30
+ touch /data/recovery/adb_initialized
+ settings put global development_settings_enabled 1
+ settings put global adb_enabled 1
+ '[' ! -d /data/misc/adb ']'
+ '[' ! -r /data/misc/adb/adb_keys ']'
+ '[' -r /data/recovery/adbkey.pub ']'
+ >>/data/misc/adb/adb_keys
+ cat /data/recovery/adbkey.pub
+ '[' -r /data/recovery/adb_temp_keys.xml.human ']'
+ xml2abx /data/recovery/adb_temp_keys.xml.human /data/misc/adb/adb_temp_keys.xml
+ chmod 0600 /data/misc/adb/adb_temp_keys.xml
+ chown system:shell /data/misc/adb/adb_temp_keys.xml
+ chcon -v u:object_r:adb_keys_file:s0 /data/misc/adb/adb_temp_keys.xml
chcon '/data/misc/adb/adb_temp_keys.xml' to u:object_r:adb_keys_file:s0
ASUS_I006D:/ #
Thank you for your explanation, I leave my footprint, I need this sometimes.

Categories

Resources