My HowTos for Android

Last Update: 07.08.2022/bs

Contents

  1. My HowTos for Android
    1. Contents
    2. Introduction
    3. History
    4. HowTos
      1. How to compile the OmniROM for the ASUS Zenfone 8
      2. How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM
      3. How to run a script at every boot using Magisk
      4. How to install Magisk into the boot partition using a script
      5. How to change files in the directory /system with Magisk
      6. How to backup the data from the phone using rsync and ssh (including some hints for using sshd on an Android phone)
      7. How to install packages (apk files) for Android via script
      8. How to replace the Fake Store from OmniROM with MicroG with a patched Playstore
      9. How to change the home directory for the user root on an Android phone
      10. Some hints for using Magisk on Android phones
    5. Links
      1. Files mentioned in the HowTos
      2. General Android LInks
      3. Magisk related links
      4. Links for the OmniROM
      5. Links for ROM Development
      6. Links for useful Tools
      7. Links for the ASUS Zenfone 8
 

Introduction


On this page I backup my HowTos regarding Android which I published elsewhere (for example in the XDA Forum)
There is also a section with links to other useful URLs for using or developing Android on this page.



Back to my home page


History


ChangeLog


07.08.2022 /bs

updated the section Some hints for using Magisk on Android phones - see also here.
updated the section with links


05.08.2022/bs

new section with link to various tools 


04.08.2022 /bs

added test instructions to instructions to use the ASUS Hardware Testtool   


23.07.2022 /bs

added the section Some hints for using Magisk on Android phones 


19.07.2022 /bs

updated the section with links

 
16.07.2022 /bs

added the section How to change the home directory for the user root on an Android phone
fixed some non-working links


05.07.2022 /bs

added the section How to install packages (apk files) for Android via script 
added the section How to replace the Fake Store from OmniROM with MicroG with a patched Playstore 


04.07.2022 /bs

updated the script to install Magisk 
added the section with Links


28.06.2022 /bs

added the section How to backup the data from the phone using rsync and ssh (including some hints for using sshd on an Android phone) 


26.06.2022 /bs

minor fixes in the instructions to use the ASUS Hardware Testtool 


25.06.2022 /bs

initial release




HowTos





Howto Overview
tbd


The HowTos are added in the chronological order in which I created them.


How to compile the OmniROM for the ASUS Zenfone 8


URL: https://forum.xda-developers.com/t/how-to-compile-the-omnirom-for-the-asus-zenfone-8.4461525/

How to compile the OmniROM for the ASUS Zenfone 8

Compiling the CustomROM OmniROM from within Linux is a very simple and straight forward process -- the developer for the OmniROM did a really amazing good job setting up the build environment for the OmniROM.

But some information are missing in the instructions (at least I did not found them ...)

Therefor I document here what I did to compile the OmniROM for the ASUS Zenfone 8 on my Linux notebook:

First install the neccessary tool called "repo" to maintain the repositories for the OmniROM ; see here https://gerrit.googlesource.com/git-repo/

Next create a new directory on your PC; switch to that directory, and initialize the necessarry repositories like described in the section "Getting Started" here: https://github.com/omnirom/android :


repo init -u https://github.com/omnirom/android.git -b android-12.0

# Then to sync up:

repo sync

Be aware that the repositories need about 140 GB disk space so this will take a while.

Please note that I did not install any additional tool to compile the OmniROM - everything neccessary was installed by synching the repositories.


When the download is finished you must add the repositories for the vendor and device tree for your phone to the manifests in the local repositories. This should be done in the file .repo/local_manifests/local_manifest.xml . For the ASUS Zenfone 8 the file should look like this:

[xtrnaw7@t15g /data/develop/android/OmniROM]$ cat .repo/local_manifests/local_manifest.xml
<?xml version="1.0" encoding="UTF-8"?>

<manifest>
<remote name="DonkeyCoyote"
fetch="https://github.com/DonkeyCoyote" />

<project path="device/asus/zenfone8" name="android_device_asus_zenfone8" remote="omnirom" revision="android-12.0" />
<project path="vendor/asus" name="proprietary_vendor_asus" remote="DonkeyCoyote" revision="android-12.1" />
</manifest>

After updating the file local_manifest.xml do another

repo sync

to sync the added repositories. This time the download will be faster because only the two additional repos will be downloaded.

Now you can start the build with these commands:


. build/envsetup.sh

brunch omni_zenfone8-user

in the directory with the downloaded repositories (use the command "breakast" instead of "brunch" to see other possible targets)

Note that the first time the compile process will take 4 hours or more. And keep in mind that the compile process will need additional 140 GB for the temporary output files.



If everything is fine there will be a ZIP file with your own CustomROM image in the directory ./out/target/product/zenfone8/ when the compile script is done, e.g:


[xtrnaw7@t15g /data/develop/android/OmniROM]$ ls -ltr out/target/product/zenfone8/omni-12-20220621-zenfone8-HOMEMADE.zip
-rw-rw-r--. 25 xtrnaw7 xtrnaw7 1253703465 Jun 25 10:03 out/target/product/zenfone8/omni-12-20220621-zenfone8-HOMEMADE.zip
[xtrnaw7@t15g /data/develop/android/OmniROM]$

That image can now be installed on the Zenfone 8 using the LineageOS Recovery or TWRP.


How to create an OmniROM image with MicroG
How to create an OmniROM image with MicroG

To create an OmniROM image with MicroG these additional steps are neccesarry:

Add the repo with the prebuild MicroG apks, android_prebuilts_prebuiltapks, to your local_manifests.xml file, e.g:

[xtrnaw7@t15g /data/develop/android/OmniROM]$ cat .repo/local_manifests/local_manifest.xml
<?xml version="1.0" encoding="UTF-8"?>

<manifest>

<remote name="DonkeyCoyote"
fetch="https://github.com/DonkeyCoyote" />
<project path="device/asus/zenfone8" name="android_device_asus_zenfone8" remote="omnirom" revision="android-12.0" />
<project path="vendor/asus" name="proprietary_vendor_asus" remote="DonkeyCoyote" revision="android-12.1" />
<project path="vendor/microg" name="android_prebuilts_prebuiltapks" remote="omnirom" revision="android-12.0" />
</manifest>
[xtrnaw7@t15g /data/develop/android/OmniROM]$


Do another repo sync to download the repository for MicroG:

repo sync

and create the CustomROM using these instructions:

export ROM_BUILDTYPE=MICROG

brunch omni_zenfone8-user


This will create an OmniROM Image with MicroG already installed, e.g:

[xtrnaw7@t15g /data/develop/android/OmniROM]$ ls -ltr out/target/product/zenfone8/omni-12-20220621-zenfone8-MICROG.zip
-rw-rw-r--. 25 xtrnaw7 xtrnaw7 1253703465 Jun 25 10:03 out/target/product/zenfone8/omni-12-20220621-zenfone8-MICROG.zip
[xtrnaw7@t15g /data/develop/android/OmniROM]$




How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM


URL: https://forum.xda-developers.com/t/how-to-use-the-hardware-test-app-from-asus-on-a-zenfone-running-a-customrom.4461533/

How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM
How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM

The Hardware Test App from ASUS for the Zenfone 8 can also be used on a ASUS Zenfone 8 running a CustomROM.

But to get the App working on a CustomROM some efforts are neccessary.

The ASUS Hardware Test App needs the permission to modify system settings. To get this permission the app must be signed with the platform certificate used for the running Android OS.
And because these certificates are not available for the public for all public available CustomROMs (for some very good reasons ...) you must compile your own CustomROM for using the ASUS Hardware Test App on a CustomROM.


So -- for those who still want to continue: Here are the steps neccessary to run the Hardware Test App from ASUS for the Zenfone 8 on a phone running a CustomROM :


First copy the apk with the ASUS Hardware Test App from a Zenfone 8 running the original Android 12 from ASUS to your PC.


This is the file

/system/apps/SMMI_TEST/SMMI_TEST.apk?

on the phone running the ASUS Android OS.

Now it's neccessary to sign the App with the platform key from your CustomROM:


In the OmniROM (and I assume that's also true for other AOSP based CustomROMs) the neccessary files, platform.pk8 and platform.x509.pem, are in the directory

./build/make/target/product/security

in your build tree for the CustomROM, e.g.

[xtrnaw7@t15g /data/develop/android/OmniROM]$ ls -l ./build/make/target/product/security/platform.*
-rw-------. 1 xtrnaw7 xtrnaw7 1219 Jun 25 09:39 ./build/make/target/product/security/platform.pk8
-rw-rw-r--. 1 xtrnaw7 xtrnaw7 1460 Jun 25 09:39 ./build/make/target/product/security/platform.x509.pem
[xtrnaw7@t15g /data/develop/android/OmniROM]$


Now re-sign the apk file using these commands:

# remove the current certificate files from the apk (probably not neccessary -- but shouldn't harm)
#
zip -d SMMI_TEST.apk META-INF/CERT.SF META-INF/CERT.RSA

# do a zip align for the apk and write the output to SMMI_TEST1.apk
#
# (zipalign is part of the OTA tools)
#
/data/develop/android/otatools/bin/zipalign 4 SMMI_TEST.apk SMMI_TEST1.apk


# test the result (there should be NO output from this command)
#
/data/develop/android/otatools/bin/zipalign -c 4 SMMI_TEST1.ap


# and now sign the apk with the platform key from the development tree for your self compiled CustomROM
# (apksigner.jar is part of the Sdk from Google for Android)
#
java -jar ./Android/Sdk/build-tools/33.0.0/lib/apksigner.jar sign --key platform.pk8 --cert platform.x509.pem SMMI_TEST1.apk


That's it . The re-signed apk file SMMI_TEST1.apk should work on your CustomROM


To test the signed apk do:

Copy the signed apk to the phone running your self compiled CustomROM and issue

ls -l /sdcard/Download/SMMI_TEST1.apk
cat /sdcard/Download/SMMI_TEST1.apk | pm install -S 25733396



If you get an error like this

130|ASUS_I006D:/ # ls -l /sdcard/Download/SMMI_TEST1.apk
-rw-rw---- 1 u0_a111 media_rw 25733396 2022-08-04 19:02 /sdcard/Download/SMMI_TEST1.apk
ASUS_I006D:/ #
ASUS_I006D:/ # cat /sdcard/Download/SMMI_TEST1.apk | pm install -S 25733396
Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Reconciliation failed...: Reconcile failed: Package com.asus.atd.smmitest has no signatures that match those in shared user android.uid.system; ignoring!]
1|ASUS_I006D:/ #   


something went wrong signing the apk. Just do it again.


To install the apk do:

If not already done:

Compile your own CustomROM (using the certificates used to sign the ASUS Hardware Test App!) and install it on the ASUS Zenfone 8. (see How to compile the OmniROM for the ASUS Zenfone 8 for how to compile the OmniROM)

Install Magisk on your phone running the self compiled CustomROM

Simulate a Magisk Module using these commands:


adb shell su - -c mkdir -p /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST

adb push SMMI_TEST1.apk /sdcard/Download/

adb shell su - -c cp /sdcard/Download/SMMI_TEST1.apk /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk

adb shell su - -c chmod o+r /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk

and reboot the phone

adb reboot


After the reboot the ASUS Hardware Test App should be visible in the directory /system/app, e.g.

130|ASUS_I006D:/ # find /system/app/SMMI_TEST/
/system/app/SMMI_TEST/
/system/app/SMMI_TEST/SMMI_TEST1.apk
ASUS_I006D:/ #

To execute the ASUS Hardware Test App do

# open a shell on the ASUS Zenfone 8 (either local or via "adb shell"), become root user

su -

and execute

# switch SELinux to permissive mode (I currently do not know the neccessary SELinux policies to avoid this step ...)
#
setenforce 0

# and start the ASUS Hardware Test App from within the shell
#
am start -n com.asus.atd.smmitest/com.asus.atd.smmitest.main.MAIN

Do not forget to enable SELinux enforcing mode after the tests are done (or reboot the phone ...)

# switch SELinux to permissive mode (I currenlty do not know the neccessary SELinux policies to avoid this step ...)
#
setenforce 


Sample Script to start the ASUS Hardware Test App


# simple script to start the ASUS Hardware App

CUR_SELINUX_STATUS="$( getenforce )"
CUR_USERID=$( id -u -n )
RESTORE_SELINUX_STATE="false"

if [ "${CUR_SELINUX_STATUS}"x != "Permissive"x ] ; then

