Skip to content

Commit

Permalink
template 1400
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Shi <[email protected]>
  • Loading branch information
simonsmh committed Sep 7, 2017
1 parent c9e9d76 commit c4fc787
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 65 deletions.
81 changes: 40 additions & 41 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Magisk Module Template Install Script
# by topjohnwu
#
#
##########################################################################################

# Detect whether in boot mode
Expand All @@ -24,8 +24,12 @@ MAGISKBIN=/data/magisk
# Default permissions
umask 022

# Initial cleanup
rm -rf $TMPDIR 2>/dev/null
mkdir -p $INSTALLER

##########################################################################################
# Flashable update-binary preparation
# Environment
##########################################################################################

OUTFD=$2
Expand All @@ -34,7 +38,7 @@ ZIP=$3
ui_print() {
if $BOOTMODE; then
echo "$1"
else
else
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
fi
Expand All @@ -43,34 +47,50 @@ ui_print() {
require_new_magisk() {
ui_print "***********************************"
ui_print "! $MAGISKBIN isn't setup properly!"
ui_print "! Please install Magisk v13.1+!"
ui_print "! Please install Magisk v14.0+!"
ui_print "***********************************"
exit 1
}

# Mount /data to access MAGISKBIN
ui_print "- Mounting /system, /vendor, /data, /cache"
mount -o ro /system 2>/dev/null
mount -o ro /vendor 2>/dev/null
mount /data 2>/dev/null
mount /cache 2>/dev/null

# MAGISKBIN must exist, binaries and utility functions are placed there
[ -d $MAGISKBIN -a -f $MAGISKBIN/magisk -a -f $MAGISKBIN/util_functions.sh ] || require_new_magisk

# Utility functions must exist
[ -f $MAGISKBIN/util_functions.sh ] || require_new_magisk
# Load utility fuctions
. $MAGISKBIN/util_functions.sh
[ ! -z $SCRIPT_VERSION -a $SCRIPT_VERSION -ge 1310 ] || require_new_magisk
get_outfd

rm -rf $TMPDIR 2>/dev/null
mkdir -p $INSTALLER
unzip -o "$ZIP" config.sh -d $INSTALLER 2>/dev/null
$BOOTMODE && ! is_mounted /magisk && abort "! Magisk is not activated!"
[ ! -f /system/build.prop ] && abort "! /system could not be mounted!"

# 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

# We need busybox/binaries to be setup
$BOOTMODE && boot_actions || recovery_actions

##########################################################################################
# Prepare
# Preparation
##########################################################################################

[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
# Extract common files
unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER 2>/dev/null

[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
# Load configurations
. $INSTALLER/config.sh

# Check the min magisk version
MIN_VER=`grep_prop template $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

# Print mod name
Expand All @@ -81,35 +101,14 @@ ui_print "******************************"
ui_print "Powered by Magisk (@topjohnwu)"
ui_print "******************************"

ui_print "- Mounting /system, /vendor, /data, /cache"
mount -o ro /system 2>/dev/null
mount -o ro /vendor 2>/dev/null
mount /data 2>/dev/null
mount /cache 2>/dev/null

[ ! -f /data/magisk.img ] && abort "! Magisk is not installed"
$BOOTMODE && ! is_mounted /magisk && abort "! Magisk is not activated!"
[ ! -f /system/build.prop ] && abort "! /system could not be mounted!"

# 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

##########################################################################################
# Install
##########################################################################################

ui_print "- Extracting module files"
unzip -o "$ZIP" -d $INSTALLER 2>/dev/null
request_size_check $INSTALLER

# We're going to use magisk binary now, require some recovery fixes
$BOOTMODE || recovery_actions
request_zip_size_check "$ZIP"

if [ -f "$IMG" ]; then
ui_print "- $IMG detected!"
ui_print "- Found $IMG"
image_size_check $IMG
if [ "$reqSizeM" -gt "$curFreeM" ]; then
newSizeM=$(((reqSizeM + curUsedM) / 32 * 32 + 64))
Expand All @@ -124,15 +123,14 @@ fi

ui_print "- Mounting $IMG to $MOUNTPATH"
MAGISKLOOP=`$MAGISKBIN/magisk --mountimg $IMG $MOUNTPATH`
is_mounted $MOUNTPATH || abort"! $IMG mount failed..."
is_mounted $MOUNTPATH || abort "! $IMG mount failed..."

# Create mod paths
rm -rf $MODPATH 2>/dev/null
mkdir -p $MODPATH

# Copy files
ui_print "- Copying files"
mv $INSTALLER/system $MODPATH/system
ui_print "- Extracting module files"
unzip -o "$ZIP" 'system/*' -d $MODPATH 2>/dev/null

# Handle replace folders
for TARGET in $REPLACE; do
Expand Down Expand Up @@ -185,6 +183,7 @@ if [ $curSizeM -gt $newSizeM ]; then
fi

$BOOTMODE || recovery_cleanup
rm -rf $TMPDIR

ui_print "- Done"
exit 0
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Make 40Mhz runing at 2.4Ghz on your Qualcomm devices!
#### NOTICE

* You should use latest Magisk Manager to install this module. If you meet any problem under installation from Magisk Manager, please try to install it from recovery.
* Resent fixes:
Magisk v13 Template v4 compatabilities
* Recent fixes:
Magisk v14 Template 1400 compatabilities

#### Credit & Support

Expand Down
32 changes: 11 additions & 21 deletions config.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
##########################################################################################
#
# Magisk
# Magisk Module Template Config Script
# by topjohnwu
#
# This is a template zip for developers
#
##########################################################################################
##########################################################################################
#
#
# 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 (common/config.sh)
# 4. For advanced features, add shell commands into the script files under common:
# post-fs-data.sh, service.sh
# 5. For changing props, add your additional/modified props into common/system.prop
#
#
##########################################################################################

##########################################################################################
# Defines
# Configs
##########################################################################################

# NOTE: This part has to be adjusted to fit your own needs

# This will be the folder name under /magisk
# This should also be the same as the id in your module.prop to prevent confusion
MODID=wifi-bonding

# Set to true if you need to enable Magic Mount
# Most mods would like it to be enabled
AUTOMOUNT=true
Expand All @@ -50,7 +42,7 @@ LATESTARTSERVICE=false

print_modname() {
ui_print "*******************************"
ui_print " Magisk Module Template "
ui_print " Magisk WiFi Bonding "
ui_print "*******************************"
}

Expand Down Expand Up @@ -80,16 +72,11 @@ REPLACE="
# Permissions
##########################################################################################

# NOTE: This part has to be adjusted to fit your own needs

set_permissions() {
# Default permissions, don't remove them
set_perm_recursive $MODPATH 0 0 0755 0644

# Only some special files require specific permissions
# The default permissions should be good enough for most cases

# Some templates if you have no idea what to do:
# Here are some examples for the set_perm functions:

# set_perm_recursive <dirname> <owner> <group> <dirpermission> <filepermission> <contexts> (default: u:object_r:system_file:s0)
# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
Expand All @@ -98,4 +85,7 @@ set_permissions() {
# 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
}
2 changes: 1 addition & 1 deletion module.prop
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version=1.0
versionCode=1
author=simonsmh
description=Wifi Bonding
template=4
template=1400

0 comments on commit c4fc787

Please sign in to comment.