Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
+ 3.9.10 适配 Magisk 20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
eritpchy committed May 2, 2020
1 parent a63c9b3 commit 15bb1df
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 190 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
/captures
/out
.externalNativeBuild
elf-cleaner.sh
settings.gradle
.cxx
.cxx
module.gradle
22 changes: 22 additions & 0 deletions module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ext {
moduleId = "module_xfingerprint_pay_wechat"
riruApiVersion = 4

moduleProp = [
name : "指纹支付 - 微信",
version : "v3.9.10",
versionCode: "1",
author : "Jason Eric",
description: "让微信支持指纹支付 Fingerprint pay for WeChat.",
api : riruApiVersion
]

magiskModuleProp = [
id : "riru-${moduleId.replace('_', '-')}",
name : "Riru - ${moduleProp['name']}",
version : moduleProp['version'],
versionCode: moduleProp['versionCode'],
author : moduleProp['author'],
description: moduleProp['description']
]
}
47 changes: 25 additions & 22 deletions module/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
apply plugin: 'com.android.library'
apply from: file(rootProject.file('module.gradle'))

android {
compileSdkVersion rootProject.ext.targetSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion

externalNativeBuild {
cmake {
arguments "-DMODULE_NAME:STRING=riru_$moduleId"
}
}
ndk {
abiFilters "armeabi-v7a", 'arm64-v8a', 'x86', 'x86_64'
}
Expand All @@ -17,29 +24,10 @@ android {
}
}

def moduleId = "module_xfingerprint_pay_wechat"
def moduleProp = [
name : "指纹支付 - 微信",
version : "v3.9.7",
versionCode: "1",
author : "Jason Eric",
description: "让微信支持指纹支付 Fingerprint pay for wechat.",
api : 4
]

def magiskModuleProp = [
id : "riru-${moduleId.replace('_', '-')}",
name : "Riru - ${moduleProp['name']}",
version : moduleProp['version'],
versionCode: moduleProp['versionCode'],
author : moduleProp['author'],
description: moduleProp['description']
]

def outDir = file("$rootDir/out")
def magiskDir = file("$outDir/magisk_module")
def zipName = "magisk-${magiskModuleProp['id']}-${magiskModuleProp['version']}.zip"
def riruDir = "$magiskDir/data/misc/riru/modules/${moduleId}"
def zipName = "magisk-${magiskModuleProp['id'].replace('_', '-')}-${magiskModuleProp['version']}.zip"
def riruDir = "$magiskDir/riru"

import java.nio.file.Files
import java.security.MessageDigest
Expand All @@ -58,6 +46,8 @@ static def renameOrFail(File from, File to) {
}
}

import org.apache.tools.ant.filters.FixCrLfFilter