if [ "${CUR_USERID}"x != "root"x ] ; then
echo "Either start this script as user \"root\" or set the SELinux mode to \"permissive\" using the command \"setenforce 0\" before starting this script"
exit 1
fi
echo "Setting the SELinux mode to \"Permissive\" ..."
setenforce 0
RESTORE_SELINUX_STATE="true"
else
echo "The SELinux mode is already \"Permissive}\" "
fi

am start -n com.asus.atd.smmitest/com.asus.atd.smmitest.main.MAIN 2>&1 | tee /sdcard/Download/test.out

if [ ${RESTORE_SELINUX_STATE} = true ] ; then
echo "Press return when done with the tests .."
read USER_INPUT
echo "Setting the SElinux mode back to \"Enforcing\" ...."
setenforce 1
else
echo "Do not forget to set the SELinxu mode back to \"Enforcing\" using the command \"setenforce 1\" "
fi



Trouble Shooting

If the boot process of the phone hangs after adding the pseudo Magisk Module for the ASUS Hardware Test App do:

# connect to the phone via adb (that should work!)
#
adb shell

# become root user
#
su -

# delete the file with the AUS Hardware Test App
#
rm /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk

# and reboot the phone
#
reboot

Most probably something went wrong signing the app or you did not do the zip align (there should be some messages visible in logcat to find the reason for the boot loop; check the output of logcat before rebooting the phone)

A useful test to find reason for the boot loop is :

# try to install the apk as root user
#
su -

# and then
#
setenforce 0
pm install /sdcard/Download/SMMI_TEST.apk


If booting the phone works but the App does not start make sure that the SELinux status is permissive.
 



How to run a script at every boot using Magisk


URL: https://forum.xda-developers.com/t/how-to-run-at-script-a-every-boot-using-magisk.4454493/

How to run at script a every boot using Magisk

How to run a script at every boot using Magisk

Note:


I tested the instructions below with Magisk 24.3 . They may or may not work with other versions of Magisk


Another very useful feature from Magisk that can also be used without creating a Magisk Module is the ability to start scripts after booting the phone:

To execute scripts after rebooting the phone just copy them to one of the directories

/data/adb/post-fs-data.d
/data/adb/service.d

on the phone, make the script executable (chmod +x scriptname) and reboot the phone.

(See also https://github.com/topjohnwu/Magisk/blob/master/docs/guides.md#boot-scripts)


Because the mapping will be done while booting the phone it will also survive updating the OS on the phone to a new version as long as the user data is not deleted and Magisk is installed.

To remove the script just delete the script and reboot the phone.

In case the phone does not boot anymore after adding the script just boot the phone from a recovery with adb support, for example from the TWRP:


# boot the phone into the bootloader and then do

sudo fastboot boot /data/backup/ASUS_ZENFONE8/twrp/twrp-3.6.1_12-1-I006D.img

Then connect via "adb shell" to the phone and delete the script .

I used this method to correct the SELinux context for the NFC device in the first version of AospExtended 9.0 for the ASUS Zenfone 8 (the device tree is recreated from scratch each time the phone boots so the change must be done after every reboot):


cat /data/adb/service.d/correct_dev_pn553.sh
#!/system/bin/sh

NFC_DEVICE="/dev/pn553"

echo ""
echo "The SELinux context for \"${NFC_DEVICE}\" is now:"
ls -lZ ${NFC_DEVICE}
echo ""
echo "Correcting the SELinux context for the NFC device \"${NFC_DEVICE}\" ..."
chcon -v u:object_r:nfc_device:s0 /dev/pn553
echo ""
echo "The SELinux context for \"${NFC_DEVICE}\" is now:"
ls -lZ ${NFC_DEVICE}

Again, if the script is tested and working you should create a Magisk module for it.

 



How to install Magisk into the boot partition using a script


URL: https://forum.xda-developers.com/t/how-to-install-magisk-into-the-boot-partition-using-a-script.4456621/

How to install Magisk into the boot partition using a script


I wrote a little shell script for Linux (bash) to add Magisk to the boot partition of a phone without user intervention called install_magisk_via_twrp.sh.

This is useful for example to re-install Magisk into the boot partition after an OS upgrade .
The script uses only fastboot, adb, a recovery image (e.g. TWRP), and the patch script from Magisk to re-install Magisk into the boot partition.

Notes

Note that the script version 1.1.0.0 or newer also works if the phone is secured via PIN or something similar.


The usage for the script is:

[xtrnaw7@t15g ~]$ /data/backup/Android/scripts_on_linux/install_magisk_via_twrp.sh -h
/data/backup/Android/scripts_on_linux/install_magisk_via_twrp.sh version - 1.1.0.0 - add Magisk to the boot partition of a phone running Android using TWRP

Usage

install_magisk_via_twrp.sh [boot_slot] [dd|fastboot] [twrp_image]

All parameter are optional

The parameter "boot_slot" can be a, b, active, inactive; current, or next; default is the current boot slot of the phone

Use the parameter "dd" to request repatching via dd in an adb session ; use the parameter "fastboot" to request repatching via "fastboot"
Default is to use "fastboot" to flash the patched boot image

The parameter "twrp_image" can be used to define another TWRP image to use. The parameter is optional - the
default for "twrp_image" is hardcoded in the script (variable TWRP_IMAGE).
The default TWRP image of the script is the TWRP for the ASUS Zenfone 8.

The phone to patch must be attached via USB.
The phone can be either in fastboot mode, in normal mode with enabled adb support, or already booted from the TWRP image


To change some of the values used by the script you can set environment variables before starting the script:

Set the environment variable REBOOT to "yes" before starting the script to automatically reboot the phone after patching the new image
Set the environment variable REBOOT to "no" before starting the script to disable the automatic reboot after patching the new image

Set the environment variable SERIAL_NUMBER to the serial number of the phone to patch if there is more then one phone connected via USB

Set the environment variable ADB_OPTIONS to the options to be used with the adb command

Set the environment variable FASTBOOT_OPTIONS to the options to be used with the fastboot command

Set the environment variable DOWNLOAD_DIR_ON_PHONE to the data directory to use on the phone (def.: /sdcard/Download)


The default TWRP image to use is "/data/backup/ASUS_ZENFONE8/twrp/twrp-3.6.1_12-1-I006D.img"

[xtrnaw7@t15g ~]$

In the default the script will ask the user for input before rebooting the phone from the patched boot partition.

To disable this request call the script like this

REBOOT=yes install_magisk_via_twrp.sh

Additional infos

Prerequisites



Test Environment

Tested on an ASUS Zenfone 8 and with


Details


Notes [as of 06.06.2022]

For the ROMs based on Android 12 for the Asus Zenfone 8 the TWRP version 3.6.1_12 or newer is required .
Enter "/get working_twrp_for_a12" in the Telegram group "OminiROM-zenfone8" to get the download link for that version.
The official TWRP images from https://twrp.me/asus/zenfone8.html can not mount the filesystem for /data (at least I did not get that working with these TWRP versions ...)


Trouble Shooting

- Error message like this

 /data/adb/magisk/boot_patch.sh[211]: can't create /proc/self/fd/: Is a directory

can be ignored (these are only error messages from the function to print some additional messages)

- Patching the boot partition via "dd" fails sometimes for unknown reason so you should only use it if you know how to fix a damaged boot partition!

- Downloading the patched boot image via "adb pull" (neccessary for patching the boot partition using fastboot) sometimes fails for unknown reason:

So if you get an error message like this:

 [ 77%] /sdcard/Download/patched_boot_a.391985.img
ERROR: Error downloading the file "/sdcard/Download/patched_boot_a.391985.img" from the phone!
just restart the script again (or download the file and flash the boot partition manually)

- If the adb connection dies and there are error messages like this

 adb: insufficient permissions for device
restart the adb server using

 adb kill-server
if that does not work disconnect and reconnect the USB cable

 
Sample output of the script
[xtrnaw7@t15g /data/backup/Android/test]$ REBOOT=yes /data/backup/Android/scripts_on_linux/install_magisk_via_twrp.sh
/data/backup/Android/scripts_on_linux/install_magisk_via_twrp.sh version - 1.0.0.0 - add Magisk to the boot partition of a phone running Android using TWRP

Using the TWRP image hardcoded in the script: "/data/backup/ASUS_ZENFONE8/twrp/twrp-3.6.1_12-1-I006D.img"
Checking the script prerquisites ...
Checking if we have write access for the current working directory "/data/backup/Android/test" ...
The script is running as user "xtrnaw7" -- will use "sudo" for the fastboot commands ...
Will patch the boot partition on the attached phone with the serial number "M6AIB760D0939LX"
Using the options "-d -s M6AIB760D0939LX " for the adb commands
Using the options " -s M6AIB760D0939LX " for the fastboot commands
Checking for a connected phone booted into fastboot mode ...
No attached phone in fastboot mode found
Checking for an attached phone with working access via adb (USB) ...
Linux localhost 5.4.134-Omni-qgki-perf-gf14a22385 #1 SMP PREEMPT Sun Jun 5 01:23:33 CEST 2022 aarch64
.. found a phone connected via USB with working adb access
The phone is booted in normal mode
The installed OS is based on Android 12 (Sun Jun 5 01:13:58 CEST 2022); the description for the distribution is "omni_zenfone8-user 12 SP2A.220305.013.A3 20 release-keys"
The installed version of Magisk is com.topjohnwu.magisk versionCode 25000
Booting the phone into the fastboot mode now ...
Waiting up to 60 seconds for the boot into the fastboot mode ...
Booting the phone from the TWRP image "/data/backup/ASUS_ZENFONE8/twrp/twrp-3.6.1_12-1-I006D.img" now ...
Sending 'boot.img' (98304 KB) OKAY [ 5.456s]
Booting OKAY [ 10.359s]
Finished. Total time: 15.872s
Waiting up to 60 seconds for the boot of the phone ....
Retrieving the current boot slot from the phone ...
The current boot slot is "_a"
The boot slot to patch is "_a"
The boot partition to patch is "boot_a"
Checking if the Magisk patch script "boot_patch.sh" exists on the phone ....
-rwxr-xr-x 1 root root 5759 1970-01-25 14:20 //data/adb/magisk/boot_patch.sh
Checking if the download directory "/sdcard/Download" exists on the phone ....
/sdcard/Download
Creating the boot image file "/sdcard/Download/boot_a.857095.img" from the partition "/dev/block/by-name/boot_a" ...
196608+0 records in
196608+0 records out
100663296 bytes (96 M) copied, 0.307712 s, 312 M/s

Checking the result ...
-rw-rw---- 1 root media_rw 100663296 2022-06-10 13:04 /sdcard/Download/boot_a.857095.img
The check sums are:
The check sum of the boot partition "/dev/block/by-name/boot_a" on the phohe is "1215279987"
The check sum of th boot image file on the phone is "/sdcard/Download/boot_a.857095.img" is "1215279987"
Patching the boot image file "/sdcard/Download/boot_a.857095.img" ...

Note: The error message "can't create /proc/self/fd/: Is a directory" can be ignored

//data/adb/magisk/boot_patch.sh[87]: can't create /proc/self/fd/: Is a directory
Parsing boot image: [/sdcard/Download/boot_a.857095.img]
HEADER_VER [3]
KERNEL_SZ [42023424]
RAMDISK_SZ [14725305]
OS_VERSION [12.0.0]
OS_PATCH_LEVEL [2022-04]
PAGESIZE [4096]
CMDLINE []
KERNEL_FMT [raw]
RAMDISK_FMT [gzip]
VBMETA
//data/adb/magisk/boot_patch.sh[109]: can't create /proc/self/fd/: Is a directory
Loading cpio: [ramdisk.cpio]
//data/adb/magisk/boot_patch.sh[136]: can't create /proc/self/fd/: Is a directory
//data/adb/magisk/boot_patch.sh[148]: can't create /proc/self/fd/: Is a directory
Loading cpio: [ramdisk.cpio]
Add entry [init] (0750)
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Add entry [overlay.d/sbin/magisk32.xz] (0644)
Add entry [overlay.d/sbin/magisk64.xz] (0644)
Patch with flag KEEPVERITY=[false] KEEPFORCEENCRYPT=[false]
Loading cpio: [ramdisk.cpio.orig]
Backup mismatch entry: [init] -> [.backup/init]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk64.xz] -> [.backup/.rmlist]
Create directory [.backup] (0000)
Add entry [.backup/.magisk] (0000)
Dump cpio: [ramdisk.cpio]
//data/adb/magisk/boot_patch.sh[211]: can't create /proc/self/fd/: Is a directory
Parsing boot image: [/sdcard/Download/boot_a.857095.img]
HEADER_VER [3]
KERNEL_SZ [42023424]
RAMDISK_SZ [14725305]
OS_VERSION [12.0.0]
OS_PATCH_LEVEL [2022-04]
PAGESIZE [4096]
CMDLINE []
KERNEL_FMT [raw]
RAMDISK_FMT [gzip]
VBMETA
Repack to boot image: [new-boot.img]
HEADER_VER [3]
KERNEL_SZ [42023424]
RAMDISK_SZ [15105154]
OS_VERSION [12.0.0]
OS_PATCH_LEVEL [2022-04]
PAGESIZE [4096]
CMDLINE []
Checking the result ...
-rw-r--r-- 1 root root 100663296 2022-06-10 13:04 //data/adb/magisk/new-boot.img
The patched boot image is "/sdcard/Download/patched_boot_a.857095.img"
Waiting now 5 seconds ...
Patching the partition "/dev/block/by-name/boot_a" from the patched boot image file "/sdcard/Download/patched_boot_a.857095.img" via fastboot ...
Downloading the patched boot image "/sdcard/Download/patched_boot_a.857095.img" from the phone ...
/sdcard/Download/patched_boot_a.857095.img: 1 file pulled, 0 skipped. 42.0 MB/s (100663296 bytes in 2.283s)
The check sum of the patched boot image "/sdcard/Download/patched_boot_a.857095.img" on the phohe is "2604803976"
The check sum of the downloaded patched boot image "patched_boot_a.857095.img" is "2604803976"
Booting the phone into the fastboot mode now ...
Waiting up to 60 seconds for the boot into the fastboot mode ...
Flashing the partition "boot_a" with the patched image "patched_boot_a.857095.img" ...
Sending 'boot_a' (98304 KB) OKAY [ 5.380s]
Writing 'boot_a' OKAY [ 0.403s]
Finished. Total time: 5.845s
Rebooting the phone now ...
Rebooting OKAY [ 0.000s]
Finished. Total time: 0.251s
 


