diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 5c8418a..d19eeb5 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -1,58 +1,62 @@ #!/sbin/sh -########################################################################################## -# -# Magisk Module Template Install Script -# by topjohnwu -# -########################################################################################## - -# Detect whether in boot mode -ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false -$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true - -# This path should work in any cases -TMPDIR=/dev/tmp -INSTALLER=$TMPDIR/install -MAGISKBIN=/data/adb/magisk -# Default permissions +################# +# Initialization +################# + umask 022 -# Initial cleanup +# Global vars +TMPDIR=/dev/tmp +PERSISTDIR=/sbin/.magisk/mirror/persist + rm -rf $TMPDIR 2>/dev/null -mkdir -p $INSTALLER +mkdir -p $TMPDIR # echo before loading util_functions ui_print() { echo "$1"; } require_new_magisk() { ui_print "*******************************" - ui_print " Please install Magisk v15.0+! " + ui_print " Please install Magisk v19.0+! " ui_print "*******************************" exit 1 } -########################################################################################## +is_legacy_script() { + unzip -l "$ZIPFILE" install.sh | grep -q install.sh + return $? +} + +print_modname() { + local len + len=`echo -n $MODNAME | wc -c` + len=$((len + 2)) + local pounds=`printf "%${len}s" | tr ' ' '*'` + ui_print "$pounds" + ui_print " $MODNAME " + ui_print "$pounds" + ui_print "*******************" + ui_print " Powered by Magisk " + ui_print "*******************" +} + +############## # Environment -########################################################################################## +############## OUTFD=$2 -ZIP=$3 +ZIPFILE=$3 mount /data 2>/dev/null -# Utility functions must exist -[ -f $MAGISKBIN/util_functions.sh ] || require_new_magisk -# Load utility fuctions -. $MAGISKBIN/util_functions.sh - -# We can't alter magisk image live, use alternative image if required -$BOOTMODE && IMG=/data/adb/magisk_merge.img -# Always mount under tmp -MOUNTPATH=$TMPDIR/magisk_img +# Load utility functions +[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk +. /data/adb/magisk/util_functions.sh +[ $MAGISK_VER_CODE -gt 18100 ] || require_new_magisk # Preperation for flashable zips -get_outfd +setup_flashable # Mount partitions mount_partitions @@ -60,95 +64,110 @@ mount_partitions # Detect version and architecture api_level_arch_detect -# You can get the Android API version from $API, the CPU architecture from $ARCH -# Useful if you are creating Android version / platform dependent mods - # Setup busybox and binaries $BOOTMODE && boot_actions || recovery_actions -########################################################################################## +############## # Preparation -########################################################################################## +############## -# Extract common files -unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER >&2 +# Extract prop file +unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2 +[ ! -f $TMPDIR/module.prop ] && abort "! Unable to extract zip file!" -[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!" -# Load configurations -. $INSTALLER/config.sh +$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules +MODULEROOT=$NVBASE/$MODDIRNAME +MODID=`grep_prop id $TMPDIR/module.prop` +MODPATH=$MODULEROOT/$MODID +MODNAME=`grep_prop name $TMPDIR/module.prop` -# Check the installed magisk version -MIN_VER=`grep_prop minMagisk $INSTALLER/module.prop` -[ ! -z $MAGISK_VER_CODE -a $MAGISK_VER_CODE -ge $MIN_VER ] || require_new_magisk -MODID=`grep_prop id $INSTALLER/module.prop` -MODPATH=$MOUNTPATH/$MODID +# Create mod paths +rm -rf $MODPATH 2>/dev/null +mkdir -p $MODPATH -# Print mod name -print_modname +########## +# Install +########## -# Please leave this message in your flashable zip for credits :) -ui_print "******************************" -ui_print "Powered by Magisk (@topjohnwu)" -ui_print "******************************" +if is_legacy_script; then + unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2 -########################################################################################## -# Install -########################################################################################## + # Load install script + . $TMPDIR/install.sh -# Get the variable reqSizeM. Use your own method to determine reqSizeM if needed -request_zip_size_check "$ZIP" + # Callbacks + print_modname + on_install -# This function will mount $IMG to $MOUNTPATH, and resize the image based on $reqSizeM -mount_magisk_img + # Custom uninstaller + [ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh -# Create mod paths -rm -rf $MODPATH 2>/dev/null -mkdir -p $MODPATH + # Skip mount + $SKIPMOUNT && touch $MODPATH/skip_mount + + # prop file + $PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop + + # Module info + cp -af $TMPDIR/module.prop $MODPATH/module.prop + + # post-fs-data scripts + $POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh + + # service scripts + $LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh + + ui_print "- Setting permissions" + set_permissions +else + print_modname + + unzip -o "$ZIPFILE" customize.sh -d $MODPATH >&2 -# Extract files to system. Use your own method if needed -ui_print "- Extracting module files" -unzip -o "$ZIP" 'system/*' -d $MODPATH >&2 + if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then + ui_print "- Extracting module files" + unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2 -# Remove placeholder -rm -f $MODPATH/system/placeholder 2>/dev/null + # Default permissions + set_perm_recursive $MODPATH 0 0 0755 0644 + fi + + # Load customization script + [ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh +fi # Handle replace folders for TARGET in $REPLACE; do + ui_print "- Replace target: $TARGET" mktouch $MODPATH$TARGET/.replace done -# Auto Mount -$AUTOMOUNT && touch $MODPATH/auto_mount - -# prop files -$PROPFILE && cp -af $INSTALLER/common/system.prop $MODPATH/system.prop - -# Module info -cp -af $INSTALLER/module.prop $MODPATH/module.prop if $BOOTMODE; then # Update info for Magisk Manager - mktouch /sbin/.core/img/$MODID/update - cp -af $INSTALLER/module.prop /sbin/.core/img/$MODID/module.prop + mktouch $NVBASE/modules/$MODID/update + cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop fi -# post-fs-data mode scripts -$POSTFSDATA && cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh - -# service mode scripts -$LATESTARTSERVICE && cp -af $INSTALLER/common/service.sh $MODPATH/service.sh +# Copy over custom sepolicy rules +if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then + ui_print "- Installing custom sepolicy patch" + PERSISTMOD=$PERSISTDIR/magisk/$MODID + mkdir -p $PERSISTMOD + cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule +fi -ui_print "- Setting permissions" -set_permissions +# Remove stuffs that don't belong to modules +rm -rf \ +$MODPATH/system/placeholder $MODPATH/customize.sh \ +$MODPATH/README.md $MODPATH/.git* 2>/dev/null -########################################################################################## +############## # Finalizing -########################################################################################## - -# Unmount magisk image and shrink if possible -unmount_magisk_img +############## +cd / $BOOTMODE || recovery_cleanup rm -rf $TMPDIR ui_print "- Done" -exit 0 +exit 0 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc8f89b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +Unified icon disabler for MIUI (xiaomi.eu) +========================================== +This module disables all of the unified icons present in xiaomi.eu and other MIUI custom ROMs systemlessly. + +Requirements +------------ +* Magisk v19+ +* MIUI based Custom ROM using it's own icon pack + +Credits +------- +* @topjohnwu for Magisk +* Xiaomi.eu forum for the idea :D + +Links +----- +* [Telegram](https://www.t.me/Sap1k) + +Notes +----- +* You will need to reapply your current theme after flashing this module for the changes to apply. +* Tested on Android 10, however should be fully compatible all the way to Android 5 + +Changelog +--------- +### v1.x +- Initial release, obsolete, made using old templates + +### v2.0 +- Initial **public** release +- Compliant with Magisk documentation diff --git a/common/post-fs-data.sh b/common/post-fs-data.sh index 64540ef..34f1a8e 100755 --- a/common/post-fs-data.sh +++ b/common/post-fs-data.sh @@ -1,6 +1,9 @@ #!/system/bin/sh -# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/... -# This will make your scripts compatible even if Magisk change its mount point in the future +# Do NOT assume where your module will be located. +# ALWAYS use $MODDIR if you need to know where this script +# and module is placed. +# This will make sure your module will still work +# if Magisk change its mount point in the future MODDIR=${0%/*} # This script will be executed in post-fs-data mode diff --git a/config.sh b/config.sh deleted file mode 100755 index e1fb9c2..0000000 --- a/config.sh +++ /dev/null @@ -1,98 +0,0 @@ -########################################################################################## -# -# Magisk Module Template Config Script -# by topjohnwu -# -########################################################################################## -########################################################################################## -# -# Instructions: -# -# 1. Place your files into system folder (delete the placeholder file) -# 2. Fill in your module's info into module.prop -# 3. Configure the settings in this file (config.sh) -# 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh -# 5. Add your additional or modified system properties into common/system.prop -# -########################################################################################## - -########################################################################################## -# Configs -########################################################################################## - -# Set to true if you need to enable Magic Mount -# Most mods would like it to be enabled -AUTOMOUNT=true - -# Set to true if you need to load system.prop -PROPFILE=false - -# Set to true if you need post-fs-data script -POSTFSDATA=false - -# Set to true if you need late_start service script -LATESTARTSERVICE=false - -########################################################################################## -# Installation Message -########################################################################################## - -# Set what you want to show when installing your mod - -print_modname() { - ui_print "***********************************************" - ui_print " Disable flat icons in MIUI (xiaomi.eu) " - ui_print "***********************************************" -} - -########################################################################################## -# Replace list -########################################################################################## - -# List all directories you want to directly replace in the system -# Check the documentations for more info about how Magic Mount works, and why you need this -# This is an example -REPLACE=" -/system/app/Youtube -/system/priv-app/SystemUI -/system/priv-app/Settings -/system/framework -" - -# Construct your own list here, it will overrride the example above -# !DO NOT! remove this if you don't need to replace anything, leave it empty as it is now -REPLACE=" -/system/media/theme/miui_mod_icons -" - -########################################################################################## -# Permissions -########################################################################################## - -set_permissions() { - # Only some special files require specific permissions - # The default permissions should be good enough for most cases - - # Here are some examples for the set_perm functions: - - # set_perm_recursive (default: u:object_r:system_file:s0) - # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644 - - # set_perm (default: u:object_r:system_file:s0) - # set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0 - # set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0 - # set_perm $MODPATH/system/lib/libart.so 0 0 0644 - - # The following is default permissions, DO NOT remove - set_perm_recursive $MODPATH 0 0 0755 0644 -} - -########################################################################################## -# Custom Functions -########################################################################################## - -# This file (config.sh) will be sourced by the main flash script after util_functions.sh -# If you need custom logic, please add them here as functions, and call these functions in -# update-binary. Refrain from adding code directly into update-binary, as it will make it -# difficult for you to migrate your modules to newer template versions. -# Make update-binary as clean as possible, try to only do function calls in it. \ No newline at end of file diff --git a/customize.sh b/customize.sh new file mode 100755 index 0000000..b0e6c7f --- /dev/null +++ b/customize.sh @@ -0,0 +1,5 @@ +#!/system/bin/sh + +REPLACE=" +/system/media/theme/miui_mod_icons +" \ No newline at end of file diff --git a/module.prop b/module.prop index 0e53b73..68f3e8e 100755 --- a/module.prop +++ b/module.prop @@ -1,7 +1,6 @@ -id=miuiflaticondisabler -name=Flat icon disabler for MIUI (xiaomi.eu) -version=v1 -versionCode=1 +id=miuiunifiedicondisable +name=Unified icon disabler for MIUI (xiaomi.eu) +version=v2 +versionCode=2 author=Sap1k -description=Disables flat icons included in xiaomi.eu ROMs -minMagisk=1500 +description=Disables unified icons included in xiaomi.eu ROMs \ No newline at end of file