android.libraryVariants.all { variant ->
def task = variant.assembleProvider.get()
task.doLast {
Expand All @@ -68,6 +58,19 @@ android.libraryVariants.all { variant ->
copy {
from "$rootDir/template/magisk_module"
into magiskDir.path
exclude 'riru.sh'
}
// copy riru.sh
copy {
from "$rootDir/template/magisk_module"
into magiskDir.path
include 'riru.sh'
filter { line ->
line.replaceAll('%%%RIRU_MODULE_ID%%%', moduleId)
.replaceAll('%%%RIRU_MIN_API_VERSION%%%', riruApiVersion.toString())
}
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
// copy .git files manually since gradle exclude it by default
Files.copy(file("$rootDir/template/magisk_module/.gitattributes").toPath(), file("${magiskDir.path}/.gitattributes").toPath())
Expand Down Expand Up @@ -100,7 +103,7 @@ android.libraryVariants.all { variant ->
file("$magiskDir/system/framework").mkdirs()
copy {
from zipTree('libs/fingerprint-pay-wechat-magisk.apk')
rename('classes.dex', 'libxfingerprint_pay_wechat.dex')
rename('classes.dex', 'libriru_module_xfingerprint_pay_wechat.dex')
into file("$magiskDir/system/framework")
include 'classes.dex'
}
Expand Down
Binary file modified module/libs/fingerprint-pay-wechat-magisk.apk
Binary file not shown.
4 changes: 3 additions & 1 deletion module/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.4.1)

set(MODULE_NAME "riru_module_xfingerprint_pay_wechat")
if (NOT DEFINED MODULE_NAME)
message(FATAL_ERROR "MODULE_NAME is not set")
endif ()

message("Build type: ${CMAKE_BUILD_TYPE}")

Expand Down
4 changes: 2 additions & 2 deletions module/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ EXPORT int nativeForkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
char appCacheDir[PATH_MAX] = {0};
snprintf(appCacheDir, PATH_MAX - 1, "%s/cache", sAppDataDir);

const char *dexPath = "/data/local/tmp/libxfingerprint_pay_wechat.dex";
const char *dexPath = "/data/local/tmp/libriru_module_xfingerprint_pay_wechat.dex";
if (access(dexPath, 0) != 0) {
dexPath = "/system/framework/libxfingerprint_pay_wechat.dex";
dexPath = "/system/framework/libriru_module_xfingerprint_pay_wechat.dex";
}
loadDex(env,
env->NewStringUTF(dexPath),
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -e
cd ${0%/*}
./gradlew clean
./gradlew :module:assembleRelease
adb shell rm -f "/data/local/tmp/libxfingerprint_pay_wechat.dex"
adb shell rm -f "/data/local/tmp/libriru_module_xfingerprint_pay_wechat.dex"
adb push ./out/*.zip /sdcard/Download/
2 changes: 1 addition & 1 deletion template/magisk_module/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ META-INF/** text eol=lf
*.prop text eol=lf
*.sh text eol=lf
*.md text eol=lf
sepolicy.rule eol=lf
sepolicy.rule text eol=lf

# Denote all files that are truly binary and should not be modified.
system/** binary
Expand Down
91 changes: 47 additions & 44 deletions template/magisk_module/customize.sh
Original file line number Diff line number Diff line change
@@ -1,64 +1,67 @@
SKIPUNZIP=1
RIRU_PATH="/data/misc/riru"
RIRU_MODULES_PATH="$RIRU_PATH/modules"

# check architecture
if [[ "$ARCH" != "arm" && "$ARCH" != "arm64" && "$ARCH" != "x86" && "$ARCH" != "x64" ]]; then
abort "! Unsupported platform: $ARCH"
else
ui_print "- Device platform: $ARCH"
fi

# check Riru version
if [[ ! -f "$RIRU_PATH/api_version" ]]; then
ui_print "*********************************************************"
ui_print "! 'Riru - Core' is not installed"
ui_print "! You can download from 'Magisk Manager' or https://github.com/RikkaApps/Riru/releases"
abort "*********************************************************"
fi
RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version")
ui_print "- Riru API version: $RIRU_API_VERSION"
if [[ "$RIRU_API_VERSION" -lt 4 ]]; then
ui_print "*********************************************************"
ui_print "! The latest version of 'Riru - Core' is required"
ui_print "! You can download from 'Magisk Manager' or https://github.com/RikkaApps/Riru/releases"
abort "*********************************************************"
fi

# extract verify.sh
ui_print "- Extracting verify.sh"
unzip -o "$ZIPFILE" 'verify.sh' -d "$TMPDIR" >&2
if [[ ! -f "$TMPDIR/verify.sh" ]]; then
ui_print "*********************************************************"
ui_print "! Unable to extract verify.sh!"
ui_print "! This zip may be corrupted, please try downloading again"
abort "*********************************************************"
if [ ! -f "$TMPDIR/verify.sh" ]; then
ui_print "*********************************************************"
ui_print "! Unable to extract verify.sh!"
ui_print "! This zip may be corrupted, please try downloading again"
abort_clean "*********************************************************"
fi
. $TMPDIR/verify.sh

# extract riru.sh
extract "$ZIPFILE" 'riru.sh' "$MODPATH"
. $MODPATH/riru.sh

check_riru_version
check_architecture

# extract libs
ui_print "- Extracting module files"
vunzip -o "$ZIPFILE" 'module.prop' 'post-fs-data.sh' 'uninstall.sh' -d "$MODPATH"

if [[ "$ARCH" == "x86" || "$ARCH" == "x64" ]]; then
ui_print "- Extracting x86/64 libraries"
vunzip -o "$ZIPFILE" 'system_x86/*' -d "$MODPATH"
extract "$ZIPFILE" 'module.prop' "$MODPATH"
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
extract "$ZIPFILE" 'uninstall.sh' "$MODPATH"
#extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH"

if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
ui_print "- Extracting x86 libraries"
extract "$ZIPFILE" "system_x86/lib/libriru_$RIRU_MODULE_ID.so" "$MODPATH"
mv "$MODPATH/system_x86/lib" "$MODPATH/system/lib"
mv "$MODPATH/system_x86/lib64" "$MODPATH/system/lib64"

if [ "$IS64BIT" = true ]; then
ui_print "- Extracting x64 libraries"
extract "$ZIPFILE" "system_x86/lib64/libriru_$RIRU_MODULE_ID.so" "$MODPATH"
mv "$MODPATH/system_x86/lib64" "$MODPATH/system/lib64"
fi
else
ui_print "- Extracting arm/arm64 libraries"
vunzip -o "$ZIPFILE" 'system/*' -d "$MODPATH"
fi
ui_print "- Extracting arm libraries"
extract "$ZIPFILE" "system/lib/libriru_$RIRU_MODULE_ID.so" "$MODPATH"

if [[ "$IS64BIT" == "false" ]]; then
ui_print "- Removing 64-bit libraries"
rm -rf "$MODPATH/system/lib64"
if [ "$IS64BIT" = true ]; then
ui_print "- Extracting arm64 libraries"
extract "$ZIPFILE" "system/lib64/libriru_$RIRU_MODULE_ID.so" "$MODPATH"
fi
fi

ui_print "- Extracting extra libraries"
extract "$ZIPFILE" "system/framework/libriru_$RIRU_MODULE_ID.dex" "$MODPATH"

# Riru files
ui_print "- Extracting extra files"
unzip -o "$ZIPFILE" 'data/*' -d "$TMPDIR" >&2
[[ -d "$RIRU_MODULES_PATH" ]] || mkdir -p "$RIRU_MODULES_PATH" || abort "! Can't mkdir -p $RIRU_MODULES_PATH"
cp -af "$TMPDIR$RIRU_MODULES_PATH/." "$RIRU_MODULES_PATH" || abort "! Can't cp -af $TMPDIR$RIRU_MODULES_PATH/. $RIRU_MODULES_PATH"
[ -d "$RIRU_MODULE_PATH" ] || mkdir -p "$RIRU_MODULE_PATH" || abort_clean "! Can't create $RIRU_MODULE_PATH"

# set permission just in case
set_perm "$RIRU_PATH" 0 0 0700
set_perm "$RIRU_PATH/modules" 0 0 0700
set_perm "$RIRU_MODULE_PATH" 0 0 0700
set_perm "$RIRU_MODULE_PATH/bin" 0 0 0700

rm -f "$RIRU_MODULE_PATH/module.prop.new"
extract "$ZIPFILE" 'riru/module.prop.new' "$RIRU_MODULE_PATH" true
set_perm "$RIRU_MODULE_PATH/module.prop.new" 0 0 0600

# set permissions
ui_print "- Setting permissions"
Expand Down
9 changes: 5 additions & 4 deletions template/magisk_module/post-fs-data.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/system/bin/sh
MODDIR=${0%/*}
MODULE_ID="module_xfingerprint_pay_wechat"
[ ! -f "$MODDIR/riru.sh" ] && exit 1
. $MODDIR/riru.sh

# Reset context jsut in case
chcon -R u:object_r:system_file:s0 "$MODDIR"

# Rename module.prop.new
if [ -f "/data/misc/riru/modules/$MODULE_ID/module.prop.new" ]; then
rm "/data/misc/riru/modules/$MODULE_ID/module.prop"
mv "/data/misc/riru/modules/$MODULE_ID/module.prop.new" "/data/misc/riru/modules/$MODULE_ID/module.prop"
if [ -f "$RIRU_MODULE_PATH/module.prop.new" ]; then
rm "$RIRU_MODULE_PATH/module.prop"
mv "$RIRU_MODULE_PATH/module.prop.new" "$RIRU_MODULE_PATH/module.prop"
fi
36 changes: 36 additions & 0 deletions template/magisk_module/riru.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/sbin/sh
RIRU_PATH="/data/misc/riru"
RIRU_MODULE_ID="%%%RIRU_MODULE_ID%%%"
RIRU_MODULE_PATH="$RIRU_PATH/modules/$RIRU_MODULE_ID"
RIRU_MIN_API_VERSION=%%%RIRU_MIN_API_VERSION%%%

abort_clean() {
rm -rf "$MODPATH"
abort "$1"
}

check_riru_version() {
if [ ! -f "$RIRU_PATH/api_version" ] && [ ! -f "$RIRU_PATH/api_version.new" ]; then
ui_print "*********************************************************"
ui_print "! Riru is not installed"
ui_print "! Please install Riru (Riru - Core) from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
abort_clean "*********************************************************"
fi
RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version.new") || RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version") || RIRU_API_VERSION=0
[ "$RIRU_API_VERSION" -eq "$RIRU_API_VERSION" ] || RIRU_API_VERSION=0
ui_print "- Riru API version: $RIRU_API_VERSION"
if [ "$RIRU_API_VERSION" -lt $RIRU_MIN_API_VERSION ]; then
ui_print "*********************************************************"
ui_print "! The latest version of Riru is required"
ui_print "! Please install Riru (Riru - Core) from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
abort_clean "*********************************************************"
fi
}

check_architecture() {
if [ "$ARCH" != "arm" ] && [ "$ARCH" != "arm64" ] && [ "$ARCH" != "x86" ] && [ "$ARCH" != "x64" ]; then
abort_clean "! Unsupported platform: $ARCH"
else
ui_print "- Device platform: $ARCH"
fi
}
7 changes: 4 additions & 3 deletions template/magisk_module/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/sbin/sh
RIRU_MODULE_PATH="/data/misc/riru/modules"
MODULE_ID="module_xfingerprint_pay_wechat"
MODDIR=${0%/*}
[ ! -f "$MODDIR/riru.sh" ] && exit 1
. $MODDIR/riru.sh

rm -rf "$RIRU_MODULE_PATH/$MODULE_ID"
rm -rf "$RIRU_MODULE_PATH"
Loading

0 comments on commit 15bb1df

Please sign in to comment.