Update 03.07.2022 /bs


The script now uses the directory /tmp for temporary file if the directory /sdcard/Download is not available. Therefor it will also work if the phone is secured by a PIN or something similar.
 


How to change files in the directory /system with Magisk


URL: https://forum.xda-developers.com/t/how-to-change-files-in-the-directory-system-with-magisk.4454489/

How to change files in the directory /system with Magisk
How to change files in the directory /system with Magisk

Note:


I tested the instructions below with Magisk 24.3 and 25.0. They may or may not work with other versions of Magisk


The filesystem for /system is normally mounted read-only and it's difficult to change files in that filesystem.


One possible solution to change files in /system is to create a Magisk module for this task.

For testing if a Magisk Module would work like expected you can "simulate" the module :


Install Magisk (see https://github.com/topjohnwu/Magisk), enable root access for the shell in Magisk and enable access via adb (this can be done in the "Developer Options" in the system settings)


Next connect to the phone using the command

adb shell

and become root user

su -

Now create a sub directory in the directory

/data/adb/modules

e.g.

ASUS_I006D:/ # ls -ld /data/adb/modules/*
drwxrws--- 3 u0_a118 media_rw 3452 2022-05-30 12:12 /data/adb/modules/playstore
ASUS_I006D:/ #


Then copy the new files for the directory /system to that directory (/data/adb/modules/<modulename>/ is equal here to / on the phone)

Example:

ASUS_I006D:/ # find /data/adb/modules/playstore
/data/adb/modules/playstore
/data/adb/modules/playstore/system
/data/adb/modules/playstore/system/etc
/data/adb/modules/playstore/system/etc/permissions
/data/adb/modules/playstore/system/etc/permissions/com.android.vending.xml
/data/adb/modules/playstore/system/priv-app
/data/adb/modules/playstore/system/priv-app/Phonesky
/data/adb/modules/playstore/system/priv-app/Phonesky/lib
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libbrotli.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libconscrypt_jni.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libcronet.85.0.4181.5.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libgame_sdk_device_info_jni.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libphonesky_data_loader.so
/data/adb/modules/playstore/system/priv-app/Phonesky/lib/arm/libtensorflowlite_jni.so
/data/adb/modules/playstore/system/priv-app/Phonesky/Phonesky.apk
/data/adb/modules/playstore/system/priv-app/FakeStore
/data/adb/modules/playstore/system/priv-app/FakeStore/oat
/data/adb/modules/playstore/system/priv-app/FakeStore/oat/arm64
/data/adb/modules/playstore/system/priv-app/FakeStore/oat/arm64/FakeStore.odex
/data/adb/modules/playstore/system/priv-app/FakeStore/oat/arm64/FakeStore.vdex
/data/adb/modules/playstore/system/priv-app/FakeStore/FakeStore.apk
ASUS_I006D:/ #

Note:

Magisk will "replace" existing directories and files in /system with the files in that directory by using bind mounts.


Now reboot the phone.

After the reboot all files in /data/adb/modules/<modulename> will be mapped to /system by Magisk, e.g:

ASUS_I006D:/ # find /system/priv-app/Phonesky/
/system/priv-app/Phonesky/
/system/priv-app/Phonesky/lib
/system/priv-app/Phonesky/lib/arm
/system/priv-app/Phonesky/lib/arm/libbrotli.so
/system/priv-app/Phonesky/lib/arm/libconscrypt_jni.so
/system/priv-app/Phonesky/lib/arm/libcronet.85.0.4181.5.so
/system/priv-app/Phonesky/lib/arm/libgame_sdk_device_info_jni.so
/system/priv-app/Phonesky/lib/arm/libphonesky_data_loader.so
/system/priv-app/Phonesky/lib/arm/libtensorflowlite_jni.so
/system/priv-app/Phonesky/Phonesky.apk
ASUS_I006D:/ #

ASUS_I006D:/ # find /system/priv-app/FakeStore/
/system/priv-app/FakeStore/
/system/priv-app/FakeStore/oat
/system/priv-app/FakeStore/oat/arm64
/system/priv-app/FakeStore/oat/arm64/FakeStore.vdex
/system/priv-app/FakeStore/oat/arm64/FakeStore.odex
/system/priv-app/FakeStore/FakeStore.apk
ASUS_I006D:/ #


Because the mapping will be done while booting the phone it will also survive updating the OS on the phone to a new version as long as the user data is not deleted and Magisk is installed.


This method to replace files in /system simulates a module in Magisk so if everything is okay I strongly recommend to create a "real" Magisk Module with the new files for /system



Update 10.06.2022

This method can also be used to replace files in the directories /vendor, /product, or /system_ext:

from https://topjohnwu.github.io/Magisk/guides.html:

The system folder​

All files you want to replace/inject should be placed in this folder. This folder will be recursively merged into the real /system; that is: existing files in the real /system will be replaced by the one in the module’s system, and new files in the module’s system will be added to the real /system.


If you place a file named .replace in any of the folders, instead of merging its contents, that folder will directly replace the one in the real system. This can be very handy for swapping out an entire folder.
But this seems to work only to replace existing files in these directories.

If something does not work check the log file in /cache :

/cache/magisk.log


Update 12.06.2022

The Magisk Module to install the patched Playstore used in this example can be downloaded here

http://bnsmb.de/files/public/Android/PlayStore_for_MicroG.zip

see also here



How to backup the data from the phone using rsync and ssh (including some hints for using sshd on an Android phone)


URL:  https://forum.xda-developers.com/t/how-to-backup-the-data-from-the-phone-using-rsync-and-ssh-including-some-hints-for-using-sshd-on-an-android-phone.4462327/


How to backup the data from the phone using rsync and ssh (including some hints for using sshd on an Android phone)
How to backup the data from the phone using rsync and ssh (including some hints for using sshd on an Android phone)

Like for all computer it's important to have a backup of the data on the phone.

For those who like me don't like to save their private data in one of the suspicious clouds there is a solution with standard Linux tools:

Use rsync and ssh to backup the data from the phone to your local workstation (see the man page for rsync for details regarding rsync and why it is useful for this task)


The neccessary tools for Android for this method can be installed with the Magisk Module MagiskSSH.

Download the Magisk Module with MagiskSSH from here

https://gitlab.com/d4rcm4rc/MagiskSSH_releases

Copy the ZIP file with the Magisk Module to the phone :

adb push magisk_ssh_v0.14.zip /sdcard/Download/

and install it via the module installation from within the Magisk App or manuell using :

adb shell su - -c /data/adb/magisk/magisk64 --install-module /sdcard/Download/magisk_ssh_v0.14.zip

Sample output of the installation:

ASUS_I006D:/ # /data/adb/magisk/magisk64 --install-module /sdcard/Download/magisk_ssh_v0.14.zip
- Current boot slot: _a
- Device is system-as-root
*******************************
OpenSSH for Android
*******************************
[0/7] Preparing module directory
[1/7] Extracting architecture unspecific module files
[2/7] Extracting libraries and binaries for arm64
[3/7] Configuring library path wrapper
[4/7] Recreating symlinks
[5/7] Creating SSH user directories
[6/7] Found sshd_config, will not copy a default one
[7/7] Cleaning up
- Setting permissions
- Done
ASUS_I006D:/ #

A reboot is required now.

adb shell reboot

For the next tasks open a adb shell and become root user.


Next create the authorized_keys file for the user root :

touch /data/ssh/root/.ssh/authorized_keys
chmod 600 /data/ssh/root/.ssh/authorized_keys

and add your public ssh key to the file /data/ssh/root/.ssh/authorized_keys.

To make sure that the keys and other data files for the MagiskSSH module are not removed while deinstalling the module you should create the file /data/ssh/KEEP_ON_UNINSTALL:

touch /data/ssh/KEEP_ON_UNINSTALL

The MagiskSSH module also installs a service to start sshd after each reboot: to disable this start create the file /data/ssh/no-autostart:

touch /data/ssh/no-autostart

To manually start or stop the sshd use the script /data/adb/modules/ssh/opensshd.init :

# start the sshd (as user root)
#
/data/adb/modules/ssh/opensshd.init start

# to stop the sshd (as user root)
#
/data/adb/modules/ssh/opensshd.init stop

Now test the access via ssh from your Linux workstation:


ssh -l root <phone_ip_address>  id

To retrieve the IP address of the phone this command can be used:

PHONE_IP_ADDRESS=$( adb shell ifconfig wlan0 | grep "inet addr:" | sed -e "s/.*inet addr://g" -e "s/[[:space:]]*Bcast.*//g" )


example :

[xtrnaw7@t15g ~]$ ssh -l root ${PHONE_IP_ADDRESS} id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
[xtrnaw7@t15g ~]$

Now you can use rsync to backup the data from the phone, e.g. to backup the photos from the phone do :


# on your local Linux workstation do:
# start the sshd on the phone via adb if not already running
#
adb shell su - -c /data/adb/modules/ssh/opensshd.init start

# retrieve the current IP address from the phone
#
PHONE_IP_ADDRESS=$( adb shell ifconfig wlan0 | grep "inet addr:" | sed -e "s/.*inet addr://g" -e "s/[[:space:]]*Bcast.*//g" )

# backup the new photos from the phone to the Linux workstation (rsync only copies new files from the phone)
# to the local directory /data/backup/ASUS_ZENFONE8/DCIM
#
rsync -av --rsync-path /data/adb/modules/ssh/usr/bin/rsync root@${PHONE_IP_ADDRESS}:/sdcard/DCIM/ /data/backup/ASUS_ZENFONE8/DCIM

# optional stop the sshd on the phone via adb
#
adb shell su - -c /data/adb/modules/ssh/opensshd.init stop

Note: The sshd configuration file used is /data/ssh/sshd_config


Sample script to backup all data in the directory /sdcard
##!/bin/bash
#
# simple script to backup the data of an phone using adb, ssh, and rsync
#
# History
#  27.06.2022 /bs
#    initial release
#


# for testing
#
#RSYNC_OPTIONS="${RSYNC_OPTIONS} --dry-run"

RSYNC_OPTIONS="${RSYNC_OPTIONS} --del "

# default is to backup the phone connected via adb over LAN
#
[ $# -ne 0 ] && ADB_OPTIONS="$*" || ADB_OPTIONS="-e"

# retrieve the serial number of the attached phone
#
SERIAL_NO="$( adb ${ADB_OPTIONS} shell getprop  ro.serialno )"
if [ "${SERIAL_NO}"x = ""x ] ; then
  echo "ERROR: Can not read the serial number of the connected phone"
  exit 89
fi

VENDOR_MODEL="$( adb ${ADB_OPTIONS} shell getprop  ro.product.vendor.model )"

BACKUP_DIR="/data/backup/ASUS_ZENFONE8/data_backup/${VENDOR_MODEL}_${SERIAL_NO}"

if [ ! -d "${BACKUP_DIR}" ] ; then
  echo "ERROR: The directory \"${BACKUP_DIR}\" does not exist"
  exit 99
fi

PHONE_IP_ADDRESS="$( adb ${ADB_OPTIONS} shell ifconfig wlan0 | grep "inet addr:" | sed  -e "s/.*inet addr://g" -e "s/[[:space:]]*Bcast.*//g" )"
if [ "${PHONE_IP_ADDRESS}"x = ""x ] ; then
  echo "ERROR: Can not detect the IP address of the phone"
  exit 100
fi
 
echo "Updating a backup of the data on the phone with the serial number \"${SERIAL_NO}\" and the IP \"${PHONE_IP_ADDRESS}\" to the directory \"${BACKUP_DIR}\" ..."
 
set -x

# start the sshd if neccessary
#
adb ${ADB_OPTIONS} shell su - -c /data/adb/modules/ssh/opensshd.init start

# do the backup
#
time rsync ${RSYNC_OPTIONS} -av --rsync-path /data/adb/modules/ssh/usr/bin/rsync   root@${PHONE_IP_ADDRESS}:/sdcard/  "${BACKUP_DIR}/"

# stop the sshd
#
adb ${ADB_OPTIONS} shell su - -c /data/adb/modules/ssh/opensshd.init stop
set +x
 


How to enable access via ssh for non-root user
How to enable access via ssh for non-root user

In the standard configuration installed by MagiskSSH ssh access is only allowed as user root because the ssh keys are in the directory /data and all non-root user can not read files in the directory /data. Therefor some efforts are neccessary to add ssh access for non-root user.

e.g. To enable the ssh access for the user shell do:

To configure ssh access for the user shell we must create a .ssh directory for the user shell in a directory tree owned by the user shell. The only directory on the phone owned by the user shell that can be used for this purpose is /storage :

ASUS_I006D:/ # ls -ld /storage
drwx--x--- 4 shell everybody 80 2022-06-26 18:37 /storage
ASUS_I006D:/ #

But unfortunately all files and directories in this directory are temporary and will be deleted after a reboot of the phone.

Therefor we configure a startup script in Magisk to create this directory tree after each reboot, e.g.

/data/adb/service.d/create_ssh_dir_for_shell.sh:

# /data/adb/service.d/create_ssh_dir_for_shell.sh
#
mkdir -p /storage/shell/.ssh

chmod -R 700 /storage/shell/

touch /storage/shell/.ssh/authorized_keys

echo "<ssh_public_key>" > /storage/shell/.ssh/authorized_keys

chmod 600 /storage/shell/.ssh/authorized_keys

chown -R shell:shell /storage/shell

To test the script just execute it one time manually as user root.

su - -c sh data/adb/service.d/create_ssh_dir_for_shell.sh

Now create a backup of the sshd config file

su - -c cp /data/ssh/sshd_config /storage/ssh/sshd_config.org.$$

and add these lines at the end of the file /data/ssh/sshd_config

Match User shell
AuthorizedKeysFile /storage/shell/.ssh/authorized_keys

Restart the sshd if it's already running


Now test the access as user shell, example:

[xtrnaw7@t15g ~]$ ssh -l shell 192.168.1.148 id
uid=2000(shell) gid=2000(shell) groups=2000(shell) context=u:r:magisk:s0
[xtrnaw7@t15g ~]$

The reason for this config is the setting "StrictMode yes" in the sshd config file /data/ssh/sshd_config (see the man page for sshd_config for details). So another "solution" is to change this setting:

With the setting "StrictModes no" in the file sshd_config the directory with the authorized_keys file for the non-root users can be anywhere (for example in /sdcard/shell)

Execute as user root:


sed -i -e "s/.*StrictModes.*//g" -e "s/UsePrivilegeSeparation/StrictModes no\nUsePrivilegeSeparation/g" /data/ssh/sshd_config

and change the entry in the file /data/ssh/sshd_config for the authorized_keys file for the user shell, for example:


Match User shell
AuthorizedKeysFile /sdcard/shell/.ssh/authorized_keys

Afterwards restart the sshd:


/data/adb/modules/ssh/opensshd.init stop
/data/adb/modules/ssh/opensshd.init start


Now create the directories and files neccessary for the ssh access (see above) in the directory /sdcard/shell:


SUS_I006D:/ # find /sdcard/shell -exec ls -ld {} \;
drwxrws--- 3 u0_a118 media_rw 3452 2022-06-26 18:32 /sdcard/shell
drwxrws--- 2 u0_a118 media_rw 3452 2022-06-26 18:32 /sdcard/shell/.ssh
-rw-rw---- 1 u0_a118 media_rw 408 2022-06-26 18:32 /sdcard/shell/.ssh/authorized_keys
ASUS_I006D:/ #

and the access as user shell via ssh should work   



How to install packages (apk files) for Android via script


URL: https://forum.xda-developers.com/t/how-to-install-packages-apk-files-for-android-via-script.4464987/

How to install packages (apk files) for Android via script
Sometimes, for example after a reinstallation of the phone from scratch, it's quite useful to install all the apps via an script.

The Android command to do that is

pm install [apk_file]


But unfortunately that does not work, neither as user shell (due to missing file access rights) nor as user root:


ASUS_I006D:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
ASUS_I006D:/ #
ASUS_I006D:/ # pm install /sdcard/Download/EssentialApps/MiXplorer_v6.58.4-API29_B22020920.apk                                                    
avc:  denied  { read } for  scontext=u:r:system_server:s0 tcontext=u:object_r:fuse:s0 tclass=file permissive=0
System server has no access to read file context u:object_r:fuse:s0 (from path /sdcard/Download/EssentialApps/MiXplorer_v6.58.4-API29_B22020920.apk, context u:r:system_server:s0)
Error: Unable to open file: /sdcard/Download/EssentialApps/MiXplorer_v6.58.4-API29_B22020920.apk
Consider using a file under /data/local/tmp/
Error: Can't open file: /sdcard/Download/EssentialApps/MiXplorer_v6.58.4-API29_B22020920.apk

Exception occurred while executing 'install':
java.lang.IllegalArgumentException: Error: Can't open file: /sdcard/Download/EssentialApps/MiXplorer_v6.58.4-API29_B22020920.apk
    at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:572)
    at com.android.server.pm.PackageManagerShellCommand.doRunInstall(PackageManagerShellCommand.java:1337)
    at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1303)
    at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:193)
    at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
    at android.os.ShellCommand.exec(ShellCommand.java:38)
    at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:24812)
    at android.os.Binder.shellCommand(Binder.java:950)
    at android.os.Binder.onTransact(Binder.java:834)
    at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4818)
    at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:8887)
    at android.os.Binder.execTransactInternal(Binder.java:1184)
    at android.os.Binder.execTransact(Binder.java:1143)
255|ASUS_I006D:/ #



After a little searching on the Internet I found a very useful workaround on this page:

https://stackoverflow.com/questions/50540334/install-apk-using-root-handling-new-limitations-of-data-local-tmp-folder


pm install also supports the installation of a package piped to stdin, e.g


cat [package_file] | pm install -S [package_size]


Example:

127|ASUS_I006D:/sdcard/Download # ls -l OmniStore.apk                                                                                             
-rw-rw---- 1 u0_a120 media_rw 4601419 2022-07-03 16:37 OmniStore.apk
ASUS_I006D:/sdcard/Download #
ASUS_I006D:/sdcard/Download # cat OmniStore.apk  | pm install -S 4601419                                                                          
Success
ASUS_I006D:/sdcard/Download #



Or, on the PC:

[xtrnaw7@t15g /data/backup/Android]$ adb shell id
uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),1078(ext_data_rw),1079(ext_obb_rw),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:shell:s0
[xtrnaw7@t15g /data/backup/Android]$

[xtrnaw7@t15g /data/backup/Android]$ cat EssentialApps/F-Droid.apk | adb shell pm install -S $( ls -l EssentialApps/F-Droid.apk | awk '{ print $5 }' )
Success
[xtrnaw7@t15g /data/backup/Android]$



So I wrote a little script to install one or more packages on an Android phone using this method.

The script can run on a PC with a connected phone with a working adb connection or in a shell on the phone

The usage of the script is:

#
# Usage on a phone:
#
# install_apk.sh [apk1|dir1 ... apk#|dir#]
#
# Usage on a PC:
#
# install_apk.sh [options_for_adb --] [apk1|dir1 ... apk#|dir#]
#
# apk# is the name of an apk file to install; dir# is a directory with apk files
# If a parameter is a directory the script will install all files with the extension .apk from that directory
#
# The options for adb are optional; the script will not check the options for adb
# the number of apk files or directories is only limited by the maxium parameter supported by the used shell.
#
# Set the variable PM_INSTALL_OPTIONS with additional options for the "pm install" command before starting the
# script if neccessary
#
# Prerequisites
#   The packages to install must exist as file either on the PC or on the phone
#   A shell on the phone or via adb command is required
#   root access is NOT neccessary
#



Sample script output for running on a phone:
ASUS_I006D:/storage/emulated/0/Download $ sh ./install_apk.sh myapps/ OmniStore.apk                                                               
Running on a phone
Directory found in the parameter: Installing all apk files found in the directory "myapps/"
The apks will be installed on the phone model ASUS_I006D with the serial number M6AIB760D0939LX
Installing these apks

 myapps//Magisk-25.1_25100.apk
myapps//Magisk-v25.0.apk
myapps//MiXplorer_v6.58.4-API29_B22020920.apk
myapps//Notecase_Pro_1.2.2.apk
myapps//com.keramidas.TitaniumBackupAddon_v1.apk
myapps//com.keramidas.TitaniumBackup_v417.apk
OmniStore.apk


Installing the apk "myapps//Magisk-25.1_25100.apk" ...
Success
"myapps//Magisk-25.1_25100.apk" succcessfully installed

Installing the apk "myapps//Magisk-v25.0.apk" ...
Failure [INSTALL_FAILED_VERSION_DOWNGRADE: Package Verification Result]
ERROR: Error installing the apk  "myapps//Magisk-v25.0.apk"

Installing the apk "myapps//MiXplorer_v6.58.4-API29_B22020920.apk" ...
Success
"myapps//MiXplorer_v6.58.4-API29_B22020920.apk" succcessfully installed

Installing the apk "myapps//Notecase_Pro_1.2.2.apk" ...
Success
"myapps//Notecase_Pro_1.2.2.apk" succcessfully installed

Installing the apk "myapps//com.keramidas.TitaniumBackupAddon_v1.apk" ...
Success
"myapps//com.keramidas.TitaniumBackupAddon_v1.apk" succcessfully installed

Installing the apk "myapps//com.keramidas.TitaniumBackup_v417.apk" ...
Success
"myapps//com.keramidas.TitaniumBackup_v417.apk" succcessfully installed

Installing the apk "OmniStore.apk" ...
Success
"OmniStore.apk" succcessfully installed

Installation summary
====================

6 package(s) successfully installed:
 
myapps//Magisk-25.1_25100.apk
myapps//MiXplorer_v6.58.4-API29_B22020920.apk
myapps//Notecase_Pro_1.2.2.apk
myapps//com.keramidas.TitaniumBackupAddon_v1.apk
myapps//com.keramidas.TitaniumBackup_v417.apk
OmniStore.apk


1 package(s) not installed:
 
myapps//Magisk-v25.0.apk


ASUS_I006D:/storage/emulated/0/Download $
 


Sample script output for running on a PC:
[xtrnaw7@t15g /data/backup/Android/myapps]$ /data/develop/android/install_apk.sh -d  -- /data/backup/Android/myapps/ ./Notecase/Notecase_Pro_1.2.1.apk
Running on a PC
Using adb with the options " -d " to install the packages
Directory found in the parameter: Installing all apk files found in the directory "/data/backup/Android/myapps/"
The apks will be installed on the phone model ASUS_I006D with the serial number M6AIB760D0939LX
Installing these apks

 /data/backup/Android/myapps//com.android.keepass_196.apk
/data/backup/Android/myapps//com.keramidas.TitaniumBackup_v417.apk
/data/backup/Android/myapps//com.matoski.adbm_v27.apk
/data/backup/Android/myapps//F-Droid.apk
/data/backup/Android/myapps//FoxMagiskModuleManager_0.4.0-rc1.apk
/data/backup/Android/myapps//Magisk-25.1_25100.apk
/data/backup/Android/myapps//MiXplorer_v6.58.4-API29_B22020920.apk
/data/backup/Android/myapps//Notecase_Pro_1.2.2.apk
./Notecase/Notecase_Pro_1.2.1.apk


Installing the apk "/data/backup/Android/myapps//com.android.keepass_196.apk" ...
Success
"/data/backup/Android/myapps//com.android.keepass_196.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//com.keramidas.TitaniumBackup_v417.apk" ...
Success
"/data/backup/Android/myapps//com.keramidas.TitaniumBackup_v417.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//com.matoski.adbm_v27.apk" ...
Success
"/data/backup/Android/myapps//com.matoski.adbm_v27.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//F-Droid.apk" ...
Success
"/data/backup/Android/myapps//F-Droid.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//FoxMagiskModuleManager_0.4.0-rc1.apk" ...
Success
"/data/backup/Android/myapps//FoxMagiskModuleManager_0.4.0-rc1.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//Magisk-25.1_25100.apk" ...
Success
"/data/backup/Android/myapps//Magisk-25.1_25100.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//MiXplorer_v6.58.4-API29_B22020920.apk" ...
Success
"/data/backup/Android/myapps//MiXplorer_v6.58.4-API29_B22020920.apk" succcessfully installed

Installing the apk "/data/backup/Android/myapps//Notecase_Pro_1.2.2.apk" ...
Success
"/data/backup/Android/myapps//Notecase_Pro_1.2.2.apk" succcessfully installed

ERROR: The file "./Notecase/Notecase_Pro_1.2.1.apk" does not exist or is not readable

Installation summary
====================

8 package(s) successfully installed:
 
/data/backup/Android/myapps//com.android.keepass_196.apk
/data/backup/Android/myapps//com.keramidas.TitaniumBackup_v417.apk
/data/backup/Android/myapps//com.matoski.adbm_v27.apk
/data/backup/Android/myapps//F-Droid.apk
/data/backup/Android/myapps//FoxMagiskModuleManager_0.4.0-rc1.apk
/data/backup/Android/myapps//Magisk-25.1_25100.apk
/data/backup/Android/myapps//MiXplorer_v6.58.4-API29_B22020920.apk
/data/backup/Android/myapps//Notecase_Pro_1.2.2.apk


1 package(s) not found:
 
./Notecase/Notecase_Pro_1.2.1.apk


[xtrnaw7@t15g /data/backup/Android/myapps]$ adb push /data/develop/android/install_apk.sh /sdcard/Download/
/data/develop/android/install_apk.sh: 1 file pushed, 0 skipped. 76.3 MB/s (5906 bytes in 0.000s)
[xtrnaw7@t15g /data/backup/Android/myapps]$ 




Download the script from here install_apk.sh

Notes:

Another method to install packages via script from an PC is

adb install [package]

This command copies the file to a temporary location on the phone and installs it then via "pm install".

e.g

[xtrnaw7@t15g /data/backup/Android/myapps]$ adb install F-Droid.apk
Performing Streamed Install
Success
[xtrnaw7@t15g /data/backup/Android/myapps]$



Another ugly and insecure method onthe phone to install an apk file using pm install as root is

pm install (insecure method)
130|ASUS_I006D:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
ASUS_I006D:/ # 
ASUS_I006D:/ # getenforce
Enforcing
ASUS_I006D:/ # setenforce 0
ASUS_I006D:/ #
ASUS_I006D:/ # getenforce                                                                                                                         
Permissive
ASUS_I006D:/ #
ASUS_I006D:/ # pm install /sdcard/Download/EssentialApps/com.matoski.adbm_v27.apk                                                                 
avc:  denied  { read } for  scontext=u:r:system_server:s0 tcontext=u:object_r:fuse:s0 tclass=file permissive=1
Success
ASUS_I006D:/ # setenforce 1
ASUS_I006D:/ #
ASUS_I006D:/ # getenforce
Enforcing
ASUS_I006D:/ #



pm install supports a lot of options -- to get the usage help for pm use

adb shell pm help

or on the phone

pm help
 
or see here: https://developer.android.com/studio/command-line/adb#pm (Google Account neccessary) or here: http://adbcommand.com/adbshell/pm
 


How to replace the Fake Store from OmniROM with MicroG with a patched Playstore


URL:  https://forum.xda-developers.com/t/magisk-module-to-replace-the-fakestore-in-the-omnirom-with-a-patched-playstore-from-nanodroid.4456421/

How to replace the Fake Store from OmniROM with MicroG with a patched Playstore
The OmniROM with MicroG contains a perfect integrated MicroG but it does not contain the Playstore. Therefor apps that rely on the License functionality of the Playstore (like for example the DWD Warnwetter App) work only partial.

Fortunately there is already a patched PlayStore that works with MicroG in the NanoDroid image.

Therefor I created a Magisk Module to replace the FakeStore in OmniROM with MicroG with the patched PlayStore from NanoDroid.

The Module will replace the apk for the FakeStore from MicroG with an empty file and add the directory

/system/priv-apps/Phonesky

with the patched PlayStore from NanoDroid.

The patched Playstore works with MicroG so that apps using the license functionality from the Playstore can also be used in ROMs using MicroG .

The ZIP file with the Magisk Module can be downloaded from here:

http://bnsmb.de/files/public/Android/PlayStore_for_MicroG.zip

Note:

For Custom ROMS without MicroG I recommend to use the ZIP file from NanoDroid to install MicroG with the patched Playstore.
 

How to change the home directory for the user root on an Android phone


URL:  https://forum.xda-developers.com/t/how-to-change-the-home-directory-for-the-user-root-on-an-android-phone.4469305/


How to change the home directory for the user root on an Android phone
When working a lot in a shell via adb on an Android phone it's usefull to be able to store some user dependent config files in the home directory of the user. So let's see how that can be implemented on a phone running Android.

Note: The config was done on OmniROM (based on Android 12)

The home directory for all user used in an (adb) shell on Android is the root directory "/".

Using a home directory for more then one user is not really usefull and in addition on Android "/" is mounted read-only so more or less useless as home directory.

Therefor this should be changed. Unfortunately there is no /etc/passwd file in Android to configure the home directory for a user.

Well, there is an /etc/passwd file (probably for compatibily reasons) but it's empty:


shell@ASUS_I006D:/ $ ls -l /etc/passwd                                                                                                   
-rw-r--r-- 1 root root 0 2009-01-01 01:00 /etc/passwd
shell@ASUS_I006D:/ $


And as far as I know there is no other config file to configure the home directory of the user in the Android OS.

So we must implement some work around to get this working.


The shell on Android behaves like normal shells on Linux and executes the file /etc/profile when starting a new session.

In Android /etc is a symbolic link to /system/etc:


root@ASUS_I006D:/ # ls -ld /etc
lrw-r--r-- 1 root root 11 2009-01-01 01:00 /etc -> /system/etc
root@ASUS_I006D:/ #



And in the default config there is no file called profile in that directory:

shell@ASUS_I006D:/ $ ls -l /etc/system/profile
ls: /etc/system/profile: No such file or directory
shell@ASUS_I006D:/ $



Because /system is also mounted read-only we need the magic tool Magisk again to create the file /system/etc/profile.

To create the file /system/etc/profile create these directories and files on the phone as user root (assuming Magisk is already installed on the phone).


root@ASUS_I006D:/ # find /data/adb/modules/initshell/                                                                                                                                          
/data/adb/modules/initshell/
/data/adb/modules/initshell/system
/data/adb/modules/initshell/system/etc
/data/adb/modules/initshell/system/etc/profile
root@ASUS_I006D:/ #



and reboot the phone. After the reboot there should be the writable file /etc/profile:

root@ASUS_I006D:/ # ls -l /etc/profile
-rw-rw-rw- 1 root root 1100 2022-07-14 14:51 /etc/profile
root@ASUS_I006D:/ #


which is in reality the file

/data/adb/modules/initshell/system/etc/profile


Now you can edit the file /etc/profile as user root until it fullfills your requirements (be aware that all changes in that file are now persistent).
To test the changes open a new adb session (you should not close the current adb session to be able to fix an error in the profile if opening a new adb session fails).


This file can now be used to define the home directory for the user. The home directory should be on one of the writable filesystem, e.g. in /data:

# add in /etc/profile

HOME="/data/home/root"

export HOME


and the result is:

root@ASUS_I006D:/ #  id
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),1078(ext_data_rw),1079(ext_obb_rw),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:su:s0

root@ASUS_I006D:/ # echo $HOME
/data/home/root
root@ASUS_I006D:/ #



Note that there is not really a writable filesystem for the user shell so this approach to change the home directory is mainly usable for the user root.

The file /etc/profile can also be used to init some other settings for (adb) sessions (e.g. change the PATH, etc) . This feature can be used for sessions for non-root users also.

For additional user dependent configs you can also create the file .profile in the home directory of the user; the file ${HOME}/.profile will be executed after the execution of the file /etc/profile.


Notes:

Be aware that creating a profile for the user root and changing the home directory for the user root might have some side effects on other processes using the shell!

Therefor it's recommended to use the command "tty -s" to test if the profile is executed in an interactive session:

#
# check if we're running in an interactive session
#
if ! tty -s; then
#
# this is not an interactive session - so we're just doing nothing at all
#
  :
else
#
# running in an interactive session
#
...
fi

You can also check if the parent process is the adb daemon to not do anything in non-adb sessions:

ps -fp $PPID| grep adbd >/dev/null
if [ $? -ne 0 ] ; then
#
# not running in an adb session
:
else
#
# running in an adb session
...
fi


For testing purpose I suggest to open at least two shells via adb to be able to fix an error in case opening a new shell fails due to a bug in the profile.

If opening a shell session fails due to an error in the /etc/profile and you do not have another open shell either delete the file /data/adb/modules/initshell/system/etc/profile with a filemanager with root access on the phone or boot the phone from a recovery image (like TWRP) and delete or edit the file /data/adb/modules/initshell/system/etc/profile.


I initially looked at this feature to enable a persistent command history for the shell on the Android phone. But after some google searches I found out that persistent history shells are disabled for the shell binary on Android. So this will not work without recompiling the shell binary.


The attached example for the profile will use the directory /data/home/root as home directory for the user root and will not change the home directory for other users. The profile will do nothing if not running in an interactive session.
The directory /data/home/root will be created by the profile if it does not yet exist.


As always, if the config is working you should create a real Magisk Module for the profile.

The Magisk Module attached, initshell.zip, can be used to create a Magisk Module with your own profile:

To create a new Magisk Module with your own /etc/profile do:


# create an empty working directory
#
TEMPDIR="/tmp/newdir"

mkdir "${TEMPDIR}"
cd "${TEMPDIR}"

# unpack the zip file in the new directory
#
unzip ../initshell.zip

# now edit the file ${TEMPDIR}/system/etc/profile

# also (optional) edit the files config.sh and module.prop in the new directory to document your changes

# the script customize.sh from the module will be executed once when the module is installed. You might add the code
# create the home directories or any other code here
#

# and recreate the zip file
#
zip -r ../initshell.zip .


 



Some hints for using Magisk on Android phones


URL: https://forum.xda-developers.com/t/some-hints-for-using-magisk-on-android-phones.4471857/

Some hints for using Magisk on Android phones
In this post I summarize everything I found out about using Magisk (https://topjohnwu.github.io/Magisk) until now. A lot of the infos in this post are already in my other posts in this board but hopefully this summary is useful anyway.

My main purpose is to configure Magisk as much as possible via scripts so this tutorial is mostly about using Magisk via CLI commands in an adb shell or from within scripts.

I will update the post whenever I found something new and interesting. A history of changes in this post is at the end of the post


PreRequisites

Most of the instructions below need an enabled adb access for the phone and root permissions for the adb shell. In addition, a working Recovery image that is able to mount the /data partition (like for example TWRP) is strongly recommended before starting to play with Magisk.

The Magisk version used for this tutorial is Magisk 25.1; the ROM used was OmniROM (Android 12 based).
The phone used was an ASUS Zenfone 8 but the instructions should work on other phones also.


Installation

Magisk consists out of two parts:

The Magisk App and the Magisk files in the boot partition. Without the files in the boot partition Magisk can do more or less nothing.

The Magisk App can be installed using the standard Android tools for installing apps.

The installation of the Magisk files into the boot partition can then be done using the Magisk App.

The official instructions to install Magisk into the boot partition are here: 

https://topjohnwu.github.io/Magisk/install.html

Magisk can also be installed via script without user intervention into the boot partition -- see here:
How to install Magisk into the boot partition using a script
 
Note that the Magisk files for the boot partition must be reinstalled after an OS upgrade.


Uninstalling Magisk

Use the Button "Uninstall Magisk" in the Magisk app. The Magisk App can also remove Magisk from the boot partition.

To uninstall the Magisk App only via script do

adb shell pm uninstall com.topjohnwu.magisk

To remove Magisk from the boot partition manually I suggest to flash the image of the original boot partition.


Installing Magisk Modules

Magisk Modules are extensions for Magisk to for example replace or add files to /system (and much more ... I suggest to study the documentation for Magisk for those that are interested in using Magisk)

Magisk Modules are distributed via ZIP files.

As of Magisk v25 or newer the official method to install Magisk Modules is to manually copy the ZIP file with the Magisk Module to the phone and then use the button "Install from storage" in the "Modules" sub menu in the Magisk App.

In previous versions of Magisk a Module browser to list and install Magisk Modules was part of the Magisk App but unfortunately the developer dropped that feature. Therefor you must search and download the available Magisk Modules using a browser on the phone or a PC.

Repositories with Magisk Modules are for example:

https://github.com/Magisk-Modules-Repo/

and

https://github.com/Magisk-Modules-Alt-Repo



There is now a new App for Android called "Fox's Magisk Module Manager" that can be used to list and download Magisk Modules to the phone
(see https://github.com/Fox2Code/FoxMagiskModuleManager)

It's also possible to install a Magisk Module via script. The commands to install an Magisk Module via script are:

# copy the Magisk Module to the phone

adb push /data/backup/Android/MagiskModules/Nano_for_Android_NDK-6_3-6300.zip /sdcard/Download/

# install the Module
#
# Note:
#
# The command can also be executed in a script runnning on the phone (without "adb shell")
#
adb shell magisk --install-module  /sdcard/Download/Nano_for_Android_NDK-6_3-6300.zip

# reboot the phone

adb reboot



Example:

[xtrnaw7@t15g ~]$ adb push  /data/backup/Android/MagiskModules/Nano_for_Android_NDK-6_3-6300.zip /sdcard/Download/
/data/backup/Android/MagiskModules/Nano_for_Android_NDK-6_3-6300.zip: 1 file pushed, 0 skipped. 37.6 MB/s (380554 bytes in 0.010s)

[xtrnaw7@t15g ~]$ adb shell magisk --install-module     /sdcard/Download/Nano_for_Android_NDK-6_3-6300.zip
- Current boot slot: _a
- Device is system-as-root
*****************************
 Nano for Android NDK
 by osm0sis @ xda-developers
*****************************
*******************
 Powered by Magisk
*******************
Archive:  /storage/emulated/0/Download/Nano_for_Android_NDK-6_3-6300.zip
  inflating: diffusion_config.sh
  inflating: module.prop
 
Mounting...
 
Extracting files...
Archive:  /storage/emulated/0/Download/Nano_for_Android_NDK-6_3-6300.zip
  inflating: META-INF/com/google/android/updater-script
  inflating: META-INF/com/google/android/update-binary
  inflating: sbin/nano
...
  inflating: etc/terminfo/l/linux
  inflating: customize.sh
  inflating: update.json
  inflating: bin/nano
  inflating: bin/nano.bin
  inflating: README.md
  inflating: diffusion_config.sh
  inflating: module.prop
 
Installing...
 
Installing nano to /data/adb/modules_update/nano-ndk/system/bin ...
Installing terminfo to /data/adb/modules_update/nano-ndk/system/etc ...
 
Unmounting...
 
Done!
[xtrnaw7@t15g ~]$  adb reboot
[xtrnaw7@t15g ~]$




Uninstalling a Magisk Module

Magisk Modules should be uninstalled via Magisk App if possible because there is no parameter for the magisk binary to uninstall a Magisk Module.

To force Magisk to remove the module after the next reboot create the file

remove

in the module directory.

If uninstalling the Magisk Module does not work or if you want to uninstall a Magisk Module via script you can just delete the directory for the Magisk Module in /data/adb/modules and reboot the phone. This can be done in an adb shell or if that does not work anymore after rebooting the phone from a Recovery Image like TWRP, e.g.

# uninstall the module "dummy_module" via adb shell commands
#

# check for an uninstall script for this module

if [ -x /data/adb/modules/dummy_module/uninstall.sh ] ; then
  echo "Executing the module uninstall script ...."

  /data/adb/modules/dummy_module/uninstall.sh
fi

adb shell rm -rf /data/adb/modules/dummy_module/

adb reboot


Note:

You should reboot the phone immediately after removing the directory with the Module.

This method is not really recommended.




List all installed Magisk Modules

The Magisk App will list all installed Magisk Modules

To list the installed Magisk Modules via CLI command use either

adb shell ls -d /data/adb/modules/* | cut -f5 -d "/"

e.g.

[xtrnaw7@t15g ~]$ adb shell ls -d /data/adb/modules/* | cut -f5 -d "/"
PlayStore_for_MicroG
ccbins
dummy_module
initshell
nano-ndk
terminalmods
[xtrnaw7@t15g ~]$


or

[xtrnaw7@t15g /data/develop/android/NewModules/initshell]$ for i in $( adb shell ls -d /data/adb/modules/* ); do printf "%-30s %s\n"  "${i##*/}" "$(  adb shell grep name= $i/module.prop 2>/dev/null | cut -f2 -d "=" | tr -s " " )" ; done
MiXplorer                      MiXplorer
PlayStore_for_MicroG           Patched Playstore from NanoDroid for MicroG (for ARM64 CPUs only)
ccbins                         Cross Compiled Binaries
dummy_module                   Dummy Module for testing a new module
initshell                      Create writable config files (/etc/profile) for sh
nano-ndk                       Nano for Android NDK
terminalmods                   Terminal Modifications
[xtrnaw7@t15g /data/develop/android/NewModules/initshell]$



or on the phone:

root@ASUS_I006D:/ # echo; for i in /data/adb/modules/*; do printf "%-30s %s\n"  "${i##*/}" "$(  grep name= $i/module.prop 2>/dev/null | cut -f2 -d "=" | tr -s " " )" ; done       

PlayStore_for_MicroG           Patched Playstore from NanoDroid for MicroG (for ARM64 CPUs only)
ccbins                         Cross Compiled Binaries
dummy_module                  
initshell                      Create writable config files (/etc/profile) for sh
nano-ndk                       Nano for Android NDK
terminalmods                   Terminal Modifications
root@ASUS_I006D:/ #


How to disable a Magisk Module

To disable a Magisk Module via script create a file called disable in the Module directory, e.g.:

touch /data/adb/modules/dummy_module/disable

The Magisk Module will then be disabled after the next reboot.

To re-enable the Magisk Module just delete the file disable in the Module directory and reboot the phone.

To list all disabled Magisk Modules do

adb shell ls /data/adb/modules/*/disable | cut -f5 -d "/"



Replacing files in /system using a Dummy Magisk Modul


One feature of Magisk Modules is the possibility to change files in the directory /system or also add new files to /system. /system is mounted read-only and in the current Android version it is not possible to remount /system read-write anymore so without Magisk it's very difficult to change files in /system.

To test this feature you do not need to create a Magisk Module : It's sufficient to simulate a Magisk Module.
For that just create the necessary directory structure and files manually.

Magisk Modules are are installed in the directory /data/adb/modules. Each Magisk Module use an uniqe sub directory in that directory. To simulate a Magisk Module open an adb shell as user root and create the directories for your Dummy Magisk Module, e.g.:

mkdir /data/adb/modules/dummy_module

# Next create the sub directory system in that new directory

mkdir /data/adb/modules/dummy_module/system


Now copy the files for /system to that directory: The files in that directory will overwrite existing files in /system after the next reboot. Files in that directory that not already exist in /system will be created in /system.

e.g

# contents of my Dummy Magisk Module
#
root@ASUS_I006D:/data/adb/modules/dummy_module/system # pwd
/data/adb/modules/dummy_module/system

root@ASUS_I006D:/data/adb/modules/dummy_module/system # find .
.
./bin
./bin/my_new_binary
./etc
./etc/my_new_file_for_systme
root@ASUS_I006D:/data/adb/modules/dummy_module/system #                  
                                                                                                    


After rebooting the phone the files are visible in /system:

root@ASUS_I006D:/ # ls -l /system/etc/my_new_file_for_systme                                                                                                                 
-rw-rw-rw- 1 root root 20 2022-07-20 16:55 /system/etc/my_new_file_for_systme

root@ASUS_I006D:/ # cat /system/etc/my_new_file_for_systme                                                                                                                   
This is my new file
root@ASUS_I006D:/ #

root@ASUS_I006D:/ # ls -l /system/bin/my_new_binary                                                                                                                          
-rwxr-xr-x 1 root root 41 2022-07-20 16:57 /system/bin/my_new_binary

root@ASUS_I006D:/ # my_new_binary                                                                                                                                            
Hello world from my dummy binary
root@ASUS_I006D:/ #


The permissions for the new files in /system are equal to the permissions of the original files in /data/adb/modules/dummy_module so if the original files are writable you can also edit the new files in /system, e.g

root@ASUS_I006D:/ # cat /system/etc/my_new_file_for_systme                                                                                                                   
This is my new file
root@ASUS_I006D:/ #

root@ASUS_I006D:/ # echo "Test Test" >> /system/etc/my_new_file_for_systme                                                                                                   
root@ASUS_I006D:/ # cat /system/etc/my_new_file_for_systme                                                                                                                   
This is my new file
Test Test
root@ASUS_I006D:/ #


(You can also edit the new files by editing the original files in /data/adb/modules/dummy_module)

These changes are persistent (because they change the original file in /data/adb/modules/<modulename>). You can also edit the files in
/data/adb/modules/<modulename> but be aware that you can not use tools that create temporary files for changing the files like for example sed: Changes done with these kind of tools are only visible after a reboot of the phone.

To change the file via script I recommend to create a new file and then replace the existing file with the new file using cp.



Notes:

Magisk does not really change the files in /system - instead it uses "bind mounts" to replace the files with others. Therefor you can always restore the original files by deleting the files in /data/adb/modules/<module_name> and rebooting the phone. Another big advantage of this technique is that you do not have to take care about an update of the OS:

Changes done via Magisk will also work after an OS upgrade (assuming you reinstalled Magisk to the boot partition after installing the OS update)

Make sure that the new files for /system are readable for the user using them; e.g some files (like for example apk files) are used by the user system). IMHO it's recommended to add the read permission (chmod o+r) to all new files for /system.

Please be careful when changing existing files in /system.

To add the necessary infos for the Magisk App to list your dummy module properly just create the file module.prop for your Dummy Magisk Module, e.g.

root@ASUS_I006D:/ # cat /data/adb/modules/dummy_module/module.prop                                                                                                           
id=dummy-module
name=Dummy Module for testing a new module
version=1.0
versionCode=1000
author=otto.meier@mynetwork.com
description=Dummy Module ..
root@ASUS_I006D:/ #



For some examples for this technique see :

How to change files in the directory /system with Magisk

How to replace the Fake Store from OmniROM with MicroG with a patched Playstore

How to change the home directory for the user root on an Android phone



How to use this technique to disable an app that can not be uninstalled

Apps that can not be uninstalled can be disabled by creating empty files for the app.

Example:

My Magisk Module for the patched Playstore must disable the installed app for the fake store
 

That's done by creating an empty file in the Magisk Module for the apk file, the result looks like this:

root@ASUS_I006D:/ # ls -l /data/adb/modules/PlayStore_for_MicroG/system/priv-app/FakeStore/FakeStore.apk                                                                     
-rw-r--r-- 1 root root 1 2022-07-15 11:54 /data/adb/modules/PlayStore_for_MicroG/system/priv-app/FakeStore/FakeStore.apk
root@ASUS_I006D:/ #

root@ASUS_I006D:/ # ls -l /system/priv-app/FakeStore/FakeStore.apk                                                                                                           
-rw-r--r-- 1 root root 1 2022-07-15 11:54 /system/priv-app/FakeStore/FakeStore.apk
root@ASUS_I006D:/ #

In case there are multiple files in the folder for the app you can also hide the entire folder:

From the original documentation from https://topjohnwu.github.io/Magisk/guides.html:

If you place a file named .replace in any of the folders, instead of merging its contents, that folder will directly replace the one in the real system. This can be very handy for swapping out an entire folder.
 


How to access the files replaced by Magisk

Use another bind mount to access the files replaced by Magisk, e.g:

root@ASUS_I006D:/ # head /data/adb/modules/fmradio/system/etc/                                                                                                                                 
cust_pms/               permissions/            public.libraries.txt
root@ASUS_I006D:/ # head /data/adb/modules/fmradio/system/etc/public.libraries.txt                                                                                                             
# See https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
#
# 04.08.2022 /bs
#  added the library libqcomfm_jni.so
#
libandroid.so
libaaudio.so
libamidi.so
libbinder_ndk.so
libc.so
root@ASUS_I006D:/ #
root@ASUS_I006D:/ #

root@ASUS_I006D:/ # head /system/etc/public.libraries.txt                                                                                                                                      
# See https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
#
# 04.08.2022 /bs
#  added the library libqcomfm_jni.so
#
libandroid.so
libaaudio.so
libamidi.so
libbinder_ndk.so
libc.so
root@ASUS_I006D:/ #

# -> The file /system/etc/public.libraries.txt is replaced by a file from a Magisk Module

# To access the original version of the file /system/etc/public.libraries.txt do

root@ASUS_I006D:/ #
root@ASUS_I006D:/ # mkdir -p /data/test
root@ASUS_I006D:/ #
root@ASUS_I006D:/ # mount -o bind /system /data/test

#
# -> /data/test is now mounted to /system
#
# -> /data/test/etc/public.libraries.txt is the original version of that file:
#

root@ASUS_I006D:/ #

root@ASUS_I006D:/ # head /data/test/etc/public.libraries.txt                                                                                                                                   
# See https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
libandroid.so
libaaudio.so
libamidi.so
libbinder_ndk.so
libc.so
libcamera2ndk.so
libdl.so
libEGL.so
libGLESv1_CM.so
root@ASUS_I006D:/ #




Replacing files in /vendor, /product, or /system_ext using a Dummy Magisk Module

The (dummy) Magisk Module can also be used to replace files in the directories /vendor, /product, or /system_ext:

from the Magisk documentation at https://topjohnwu.github.io/Magisk/guides.html:

If you want to replace files in /vendor, /product, or /system_ext, please place them under system/vendor, system/product, and system/system_ext respectively. Magisk will transparently handle whether these partitions are in a separate partition or not.

Note that this works only to replace existing files in these directories - you can not add new files to these directories using this method.


Example:

root@ASUS_I006D:/ # cd /data/adb/modules/dummy_module/system                                                                                                                 

#
# files in the Magisk Module
#
root@ASUS_I006D:/data/adb/modules/dummy_module/system # find . -type f
./bin/my_new_binary
./etc/my_new_file_for_systme
./product/mynewfile
./product/media/audio/alarms/Krypton.ogg
./vendor/mynewfile
./vendor/etc/sap.conf
./system_ext/mynewfile
./system_ext/etc/dpm/dpm.conf
root@ASUS_I006D:/data/adb/modules/dummy_module/system #
#
#  the new files for /product, /vendor, and /system_ext in the Magisk Module do not exist:
#
root@ASUS_I006D:/data/adb/modules/dummy_module/system # ls -l /product/mynewfile /vendor/mynewfile /system_ext/mynewfile
ls: /product/mynewfile: No such file or directory
ls: /vendor/mynewfile: No such file or directory
ls: /system_ext/mynewfile: No such file or directory

#
# The existing files in /product, /vendor, and /system_ext are replaced with the files from the Magisk Moduel
#
root@ASUS_I006D:/data/adb/modules/dummy_module/system # cksum ./product/media/audio/alarms/Krypton.ogg  /product/media/audio/alarms/Krypton.ogg                              
4294967295 0 ./product/media/audio/alarms/Krypton.ogg
4294967295 0 /product/media/audio/alarms/Krypton.ogg
root@ASUS_I006D:/data/adb/modules/dummy_module/system #

root@ASUS_I006D:/data/adb/modules/dummy_module/system # cksum ./vendor/etc/sap.conf /vendor/etc/sap.conf
1967598015 7121 ./vendor/etc/sap.conf
1967598015 7121 /vendor/etc/sap.conf
root@ASUS_I006D:/data/adb/modules/dummy_module/system #

root@ASUS_I006D:/data/adb/modules/dummy_module/system # cksum  ./system_ext/etc/dpm/dpm.conf /system_ext/etc/dpm/dpm.conf
1970692378 2925 ./system_ext/etc/dpm/dpm.conf
1970692378 2925 /system_ext/etc/dpm/dpm.conf
root@ASUS_I006D:/data/adb/modules/dummy_module/system #

root@ASUS_I006D:/data/adb/modules/dummy_module/system # grep mynewfile /cache/magisk.log                                                                                     
01-01 00:11:51.764   767   769 W : Unable to add: /product/mynewfile, skipped
01-01 00:11:51.771   767   769 W : Unable to add: /system_ext/mynewfile, skipped
01-01 00:11:51.771   767   769 W : Unable to add: /vendor/mynewfile, skipped
root@ASUS_I006D:/data/adb/modules/dummy_module/system #



A work around to create new files in sub directories in /product, /vendor, or /system_ext:

Copy the complete existing folder to the sub directory in /data/adb/modules/<magisk_module>/system/[product|vendor|system_ext]/; create the file .replace in that directory and add the new file(s) to that directory.

Example:


root@ASUS_I006D:/ # find /data/adb/modules/testmodule/                                                                                                                                         
/data/adb/modules/testmodule/
/data/adb/modules/testmodule/system
/data/adb/modules/testmodule/system/product
/data/adb/modules/testmodule/system/product/lib
/data/adb/modules/testmodule/system/product/lib/.replace
/data/adb/modules/testmodule/system/product/lib/libframesequence.so
/data/adb/modules/testmodule/system/product/lib/libgiftranscode.so
/data/adb/modules/testmodule/system/product/lib/newfile001
/data/adb/modules/testmodule/system/vendor
/data/adb/modules/testmodule/system/vendor/app
/data/adb/modules/testmodule/system/vendor/app/TimeService
/data/adb/modules/testmodule/system/vendor/app/TimeService/TimeService.apk
/data/adb/modules/testmodule/system/vendor/app/TimeService/oat
/data/adb/modules/testmodule/system/vendor/app/TimeService/oat/arm64
/data/adb/modules/testmodule/system/vendor/app/TimeService/oat/arm64/TimeService.vdex
/data/adb/modules/testmodule/system/vendor/app/TimeService/oat/arm64/TimeService.odex
/data/adb/modules/testmodule/system/vendor/app/TimeService/newfile002
/data/adb/modules/testmodule/system/vendor/app/TimeService/.replace
/data/adb/modules/testmodule/system/system_ext
/data/adb/modules/testmodule/system/system_ext/app
/data/adb/modules/testmodule/system/system_ext/app/FM2
/data/adb/modules/testmodule/system/system_ext/app/FM2/.replace
/data/adb/modules/testmodule/system/system_ext/app/FM2/FM2.apk
/data/adb/modules/testmodule/system/system_ext/app/FM2/lib
/data/adb/modules/testmodule/system/system_ext/app/FM2/lib/arm64
/data/adb/modules/testmodule/system/system_ext/app/FM2/lib/arm64/libqcomfm_jni.so
/data/adb/modules/testmodule/system/system_ext/app/FM2/oat
/data/adb/modules/testmodule/system/system_ext/app/FM2/oat/arm64
/data/adb/modules/testmodule/system/system_ext/app/FM2/oat/arm64/FM2.odex
/data/adb/modules/testmodule/system/system_ext/app/FM2/oat/arm64/FM2.vdex
/data/adb/modules/testmodule/system/system_ext/app/FM2/newfile003
root@ASUS_I006D:/ #

root@ASUS_I006D:/ #   find /data/adb/modules/testmodule/system | grep newfile

/data/adb/modules/testmodule/system/product/lib/newfile001
/data/adb/modules/testmodule/system/vendor/app/TimeService/newfile002
/data/adb/modules/testmodule/system/system_ext/app/FM2/newfile003
root@ASUS_I006D:/ # 

root@ASUS_I006D:/ # pwd
/
root@ASUS_I006D:/ # ls -l $( find /data/adb/modules/testmodule/system | grep newfile | cut -f6- -d "/" )

-rw-r--r-- 1 root root 0 2022-08-07 14:34 system/product/lib/newfile001
-rw-r--r-- 1 root root 0 2022-08-07 14:24 system/system_ext/app/FM2/newfile003
-rw-r--r-- 1 root root 0 2022-08-07 14:36 system/vendor/app/TimeService/newfile002
root@ASUS_I006D:/ #




Executing scripts while booting the phone

Magisk also supports executing additional scripts while booting the phone.

The scripts to be executed must be copied to one of these directories

/data/adb/post-fs-data.d/   

/data/adb/service.d/     

see the description in the original Magisk documentation: https://topjohnwu.github.io/Magisk/details.html

A working example for this technique is described in this forum entry:

How to run a script at every boot using Magisk


Another example for using this technique I found here https://gist.github.com/niikoo/3f6bd13a69f2d68f3dd51cc667e79bdc

# Boot logging
# Create the file: /data/adb/post-fs-data.d/0001logcatboot

#!/system/bin/sh
mkdir -p /cache/logs
/system/bin/logcat -r 1024 -n 9 -v threadTime -f /cache/logs/log >info.log 2>err.log &



Note that I added commands to create / cleanup the log directory and changed the logcat command on my phone:

#!/system/bin/sh
m
kdir -p /cache/logs
rm -rf /cache/logs/*
/system/bin/logcat -r 102400 -n 9 -v threadTime -f /cache/logs/log >/cache/logs/info.log 2>/cache/logs/err.log &




Creating Magisk Modules

The official documentation for creating a Magisk Module is here: https://topjohnwu.github.io/Magisk/guides.html

Creating Magisk Modules that only use the standard features isn't that difficult and the official documentation should be sufficient.

I suggest to download an existing simple Magisk Module; unzip the ZIP file and study the contents.



Directories and files used by Magisk

The directories and files used by Magisk are documented here https://topjohnwu.github.io/Magisk/guides.html

Some important directories and files for developing and trouble shooting Magisk Modules are:

The logfile used by Magisk is 

/cache/magisk.log 

In case something goes wrong with a Magisk Module you should first check that file.

The base directory for the data files for Magisk is

/data/adb


The config setttings for Magisk are stored in the SQLite  database

/data/adb/magisk.db


To view (or probably) change the database entries via script you can either use sqlite3 binary (if installed), e.g.


ASUS_I006D:/ #  sqlite3 /data/adb/magisk.db .tables

denylist  policies  settings  strings

ASUS_I006D:/ #

ASUS_I006D:/ # sqlite3 /data/adb/magisk.db                                                                                                                                   
SQLite version 3.7.6.3-Titanium
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

sqlite> .headers on
sqlite> .mode column
sqlite>
sqlite> .tables
denylist  policies  settings  strings
sqlite>
sqlite> .schema
CREATE TABLE denylist (package_name TEXT, process TEXT, PRIMARY KEY(package_name, process));
CREATE TABLE policies (uid INT, policy INT, until INT, logging INT, notification INT, PRIMARY KEY(uid));
CREATE TABLE settings (key TEXT, value INT, PRIMARY KEY(key));
CREATE TABLE strings (key TEXT, value TEXT, PRIMARY KEY(key));
sqlite>
sqlite> select * from denylist ;
sqlite>
sqlite> select * from policies ;
uid         policy      until       logging     notification
----------  ----------  ----------  ----------  ------------
2000        2           0           1           1          
10134       1           0           1           1          
sqlite>
sqlite> select * from settings ;
key         value    
----------  ----------
denylist    0        
su_biometr  0        
sqlite>
sqlite> select * from strings ;
sqlite>


 

or the magisk binary, e.g:

ASUS_I006D:/ # magisk --sqlite  'select * from policies'                                                                                                                    

logging=1|notification=1|policy=2|uid=2000|until=0

ASUS_I006D:/ #

ASUS_I006D:/ # magisk --sqlite  'select * from settings'                                                                                                                    
key=denylist|value=0
key=su_biometric|
value=0
ASUS_I006D:/ #




Backup the Magisk config

To backup the Magisk config just copy the directories in /data/adb except the directory /data/adb/magisk (that directory is used for the binaries only)


[xtrnaw7@t15g /data/develop/android]$ adb shell tar --exclude data/adb/magisk/ -czf /sdcard/Download/magisk_config_$( date +%Y-%m-%d).$$.tar /data/adb/
removing leading '/' from member names

[xtrnaw7@t15g /data/develop/android]$ adb pull /sdcard/Download/magisk_config_$( date +%Y-%m-%d).$$.tar
/sdcard/Download/magisk_config_2022-07-20.108257.tar: 1 file pulled, 0 skipped. 37.4 MB/s (4555799 bytes in 0.116s)

[xtrnaw7@t15g /data/develop/android]$ tar -tvf magisk_config_2022-07-20.108257.tar
drwx------ root/root         0 1970-02-06 05:38 data/adb
-rw------- root/root     40960 2022-07-20 16:25 data/adb/magisk.db
drwxr-xr-x root/root         0 2022-07-20 16:52 data/adb/modules/
drwxr-xr-x root/root         0 1970-02-02 07:56 data/adb/modules/initshell/
drwxr-xr-x root/root         0 2022-07-16 18:49 data/adb/modules/initshell/system/
drwxr-xr-x root/root         0 2022-07-16 18:49 data/adb/modules/initshell/system/etc/
...
drwxrwxrwx root/root         0 2022-07-14 19:01 data/adb/shell/system/
drwxrwxrwx root/root         0 2022-07-14 19:01 data/adb/shell/system/etc/
-rw-rw-rw- root/root      1510 2022-07-14 18:08 data/adb/shell/system/etc/profile
[xtrnaw7@t15g /data/develop/android]$


To restore the backup unpack the tar file on the phone and reboot the phone.


Trouble Shooting

An error like this

08-06 18:41:39.341 +0000  1356  1726 W ziparchive: Unable to open '/system/app/AsusFMRadio/AsusFMRadio.apk': Permission denied
08-06 18:41:39.341 +0000  1356  1726 E system_server: Failed to open APK '/system/app/AsusFMRadio/AsusFMRadio.apk': I/O error
08-06 18:41:39.354 +0000  1356  1356 W PackageManager: Failed to parse /system/app/AsusFMRadio: Failed to parse /system/app/AsusFMRadio/AsusFMRadio.apk

is most of the time caused by missing read permissions for the file.

Use

chmod o+r /system/app/AsusFMRadio/AsusFMRadio.apk

to fix it.

If something went wrong and booting the phone does not work anymore after installing a MagiskModule just remove the files in
/data/adb/modules/<modulename> and reboot the phone :

Either connect via adb to the not booting phone (this should be possible in most cases even if the boot process does not finish), delete the files, and reboot the phone. Or reboot the phone from a Recovery image like TWRP, delete the files in /data/adb/modules/<modulename>, and reboot the phone.

The same procedure can be used if booting the phone does not work anymore after adding another init script - just delete the new script in

/data/adb/post-fs-data.d


or

/data/adb/service.d

and reboot the phone


To catch errors from a script executed by Magisk you might use this technique

# redirect STDERR of all commands in the script to a file
#
exec 2>/data/script_stderr.log
set -x

... rest of your script



To remove all installed Magisk Modules using the official method use:


magisk --remove-modules  

to remove all modules (but not the new init scripts!) and reboot the phone

According to the FAQ Magisk will not start if the phone is booted into save mode (see https://topjohnwu.github.io/Magisk/faq.html)

Be aware that after rebooting the phone again in normal mode all Magisk Modules are disabled and must be enabled again either using the Magisk App or via CLI command:

To reenable all Magisk Modules via shell command do

adb shell rm /data/adb/modules/*/disable

 

History of this entry

07.08.2022 /bs

Added additional infos about the permissions for new files for /system.

Added additional commands to the script for catching the OS logs while booting the phone

Added infos about a workaround to add new files to /product, /vendor, or /system_ext

Added infos about how to access file replaced by a Magisk Module



Links



Files mentioned in the HowTos


URL
Content
Comment
install_apk.sh How to install packages (apk files) for Android via script
install_magisk_via_twrp.sh
How_to_install_Magisk_into_the_boot
PlayStore_for_MicroG.zip
How to replace the Fake Store from OmniROM with MicroG with a patched Playstore 
initshell.zip
How to change the home directory for the user root on an Android phone
profile
How to change the home directory for the user root on an Android phone




General Android LInks


URL
Content
Comment
https://microg.org/ MicroG homepage
https://nanolx.org/ NanoDroid homepage
https://downloads.nanolx.org/NanoDroid/Stable/ NanoDroid Downloads
https://twrp.me/ TWRP homepage
https://f-droid.org/ F-Droid homepage
http://adbcommand.com/
adb commands manual
https://android-doc.github.io/tools/help/adb.html
adb command documentation
https://developer.android.com/studio/command-line/adb#shellcommands
pm usage help Google account neccessary
https://developer.android.com/studio/command-line/adb#pm
Google account neccessary
https://developer.android.com/studio/command-line/adb#am
Google account neccessary



Magisk related links



URL
Content
Comment
https://github.com/topjohnwu/Magisk
Magisk home page
Magisk the must have for every Android phone
https://topjohnwu.github.io/Magisk/install.html
Instructions to install Magisk

https://topjohnwu.github.io/Magisk/
Magisk documentation

https://topjohnwu.github.io/Magisk/guides.html
Magisk developer guide

https://topjohnwu.github.io/Magisk/tools.html
Magisk Tools documentation

https://github.com/Magisk-Modules-Repo/
Repository with Magisk Modules

https://github.com/Magisk-Modules-Repo/ssh
Magisk module with ssh and rsync

https://github.com/Fox2Code/FoxMagiskModuleManager
Fox Magisk ModuleManager

https://github.com/Magisk-Modules-Alt-Repo/
Another repository with Magisk Modules




Links for the OmniROM


URL
Content
Comment
https://omnirom.org/
OmniROM Homage
OmniROM is Custom ROM for Android phones
https://forum.xda-developers.com/c/omnirom.2601/ OmniROM Forums on XDA

https://download.lineageos.org/sake
Images and Recoveries for LineageOS 19
LineageOS is a Custom ROM for Android ; the Lineaage Recovery image can be used to install the OmniROM on an Android phone



https://wiki.lineageos.org/devices/sake/install?
Instructions to install the Recovery from the LineageOS

https://github.com/omnirom/android_prebuilts_prebuiltapks
List of MicroG packages in the OmniROM image with MicroG





Links for ROM Development


URL
Content
Comment
https://gerrit.googlesource.com/git-repo/
repo script for buidling your own CustomROM

https://source.android.com/setup/develop/repo
documentation for the repo command

https://github.com/omnirom/android
Getting started doc for the OmniROM

https://github.com/omnirom
Repositories for building the OmniROM

https://developer.android.com/studio/command-line/
Documentation for the command line tools from the Android Studio

https://developer.android.com/studio/command-line/apksigner Documentation for the apk signer from the Android studio
https://developer.android.com/studio/command-line/zipalign Documentation for zipalign (zipalign must be used align a APK file)
zipalign is part of the Android Studio
https://developer.android.com/studio7
Android Studio Download

https://developer.android.com/ndk/downloads NDK Downloads

https://github.com/android/ndk/wiki/Unsupported-Downloads
NDK Downloads (old versions)

https://github.com/omnirom/android_prebuilts_prebuiltapks
Prebuild MicroG packages for the OmniROM

https://github.com/DonkeyCoyote/proprietary_vendor_asus Vendor packages for the ASUS Zenfone 8 (neccessary for building your own CustomROM)
https://github.com/omnirom/android_device_asus_zenfone8/tree/android-12.1 Device tree for the ASUS Zenfone 8 (neccessary for building your own CustomROM)
https://github.com/TheMuppets/
Vendor packages for various devices

https://github.com/DonkeyCoyote/
Vendor packages for various devices
https://github.com/aosp-mirror/platform_build/tree/android12-platform-release/target/product/security
How to create a the ssl keys for a CustomROM image







Links for useful Tools


URL
Content
Comment
http://java-decompiler.github.io/#jd-gui-download
Java Decompiler
(jar file with GUI)
http://java-decompiler.github.io/#jd-gui-download

Tools to work with android .dex and java .class files

  1. dex-reader/writer: Read/write the Dalvik Executable (.dex) file. It has a light weight API similar with ASM.
  2. d2j-dex2jar: Convert .dex file to .class files (zipped as jar)
  3. smali/baksmali: disassemble dex to smali files and assemble dex from smali files. different implementation to smali/baksmali, same syntax, but we support escape in type desc "Lcom/dex2jar\t\u1234;"
  4. other tools: d2j-decrypt-string

https://forum.xda-developers.com/t/tool-imjtool-unpack-and-extract-a-variety-of-ota-images-from-various-vendors.4078159/

http://newandroidbook.com/tools/imjtool.html
mjtool - Unpack and extract a variety of OTA images from various vendors
https://forum.xda-developers.com/t/tool-android-image-kitchen-unpack-repack-kernel-ramdisk-win-android-linux-mac.2073775/ Android Image Kitchen - Unpack/Repack Kernel Ramdisk [Win/Android/Linux/Mac]
https://github.com/hzw1199/xml2axml/releases Convert compiled XML to plain XML and vice versa
https://forum.xda-developers.com/t/linux-guide-rom-payload-image-dump.4196055/

https://github.com/ssut/payload-dumper-go

ROM payload image dumper - a python script to extract the images for the file payload.bin images for Android 12
https://shatter-box.com/knowledgebase/android-apk-signing-tool-apk-signer/
Android APK Signing Tool (APK Signer)
Note;

Android APK Signing Tool (APK Signer)

Use the apk signer from the Android studio



https://forum.xda-developers.com/t/tool-tickle-my-android-decompile-recompile-with-ease.1633333/
"TMA is a quick, powerful and easy-to-use tool that uses a piece of java called "apktool" to decompile and recompile Android app's. "

https://github.com/pxb1988/dex2jar
"Tools to work with android .dex and java .class files

    dex-reader/writer: Read/write the Dalvik Executable (.dex) file. It has a light weight API similar with ASM.

    d2j-dex2jar: Convert .dex file to .class files (zipped as jar)

    smali/baksmali: disassemble dex to smali files and assemble dex from smali files. different implementation to smali/baksmali, same syntax, but we support escape in type desc "Lcom/dex2jar\t\u1234;"

    other tools: d2j-decrypt-string"



   

Links for the ASUS Zenfone 8


URL
Content
Comment
https://www.asus.com/de/Mobile/Phones/ZenFone/Zenfone-8/HelpDesk_BIOS/
ASUS Zenfone 8 Firmware Download

https://forum.xda-developers.com/t/firmware-download-links.4308547/
XDA Forum for ASUS Zenfone 8 Firmware Download

https://twrp.me/asus/zenfone8.html
official TWRP for the ASUS Zenfone 8

https://www.asus-zenfone.com/2015/10/official-asus-zenfone-2-unlock.html
Official Tool from ASUS to Unlock the ASUS Zenfone 8

https://zentalk.asus.com/en/discussion/27136/unlock-relock-bootloader-unofficially-for-zenfone-3
Instructions to unlock the ASUS Zenfone 8

https://forum.xda-developers.com/f/asus-zenfone-8.12291/ XDA Forums for the ASUS Zenfone 8

https://forum.xda-developers.com/t/recovery-twrp-for-zenfone-8.4329139/
XDA Forum for TWRP for the ASUS Zenfone 8

https://forum.xda-developers.com/t/full-recover-to-stock-if-things-went-really-bad.4337467/
Instructions to install the Android raw image  from ASUS on the ASUS Zenfone 8

https://www.asus.com/Content/Android-13-Beta/
Android 13 Beta and a raw image for Android 12

https://www.asus.com/Content/Android-12-Beta/
Android 12 Beta and a raw image for Android 11
https://dl.omnirom.org/zenfone8/ OmniROM Images for the ASUS Zenfone 8




back top top